Skip to content

[SYCL] Implement SYCL 2020 multi_ptr #6893

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 22 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
86cb94a
[SYCL] Implement SYCL 2020 multi_ptr
steffenlarsen Sep 4, 2022
a91e39a
Make address space case work-around for NVPTX and AMDGCN
steffenlarsen Sep 28, 2022
1a6ebb4
Fix formatting
steffenlarsen Sep 28, 2022
b0a0a0e
Correctly propagate decoration in matrix-tensorcore
steffenlarsen Sep 28, 2022
81697c8
Remember joint_matrix_store_impl
steffenlarsen Sep 28, 2022
b408f92
Make getPointerAdjusted auto to preserve address space
steffenlarsen Sep 28, 2022
f467339
Update sycl/include/sycl/ext/intel/experimental/fpga_lsu.hpp
steffenlarsen Sep 29, 2022
90689a3
Fix naming in fpga_lsu
steffenlarsen Sep 29, 2022
06ec7e8
Address review comments
steffenlarsen Sep 30, 2022
ffc89ae
Move SPIR-V casts to SPIRVBuiltins.td and make const
steffenlarsen Sep 30, 2022
ef595db
Fix getting decorated ptrs in atomic
steffenlarsen Sep 30, 2022
46b2677
Remove pointer, ref, and quals instead of propagating in deduce_AS
steffenlarsen Sep 30, 2022
9d5c063
Correct use of decorated pointers for atomics
steffenlarsen Oct 3, 2022
bf30cfa
Add decoration to matrix-jit-use.cpp and adjust extensions
steffenlarsen Oct 5, 2022
309bea3
Merge remote-tracking branch 'intel/sycl' into steffen/SYCL2020_multi…
steffenlarsen Oct 7, 2022
0a0cd43
Fix formatting
steffenlarsen Oct 7, 2022
bae047d
Fix merge mistake
steffenlarsen Oct 7, 2022
2a7b384
Fix another merge mistake
steffenlarsen Oct 7, 2022
427777e
Remove deprecation of legacy enum and add notes to deprecate legacy
steffenlarsen Oct 11, 2022
ced5db7
Fix generic cast SPIR-V builtin signatures
steffenlarsen Oct 12, 2022
eec663f
Fix formatting
steffenlarsen Oct 12, 2022
2a80b38
Move operator= sfinae into template args to appease MSVC
steffenlarsen Oct 12, 2022
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
6 changes: 6 additions & 0 deletions clang/lib/Sema/SPIRVBuiltins.td
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,12 @@ foreach AS = [GlobalAS, LocalAS, PrivateAS] in {
def : SPVBuiltin<"GenericCastToPtrExplicit", [PointerType<Char, AS>, PointerType<Char, GenericAS>], Attr.Const>;
}

foreach Ty = [Void, ConstType<Void>, VolatileType<Void>, VolatileType<ConstType<Void>>] in {
def : SPVBuiltin<"GenericCastToPtrExplicit_ToGlobal", [PointerType<Ty, GlobalAS>, PointerType<Ty, DefaultAS>, Int], Attr.Const>;
def : SPVBuiltin<"GenericCastToPtrExplicit_ToLocal", [PointerType<Ty, LocalAS>, PointerType<Ty, DefaultAS>, Int], Attr.Const>;
def : SPVBuiltin<"GenericCastToPtrExplicit_ToPrivate", [PointerType<Ty, PrivateAS>, PointerType<Ty, DefaultAS>, Int], Attr.Const>;
}

foreach Type = TLFloat.List in {
foreach v = [2, 3, 4, 8, 16] in {
def : SPVBuiltin<"VectorTimesScalar", [VectorType<Type, v>, VectorType<Type, v>, Type], Attr.Const>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ location at `src` + `get_local_id()`.

[source,c++]
----
template <typename T, access::address_space Space>
T load(const multi_ptr<T, Space>* src)
template <typename T, access::address_space Space, access::decorated IsDecorated>
T load(const multi_ptr<T, Space, IsDecorated>* src)
----
_Constraints_: `T` must be a _NumericType_. `Space` must be
`access::address_space::global_space` or `access::address_space::local_space`.
Expand All @@ -92,8 +92,8 @@ location at `src` + `get_local_id()`.

[source,c++]
----
template <int N, typename T, access::address_space Space>
vec<T, N> load(const multi_ptr<T, Space> src)
template <int N, typename T, access::address_space Space, access::decorated IsDecorated>
vec<T, N> load(const multi_ptr<T, Space, IsDecorated> src)
----
_Constraints_: `T` must be a _NumericType_. `Space` must be
`access::address_space::global_space` or `access::address_space::local_space`.
Expand Down Expand Up @@ -122,8 +122,8 @@ _Effects_: Writes the value of `x` from each work-item to the memory location at

[source,c++]
----
template <typename T, access::address_space Space>
void store(multi_ptr<T, Space> dst, const T& x)
template <typename T, access::address_space Space, access::decorated IsDecorated>
void store(multi_ptr<T, Space, IsDecorated> dst, const T& x)
----
_Constraints_: `T` must be a _NumericType_. `Space` must be
`access::address_space::global_space` or `access::address_space::local_space`.
Expand All @@ -136,8 +136,8 @@ _Effects_: Writes the value of `x` from each work-item to the memory location at

[source,c++]
----
template <typename T, access::address_space Space>
void store(multi_ptr<T, Space> dst, const vec<T, N>& x)
template <typename T, access::address_space Space, access::decorated IsDecorated>
void store(multi_ptr<T, Space, IsDecorated> dst, const vec<T, N>& x)
----
_Constraints_: `T` must be a _NumericType_. `Space` must be
`access::address_space::global_space` or `access::address_space::local_space`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,10 @@ IMPORTANT: In the current implementation, only the subgroup scope is supported.
namespace sycl::ext::oneapi::experimental::matrix {
template <typename Group, typename T, size_t NumRows, size_t NumCols,
matrix_layout Layout,
access::address_space Space>
access::address_space Space,
access::decorated IsDecorated>
void joint_matrix_load(Group sg, joint_matrix<T, NumRows, NumCols, Layout, Group> &res,
multi_ptr<T, Space> src, size_t stride, matrix_layout MemLayout);
multi_ptr<T, Space, IsDecorated> src, size_t stride, matrix_layout MemLayout);
}
```
This function loads data from memory to the 2d tiles/registers of Intel AMX/DPAS.
Expand All @@ -143,9 +144,10 @@ This function loads data from memory to the 2d tiles/registers of Intel AMX/DPAS
namespace sycl::ext::oneapi::experimental::matrix {
template <typename Group, typename T, size_t NumRows, size_t NumCols,
matrix_layout L,
access::address_space Space>
access::address_space Space,
access::decorated IsDecorated>
void joint_matrix_store(Group sg, joint_matrix<T, NumRows, NumCols, L, Group> &res,
multi_ptr<T, Space> src, size_t stride, matrix_layout memL);
multi_ptr<T, Space, IsDecorated> src, size_t stride, matrix_layout memL);
}
```
This function stores the data from the 2d tiles back to memory.
Expand Down
68 changes: 58 additions & 10 deletions sycl/include/CL/__spirv/spirv_ops.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,30 +315,78 @@ __SPIRV_ATOMICS(__SPIRV_ATOMIC_MINMAX, Max)
#undef __SPIRV_ATOMIC_UNSIGNED
#undef __SPIRV_ATOMIC_XOR

extern SYCL_EXTERNAL __attribute__((opencl_global)) void *
__spirv_GenericCastToPtrExplicit_ToGlobal(const void *Ptr,
__spv::StorageClass::Flag S) noexcept;

extern SYCL_EXTERNAL __attribute__((opencl_local)) void *
__spirv_GenericCastToPtrExplicit_ToLocal(const void *Ptr,
__spv::StorageClass::Flag S) noexcept;

template <typename dataT>
extern __attribute__((opencl_global)) dataT *
__SYCL_GenericCastToPtrExplicit_ToGlobal(const void *Ptr) noexcept {
__SYCL_GenericCastToPtrExplicit_ToGlobal(void *Ptr) noexcept {
return (__attribute__((opencl_global)) dataT *)
__spirv_GenericCastToPtrExplicit_ToGlobal(
Ptr, __spv::StorageClass::CrossWorkgroup);
}

template <typename dataT>
extern const __attribute__((opencl_global)) dataT *
__SYCL_GenericCastToPtrExplicit_ToGlobal(const void *Ptr) noexcept {
return (const __attribute__((opencl_global)) dataT *)
__spirv_GenericCastToPtrExplicit_ToGlobal(
Ptr, __spv::StorageClass::CrossWorkgroup);
}

template <typename dataT>
extern const volatile __attribute__((opencl_global)) dataT *
__SYCL_GenericCastToPtrExplicit_ToGlobal(const volatile void *Ptr) noexcept {
return (const volatile __attribute__((opencl_global)) dataT *)
__spirv_GenericCastToPtrExplicit_ToGlobal(
Ptr, __spv::StorageClass::CrossWorkgroup);
}

template <typename dataT>
extern __attribute__((opencl_local)) dataT *
__SYCL_GenericCastToPtrExplicit_ToLocal(const void *Ptr) noexcept {
__SYCL_GenericCastToPtrExplicit_ToLocal(void *Ptr) noexcept {
return (__attribute__((opencl_local)) dataT *)
__spirv_GenericCastToPtrExplicit_ToLocal(Ptr,
__spv::StorageClass::Workgroup);
}

template <typename dataT>
extern const __attribute__((opencl_local)) dataT *
__SYCL_GenericCastToPtrExplicit_ToLocal(const void *Ptr) noexcept {
return (const __attribute__((opencl_local)) dataT *)
__spirv_GenericCastToPtrExplicit_ToLocal(Ptr,
__spv::StorageClass::Workgroup);
}

template <typename dataT>
extern const volatile __attribute__((opencl_local)) dataT *
__SYCL_GenericCastToPtrExplicit_ToLocal(const volatile void *Ptr) noexcept {
return (const volatile __attribute__((opencl_local)) dataT *)
__spirv_GenericCastToPtrExplicit_ToLocal(Ptr,
__spv::StorageClass::Workgroup);
}

template <typename dataT>
extern __attribute__((opencl_private)) dataT *
__SYCL_GenericCastToPtrExplicit_ToPrivate(void *Ptr) noexcept {
return (__attribute__((opencl_private)) dataT *)
__spirv_GenericCastToPtrExplicit_ToPrivate(Ptr,
__spv::StorageClass::Function);
}

template <typename dataT>
extern const __attribute__((opencl_private)) dataT *
__SYCL_GenericCastToPtrExplicit_ToPrivate(const void *Ptr) noexcept {
return (const __attribute__((opencl_private)) dataT *)
__spirv_GenericCastToPtrExplicit_ToPrivate(Ptr,
__spv::StorageClass::Function);
}

template <typename dataT>
extern const volatile __attribute__((opencl_private)) dataT *
__SYCL_GenericCastToPtrExplicit_ToPrivate(const volatile void *Ptr) noexcept {
return (const volatile __attribute__((opencl_private)) dataT *)
__spirv_GenericCastToPtrExplicit_ToPrivate(Ptr,
__spv::StorageClass::Function);
}

template <typename dataT>
__SYCL_CONVERGENT__ extern SYCL_EXTERNAL dataT
__spirv_SubgroupShuffleINTEL(dataT Data, uint32_t InvocationId) noexcept;
Expand Down
Loading