[Openmp-commits] [openmp] 2a43688 - [nfc][libomptarget] Refactor nvptx/target_impl.cu

Jon Chesterfield via Openmp-commits openmp-commits at lists.llvm.org
Tue Jan 14 11:27:58 PST 2020


Author: Jon Chesterfield
Date: 2020-01-14T19:27:45Z
New Revision: 2a43688a0a074a70e395491fa0c3cdb4556ccea4

URL: https://github.com/llvm/llvm-project/commit/2a43688a0a074a70e395491fa0c3cdb4556ccea4
DIFF: https://github.com/llvm/llvm-project/commit/2a43688a0a074a70e395491fa0c3cdb4556ccea4.diff

LOG: [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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu b/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
index 97a5ce34962c..50867bc4010a 100644
--- a/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
+++ b/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
@@ -19,17 +19,14 @@
 #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);
 }


        


More information about the Openmp-commits mailing list