diff --git a/include/oneapi/dpl/pstl/hetero/dpcpp/sycl_iterator.h b/include/oneapi/dpl/pstl/hetero/dpcpp/sycl_iterator.h index a38d6520b4f..b238133ace0 100644 --- a/include/oneapi/dpl/pstl/hetero/dpcpp/sycl_iterator.h +++ b/include/oneapi/dpl/pstl/hetero/dpcpp/sycl_iterator.h @@ -17,6 +17,7 @@ #define _ONEDPL_SYCL_ITERATOR_H #include +#include #include "../../onedpl_config.h" #include "sycl_defs.h" @@ -149,14 +150,14 @@ struct _ModeConverter static constexpr access_mode __value = access_mode::discard_write; }; -template ::value_type> +template ::value_type>> using __default_alloc_vec_iter = typename std::vector::iterator; -template ::value_type> +template ::value_type>> using __usm_shared_alloc_vec_iter = typename std::vector>::iterator; -template ::value_type> +template ::value_type>> using __usm_host_alloc_vec_iter = typename std::vector>::iterator; @@ -164,48 +165,17 @@ using __usm_host_alloc_vec_iter = // std::vector::iterator can be distinguished between three different allocators, the // default, usm_shared, and usm_host. If all are distinct, it is very unlikely any non-usm based allocator // could be confused with a usm allocator. -template -struct __vector_iter_distinguishes_by_allocator : std::false_type -{ -}; -template -struct __vector_iter_distinguishes_by_allocator< - Iter, std::enable_if_t, __usm_shared_alloc_vec_iter> && - !std::is_same_v<__default_alloc_vec_iter, __usm_host_alloc_vec_iter> && - !std::is_same_v<__usm_host_alloc_vec_iter, __usm_shared_alloc_vec_iter>>> - : std::true_type -{ -}; - -template -struct __is_known_usm_vector_iter_impl : std::false_type -{ -}; - template -struct __is_known_usm_vector_iter_impl< - Iter, std::enable_if_t>, - std::is_same>>, - oneapi::dpl::__internal::__vector_iter_distinguishes_by_allocator>::value>> : std::true_type -{ -}; - -template -struct __is_known_usm_vector_iter : std::false_type -{ -}; +constexpr bool __vector_iter_distinguishes_by_allocator_v = + !std::is_same_v<__default_alloc_vec_iter, __usm_shared_alloc_vec_iter> && + !std::is_same_v<__default_alloc_vec_iter, __usm_host_alloc_vec_iter> && + !std::is_same_v<__usm_host_alloc_vec_iter, __usm_shared_alloc_vec_iter>; -//We must avoid instantiating vector of const, reference, or function elements to avoid ill-formed vector instantiation template -struct __is_known_usm_vector_iter< - Iter, std::enable_if_t::value_type>, - std::is_reference::value_type>, - std::is_function::value_type>>>, - oneapi::dpl::__internal::__is_known_usm_vector_iter_impl>::value>> : std::true_type -{ -}; +constexpr bool __is_known_usm_vector_iter_v = + oneapi::dpl::__internal::__vector_iter_distinguishes_by_allocator_v && + (std::is_same_v> || + std::is_same_v>); } // namespace __internal diff --git a/include/oneapi/dpl/pstl/hetero/dpcpp/utils_ranges_sycl.h b/include/oneapi/dpl/pstl/hetero/dpcpp/utils_ranges_sycl.h index 4e2f8626950..09f17157c20 100644 --- a/include/oneapi/dpl/pstl/hetero/dpcpp/utils_ranges_sycl.h +++ b/include/oneapi/dpl/pstl/hetero/dpcpp/utils_ranges_sycl.h @@ -209,7 +209,7 @@ struct is_passed_directly -struct is_passed_directly::value>> +struct is_passed_directly>> : std::true_type { }; @@ -236,7 +236,9 @@ struct is_passed_directly> : is_pas template struct is_passed_directly> - : ::std::conjunction, is_passed_directly> + : ::std::conjunction< + is_passed_directly, + is_passed_directly::IndexMap>> { }; diff --git a/test/parallel_api/iterator/input_data_sweep_usm_allocator.pass.cpp b/test/parallel_api/iterator/input_data_sweep_usm_allocator.pass.cpp index 90b635a4e86..ceb0d2036c9 100644 --- a/test/parallel_api/iterator/input_data_sweep_usm_allocator.pass.cpp +++ b/test/parallel_api/iterator/input_data_sweep_usm_allocator.pass.cpp @@ -47,7 +47,7 @@ test_usm_shared_alloc(Policy&& policy, T trash, size_t n, const std::string& typ __recurse, 0, /*__read =*/true, /*__reset_read=*/true, /*__write=*/true, /*__check_write=*/true, /*__usable_as_perm_map=*/true, /*__usable_as_perm_src=*/ - TestUtils::__vector_impl_distinguishes_usm_allocator_from_default::value, + TestUtils::__vector_impl_distinguishes_usm_allocator_from_default_v, /*__is_reversible=*/true>(policy, shared_data_vec.begin(), shared_data_vec.end(), counting, copy_out.get_data(), shared_data_vec.begin(), copy_out.get_data(), counting, trash, std::string("usm_shared_alloc_vector<") + type_text + std::string(">")); @@ -77,7 +77,7 @@ test_usm_host_alloc(Policy&& policy, T trash, size_t n, const std::string& type_ wrap_recurse< __recurse, 0, /*__read =*/true, /*__reset_read=*/true, /*__write=*/true, /*__check_write=*/true, /*__usable_as_perm_map=*/true, /*__usable_as_perm_src=*/ - TestUtils::__vector_impl_distinguishes_usm_allocator_from_default::value, + TestUtils::__vector_impl_distinguishes_usm_allocator_from_default_v, /*__is_reversible=*/true>(policy, host_data_vec.begin(), host_data_vec.end(), counting, copy_out.get_data(), host_data_vec.begin(), copy_out.get_data(), counting, trash, std::string("usm_host_alloc_vector<") + type_text + std::string(">")); diff --git a/test/support/utils.h b/test/support/utils.h index d314346875b..ccbd4d4ba68 100644 --- a/test/support/utils.h +++ b/test/support/utils.h @@ -854,14 +854,14 @@ struct _ZipIteratorAdapter }; #if TEST_DPCPP_BACKEND_PRESENT -template ::value_type> +template ::value_type>> using __default_alloc_vec_iter = typename std::vector::iterator; -template ::value_type> +template ::value_type>> using __usm_shared_alloc_vec_iter = typename std::vector>::iterator; -template ::value_type> +template ::value_type>> using __usm_host_alloc_vec_iter = typename std::vector>::iterator; @@ -869,19 +869,12 @@ using __usm_host_alloc_vec_iter = // std::vector::iterator can be distinguished between three different allocators, the // default, usm_shared, and usm_host. If all are distinct, it is very unlikely any non-usm based allocator // could be confused with a usm allocator. -template -struct __vector_impl_distinguishes_usm_allocator_from_default : std::false_type -{ -}; - template -struct __vector_impl_distinguishes_usm_allocator_from_default< - Iter, std::enable_if_t, __usm_shared_alloc_vec_iter> && - !std::is_same_v<__default_alloc_vec_iter, __usm_host_alloc_vec_iter> && - !std::is_same_v<__usm_host_alloc_vec_iter, __usm_shared_alloc_vec_iter>>> - : std::true_type -{ -}; +constexpr bool __vector_impl_distinguishes_usm_allocator_from_default_v = + !std::is_same_v<__default_alloc_vec_iter, __usm_shared_alloc_vec_iter> && + !std::is_same_v<__default_alloc_vec_iter, __usm_host_alloc_vec_iter> && + !std::is_same_v<__usm_host_alloc_vec_iter, __usm_shared_alloc_vec_iter>; + #endif //TEST_DPCPP_BACKEND_PRESENT ////////////////////////////////////////////////////////////////////////////////