Skip to content

Remove restrictions on sycl::group_broadcast #4717

Closed
@masterleinad

Description

@masterleinad

Is your feature request related to a problem? Please describe
Related to kokkos/kokkos#4388.
Despite SYCL2020 not constraining sycl::group_broadcast (https://www.khronos.org/registry/SYCL/specs/sycl-2020/html/sycl-2020.html#_group_broadcast), the oneAPI implementation does, see

// ---- group_broadcast
template <typename Group, typename T>
detail::enable_if_t<(is_group_v<std::decay_t<Group>> &&
detail::is_scalar_arithmetic<T>::value),
T>
group_broadcast(Group, T x, typename Group::id_type local_id) {
#ifdef __SYCL_DEVICE_ONLY__
return sycl::detail::spirv::GroupBroadcast<Group>(x, local_id);
#else
(void)x;
(void)local_id;
throw runtime_error("Group algorithms are not supported on host device.",
PI_INVALID_DEVICE);
#endif
}
template <typename Group, typename T>
detail::enable_if_t<(is_group_v<std::decay_t<Group>> &&
detail::is_scalar_arithmetic<T>::value),
T>
group_broadcast(Group g, T x, typename Group::linear_id_type linear_local_id) {
#ifdef __SYCL_DEVICE_ONLY__
return group_broadcast(
g, x,
sycl::detail::linear_id_to_id(g.get_local_range(), linear_local_id));
#else
(void)g;
(void)x;
(void)linear_local_id;
throw runtime_error("Group algorithms are not supported on host device.",
PI_INVALID_DEVICE);
#endif
}
template <typename Group, typename T>
detail::enable_if_t<(is_group_v<std::decay_t<Group>> &&
detail::is_scalar_arithmetic<T>::value),
T>
group_broadcast(Group g, T x) {
#ifdef __SYCL_DEVICE_ONLY__
return group_broadcast(g, x, 0);
#else
(void)g;
(void)x;
throw runtime_error("Group algorithms are not supported on host device.",
PI_INVALID_DEVICE);
#endif
}
.

Describe the solution you would like
Remove the restriction to arithmetic types.

Describe alternatives you have considered
There is a workaround in kokkos/kokkos#4388 that should also work as a general fallback option if a more efficient implementation for non-arithmetic types cannot be provided.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions