Skip to content

Commit da3b5df

Browse files
authored
[SYCL] Add atomic64 aspect decoration to atomic_ref<T *> (#14052)
atomic_ref<T *> uses 64-bit atomics and it should be decorated with the corresponding aspect. fixes: #12743
1 parent f2cd2a8 commit da3b5df

File tree

5 files changed

+22
-16
lines changed

5 files changed

+22
-16
lines changed

sycl/include/sycl/atomic_ref.hpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,9 +568,14 @@ class [[__sycl_detail__::__uses_aspects__(aspect::atomic64)]] atomic_ref_impl<
568568
// Partial specialization for pointer types
569569
// Arithmetic is emulated because target's representation of T* is unknown
570570
// TODO: Find a way to use intptr_t or uintptr_t atomics instead
571-
template <typename T, bool IsAspectAtomic64AttrUsed, memory_order DefaultOrder, memory_scope DefaultScope,
572-
access::address_space AddressSpace>
573-
class atomic_ref_impl<T *, IsAspectAtomic64AttrUsed, DefaultOrder, DefaultScope, AddressSpace>
571+
template <typename T, bool IsAspectAtomic64AttrUsed, memory_order DefaultOrder,
572+
memory_scope DefaultScope, access::address_space AddressSpace>
573+
#ifndef __SYCL_DEVICE_ONLY__
574+
class atomic_ref_impl<
575+
#else
576+
class [[__sycl_detail__::__uses_aspects__(aspect::atomic64)]] atomic_ref_impl<
577+
#endif
578+
T *, IsAspectAtomic64AttrUsed, DefaultOrder, DefaultScope, AddressSpace>
574579
: public atomic_ref_base<uintptr_t, DefaultOrder, DefaultScope,
575580
AddressSpace> {
576581

sycl/test-e2e/syclcompat/atomic/atomic_arith.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@
3232

3333
// UNSUPPORTED: hip
3434

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

4038
#include <cstddef>

sycl/test-e2e/syclcompat/atomic/atomic_comp_exchange.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@
3232

3333
// UNSUPPORTED: hip
3434

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

4038
#include <type_traits>

sycl/test-e2e/syclcompat/math/math_ops.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020
* tests for non-vectorized math helper functions
2121
**************************************************************************/
2222

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

2826
#include <syclcompat/dims.hpp>

sycl/test/optional_kernel_features/atomic_ref-atomic64-aspect.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
// RUN: %clangxx %s -S -o %t.ll -fsycl-device-only -Xclang -disable-llvm-passes
22
// RUN: FileCheck %s --input-file %t.ll
33

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

1011
#include <sycl/sycl.hpp>
@@ -46,6 +47,12 @@ int main() {
4647
sycl::atomic_ref<int, sycl::memory_order_acq_rel,
4748
sycl::memory_scope_device,
4849
sycl::access::address_space::local_space>(val_int);
50+
51+
double *ptr = nullptr;
52+
auto ref_double_ptr =
53+
sycl::atomic_ref<double *, sycl::memory_order_acq_rel,
54+
sycl::memory_scope_device,
55+
sycl::access::address_space::local_space>(ptr);
4956
});
5057
});
5158
return 0;

0 commit comments

Comments
 (0)