[nfc][libomptarget] Refactor nvptx/target_impl.cu
authorJon Chesterfield <jonathanchesterfield@gmail.com>
Tue, 14 Jan 2020 19:27:44 +0000 (19:27 +0000)
committerJon Chesterfield <jonathanchesterfield@gmail.com>
Tue, 14 Jan 2020 19:27:45 +0000 (19:27 +0000)
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

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

index 97a5ce34962ceabd7fe2b7922478a8b9744c2349..50867bc4010af6a51bba30ad18c60e7903672f55 100644 (file)
 #define SET 1u
 
 EXTERN void __kmpc_impl_init_lock(omp_lock_t *lock) {
-  omp_unset_lock(lock);
+  __kmpc_impl_unset_lock(lock);
 }
 
 EXTERN void __kmpc_impl_destroy_lock(omp_lock_t *lock) {
-  omp_unset_lock(lock);
+  __kmpc_impl_unset_lock(lock);
 }
 
 EXTERN void __kmpc_impl_set_lock(omp_lock_t *lock) {
-  // int atomicCAS(int* address, int compare, int val);
-  // (old == compare ? val : old)
-
   // TODO: not sure spinning is a good idea here..
   while (__kmpc_atomic_cas(lock, UNSET, SET) != UNSET) {
     clock_t start = clock();
@@ -49,7 +46,5 @@ EXTERN void __kmpc_impl_unset_lock(omp_lock_t *lock) {
 }
 
 EXTERN int __kmpc_impl_test_lock(omp_lock_t *lock) {
-  // int atomicCAS(int* address, int compare, int val);
-  // (old == compare ? val : old)
-  return atomicAdd(lock, 0);
+  return __kmpc_atomic_add(lock, 0u);
 }