diff --git a/tests/usm/usm_api.h b/tests/usm/usm_api.h index 318defbbf..3093cd039 100644 --- a/tests/usm/usm_api.h +++ b/tests/usm/usm_api.h @@ -217,11 +217,35 @@ void check_values(const T *begin, const ReferenceIt &reference) { } } +/** @brief Trait for tests that have no additional device requirements + * + * Tests implementing this trait do not require any device support beyond + * the destination memory location. + */ +struct noAdditionalDeviceRequirements { + static bool supports_device(sycl_cts::util::logger&, const sycl::queue&) { + return true; + } +}; + +/** @brief Trait for tests that require support for a given USM alloc type + * + * Tests implementing this trait require device support for a specific + * type of allocation (e.g. as a source memory location). + */ +template +struct requiresUsmAllocationSupport { + static bool supports_device(sycl_cts::util::logger& log, + const sycl::queue& queue) { + return check_device_support(log, queue); + } +}; + /** @brief Provides generic copy test logic for memcpy() and copy() tests * @tparam sourceAllocation Allocation type to use for data source */ template -class copyGeneric { +class copyGeneric : public requiresUsmAllocationSupport { protected: using storage_t = storage; const typename storage_t::type source; @@ -251,13 +275,6 @@ class copy : public copyGeneric { */ static constexpr bool has_non_usm_support() { return true; } - /** @brief This test only works on devices with `sourceAllocation` support - */ - static bool supports_device(sycl_cts::util::logger& log, - const sycl::queue& queue) { - return check_device_support(log, queue); - } - template static std::string description() { return "copy from " + get_allocation_decription() + @@ -283,13 +300,6 @@ class memcpy : public copyGeneric { */ static constexpr bool has_non_usm_support() { return true; } - /** @brief This test only works on devices with `sourceAllocation` support - */ - static bool supports_device(sycl_cts::util::logger& log, - const sycl::queue& queue) { - return check_device_support(log, queue); - } - template static std::string description() { return "memcpy from " + get_allocation_decription() + @@ -326,7 +336,7 @@ using memcpy_from_shared = detail::memcpy; /** @brief Provides test logic for the fill() member function tests */ template -class fill { +class fill : public detail::noAdditionalDeviceRequirements { const T value; public: @@ -336,13 +346,6 @@ class fill { */ static constexpr bool has_non_usm_support() { return false; } - /** @brief This test doesn't have any device requirements - */ - static bool supports_device(sycl_cts::util::logger& log, - const sycl::queue& queue) { - return true; - } - template static std::string description() { return "fill using " + get_allocation_decription(); @@ -364,7 +367,7 @@ class fill { /** @brief Provides test logic for the memset() member function tests */ template -class memset { +class memset : public detail::noAdditionalDeviceRequirements { const int value; public: @@ -376,13 +379,6 @@ class memset { */ static constexpr bool has_non_usm_support() { return false; } - /** @brief This test doesn't have any device requirements - */ - static bool supports_device(sycl_cts::util::logger& log, - const sycl::queue& queue) { - return true; - } - template static std::string description() { return "memset using " + get_allocation_decription(); @@ -404,7 +400,7 @@ class memset { /** @brief Provides test logic for the prefetch() member function tests */ template -class prefetch { +class prefetch : public detail::noAdditionalDeviceRequirements { public: static constexpr size_t size = count * sizeof(T); @@ -414,13 +410,6 @@ class prefetch { */ static constexpr bool has_non_usm_support() { return false; } - /** @brief This test doesn't have any device requirements - */ - static bool supports_device(sycl_cts::util::logger& log, - const sycl::queue& queue) { - return true; - } - template static std::string description() { return "prefetch using " + get_allocation_decription(); @@ -439,7 +428,7 @@ class prefetch { /** @brief Provides test logic for the mem_advise() member function tests */ template -class mem_advise { +class mem_advise : public detail::noAdditionalDeviceRequirements { public: static constexpr size_t size = count * sizeof(T); @@ -449,13 +438,6 @@ class mem_advise { */ static constexpr bool has_non_usm_support() { return false; } - /** @brief This test doesn't have any device requirements - */ - static bool supports_device(sycl_cts::util::logger& log, - const sycl::queue& queue) { - return true; - } - template static std::string description() { return "mem_advise using " + get_allocation_decription();