Skip to content

Commit 2a43688

Browse files
[nfc][libomptarget] Refactor nvptx/target_impl.cu
Summary: [nfc][libomptarget] Refactor nxptx/target_impl.cu Use __kmpc_impl_atomic_add instead of atomicAdd to match the rest of the file. Alternatively, target_impl.cu could use the cuda functions directly. Using a mixture in this file was an oversight, happy to resolve in either direction. Removed some comments that look outdated. Call __kmpc_impl_unset_lock directly to avoid a redundant diagnostic and remove an implict dependency on interface.h. Reviewers: ABataev, grokos, jdoerfert Reviewed By: jdoerfert Subscribers: jfb, openmp-commits Tags: #openmp Differential Revision: https://reviews.llvm.org/D72719
1 parent 2d287be commit 2a43688

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,14 @@
1919
#define SET 1u
2020

2121
EXTERN void __kmpc_impl_init_lock(omp_lock_t *lock) {
22-
omp_unset_lock(lock);
22+
__kmpc_impl_unset_lock(lock);
2323
}
2424

2525
EXTERN void __kmpc_impl_destroy_lock(omp_lock_t *lock) {
26-
omp_unset_lock(lock);
26+
__kmpc_impl_unset_lock(lock);
2727
}
2828

2929
EXTERN void __kmpc_impl_set_lock(omp_lock_t *lock) {
30-
// int atomicCAS(int* address, int compare, int val);
31-
// (old == compare ? val : old)
32-
3330
// TODO: not sure spinning is a good idea here..
3431
while (__kmpc_atomic_cas(lock, UNSET, SET) != UNSET) {
3532
clock_t start = clock();
@@ -49,7 +46,5 @@ EXTERN void __kmpc_impl_unset_lock(omp_lock_t *lock) {
4946
}
5047

5148
EXTERN int __kmpc_impl_test_lock(omp_lock_t *lock) {
52-
// int atomicCAS(int* address, int compare, int val);
53-
// (old == compare ? val : old)
54-
return atomicAdd(lock, 0);
49+
return __kmpc_atomic_add(lock, 0u);
5550
}

0 commit comments

Comments
 (0)