[PATCH] D114553: [HIP] Add atomic load, atomic store and atomic cmpxchng_weak builtin support in HIP-clang
Yaxun Liu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 26 07:52:22 PST 2021
yaxunl added inline comments.
================
Comment at: clang/test/CodeGenCUDA/atomic-ops.cu:14
+// CHECK: load atomic i32, i32* {{%[0-9]+}} syncscope("singlethread-one-as") monotonic, align 4
+// CHECK: store i32 {{%[0-9]+}}, i32* %{{.*}}, align 4
+// CHECK: cmpxchg weak i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as") monotonic monotonic, align 4
----------------
should have atomic, syncscope and monotonic. same as below
================
Comment at: clang/test/CodeGenCUDA/atomic-ops.cu:31
+ __hip_atomic_store(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
+ flag = __hip_atomic_compare_exchange_weak(ptr, ptr2, val, desired, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
return flag ? val : desired;
----------------
the signature of `__hip_atomic_compare_exchange_weak` is the same as `__hip_atomic_compare_exchange_strong` and should be called with the same arguments. It should end up with one atomic cmpxchg instruction in IR. same as below
================
Comment at: clang/test/SemaCUDA/atomic-ops.cu:10
+ val = __hip_atomic_load(pi32, 0, 0); // expected-error {{synchronization scope argument to atomic operation is invalid}}
+ val = __hip_atomic_load(pi32, 0, __HIP_MEMORY_SCOPE_SINGLETHREAD);
+ val = __hip_atomic_load(pi32, 0, __HIP_MEMORY_SCOPE_WAVEFRONT);
----------------
should use predefined macros for memory order, e.g. __ATOMIC_RELAXED. same as below
================
Comment at: clang/test/SemaCUDA/atomic-ops.cu:67
+ flag = __hip_atomic_compare_exchange_weak(ptr, 0, 0, 0, 0, __HIP_MEMORY_SCOPE_SYSTEM); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ flag = __hip_atomic_compare_exchange_weak(ptr, ptr2, val, desired, 0, __HIP_MEMORY_SCOPE_SYSTEM);
+ flag = __hip_atomic_compare_exchange_weak(ptr, ptr2, val, desired, 1, __HIP_MEMORY_SCOPE_SINGLETHREAD);
----------------
signature is wrong. see above comments.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114553/new/
https://reviews.llvm.org/D114553
More information about the cfe-commits
mailing list