diff --git a/test_plans/queue-shortcut-functions.asciidoc b/test_plans/queue-shortcut-functions.asciidoc index 744b320ca..b79f88281 100644 --- a/test_plans/queue-shortcut-functions.asciidoc +++ b/test_plans/queue-shortcut-functions.asciidoc @@ -80,16 +80,16 @@ The below functions are called to set some USM zero-initialized buffer `ptr` to ==== Prefetch Each of the below functions is called with some USM buffer. It is checked whether the return type of the functions is `event`. The USM buffers are allocation type `shared`. If the used device lacks this capability (aspect `aspect::usm_shared_allocations`), this test is skipped. -* `event prefetch(void* ptr, size_t numBytes)` -* `event prefetch(void* ptr, size_t numBytes, event depEvent)` -* `event prefetch(void* ptr, size_t numBytes, const std::vector& depEvents)` +* `event prefetch(const void* ptr, size_t numBytes)` +* `event prefetch(const void* ptr, size_t numBytes, event depEvent)` +* `event prefetch(const void* ptr, size_t numBytes, const std::vector& depEvents)` ==== Memory advise Each of the below functions is called with some USM buffer. It is checked whether the return type of the functions is `event`. The value of `advice` is `0`. The USM buffers are allocation type `device`. If the used device lacks this capability (aspect `aspect::usm_device_allocations`), this test is skipped. -* `event mem_advise(void* ptr, size_t numBytes, int advice)` -* `event mem_advise(void* ptr, size_t numBytes, int advice, event depEvent)` -* `event mem_advise(void* ptr, size_t numBytes, int advice, const std::vector& depEvents)` +* `event mem_advise(const void* ptr, size_t numBytes, int advice)` +* `event mem_advise(const void* ptr, size_t numBytes, int advice, event depEvent)` +* `event mem_advise(const void* ptr, size_t numBytes, int advice, const std::vector& depEvents)` === Explicit copy All accessors used are one-dimensional. diff --git a/tests/queue/queue_shortcuts_usm.h b/tests/queue/queue_shortcuts_usm.h index 1291f569d..0507db063 100644 --- a/tests/queue/queue_shortcuts_usm.h +++ b/tests/queue/queue_shortcuts_usm.h @@ -162,8 +162,6 @@ template void test_unified_shared_memory(sycl::queue q, unsigned int element_count) { const bool has_usm_device_allocations = q.get_device().has(sycl::aspect::usm_device_allocations); - const bool has_usm_shared_allocations = - q.get_device().has(sycl::aspect::usm_shared_allocations); runner_memcpy runner(q, element_count); @@ -234,10 +232,16 @@ void test_unified_shared_memory(sycl::queue q, unsigned int element_count) { "Device does not support USM device allocations. " "Skipping the test case."); } +} + +template +void test_prefetch(sycl::queue q, unsigned int element_count) { + const bool has_usm_shared_allocations = + q.get_device().has(sycl::aspect::usm_shared_allocations); - // prefetch if (has_usm_shared_allocations) { - T* ptr = sycl::malloc_shared(element_count, q); + const T* ptr = + static_cast(sycl::malloc_shared(element_count, q)); sycl::event prefetch_no_events = q.prefetch(ptr, element_count * sizeof(T)); sycl::event prefetch_single_event = q.prefetch(ptr, element_count * sizeof(T), prefetch_no_events); @@ -246,16 +250,22 @@ void test_unified_shared_memory(sycl::queue q, unsigned int element_count) { {prefetch_no_events, prefetch_single_event}); prefetch_multiple_events.wait(); prefetch_no_events.wait(); - sycl::free(ptr, q); + sycl::free(const_cast(ptr), q); } else { WARN( "Device does not support USM shared allocations. " "Skipping the test case."); } +} + +template +void test_mem_advise(sycl::queue q, unsigned int element_count) { + const bool has_usm_device_allocations = + q.get_device().has(sycl::aspect::usm_device_allocations); - // advise if (has_usm_device_allocations) { - T* ptr = sycl::malloc_device(element_count, q); + const T* ptr = + static_cast(sycl::malloc_device(element_count, q)); constexpr int advice = 0; sycl::event advise_no_events = q.mem_advise(ptr, element_count * sizeof(T), advice); @@ -266,7 +276,7 @@ void test_unified_shared_memory(sycl::queue q, unsigned int element_count) { {advise_no_events, advise_single_event}); advise_multiple_events.wait(); advise_no_events.wait(); - sycl::free(ptr, q); + sycl::free(const_cast(ptr), q); } else { WARN( "Device does not support USM device allocations. " @@ -283,6 +293,10 @@ class check_queue_shortcuts_usm_for_type { INFO("for type \"" << type_name << "\": "); test_unified_shared_memory(queue, element_count); +#if !SYCL_CTS_COMPILING_WITH_SIMSYCL + test_prefetch(queue, element_count); + test_mem_advise(queue, element_count); +#endif } }; diff --git a/tests/usm/usm_api.h b/tests/usm/usm_api.h index 3093cd039..e672b0d95 100644 --- a/tests/usm/usm_api.h +++ b/tests/usm/usm_api.h @@ -416,7 +416,7 @@ class prefetch : public detail::noAdditionalDeviceRequirements { } template - auto call(parentT &parent, T *ptr, depEventsT &&... events) const { + auto call(parentT& parent, const T* ptr, depEventsT&&... events) const { return parent.prefetch(ptr, size, std::forward(events)...); } @@ -444,7 +444,7 @@ class mem_advise : public detail::noAdditionalDeviceRequirements { } template - auto call(parentT &parent, T *ptr, depEventsT &&... events) const { + auto call(parentT& parent, const T* ptr, depEventsT&&... events) const { const int advice = 0; // Reset to defaults according to the SYCL 2020 spec return parent.mem_advise(ptr, size, advice, std::forward(events)...); diff --git a/tests/usm/usm_api_mem_advise_handler_no_events.cpp b/tests/usm/usm_api_mem_advise_handler_no_events.cpp index 1284982c7..61bd75cd4 100644 --- a/tests/usm/usm_api_mem_advise_handler_no_events.cpp +++ b/tests/usm/usm_api_mem_advise_handler_no_events.cpp @@ -8,34 +8,16 @@ *******************************************************************************/ #include "../common/common.h" +#include "../common/disabled_for_test_case.h" #include "usm_api.h" -#define TEST_NAME usm_api_mem_advise_handler_no_events - -namespace TEST_NAMESPACE { +namespace usm_api_mem_advise_handler_no_events { using namespace usm_api; -template -using run_tests = run_all_tests; - -/** Test instance - */ -class TEST_NAME : public sycl_cts::util::test_base { - public: - /** return information about this test - */ - void get_info(test_base::info &out) const override { - set_test_info(out, TOSTRING(TEST_NAME), TEST_FILE); - } - - /** execute the test - */ - void run(sycl_cts::util::logger &log) override { - run_tests{}(log); - } -}; - -// construction of this proxy will register the above test -sycl_cts::util::test_proxy proxy; +DISABLED_FOR_TEST_CASE(SimSYCL) +("usm_api_mem_advise_handler_no_events", "[usm]")({ + sycl_cts::util::logger log; + run_all_tests{}(log); +}); -} // namespace TEST_NAMESPACE +} // namespace usm_api_mem_advise_handler_no_events diff --git a/tests/usm/usm_api_mem_advise_queue_multiple_events.cpp b/tests/usm/usm_api_mem_advise_queue_multiple_events.cpp index e5df3d6cf..ef441a2a1 100644 --- a/tests/usm/usm_api_mem_advise_queue_multiple_events.cpp +++ b/tests/usm/usm_api_mem_advise_queue_multiple_events.cpp @@ -8,34 +8,16 @@ *******************************************************************************/ #include "../common/common.h" +#include "../common/disabled_for_test_case.h" #include "usm_api.h" -#define TEST_NAME usm_api_mem_advise_queue_multiple_events - -namespace TEST_NAMESPACE { +namespace usm_api_mem_advise_queue_multiple_events { using namespace usm_api; -template -using run_tests = run_all_tests; - -/** Test instance - */ -class TEST_NAME : public sycl_cts::util::test_base { - public: - /** return information about this test - */ - void get_info(test_base::info &out) const override { - set_test_info(out, TOSTRING(TEST_NAME), TEST_FILE); - } - - /** execute the test - */ - void run(sycl_cts::util::logger &log) override { - run_tests{}(log); - } -}; - -// construction of this proxy will register the above test -sycl_cts::util::test_proxy proxy; +DISABLED_FOR_TEST_CASE(SimSYCL) +("usm_api_mem_advise_queue_multiple_events", "[usm]")({ + sycl_cts::util::logger log; + run_all_tests{}(log); +}); -} // namespace TEST_NAMESPACE +} // namespace usm_api_mem_advise_queue_multiple_events diff --git a/tests/usm/usm_api_mem_advise_queue_no_events.cpp b/tests/usm/usm_api_mem_advise_queue_no_events.cpp index 720139d52..9e2aa287c 100644 --- a/tests/usm/usm_api_mem_advise_queue_no_events.cpp +++ b/tests/usm/usm_api_mem_advise_queue_no_events.cpp @@ -7,34 +7,16 @@ *******************************************************************************/ #include "../common/common.h" +#include "../common/disabled_for_test_case.h" #include "usm_api.h" -#define TEST_NAME usm_api_mem_advise_queue_no_events - -namespace TEST_NAMESPACE { +namespace usm_api_mem_advise_queue_no_events { using namespace usm_api; -template -using run_tests = run_all_tests; - -/** Test instance - */ -class TEST_NAME : public sycl_cts::util::test_base { - public: - /** return information about this test - */ - void get_info(test_base::info &out) const override { - set_test_info(out, TOSTRING(TEST_NAME), TEST_FILE); - } - - /** execute the test - */ - void run(sycl_cts::util::logger &log) override { - run_tests{}(log); - } -}; - -// construction of this proxy will register the above test -sycl_cts::util::test_proxy proxy; +DISABLED_FOR_TEST_CASE(SimSYCL) +("usm_api_mem_advise_queue_no_events", "[usm]")({ + sycl_cts::util::logger log; + run_all_tests{}(log); +}); -} // namespace TEST_NAMESPACE +} // namespace usm_api_mem_advise_queue_no_events diff --git a/tests/usm/usm_api_mem_advise_queue_single_event.cpp b/tests/usm/usm_api_mem_advise_queue_single_event.cpp index b45ac0d32..3237ab96d 100644 --- a/tests/usm/usm_api_mem_advise_queue_single_event.cpp +++ b/tests/usm/usm_api_mem_advise_queue_single_event.cpp @@ -7,34 +7,16 @@ *******************************************************************************/ #include "../common/common.h" +#include "../common/disabled_for_test_case.h" #include "usm_api.h" -#define TEST_NAME usm_api_mem_advise_queue_single_event - -namespace TEST_NAMESPACE { +namespace usm_api_mem_advise_queue_single_event { using namespace usm_api; -template -using run_tests = run_all_tests; - -/** Test instance - */ -class TEST_NAME : public sycl_cts::util::test_base { - public: - /** return information about this test - */ - void get_info(test_base::info &out) const override { - set_test_info(out, TOSTRING(TEST_NAME), TEST_FILE); - } - - /** execute the test - */ - void run(sycl_cts::util::logger &log) override { - run_tests{}(log); - } -}; - -// construction of this proxy will register the above test -sycl_cts::util::test_proxy proxy; +DISABLED_FOR_TEST_CASE(SimSYCL) +("usm_api_mem_advise_queue_single_event", "[usm]")({ + sycl_cts::util::logger log; + run_all_tests{}(log); +}); -} // namespace TEST_NAMESPACE +} // namespace usm_api_mem_advise_queue_single_event diff --git a/tests/usm/usm_api_prefetch_handler_no_events.cpp b/tests/usm/usm_api_prefetch_handler_no_events.cpp index 9472b275a..6d34ed7cb 100644 --- a/tests/usm/usm_api_prefetch_handler_no_events.cpp +++ b/tests/usm/usm_api_prefetch_handler_no_events.cpp @@ -8,34 +8,16 @@ *******************************************************************************/ #include "../common/common.h" +#include "../common/disabled_for_test_case.h" #include "usm_api.h" -#define TEST_NAME usm_api_prefetch_handler_no_events - -namespace TEST_NAMESPACE { +namespace usm_api_prefetch_handler_no_events { using namespace usm_api; -template -using run_tests = run_all_tests; - -/** Test instance - */ -class TEST_NAME : public sycl_cts::util::test_base { - public: - /** return information about this test - */ - void get_info(test_base::info &out) const override { - set_test_info(out, TOSTRING(TEST_NAME), TEST_FILE); - } - - /** execute the test - */ - void run(sycl_cts::util::logger &log) override { - run_tests{}(log); - } -}; - -// construction of this proxy will register the above test -sycl_cts::util::test_proxy proxy; +DISABLED_FOR_TEST_CASE(SimSYCL) +("usm_api_prefetch_handler_no_events", "[usm]")({ + sycl_cts::util::logger log; + run_all_tests{}(log); +}); -} // namespace TEST_NAMESPACE +} // namespace usm_api_prefetch_handler_no_events diff --git a/tests/usm/usm_api_prefetch_queue_multiple_events.cpp b/tests/usm/usm_api_prefetch_queue_multiple_events.cpp index 5233b2bb7..6ab24fc0a 100644 --- a/tests/usm/usm_api_prefetch_queue_multiple_events.cpp +++ b/tests/usm/usm_api_prefetch_queue_multiple_events.cpp @@ -8,34 +8,16 @@ *******************************************************************************/ #include "../common/common.h" +#include "../common/disabled_for_test_case.h" #include "usm_api.h" -#define TEST_NAME usm_api_prefetch_queue_multiple_events - -namespace TEST_NAMESPACE { +namespace usm_api_prefetch_queue_multiple_events { using namespace usm_api; -template -using run_tests = run_all_tests; - -/** Test instance - */ -class TEST_NAME : public sycl_cts::util::test_base { - public: - /** return information about this test - */ - void get_info(test_base::info &out) const override { - set_test_info(out, TOSTRING(TEST_NAME), TEST_FILE); - } - - /** execute the test - */ - void run(sycl_cts::util::logger &log) override { - run_tests{}(log); - } -}; - -// construction of this proxy will register the above test -sycl_cts::util::test_proxy proxy; +DISABLED_FOR_TEST_CASE(SimSYCL) +("usm_api_prefetch_queue_multiple_events", "[usm]")({ + sycl_cts::util::logger log; + run_all_tests{}(log); +}); -} // namespace TEST_NAMESPACE +} // namespace usm_api_prefetch_queue_multiple_events diff --git a/tests/usm/usm_api_prefetch_queue_no_events.cpp b/tests/usm/usm_api_prefetch_queue_no_events.cpp index fa02a5f06..e70cfdae7 100644 --- a/tests/usm/usm_api_prefetch_queue_no_events.cpp +++ b/tests/usm/usm_api_prefetch_queue_no_events.cpp @@ -7,34 +7,16 @@ *******************************************************************************/ #include "../common/common.h" +#include "../common/disabled_for_test_case.h" #include "usm_api.h" -#define TEST_NAME usm_api_prefetch_queue_no_events - -namespace TEST_NAMESPACE { +namespace usm_api_prefetch_queue_no_events { using namespace usm_api; -template -using run_tests = run_all_tests; - -/** Test instance - */ -class TEST_NAME : public sycl_cts::util::test_base { - public: - /** return information about this test - */ - void get_info(test_base::info &out) const override { - set_test_info(out, TOSTRING(TEST_NAME), TEST_FILE); - } - - /** execute the test - */ - void run(sycl_cts::util::logger &log) override { - run_tests{}(log); - } -}; - -// construction of this proxy will register the above test -sycl_cts::util::test_proxy proxy; +DISABLED_FOR_TEST_CASE(SimSYCL) +("usm_api_prefetch_queue_no_events", "[usm]")({ + sycl_cts::util::logger log; + run_all_tests{}(log); +}); -} // namespace TEST_NAMESPACE +} // namespace usm_api_prefetch_queue_no_events diff --git a/tests/usm/usm_api_prefetch_queue_single_event.cpp b/tests/usm/usm_api_prefetch_queue_single_event.cpp index b5b2da55e..3d6657f88 100644 --- a/tests/usm/usm_api_prefetch_queue_single_event.cpp +++ b/tests/usm/usm_api_prefetch_queue_single_event.cpp @@ -7,34 +7,16 @@ *******************************************************************************/ #include "../common/common.h" +#include "../common/disabled_for_test_case.h" #include "usm_api.h" -#define TEST_NAME usm_api_prefetch_queue_single_event - -namespace TEST_NAMESPACE { +namespace usm_api_prefetch_queue_single_event { using namespace usm_api; -template -using run_tests = run_all_tests; - -/** Test instance - */ -class TEST_NAME : public sycl_cts::util::test_base { - public: - /** return information about this test - */ - void get_info(test_base::info &out) const override { - set_test_info(out, TOSTRING(TEST_NAME), TEST_FILE); - } - - /** execute the test - */ - void run(sycl_cts::util::logger &log) override { - run_tests{}(log); - } -}; - -// construction of this proxy will register the above test -sycl_cts::util::test_proxy proxy; +DISABLED_FOR_TEST_CASE(SimSYCL) +("usm_api_prefetch_queue_single_event", "[usm]")({ + sycl_cts::util::logger log; + run_all_tests{}(log); +}); -} // namespace TEST_NAMESPACE +} // namespace usm_api_prefetch_queue_single_event