-
Notifications
You must be signed in to change notification settings - Fork 156
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
Using sycl::atomic_ref<...>{}.store()
defaults to __ATOMIC_SEQ_CST
leading to a compiler error.
#1466
Comments
It does not default to Our implementation of the builtin looks like so: inline constexpr int builtin_memory_order(memory_order o) noexcept {
switch(o){
case memory_order::relaxed:
return __ATOMIC_RELAXED;
case memory_order::acquire:
return __ATOMIC_ACQUIRE;
case memory_order::release:
return __ATOMIC_RELEASE;
case memory_order::acq_rel:
return __ATOMIC_ACQ_REL;
case memory_order::seq_cst:
return __ATOMIC_SEQ_CST;
}
return __ATOMIC_RELAXED;
}
template <access::address_space S, class T>
HIPSYCL_HIPLIKE_BUILTIN void
__hipsycl_atomic_store(T *addr, T x, memory_order order,
memory_scope scope) noexcept {
__atomic_store_n(addr, x, builtin_memory_order(order));
} which then compiles to: define void @_ZNK7hipsycl4sycl10atomic_refIiLNS0_12memory_orderE0ELNS0_12memory_scopeE3ELNS0_6access13address_spaceE4EE5storeEiS2_S3_(%"class.hipsycl::sycl::atomic_ref"* nocapture noundef nonnull readonly align 8 dereferenceable(8) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 comdat align 2 {
%5 = getelementptr inbounds %"class.hipsycl::sycl::atomic_ref", %"class.hipsycl::sycl::atomic_ref"* %0, i64 0, i32 0
%6 = load i32*, i32** %5, align 8
switch i32 %2, label %11 [
i32 4, label %10
i32 1, label %7
i32 2, label %8
i32 3, label %9
]
7: ; preds = %4
br label %11
8: ; preds = %4
br label %11
9: ; preds = %4
br label %11
10: ; preds = %4
br label %11
11: ; preds = %4, %10, %9, %8, %7
%.0 = phi i32 [ 5, %10 ], [ 4, %9 ], [ 3, %8 ], [ 2, %7 ], [ 0, %4 ]
switch i32 %.0, label %12 [
i32 3, label %13
i32 5, label %14
]
12: ; preds = %11
store atomic i32 %1, i32* %6 monotonic, align 4
br label %15
13: ; preds = %11
store atomic i32 %1, i32* %6 release, align 4
br label %15
14: ; preds = %11
store atomic i32 %1, i32* %6 seq_cst, align 4
br label %15
15: ; preds = %14, %13, %12
ret void
} The code path with the We could just silently ignore the As a general pointer, I would also suggest to use |
Could we instead emit a trap for |
@fknorr Good idea, I think this could work. The LLVM nvptx backend supports the |
Bug summary
Calling
store()
onsycl::atomic_ref<int, sycl::memory_order::relaxed, sycl::memory_scope::device>
unexpectedly defaults to__ATOMIC_SEQ_CST
, causing the following error:To Reproduce
Compile the following code:
With the following CMake configuration:
And this command:
cmake -DCMAKE_PREFIX_PATH="/path/to/AdaptiveCpp" -DACPP_TARGETS=cuda:sm_75 -DCMAKE_C_COMPILER=/usr/lib/llvm-14/bin/clang -DCMAKE_CXX_COMPILER=/usr/lib/llvm-14/bin/clang++ -G Ninja ..
The same error occurs when compiling the following CUDA code:
However, compiling the CUDA code with
__ATOMIC_RELAXED
works:Describe your setup
Additional context
Using LLVM 17 (clang 17.0.6) does not resolve the issue.
The text was updated successfully, but these errors were encountered: