From deaf945db7433d83311eb63d7e6b5e873813c732 Mon Sep 17 00:00:00 2001 From: vladimirkhashev Date: Mon, 19 Jun 2023 08:28:38 -0700 Subject: [PATCH 1/5] Added tests for oneapi queue_empty ext --- CMakeLists.txt | 3 + .../oneapi_queue_empty/CMakeLists.txt | 5 + .../queue_empty_ext_test.cpp | 122 ++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 tests/extension/oneapi_queue_empty/CMakeLists.txt create mode 100644 tests/extension/oneapi_queue_empty/queue_empty_ext_test.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a8e4c7b6..0b798f2f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,9 @@ add_cts_option(SYCL_CTS_ENABLE_EXT_ONEAPI_MEMCPY2D_TESTS add_cts_option(SYCL_CTS_ENABLE_EXT_ONEAPI_WEAK_OBJECT_TESTS "Enable extension oneAPI weak_object tests" OFF) +add_cts_option(SYCL_CTS_ENABLE_EXT_ONEAPI_QUEUE_EMPTY + "Enable extension oneAPI queue_empty tests" OFF) + # TODO: Deprecated - remove add_cts_option(SYCL_CTS_ENABLE_VERBOSE_LOG "Enable debug-level logs (deprecated)" OFF) diff --git a/tests/extension/oneapi_queue_empty/CMakeLists.txt b/tests/extension/oneapi_queue_empty/CMakeLists.txt new file mode 100644 index 000000000..1bd6d3854 --- /dev/null +++ b/tests/extension/oneapi_queue_empty/CMakeLists.txt @@ -0,0 +1,5 @@ +if(SYCL_CTS_ENABLE_EXT_ONEAPI_QUEUE_EMPTY) + file(GLOB test_cases_list *.cpp) + + add_cts_test(${test_cases_list}) +endif() \ No newline at end of file diff --git a/tests/extension/oneapi_queue_empty/queue_empty_ext_test.cpp b/tests/extension/oneapi_queue_empty/queue_empty_ext_test.cpp new file mode 100644 index 000000000..9ac817515 --- /dev/null +++ b/tests/extension/oneapi_queue_empty/queue_empty_ext_test.cpp @@ -0,0 +1,122 @@ +/******************************************************************************* +// +// SYCL 2020 Conformance Test Suite +// +// Copyright (c) 2023 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +*******************************************************************************/ +#include "../../common/common.h" + +constexpr size_t buf_size = 10; +constexpr size_t iter_num = 10000000; + +template +class Kernel { + AccT array_acc; + + public: + Kernel(AccT acc) : array_acc(acc) {} + void operator()() const { + for (size_t i = 0; i < iter_num; i++) { + int val = sycl::sqrt(float(i)); + array_acc[val % array_acc.size()] = i; + } + } +}; + +TEST_CASE( + "Test for \"Queue empty\" extension, check extension functionality" + "when no commands are submitted to the queue", + "[oneapi_queue_empty]") { +#ifndef SYCL_EXT_ONEAPI_QUEUE_EMPTY + SKIP("SYCL_EXT_ONEAPI_QUEUE_EMPTY is not defined"); +#else + auto queue = sycl_cts::util::get_cts_object::queue(); + auto is_empty = queue.ext_oneapi_empty(); + CHECK(std::is_same_v); + CHECK(is_empty); +#endif +} + +TEST_CASE( + "Test for \"Queue empty\" extension, check extension functionality" + "after commands are submitted to the queue, test 1", + "[oneapi_queue_empty]") { +#ifndef SYCL_EXT_ONEAPI_QUEUE_EMPTY + SKIP("SYCL_EXT_ONEAPI_QUEUE_EMPTY is not defined"); +#else + auto queue = sycl_cts::util::get_cts_object::queue(); + + size_t array[buf_size]; + sycl::buffer array_buf(array, buf_size); + + auto e = queue.submit([&](sycl::handler& cgh) { + auto array_acc = + array_buf.template get_access(cgh); + cgh.single_task(Kernel(array_acc)); + }); + + bool is_empty = queue.ext_oneapi_empty(); + if (e.get_info() != + sycl::info::event_command_status::complete) { + CHECK(!is_empty); + } + + queue.wait(); + + is_empty = queue.ext_oneapi_empty(); + CHECK(is_empty); +#endif +} + +TEST_CASE( + "Test for \"Queue empty\" extension, check extension functionality" + "after commands are submitted to the queue, test 2", + "[oneapi_queue_empty]") { +#ifndef SYCL_EXT_ONEAPI_QUEUE_EMPTY + SKIP("SYCL_EXT_ONEAPI_QUEUE_EMPTY is not defined"); +#else + auto queue = sycl_cts::util::get_cts_object::queue(); + + size_t array[buf_size]; + sycl::buffer array_buf(array, buf_size); + + auto Ea = queue.submit([&](sycl::handler& cgh) { + auto array_acc = + array_buf.template get_access(cgh); + cgh.single_task(Kernel(array_acc)); + }); + + auto Eb = queue.submit([&](sycl::handler& cgh) { + cgh.depends_on(Ea); + auto array_acc = + array_buf.template get_access(cgh); + cgh.single_task(Kernel(array_acc)); + }); + + Ea.wait(); + + bool is_empty = queue.ext_oneapi_empty(); + if (Eb.get_info() != + sycl::info::event_command_status::complete) { + CHECK(!is_empty); + } + + Eb.wait(); + + is_empty = queue.ext_oneapi_empty(); + CHECK(is_empty); +#endif +} From 5ba09beddd82e20bb7d0ae355068a61f6e2912f4 Mon Sep 17 00:00:00 2001 From: vladimirkhashev Date: Mon, 19 Jun 2023 08:38:28 -0700 Subject: [PATCH 2/5] Small edit --- tests/extension/oneapi_queue_empty/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/extension/oneapi_queue_empty/CMakeLists.txt b/tests/extension/oneapi_queue_empty/CMakeLists.txt index 1bd6d3854..881032738 100644 --- a/tests/extension/oneapi_queue_empty/CMakeLists.txt +++ b/tests/extension/oneapi_queue_empty/CMakeLists.txt @@ -2,4 +2,4 @@ if(SYCL_CTS_ENABLE_EXT_ONEAPI_QUEUE_EMPTY) file(GLOB test_cases_list *.cpp) add_cts_test(${test_cases_list}) -endif() \ No newline at end of file +endif() From c02d4d79a5f6f179966a6bbb4771ba111bbd7d7c Mon Sep 17 00:00:00 2001 From: vladimirkhashev Date: Wed, 21 Jun 2023 06:37:19 -0700 Subject: [PATCH 3/5] Added namespace --- tests/extension/oneapi_queue_empty/queue_empty_ext_test.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/extension/oneapi_queue_empty/queue_empty_ext_test.cpp b/tests/extension/oneapi_queue_empty/queue_empty_ext_test.cpp index 9ac817515..3c2dfbdae 100644 --- a/tests/extension/oneapi_queue_empty/queue_empty_ext_test.cpp +++ b/tests/extension/oneapi_queue_empty/queue_empty_ext_test.cpp @@ -19,6 +19,7 @@ *******************************************************************************/ #include "../../common/common.h" +namespace queue_empty::tests { constexpr size_t buf_size = 10; constexpr size_t iter_num = 10000000; @@ -120,3 +121,4 @@ TEST_CASE( CHECK(is_empty); #endif } +} // namespace queue_empty::tests From 9be0382def557dd89bdc97422dd250dc5679d5b8 Mon Sep 17 00:00:00 2001 From: vladimirkhashev Date: Thu, 29 Jun 2023 05:03:59 -0700 Subject: [PATCH 4/5] Apply comments --- .../oneapi_queue_empty/queue_empty_ext_test.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/extension/oneapi_queue_empty/queue_empty_ext_test.cpp b/tests/extension/oneapi_queue_empty/queue_empty_ext_test.cpp index 3c2dfbdae..399334e02 100644 --- a/tests/extension/oneapi_queue_empty/queue_empty_ext_test.cpp +++ b/tests/extension/oneapi_queue_empty/queue_empty_ext_test.cpp @@ -64,8 +64,7 @@ TEST_CASE( sycl::buffer array_buf(array, buf_size); auto e = queue.submit([&](sycl::handler& cgh) { - auto array_acc = - array_buf.template get_access(cgh); + auto array_acc = sycl::accessor(array_buf, cgh, sycl::write_only); cgh.single_task(Kernel(array_acc)); }); @@ -95,15 +94,13 @@ TEST_CASE( sycl::buffer array_buf(array, buf_size); auto Ea = queue.submit([&](sycl::handler& cgh) { - auto array_acc = - array_buf.template get_access(cgh); + auto array_acc = sycl::accessor(array_buf, cgh, sycl::write_only); cgh.single_task(Kernel(array_acc)); }); auto Eb = queue.submit([&](sycl::handler& cgh) { cgh.depends_on(Ea); - auto array_acc = - array_buf.template get_access(cgh); + auto array_acc = sycl::accessor(array_buf, cgh, sycl::write_only); cgh.single_task(Kernel(array_acc)); }); From 9e540c2cd2e0bf0648e292e512df7d66dd99bc5b Mon Sep 17 00:00:00 2001 From: Alexey Bader Date: Fri, 7 Jul 2023 15:09:38 -0700 Subject: [PATCH 5/5] Update tests/extension/oneapi_queue_empty/queue_empty_ext_test.cpp --- tests/extension/oneapi_queue_empty/queue_empty_ext_test.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/extension/oneapi_queue_empty/queue_empty_ext_test.cpp b/tests/extension/oneapi_queue_empty/queue_empty_ext_test.cpp index 399334e02..efcd57531 100644 --- a/tests/extension/oneapi_queue_empty/queue_empty_ext_test.cpp +++ b/tests/extension/oneapi_queue_empty/queue_empty_ext_test.cpp @@ -60,8 +60,7 @@ TEST_CASE( #else auto queue = sycl_cts::util::get_cts_object::queue(); - size_t array[buf_size]; - sycl::buffer array_buf(array, buf_size); + sycl::buffer array_buf(buf_size); auto e = queue.submit([&](sycl::handler& cgh) { auto array_acc = sycl::accessor(array_buf, cgh, sycl::write_only);