Skip to content

[SYCL] Add atomic64 aspect decoration to atomic_ref<T *> #14052

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 4 commits into from
Jun 13, 2024
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
11 changes: 8 additions & 3 deletions sycl/include/sycl/atomic_ref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,9 +568,14 @@ class [[__sycl_detail__::__uses_aspects__(aspect::atomic64)]] atomic_ref_impl<
// Partial specialization for pointer types
// Arithmetic is emulated because target's representation of T* is unknown
// TODO: Find a way to use intptr_t or uintptr_t atomics instead
template <typename T, bool IsAspectAtomic64AttrUsed, memory_order DefaultOrder, memory_scope DefaultScope,
access::address_space AddressSpace>
class atomic_ref_impl<T *, IsAspectAtomic64AttrUsed, DefaultOrder, DefaultScope, AddressSpace>
template <typename T, bool IsAspectAtomic64AttrUsed, memory_order DefaultOrder,
memory_scope DefaultScope, access::address_space AddressSpace>
#ifndef __SYCL_DEVICE_ONLY__
class atomic_ref_impl<
#else
class [[__sycl_detail__::__uses_aspects__(aspect::atomic64)]] atomic_ref_impl<
#endif
T *, IsAspectAtomic64AttrUsed, DefaultOrder, DefaultScope, AddressSpace>
: public atomic_ref_base<uintptr_t, DefaultOrder, DefaultScope,
AddressSpace> {

Expand Down
4 changes: 1 addition & 3 deletions sycl/test-e2e/syclcompat/atomic/atomic_arith.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@

// UNSUPPORTED: hip

// FIXME: Remove "-fsycl-device-code-split=per_kernel" option after fixing
// https://github.com/intel/llvm/issues/12743.
// RUN: %clangxx -std=c++20 -fsycl -fsycl-targets=%{sycl_triple} -fsycl-device-code-split=per_kernel %s -o %t.out
// RUN: %clangxx -std=c++20 -fsycl -fsycl-targets=%{sycl_triple} %s -o %t.out
// RUN: %{run} %t.out

#include <cstddef>
Expand Down
4 changes: 1 addition & 3 deletions sycl/test-e2e/syclcompat/atomic/atomic_comp_exchange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@

// UNSUPPORTED: hip

// FIXME: Remove "-fsycl-device-code-split=per_kernel" option after fixing
// https://github.com/intel/llvm/issues/12743.
// RUN: %clangxx -std=c++20 -fsycl -fsycl-targets=%{sycl_triple} -fsycl-device-code-split=per_kernel %s -o %t.out
// RUN: %clangxx -std=c++20 -fsycl -fsycl-targets=%{sycl_triple} %s -o %t.out
// RUN: %{run} %t.out

#include <type_traits>
Expand Down
4 changes: 1 addition & 3 deletions sycl/test-e2e/syclcompat/math/math_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
* tests for non-vectorized math helper functions
**************************************************************************/

// FIXME: Remove "-fsycl-device-code-split=per_kernel" option after fixing
// https://github.com/intel/llvm/issues/12743.
// RUN: %clangxx -std=c++20 -fsycl -fsycl-targets=%{sycl_triple} -fsycl-device-code-split=per_kernel %s -o %t.out
// RUN: %clangxx -std=c++20 -fsycl -fsycl-targets=%{sycl_triple} %s -o %t.out
// RUN: %{run} %t.out

#include <syclcompat/dims.hpp>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// RUN: %clangxx %s -S -o %t.ll -fsycl-device-only -Xclang -disable-llvm-passes
// RUN: FileCheck %s --input-file %t.ll

// CHECK: !sycl_types_that_use_aspects = !{![[#MDNUM1:]], ![[#MDNUM2:]], ![[#MDNUM3:]]}
// CHECK: ![[#MDNUM1]] = !{!"class.sycl::_V1::detail::atomic_ref_impl", i32 [[#ASPECT_NUM:]]}
// CHECK: ![[#MDNUM2]] = !{!"class.sycl::_V1::detail::atomic_ref_impl.2", i32 [[#ASPECT_NUM:]]}
// CHECK: ![[#MDNUM3]] = !{!"class.sycl::_V1::detail::atomic_ref_impl.7", i32 [[#ASPECT_NUM:]]}
// CHECK: !sycl_types_that_use_aspects = !{![[#MDNUM1:]], ![[#MDNUM2:]], ![[#MDNUM3:]], ![[#MDNUM4:]]}
// CHECK: ![[#MDNUM1]] = !{!"class.sycl::_V1::detail::atomic_ref_impl.20", i32 [[#ASPECT_NUM:]]}
// CHECK-NEXT: ![[#MDNUM2]] = !{!"class.sycl::_V1::detail::atomic_ref_impl", i32 [[#ASPECT_NUM:]]}
// CHECK-NEXT: ![[#MDNUM3]] = !{!"class.sycl::_V1::detail::atomic_ref_impl.2", i32 [[#ASPECT_NUM:]]}
// CHECK-NEXT: ![[#MDNUM4]] = !{!"class.sycl::_V1::detail::atomic_ref_impl.7", i32 [[#ASPECT_NUM:]]}
// CHECK: !{{.*}} = !{!"atomic64", i32 [[#ASPECT_NUM]]}

#include <sycl/sycl.hpp>
Expand Down Expand Up @@ -46,6 +47,12 @@ int main() {
sycl::atomic_ref<int, sycl::memory_order_acq_rel,
sycl::memory_scope_device,
sycl::access::address_space::local_space>(val_int);

double *ptr = nullptr;
auto ref_double_ptr =
sycl::atomic_ref<double *, sycl::memory_order_acq_rel,
sycl::memory_scope_device,
sycl::access::address_space::local_space>(ptr);
});
});
return 0;
Expand Down
Loading