Skip to content
Closed
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
7 changes: 7 additions & 0 deletions sycl/include/sycl/detail/generic_type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,13 @@ struct mptr_or_vec_elem_type<const multi_ptr<ElementType, Space, IsDecorated>>
template <typename T>
using mptr_or_vec_elem_type_t = typename mptr_or_vec_elem_type<T>::type;

template <int Size>
using cl_unsigned = std::conditional_t<
Size == 1, opencl::cl_uchar,
std::conditional_t<
Size == 2, opencl::cl_ushort,
std::conditional_t<Size == 4, opencl::cl_uint, opencl::cl_ulong>>>;

// select_apply_cl_scalar_t selects from T8/T16/T32/T64 basing on
// sizeof(IN). expected to handle scalar types.
template <typename T, typename T8, typename T16, typename T32, typename T64>
Expand Down
10 changes: 10 additions & 0 deletions sycl/include/sycl/detail/helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,16 @@ template <size_t count, class F> void loop(F &&f) {
loop_impl(std::make_index_sequence<count>{}, std::forward<F>(f));
}

template <size_t count, size_t limit, class F>
void loop_unroll_up_to(F &&f) {
if constexpr (count > limit)
for (size_t i = 0; i < count; ++i)
f(i);
else
loop<count>([&](auto i) { f(i); });
}

inline constexpr bool is_power_of_two(int x) { return (x & (x - 1)) == 0; }
} // namespace detail

} // __SYCL_INLINE_VER_NAMESPACE(_V1)
Expand Down
15 changes: 15 additions & 0 deletions sycl/include/sycl/detail/type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ template <typename T> struct is_group_helper : std::false_type {};
template <typename Group, std::size_t Extent>
struct is_group_helper<group_with_scratchpad<Group, Extent>> : std::true_type {
};
template <typename T>
inline constexpr bool is_group_helper_v = is_group_helper<T>::value;
} // namespace detail
} // namespace experimental
} // namespace ext::oneapi
Expand All @@ -52,6 +54,8 @@ template <typename T>
struct is_generic_group
: std::integral_constant<bool,
is_group<T>::value || is_sub_group<T>::value> {};
template <typename T>
inline constexpr bool is_generic_group_v = is_generic_group<T>::value;

namespace half_impl {
class half;
Expand Down Expand Up @@ -280,6 +284,17 @@ struct is_vector_bool
template <typename T>
struct is_bool : bool_constant<is_scalar_bool<vector_element_t<T>>::value> {};

// is_multi_ptr
template <typename T> struct is_multi_ptr_impl : public std::false_type {};

template <typename T, access::address_space Space,
access::decorated DecorateAddress>
struct is_multi_ptr_impl<multi_ptr<T, Space, DecorateAddress>>
: public std::true_type {};

template <typename T>
constexpr bool is_multi_ptr_v = is_multi_ptr_impl<std::remove_cv_t<T>>::value;

// is_pointer
template <typename T> struct is_pointer_impl : std::false_type {};

Expand Down
Loading