Skip to content

[SYCL] group algorithm routines with broadened supported types #4910

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

Merged
Merged
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
31 changes: 24 additions & 7 deletions sycl/include/CL/sycl/group_algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,12 @@ joint_none_of(Group g, Ptr first, Ptr last, Predicate pred) {
}

// ---- shift_group_left
// TODO: remove check for detail::is_vec<T> once sycl::vec is trivially
// copyable.
template <typename Group, typename T>
detail::enable_if_t<(std::is_same<std::decay_t<Group>, sub_group>::value &&
detail::is_arithmetic<T>::value),
(std::is_trivially_copyable<T>::value ||
detail::is_vec<T>::value)),
T>
shift_group_left(Group, T x, typename Group::linear_id_type delta = 1) {
#ifdef __SYCL_DEVICE_ONLY__
Expand All @@ -402,9 +405,12 @@ shift_group_left(Group, T x, typename Group::linear_id_type delta = 1) {
}

// ---- shift_group_right
// TODO: remove check for detail::is_vec<T> once sycl::vec is trivially
// copyable.
template <typename Group, typename T>
detail::enable_if_t<(std::is_same<std::decay_t<Group>, sub_group>::value &&
detail::is_arithmetic<T>::value),
(std::is_trivially_copyable<T>::value ||
detail::is_vec<T>::value)),
T>
shift_group_right(Group, T x, typename Group::linear_id_type delta = 1) {
#ifdef __SYCL_DEVICE_ONLY__
Expand All @@ -418,9 +424,12 @@ shift_group_right(Group, T x, typename Group::linear_id_type delta = 1) {
}

// ---- permute_group_by_xor
// TODO: remove check for detail::is_vec<T> once sycl::vec is trivially
// copyable.
template <typename Group, typename T>
detail::enable_if_t<(std::is_same<std::decay_t<Group>, sub_group>::value &&
detail::is_arithmetic<T>::value),
(std::is_trivially_copyable<T>::value ||
detail::is_vec<T>::value)),
T>
permute_group_by_xor(Group, T x, typename Group::linear_id_type mask) {
#ifdef __SYCL_DEVICE_ONLY__
Expand All @@ -434,9 +443,12 @@ permute_group_by_xor(Group, T x, typename Group::linear_id_type mask) {
}

// ---- select_from_group
// TODO: remove check for detail::is_vec<T> once sycl::vec is trivially
// copyable.
template <typename Group, typename T>
detail::enable_if_t<(std::is_same<std::decay_t<Group>, sub_group>::value &&
detail::is_arithmetic<T>::value),
(std::is_trivially_copyable<T>::value ||
detail::is_vec<T>::value)),
T>
select_from_group(Group, T x, typename Group::id_type local_id) {
#ifdef __SYCL_DEVICE_ONLY__
Expand All @@ -450,9 +462,12 @@ select_from_group(Group, T x, typename Group::id_type local_id) {
}

// ---- group_broadcast
// TODO: remove check for detail::is_vec<T> once sycl::vec is trivially
// copyable.
template <typename Group, typename T>
detail::enable_if_t<(is_group_v<std::decay_t<Group>> &&
detail::is_scalar_arithmetic<T>::value),
(std::is_trivially_copyable<T>::value ||
detail::is_vec<T>::value)),
T>
group_broadcast(Group, T x, typename Group::id_type local_id) {
#ifdef __SYCL_DEVICE_ONLY__
Expand All @@ -467,7 +482,8 @@ group_broadcast(Group, T x, typename Group::id_type local_id) {

template <typename Group, typename T>
detail::enable_if_t<(is_group_v<std::decay_t<Group>> &&
detail::is_scalar_arithmetic<T>::value),
(std::is_trivially_copyable<T>::value ||
detail::is_vec<T>::value)),
T>
group_broadcast(Group g, T x, typename Group::linear_id_type linear_local_id) {
#ifdef __SYCL_DEVICE_ONLY__
Expand All @@ -485,7 +501,8 @@ group_broadcast(Group g, T x, typename Group::linear_id_type linear_local_id) {

template <typename Group, typename T>
detail::enable_if_t<(is_group_v<std::decay_t<Group>> &&
detail::is_scalar_arithmetic<T>::value),
(std::is_trivially_copyable<T>::value ||
detail::is_vec<T>::value)),
T>
group_broadcast(Group g, T x) {
#ifdef __SYCL_DEVICE_ONLY__
Expand Down