Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for iterators with const-qualified value type #1527

Merged
merged 3 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions include/oneapi/dpl/pstl/hetero/dpcpp/sycl_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,36 @@ struct __vector_iter_distinguishes_by_allocator<
{
};

template <typename Iter, typename Void = void>
struct __is_known_usm_vector_iter_impl : std::false_type
{
};

template <typename Iter>
struct __is_known_usm_vector_iter_impl<
Iter, std::enable_if_t<std::conjunction<
std::disjunction<std::is_same<Iter, oneapi::dpl::__internal::__usm_shared_alloc_vec_iter<Iter>>,
std::is_same<Iter, oneapi::dpl::__internal::__usm_host_alloc_vec_iter<Iter>>>,
oneapi::dpl::__internal::__vector_iter_distinguishes_by_allocator<Iter>>::value>> : std::true_type
{
};

template <typename Iter, typename Void = void>
struct __is_known_usm_vector_iter : std::false_type
{
};

//We must avoid instantiating vector of const, reference, or function elements to avoid ill-formed vector instantiation
template <typename Iter>
struct __is_known_usm_vector_iter<
Iter, std::enable_if_t<std::conjunction<
std::negation<std::disjunction<std::is_const<typename std::iterator_traits<Iter>::value_type>,
std::is_reference<typename std::iterator_traits<Iter>::value_type>,
std::is_function<typename std::iterator_traits<Iter>::value_type>>>,
oneapi::dpl::__internal::__is_known_usm_vector_iter_impl<Iter>>::value>> : std::true_type
{
};

} // namespace __internal

template <typename T, typename Allocator>
Expand Down
7 changes: 2 additions & 5 deletions include/oneapi/dpl/pstl/hetero/dpcpp/utils_ranges_sycl.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,8 @@ struct is_passed_directly<Iter, ::std::enable_if_t<Iter::is_passed_directly::val

//support std::vector::iterator with usm host / shared allocator as passed directly
template <typename Iter>
struct is_passed_directly<
Iter, std::enable_if_t<(std::is_same_v<Iter, oneapi::dpl::__internal::__usm_shared_alloc_vec_iter<Iter>> ||
std::is_same_v<Iter, oneapi::dpl::__internal::__usm_host_alloc_vec_iter<Iter>>) &&
oneapi::dpl::__internal::__vector_iter_distinguishes_by_allocator<Iter>::value>> :
std::true_type
struct is_passed_directly<Iter, std::enable_if_t<oneapi::dpl::__internal::__is_known_usm_vector_iter<Iter>::value>>
: std::true_type
{
};

Expand Down
Loading