From bee45c380d0c603809a4813ec1c4cac6967a8fca Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Thu, 18 Jan 2024 16:15:54 -0800 Subject: [PATCH 1/9] Throw when USM not supported by Device --- sycl/source/detail/usm/usm_impl.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sycl/source/detail/usm/usm_impl.cpp b/sycl/source/detail/usm/usm_impl.cpp index 396750acf3044..4260bb8569b07 100644 --- a/sycl/source/detail/usm/usm_impl.cpp +++ b/sycl/source/detail/usm/usm_impl.cpp @@ -252,6 +252,11 @@ void *alignedAlloc(size_t Alignment, size_t Size, const context &Ctxt, PrepareNotify.scopedNotify( (uint16_t)xpti::trace_point_type_t::mem_alloc_begin); #endif + if (Kind == alloc::device && + !Dev.has(sycl::aspect::usm_device_allocations)) { + throw sycl::exception(sycl::errc::feature_not_supported, + "Device does not support Unified Shared Memory!"); + } void *RetVal = alignedAllocInternal(Alignment, Size, getSyclObjImpl(Ctxt).get(), getSyclObjImpl(Dev).get(), Kind, PropList); From 04595ade1fc6daaacdf4e15397c6fb05945234c2 Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Fri, 9 Feb 2024 07:27:11 -0800 Subject: [PATCH 2/9] Update usm_impl.cpp --- sycl/source/detail/usm/usm_impl.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sycl/source/detail/usm/usm_impl.cpp b/sycl/source/detail/usm/usm_impl.cpp index 965a4f47f57c7..3db9df8b52337 100755 --- a/sycl/source/detail/usm/usm_impl.cpp +++ b/sycl/source/detail/usm/usm_impl.cpp @@ -273,11 +273,6 @@ void *alignedAlloc(size_t Alignment, size_t Size, const context &Ctxt, PrepareNotify.scopedNotify( (uint16_t)xpti::trace_point_type_t::mem_alloc_begin); #endif - if (Kind == alloc::device && - !Dev.has(sycl::aspect::usm_device_allocations)) { - throw sycl::exception(sycl::errc::feature_not_supported, - "Device does not support Unified Shared Memory!"); - } void *RetVal = alignedAllocInternal(Alignment, Size, getSyclObjImpl(Ctxt).get(), getSyclObjImpl(Dev).get(), Kind, PropList); From a3cd85778d5e63a1af563393c24e8660dab5e48c Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Mon, 26 Feb 2024 20:38:49 -0800 Subject: [PATCH 3/9] Emit error when set_final_data called with non-const iterator --- sycl/include/sycl/buffer.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sycl/include/sycl/buffer.hpp b/sycl/include/sycl/buffer.hpp index 0ef5494088e3a..d7c79fa24b6dc 100644 --- a/sycl/include/sycl/buffer.hpp +++ b/sycl/include/sycl/buffer.hpp @@ -629,6 +629,8 @@ class buffer : public detail::buffer_plain, template detail::EnableIfOutputIteratorT set_final_data_internal(Destination FinalData) { + static_assert(!std::is_const_v>, + "set_final_data must be called with a non-const iterator!"); const size_t Size = size(); buffer_plain::set_final_data_internal( [FinalData, Size](const std::function &F) { From 002d53d0cee27a638d5da15f838714ca0d58857d Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Tue, 27 Feb 2024 09:56:52 -0800 Subject: [PATCH 4/9] Fix EnableIfOuputIteratorT --- sycl/include/sycl/detail/common.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sycl/include/sycl/detail/common.hpp b/sycl/include/sycl/detail/common.hpp index a8c94e32d81c6..05f9bb8bbadb8 100644 --- a/sycl/include/sycl/detail/common.hpp +++ b/sycl/include/sycl/detail/common.hpp @@ -35,7 +35,9 @@ using EnableIfOutputPointerT = std::enable_if_t< template using EnableIfOutputIteratorT = std::enable_if_t< - /*is_output_iterator::value &&*/ !std::is_pointer_v>; + /*is_output_iterator::value &&*/ !std::is_pointer_v && + !std::is_const_v::reference>>>; #if !defined(NDEBUG) && (_MSC_VER > 1929 || __has_builtin(__builtin_FILE)) #define __CODELOC_FILE_NAME __builtin_FILE() From 27f829496a30abe8c546c4b42acc373c2b3a383f Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Tue, 27 Feb 2024 09:57:07 -0800 Subject: [PATCH 5/9] Fix EnableIfOuputIteratorT --- sycl/include/sycl/buffer.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/sycl/include/sycl/buffer.hpp b/sycl/include/sycl/buffer.hpp index d7c79fa24b6dc..0ef5494088e3a 100644 --- a/sycl/include/sycl/buffer.hpp +++ b/sycl/include/sycl/buffer.hpp @@ -629,8 +629,6 @@ class buffer : public detail::buffer_plain, template detail::EnableIfOutputIteratorT set_final_data_internal(Destination FinalData) { - static_assert(!std::is_const_v>, - "set_final_data must be called with a non-const iterator!"); const size_t Size = size(); buffer_plain::set_final_data_internal( [FinalData, Size](const std::function &F) { From b69423f10bb3da292f859c0805901ae69cfe1e33 Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Tue, 27 Feb 2024 12:19:33 -0800 Subject: [PATCH 6/9] Fix EnableIfOutputIteratorT --- sycl/include/sycl/detail/common.hpp | 26 ++++++++++---------- sycl/include/sycl/detail/stl_type_traits.hpp | 5 ++++ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/sycl/include/sycl/detail/common.hpp b/sycl/include/sycl/detail/common.hpp index 05f9bb8bbadb8..fe0c65fa28b0f 100644 --- a/sycl/include/sycl/detail/common.hpp +++ b/sycl/include/sycl/detail/common.hpp @@ -8,16 +8,16 @@ #pragma once +#include // for array +#include // for assert +#include // for size_t +#include // for allocator, operator+ #include // for __SYCL_ALWAYS_INLINE #include // for __SYCL_EXPORT #include // for pi_int32 - -#include // for array -#include // for assert -#include // for size_t -#include // for allocator, operator+ -#include // for enable_if_t -#include // for index_sequence, make_i... +#include // for is_output_iteratior +#include // for enable_if_t +#include // for index_sequence, make_i... // Default signature enables the passing of user code location information to // public methods as a default argument. @@ -30,14 +30,14 @@ namespace detail { // TODO: Align these checks with the SYCL specification when the behaviour // with void * is clarified. template -using EnableIfOutputPointerT = std::enable_if_t< - /*is_output_iterator::value &&*/ std::is_pointer_v>; +using EnableIfOutputPointerT = + std::enable_if_t::value && + std::is_pointer_v>; template -using EnableIfOutputIteratorT = std::enable_if_t< - /*is_output_iterator::value &&*/ !std::is_pointer_v && - !std::is_const_v::reference>>>; +using EnableIfOutputIteratorT = + std::enable_if_t::value && + !std::is_pointer_v>; #if !defined(NDEBUG) && (_MSC_VER > 1929 || __has_builtin(__builtin_FILE)) #define __CODELOC_FILE_NAME __builtin_FILE() diff --git a/sycl/include/sycl/detail/stl_type_traits.hpp b/sycl/include/sycl/detail/stl_type_traits.hpp index 000a04d113c70..b8e7f802115a4 100644 --- a/sycl/include/sycl/detail/stl_type_traits.hpp +++ b/sycl/include/sycl/detail/stl_type_traits.hpp @@ -49,6 +49,11 @@ struct is_output_iterator> { static constexpr bool value = true; }; +template <> +struct is_output_iterator { + static constexpr bool value = true; +}; + } // namespace detail } // namespace _V1 } // namespace sycl From f01763a530f4f388626345d9a7245652d0f127d5 Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Tue, 27 Feb 2024 12:43:05 -0800 Subject: [PATCH 7/9] Fix EnableIfOutputIteratorT --- sycl/include/sycl/detail/common.hpp | 4 ---- sycl/include/sycl/detail/stl_type_traits.hpp | 7 ++++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/sycl/include/sycl/detail/common.hpp b/sycl/include/sycl/detail/common.hpp index fe0c65fa28b0f..5a6fd5472615f 100644 --- a/sycl/include/sycl/detail/common.hpp +++ b/sycl/include/sycl/detail/common.hpp @@ -25,10 +25,6 @@ namespace sycl { inline namespace _V1 { namespace detail { -// The check for output iterator is commented out as it blocks set_final_data -// with void * argument to be used. -// TODO: Align these checks with the SYCL specification when the behaviour -// with void * is clarified. template using EnableIfOutputPointerT = std::enable_if_t::value && diff --git a/sycl/include/sycl/detail/stl_type_traits.hpp b/sycl/include/sycl/detail/stl_type_traits.hpp index b8e7f802115a4..2f43094333938 100644 --- a/sycl/include/sycl/detail/stl_type_traits.hpp +++ b/sycl/include/sycl/detail/stl_type_traits.hpp @@ -49,9 +49,10 @@ struct is_output_iterator> { static constexpr bool value = true; }; -template <> -struct is_output_iterator { - static constexpr bool value = true; +// the case when T = void * is hardcoded because of a reference to void error +// that is generated by the previous speialization +template <> struct is_output_iterator { + static constexpr bool value = true; }; } // namespace detail From 3e52d55946daa1926bc95ce8a560d4b9d263f5b8 Mon Sep 17 00:00:00 2001 From: Lorenc Bushi <113361374+lbushi25@users.noreply.github.com> Date: Tue, 27 Feb 2024 18:33:07 -0500 Subject: [PATCH 8/9] Update stl_type_traits.hpp --- sycl/include/sycl/detail/stl_type_traits.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/include/sycl/detail/stl_type_traits.hpp b/sycl/include/sycl/detail/stl_type_traits.hpp index 2f43094333938..f81fc9ec035b4 100644 --- a/sycl/include/sycl/detail/stl_type_traits.hpp +++ b/sycl/include/sycl/detail/stl_type_traits.hpp @@ -52,7 +52,7 @@ struct is_output_iterator> { // the case when T = void * is hardcoded because of a reference to void error // that is generated by the previous speialization template <> struct is_output_iterator { - static constexpr bool value = true; + static constexpr bool value = false; }; } // namespace detail From 17e2860f4fce580e3053d59003c585172b02b108 Mon Sep 17 00:00:00 2001 From: Lorenc Bushi <113361374+lbushi25@users.noreply.github.com> Date: Tue, 27 Feb 2024 18:39:24 -0500 Subject: [PATCH 9/9] Update stl_type_traits.hpp --- sycl/include/sycl/detail/stl_type_traits.hpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/sycl/include/sycl/detail/stl_type_traits.hpp b/sycl/include/sycl/detail/stl_type_traits.hpp index f81fc9ec035b4..000a04d113c70 100644 --- a/sycl/include/sycl/detail/stl_type_traits.hpp +++ b/sycl/include/sycl/detail/stl_type_traits.hpp @@ -49,12 +49,6 @@ struct is_output_iterator> { static constexpr bool value = true; }; -// the case when T = void * is hardcoded because of a reference to void error -// that is generated by the previous speialization -template <> struct is_output_iterator { - static constexpr bool value = false; -}; - } // namespace detail } // namespace _V1 } // namespace sycl