Skip to content

[SYCL] Add 64-bit type support to load/store sub-group functions #1999

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 1 commit into from
Jun 29, 2020
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
9 changes: 9 additions & 0 deletions sycl/include/CL/__spirv/spirv_ops.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,15 @@ __SYCL_CONVERGENT__ extern SYCL_EXTERNAL void
__spirv_SubgroupBlockWriteINTEL(__attribute__((opencl_global)) uint32_t *Ptr,
dataT Data) noexcept;

template <typename dataT>
__SYCL_CONVERGENT__ extern SYCL_EXTERNAL dataT __spirv_SubgroupBlockReadINTEL(
const __attribute__((opencl_global)) uint64_t *Ptr) noexcept;

template <typename dataT>
__SYCL_CONVERGENT__ extern SYCL_EXTERNAL void
__spirv_SubgroupBlockWriteINTEL(__attribute__((opencl_global)) uint64_t *Ptr,
dataT Data) noexcept;

template <typename dataT>
extern SYCL_EXTERNAL int32_t __spirv_ReadPipe(RPipeTy<dataT> Pipe, dataT *Data,
int32_t Size,
Expand Down
12 changes: 6 additions & 6 deletions sycl/include/CL/sycl/detail/generic_type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,12 @@ using select_apply_cl_scalar_t =

// Shortcuts for selecting scalar int/unsigned int/fp type.
template <typename T>
using select_cl_scalar_intergal_signed_t =
using select_cl_scalar_integral_signed_t =
select_apply_cl_scalar_t<T, sycl::cl_char, sycl::cl_short, sycl::cl_int,
sycl::cl_long>;

template <typename T>
using select_cl_scalar_intergal_unsigned_t =
using select_cl_scalar_integral_unsigned_t =
select_apply_cl_scalar_t<T, sycl::cl_uchar, sycl::cl_ushort, sycl::cl_uint,
sycl::cl_ulong>;

Expand All @@ -382,16 +382,16 @@ using select_cl_scalar_float_t =
sycl::cl_double>;

template <typename T>
using select_cl_scalar_intergal_t =
using select_cl_scalar_integral_t =
conditional_t<std::is_signed<T>::value,
select_cl_scalar_intergal_signed_t<T>,
select_cl_scalar_intergal_unsigned_t<T>>;
select_cl_scalar_integral_signed_t<T>,
select_cl_scalar_integral_unsigned_t<T>>;

// select_cl_scalar_t picks corresponding cl_* type for input
// scalar T or returns T if T is not scalar.
template <typename T>
using select_cl_scalar_t = conditional_t<
std::is_integral<T>::value, select_cl_scalar_intergal_t<T>,
std::is_integral<T>::value, select_cl_scalar_integral_t<T>,
conditional_t<
std::is_floating_point<T>::value, select_cl_scalar_float_t<T>,
// half is a special case: it is implemented differently on host and
Expand Down
6 changes: 2 additions & 4 deletions sycl/include/CL/sycl/intel/sub_group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,9 @@ __SYCL_SG_GENERATE_BODY_2ARG(shuffle_up, SubgroupShuffleUpINTEL)

#undef __SYCL_SG_GENERATE_BODY_2ARG

// Selects 8-bit, 16-bit or 32-bit type depending on size of T. If T doesn't
// maps to mentioned types, then void is returned
// Selects 8, 16, 32, or 64-bit type depending on size of scalar type T.
template <typename T>
using SelectBlockT =
select_apply_cl_scalar_t<T, uint8_t, uint16_t, uint32_t, void>;
using SelectBlockT = select_cl_scalar_integral_unsigned_t<T>;

template <typename T, access::address_space Space>
using AcceptableForGlobalLoadStore =
Expand Down
23 changes: 22 additions & 1 deletion sycl/test/sub_group/load_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ template <typename T> void check(queue &Queue) {
int main() {
queue Queue;
if (!Queue.get_device().has_extension("cl_intel_subgroups") &&
!Queue.get_device().has_extension("cl_intel_subgroups_short")) {
!Queue.get_device().has_extension("cl_intel_subgroups_short") &&
!Queue.get_device().has_extension("cl_intel_subgroups_long")) {
std::cout << "Skipping test\n";
return 0;
}
Expand Down Expand Up @@ -200,6 +201,26 @@ int main() {
check<aligned_half, 8>(Queue);
}
}
if (Queue.get_device().has_extension("cl_intel_subgroups_long")) {
typedef long aligned_long __attribute__((aligned(16)));
check<aligned_long>(Queue);
check<aligned_long, 1>(Queue);
check<aligned_long, 2>(Queue);
check<aligned_long, 4>(Queue);
check<aligned_long, 8>(Queue);
typedef unsigned long aligned_ulong __attribute__((aligned(16)));
check<aligned_ulong>(Queue);
check<aligned_ulong, 1>(Queue);
check<aligned_ulong, 2>(Queue);
check<aligned_ulong, 4>(Queue);
check<aligned_ulong, 8>(Queue);
typedef double aligned_double __attribute__((aligned(16)));
check<aligned_double>(Queue);
check<aligned_double, 1>(Queue);
check<aligned_double, 2>(Queue);
check<aligned_double, 4>(Queue);
check<aligned_double, 8>(Queue);
}
std::cout << "Test passed." << std::endl;
return 0;
}