From 830b451b320fa9ccba99799b93e19a0d846d445a Mon Sep 17 00:00:00 2001 From: Victor Perez Date: Fri, 13 Sep 2024 12:38:11 +0100 Subject: [PATCH 1/2] [SYCL] Add `(raw|decorated)_generic_ptr` aliases https://github.com/KhronosGroup/SYCL-Docs/pull/598 adds these aliases to the spec. Prepare for spec change by adding them to the implementation beforehand. Extend tests so all `multi_ptr` aliases are checked. Signed-off-by: Victor Perez --- sycl/include/sycl/pointers.hpp | 10 ++++ sycl/test/multi_ptr/aliases.cpp | 87 +++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 sycl/test/multi_ptr/aliases.cpp diff --git a/sycl/include/sycl/pointers.hpp b/sycl/include/sycl/pointers.hpp index c74a8e104ab82..cd082b9f79904 100644 --- a/sycl/include/sycl/pointers.hpp +++ b/sycl/include/sycl/pointers.hpp @@ -47,6 +47,11 @@ using private_ptr = // The interface exposes non-decorated pointer while keeping the // address space information internally. +template +using raw_generic_ptr = + multi_ptr; + template using raw_global_ptr = multi_ptr +using decorated_generic_ptr = + multi_ptr; + template using decorated_global_ptr = multi_ptr + +#include + +template +void test_address_space_aliases() { + static_assert(std::is_same_v< + sycl::generic_ptr, + sycl::multi_ptr>); + static_assert(std::is_same_v< + sycl::global_ptr, + sycl::multi_ptr>); + static_assert(std::is_same_v< + sycl::local_ptr, + sycl::multi_ptr>); + static_assert(std::is_same_v< + sycl::private_ptr, + sycl::multi_ptr>); +} + +template void test_aliases() { + // Template specialization aliases for different pointer address spaces + test_address_space_aliases(); + test_address_space_aliases(); + test_address_space_aliases(); + + // Template specialization aliases for different pointer address spaces. + // The interface exposes non-decorated pointer while keeping the + // address space information internally. + static_assert(std::is_same_v< + sycl::raw_generic_ptr, + sycl::multi_ptr>); + static_assert(std::is_same_v< + sycl::raw_global_ptr, + sycl::multi_ptr>); + static_assert(std::is_same_v< + sycl::raw_local_ptr, + sycl::multi_ptr>); + static_assert(std::is_same_v< + sycl::raw_private_ptr, + sycl::multi_ptr>); + + // Template specialization aliases for different pointer address spaces. + // The interface exposes decorated pointer. + static_assert(std::is_same_v< + sycl::decorated_generic_ptr, + sycl::multi_ptr>); + static_assert(std::is_same_v< + sycl::decorated_global_ptr, + sycl::multi_ptr>); + static_assert(std::is_same_v< + sycl::decorated_local_ptr, + sycl::multi_ptr>); + static_assert(std::is_same_v< + sycl::decorated_private_ptr, + sycl::multi_ptr>); +} + +// Test "minimal set of types" in the CTS. As we are just testing aliases are +// present in this test, this should work for any type. + +template void test_aliases(); +template void test_aliases(); From dda54ccb9fadfa86ca77985c5c875a5ae6884360 Mon Sep 17 00:00:00 2001 From: Victor Perez Date: Fri, 8 Nov 2024 10:13:30 +0000 Subject: [PATCH 2/2] Drop alias in test --- sycl/test/check_device_code/extensions/address_cast.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/sycl/test/check_device_code/extensions/address_cast.cpp b/sycl/test/check_device_code/extensions/address_cast.cpp index 36251cecbbc3b..c265a5e2fe74b 100644 --- a/sycl/test/check_device_code/extensions/address_cast.cpp +++ b/sycl/test/check_device_code/extensions/address_cast.cpp @@ -11,12 +11,6 @@ using namespace sycl; using namespace sycl::ext::oneapi::experimental; -// FIXME: should be removed when https://github.com/intel/llvm/pull/15389 is merged in. -template -using decorated_generic_ptr = - multi_ptr; - namespace static_as_cast { // CHECK-LABEL: define dso_local spir_func void @_ZN14static_as_cast19to_global_decoratedEN4sycl3_V19multi_ptrIiLNS1_6access13address_spaceE6ELNS3_9decoratedE1EEE( // CHECK-SAME: ptr addrspace(4) dead_on_unwind noalias nocapture writable writeonly sret(%"class.sycl::_V1::multi_ptr") align 8 [[AGG_RESULT:%.*]], ptr nocapture noundef readonly byval(%"class.sycl::_V1::multi_ptr.0") align 8 [[P:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] !srcloc [[META6:![0-9]+]] !sycl_fixed_targets [[META7:![0-9]+]] {