[Openmp-commits] [openmp] r349260 - [OpenMP] Fixes for LIBOMP_OMP_VERSION=45/40

Roman Lebedev via Openmp-commits openmp-commits at lists.llvm.org
Sat Dec 15 01:23:40 PST 2018


Author: lebedevri
Date: Sat Dec 15 01:23:39 2018
New Revision: 349260

URL: http://llvm.org/viewvc/llvm-project?rev=349260&view=rev
Log:
[OpenMP] Fixes for LIBOMP_OMP_VERSION=45/40

Summary:
I have discovered this because i wanted to experiment with
building static libomp (with openmp-4.0 support only)
for debugging purposes.

There are three kinds of problems here:
1. `__kmp_compare_and_store_acq()` simply does not exist.
   It was added in D47903 by @jlpeyton.
   I'm guessing `__kmp_atomic_compare_store_acq()` was meant.
2. In `__kmp_is_ticket_lock_initialized()`,
   `lck->lk.initialized` is `std::atomic<bool>`,
   while `lck` is `kmp_ticket_lock_t *`.
   Naturally, they can't be equality-compared.
   Either, it should return the value read from `lck->lk.initialized`,
   or do what `__kmp_is_queuing_lock_initialized()` does,
   compare the passed pointer with the field in the struct
   pointed by the pointer. I think the latter is correct-er choice here.
3. Tests were not versioned.
   They assume that `LIBOMP_OMP_VERSION` is at the latest version.

This does not touch LIBOMP_OMP_VERSION=30. That is still broken.

Reviewers: jlpeyton, Hahnfeld, AndreyChurbanov

Reviewed By: AndreyChurbanov

Subscribers: guansong, jfb, openmp-commits, jlpeyton

Tags: #openmp

Differential Revision: https://reviews.llvm.org/D55496

Modified:
    openmp/trunk/runtime/src/kmp_lock.cpp
    openmp/trunk/runtime/src/kmp_lock.h
    openmp/trunk/runtime/src/kmp_tasking.cpp
    openmp/trunk/runtime/test/api/omp_alloc.c
    openmp/trunk/runtime/test/lit.cfg
    openmp/trunk/runtime/test/lit.site.cfg.in
    openmp/trunk/runtime/test/ompt/misc/control_tool_no_ompt_support.c
    openmp/trunk/runtime/test/tasking/bug_nested_proxy_task.c
    openmp/trunk/runtime/test/tasking/bug_proxy_task_dep_waiting.c
    openmp/trunk/runtime/test/tasking/kmp_task_reduction_nest.cpp
    openmp/trunk/runtime/test/tasking/kmp_taskloop.c
    openmp/trunk/runtime/test/tasking/omp_task_priority.c
    openmp/trunk/runtime/test/tasking/omp_taskloop_grainsize.c
    openmp/trunk/runtime/test/tasking/omp_taskloop_num_tasks.c
    openmp/trunk/runtime/test/worksharing/for/kmp_doacross_check.c
    openmp/trunk/runtime/test/worksharing/for/kmp_sch_simd_guided.c
    openmp/trunk/runtime/test/worksharing/for/kmp_sch_simd_runtime_api.c
    openmp/trunk/runtime/test/worksharing/for/kmp_sch_simd_runtime_guided.c
    openmp/trunk/runtime/test/worksharing/for/kmp_sch_simd_runtime_static.c
    openmp/trunk/runtime/test/worksharing/for/omp_doacross.c

Modified: openmp/trunk/runtime/src/kmp_lock.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_lock.cpp?rev=349260&r1=349259&r2=349260&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_lock.cpp (original)
+++ openmp/trunk/runtime/src/kmp_lock.cpp Sat Dec 15 01:23:39 2018
@@ -3359,7 +3359,7 @@ static void __kmp_init_nested_futex_lock
 #endif
 
 static int __kmp_is_ticket_lock_initialized(kmp_ticket_lock_t *lck) {
-  return lck == lck->lk.initialized;
+  return lck == lck->lk.self;
 }
 
 static void __kmp_init_ticket_lock_with_checks(kmp_ticket_lock_t *lck) {

Modified: openmp/trunk/runtime/src/kmp_lock.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_lock.h?rev=349260&r1=349259&r2=349260&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_lock.h (original)
+++ openmp/trunk/runtime/src/kmp_lock.h Sat Dec 15 01:23:39 2018
@@ -649,7 +649,7 @@ extern int (*__kmp_acquire_user_lock_wit
       }                                                                        \
     }                                                                          \
     if (lck->tas.lk.poll != 0 ||                                               \
-        !__kmp_compare_and_store_acq(&lck->tas.lk.poll, 0, gtid + 1)) {        \
+        !__kmp_atomic_compare_store_acq(&lck->tas.lk.poll, 0, gtid + 1)) {     \
       kmp_uint32 spins;                                                        \
       KMP_FSYNC_PREPARE(lck);                                                  \
       KMP_INIT_YIELD(spins);                                                   \
@@ -659,8 +659,8 @@ extern int (*__kmp_acquire_user_lock_wit
       } else {                                                                 \
         KMP_YIELD_SPIN(spins);                                                 \
       }                                                                        \
-      while (lck->tas.lk.poll != 0 ||                                          \
-             !__kmp_compare_and_store_acq(&lck->tas.lk.poll, 0, gtid + 1)) {   \
+      while (lck->tas.lk.poll != 0 || !__kmp_atomic_compare_store_acq(         \
+                                          &lck->tas.lk.poll, 0, gtid + 1)) {   \
         if (TCR_4(__kmp_nth) >                                                 \
             (__kmp_avail_proc ? __kmp_avail_proc : __kmp_xproc)) {             \
           KMP_YIELD(TRUE);                                                     \
@@ -702,7 +702,7 @@ static inline int __kmp_test_user_lock_w
       }
     }
     return ((lck->tas.lk.poll == 0) &&
-            __kmp_compare_and_store_acq(&lck->tas.lk.poll, 0, gtid + 1));
+            __kmp_atomic_compare_store_acq(&lck->tas.lk.poll, 0, gtid + 1));
   } else {
     KMP_DEBUG_ASSERT(__kmp_test_user_lock_with_checks_ != NULL);
     return (*__kmp_test_user_lock_with_checks_)(lck, gtid);
@@ -767,7 +767,7 @@ extern int (*__kmp_acquire_nested_user_l
       *depth = KMP_LOCK_ACQUIRED_NEXT;                                         \
     } else {                                                                   \
       if ((lck->tas.lk.poll != 0) ||                                           \
-          !__kmp_compare_and_store_acq(&lck->tas.lk.poll, 0, gtid + 1)) {      \
+          !__kmp_atomic_compare_store_acq(&lck->tas.lk.poll, 0, gtid + 1)) {   \
         kmp_uint32 spins;                                                      \
         KMP_FSYNC_PREPARE(lck);                                                \
         KMP_INIT_YIELD(spins);                                                 \
@@ -777,8 +777,9 @@ extern int (*__kmp_acquire_nested_user_l
         } else {                                                               \
           KMP_YIELD_SPIN(spins);                                               \
         }                                                                      \
-        while ((lck->tas.lk.poll != 0) ||                                      \
-               !__kmp_compare_and_store_acq(&lck->tas.lk.poll, 0, gtid + 1)) { \
+        while (                                                                \
+            (lck->tas.lk.poll != 0) ||                                         \
+            !__kmp_atomic_compare_store_acq(&lck->tas.lk.poll, 0, gtid + 1)) { \
           if (TCR_4(__kmp_nth) >                                               \
               (__kmp_avail_proc ? __kmp_avail_proc : __kmp_xproc)) {           \
             KMP_YIELD(TRUE);                                                   \
@@ -826,7 +827,7 @@ static inline int __kmp_test_nested_user
       return ++lck->tas.lk.depth_locked; /* same owner, depth increased */
     }
     retval = ((lck->tas.lk.poll == 0) &&
-              __kmp_compare_and_store_acq(&lck->tas.lk.poll, 0, gtid + 1));
+              __kmp_atomic_compare_store_acq(&lck->tas.lk.poll, 0, gtid + 1));
     if (retval) {
       KMP_MB();
       lck->tas.lk.depth_locked = 1;

Modified: openmp/trunk/runtime/src/kmp_tasking.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_tasking.cpp?rev=349260&r1=349259&r2=349260&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_tasking.cpp (original)
+++ openmp/trunk/runtime/src/kmp_tasking.cpp Sat Dec 15 01:23:39 2018
@@ -811,8 +811,10 @@ static void __kmp_task_finish(kmp_int32
                               kmp_taskdata_t *resumed_task) {
   kmp_taskdata_t *taskdata = KMP_TASK_TO_TASKDATA(task);
   kmp_info_t *thread = __kmp_threads[gtid];
+#if OMP_45_ENABLED
   kmp_task_team_t *task_team =
       thread->th.th_task_team; // might be NULL for serial teams...
+#endif // OMP_45_ENABLED
   kmp_int32 children = 0;
 
   KA_TRACE(10, ("__kmp_task_finish(enter): T#%d finishing task %p and resuming "

Modified: openmp/trunk/runtime/test/api/omp_alloc.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/api/omp_alloc.c?rev=349260&r1=349259&r2=349260&view=diff
==============================================================================
--- openmp/trunk/runtime/test/api/omp_alloc.c (original)
+++ openmp/trunk/runtime/test/api/omp_alloc.c Sat Dec 15 01:23:39 2018
@@ -1,4 +1,7 @@
 // RUN: %libomp-compile-and-run
+
+// REQUIRES: openmp-5.0
+
 #include <stdio.h>
 #include <stdint.h>
 #include <omp.h>

Modified: openmp/trunk/runtime/test/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/lit.cfg?rev=349260&r1=349259&r2=349260&view=diff
==============================================================================
--- openmp/trunk/runtime/test/lit.cfg (original)
+++ openmp/trunk/runtime/test/lit.cfg Sat Dec 15 01:23:39 2018
@@ -91,6 +91,15 @@ if config.has_ompt:
     # for callback.h
     config.test_flags += " -I " + config.test_source_root + "/ompt"
 
+if config.libomp_omp_version >= 50:
+    config.available_features.add("openmp-5.0")
+
+if config.libomp_omp_version >= 45:
+    config.available_features.add("openmp-4.5")
+
+if config.libomp_omp_version >= 40:
+    config.available_features.add("openmp-4.0")
+
 if 'Linux' in config.operating_system:
     config.available_features.add("linux")
 

Modified: openmp/trunk/runtime/test/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/lit.site.cfg.in?rev=349260&r1=349259&r2=349260&view=diff
==============================================================================
--- openmp/trunk/runtime/test/lit.site.cfg.in (original)
+++ openmp/trunk/runtime/test/lit.site.cfg.in Sat Dec 15 01:23:39 2018
@@ -6,6 +6,7 @@ config.test_compiler_features = @OPENMP_
 config.test_filecheck = "@OPENMP_FILECHECK_EXECUTABLE@"
 config.test_openmp_flags = "@OPENMP_TEST_OPENMP_FLAGS@"
 config.test_extra_flags = "@OPENMP_TEST_FLAGS@"
+config.libomp_omp_version = @LIBOMP_OMP_VERSION@
 config.libomp_obj_root = "@CMAKE_CURRENT_BINARY_DIR@"
 config.library_dir = "@LIBOMP_LIBRARY_DIR@"
 config.omp_header_directory = "@LIBOMP_BINARY_DIR@/src"

Modified: openmp/trunk/runtime/test/ompt/misc/control_tool_no_ompt_support.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/ompt/misc/control_tool_no_ompt_support.c?rev=349260&r1=349259&r2=349260&view=diff
==============================================================================
--- openmp/trunk/runtime/test/ompt/misc/control_tool_no_ompt_support.c (original)
+++ openmp/trunk/runtime/test/ompt/misc/control_tool_no_ompt_support.c Sat Dec 15 01:23:39 2018
@@ -1,4 +1,7 @@
 // RUN: %libomp-compile-and-run
+
+// REQUIRES: openmp-5.0
+
 #include <omp.h>
 
 int main()

Modified: openmp/trunk/runtime/test/tasking/bug_nested_proxy_task.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/tasking/bug_nested_proxy_task.c?rev=349260&r1=349259&r2=349260&view=diff
==============================================================================
--- openmp/trunk/runtime/test/tasking/bug_nested_proxy_task.c (original)
+++ openmp/trunk/runtime/test/tasking/bug_nested_proxy_task.c Sat Dec 15 01:23:39 2018
@@ -1,4 +1,5 @@
 // RUN: %libomp-compile -lpthread && %libomp-run
+// REQUIRES: openmp-4.5
 // The runtime currently does not get dependency information from GCC.
 // UNSUPPORTED: gcc
 

Modified: openmp/trunk/runtime/test/tasking/bug_proxy_task_dep_waiting.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/tasking/bug_proxy_task_dep_waiting.c?rev=349260&r1=349259&r2=349260&view=diff
==============================================================================
--- openmp/trunk/runtime/test/tasking/bug_proxy_task_dep_waiting.c (original)
+++ openmp/trunk/runtime/test/tasking/bug_proxy_task_dep_waiting.c Sat Dec 15 01:23:39 2018
@@ -1,4 +1,5 @@
 // RUN: %libomp-compile -lpthread && %libomp-run
+// REQUIRES: openmp-4.5
 // The runtime currently does not get dependency information from GCC.
 // UNSUPPORTED: gcc
 

Modified: openmp/trunk/runtime/test/tasking/kmp_task_reduction_nest.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/tasking/kmp_task_reduction_nest.cpp?rev=349260&r1=349259&r2=349260&view=diff
==============================================================================
--- openmp/trunk/runtime/test/tasking/kmp_task_reduction_nest.cpp (original)
+++ openmp/trunk/runtime/test/tasking/kmp_task_reduction_nest.cpp Sat Dec 15 01:23:39 2018
@@ -1,5 +1,6 @@
 // RUN: %libomp-cxx-compile-and-run
 // RUN: %libomp-cxx-compile -DFLG=1 && %libomp-run
+// REQUIRES: openmp-5.0
 // GCC-5 is needed for OpenMP 4.0 support (taskgroup)
 // XFAIL: gcc-4
 #include <cstdio>

Modified: openmp/trunk/runtime/test/tasking/kmp_taskloop.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/tasking/kmp_taskloop.c?rev=349260&r1=349259&r2=349260&view=diff
==============================================================================
--- openmp/trunk/runtime/test/tasking/kmp_taskloop.c (original)
+++ openmp/trunk/runtime/test/tasking/kmp_taskloop.c Sat Dec 15 01:23:39 2018
@@ -1,5 +1,6 @@
 // RUN: %libomp-compile-and-run
 // RUN: %libomp-compile && env KMP_TASKLOOP_MIN_TASKS=1 %libomp-run
+// REQUIRES: openmp-4.5
 #include <stdio.h>
 #include <omp.h>
 #include "omp_my_sleep.h"

Modified: openmp/trunk/runtime/test/tasking/omp_task_priority.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/tasking/omp_task_priority.c?rev=349260&r1=349259&r2=349260&view=diff
==============================================================================
--- openmp/trunk/runtime/test/tasking/omp_task_priority.c (original)
+++ openmp/trunk/runtime/test/tasking/omp_task_priority.c Sat Dec 15 01:23:39 2018
@@ -1,4 +1,5 @@
 // RUN: %libomp-compile && env OMP_MAX_TASK_PRIORITY=42 %libomp-run
+// REQUIRES: openmp-4.5
 // Test OMP 4.5 task priorities
 // Currently only API function and envirable parsing implemented.
 // Test environment sets envirable: OMP_MAX_TASK_PRIORITY=42 as tested below.

Modified: openmp/trunk/runtime/test/tasking/omp_taskloop_grainsize.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/tasking/omp_taskloop_grainsize.c?rev=349260&r1=349259&r2=349260&view=diff
==============================================================================
--- openmp/trunk/runtime/test/tasking/omp_taskloop_grainsize.c (original)
+++ openmp/trunk/runtime/test/tasking/omp_taskloop_grainsize.c Sat Dec 15 01:23:39 2018
@@ -1,5 +1,6 @@
 // RUN: %libomp-compile-and-run
 // RUN: %libomp-compile && env KMP_TASKLOOP_MIN_TASKS=1 %libomp-run
+// REQUIRES: openmp-4.5
 
 // These compilers don't support the taskloop construct
 // UNSUPPORTED: gcc-4, gcc-5, icc-16

Modified: openmp/trunk/runtime/test/tasking/omp_taskloop_num_tasks.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/tasking/omp_taskloop_num_tasks.c?rev=349260&r1=349259&r2=349260&view=diff
==============================================================================
--- openmp/trunk/runtime/test/tasking/omp_taskloop_num_tasks.c (original)
+++ openmp/trunk/runtime/test/tasking/omp_taskloop_num_tasks.c Sat Dec 15 01:23:39 2018
@@ -1,5 +1,6 @@
 // RUN: %libomp-compile-and-run
 // RUN: %libomp-compile && env KMP_TASKLOOP_MIN_TASKS=1 %libomp-run
+// REQUIRES: openmp-4.5
 
 // These compilers don't support the taskloop construct
 // UNSUPPORTED: gcc-4, gcc-5, icc-16

Modified: openmp/trunk/runtime/test/worksharing/for/kmp_doacross_check.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/worksharing/for/kmp_doacross_check.c?rev=349260&r1=349259&r2=349260&view=diff
==============================================================================
--- openmp/trunk/runtime/test/worksharing/for/kmp_doacross_check.c (original)
+++ openmp/trunk/runtime/test/worksharing/for/kmp_doacross_check.c Sat Dec 15 01:23:39 2018
@@ -1,4 +1,5 @@
 // RUN: %libomp-compile-and-run
+// REQUIRES: openmp-4.5
 // UNSUPPORTED: gcc
 // This test is incompatible with gcc because of the explicit call to
 // __kmpc_doacross_fini().  gcc relies on an implicit call to this function

Modified: openmp/trunk/runtime/test/worksharing/for/kmp_sch_simd_guided.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/worksharing/for/kmp_sch_simd_guided.c?rev=349260&r1=349259&r2=349260&view=diff
==============================================================================
--- openmp/trunk/runtime/test/worksharing/for/kmp_sch_simd_guided.c (original)
+++ openmp/trunk/runtime/test/worksharing/for/kmp_sch_simd_guided.c Sat Dec 15 01:23:39 2018
@@ -1,4 +1,5 @@
 // RUN: %libomp-compile-and-run
+// REQUIRES: openmp-4.5
 /*
   Test for the 'schedule(simd:guided)' clause.
   Compiler needs to generate a dynamic dispatching and pass the schedule

Modified: openmp/trunk/runtime/test/worksharing/for/kmp_sch_simd_runtime_api.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/worksharing/for/kmp_sch_simd_runtime_api.c?rev=349260&r1=349259&r2=349260&view=diff
==============================================================================
--- openmp/trunk/runtime/test/worksharing/for/kmp_sch_simd_runtime_api.c (original)
+++ openmp/trunk/runtime/test/worksharing/for/kmp_sch_simd_runtime_api.c Sat Dec 15 01:23:39 2018
@@ -1,4 +1,5 @@
 // RUN: %libomp-compile-and-run
+// REQUIRES: openmp-4.5
 
 // The test checks schedule(simd:runtime)
 // in combination with omp_set_schedule()

Modified: openmp/trunk/runtime/test/worksharing/for/kmp_sch_simd_runtime_guided.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/worksharing/for/kmp_sch_simd_runtime_guided.c?rev=349260&r1=349259&r2=349260&view=diff
==============================================================================
--- openmp/trunk/runtime/test/worksharing/for/kmp_sch_simd_runtime_guided.c (original)
+++ openmp/trunk/runtime/test/worksharing/for/kmp_sch_simd_runtime_guided.c Sat Dec 15 01:23:39 2018
@@ -6,6 +6,7 @@
 // RUN: env OMP_SCHEDULE=dynamic,1 %libomp-run 1
 // RUN: env OMP_SCHEDULE=dynamic,2 %libomp-run 2
 // RUN: env OMP_SCHEDULE=auto      %libomp-run
+// REQUIRES: openmp-4.5
 
 // The test checks schedule(simd:runtime)
 // in combination with OMP_SCHEDULE=guided[,chunk]

Modified: openmp/trunk/runtime/test/worksharing/for/kmp_sch_simd_runtime_static.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/worksharing/for/kmp_sch_simd_runtime_static.c?rev=349260&r1=349259&r2=349260&view=diff
==============================================================================
--- openmp/trunk/runtime/test/worksharing/for/kmp_sch_simd_runtime_static.c (original)
+++ openmp/trunk/runtime/test/worksharing/for/kmp_sch_simd_runtime_static.c Sat Dec 15 01:23:39 2018
@@ -1,5 +1,6 @@
 // RUN: %libomp-compile && %libomp-run
 // RUN: %libomp-run 1 && %libomp-run 2
+// REQUIRES: openmp-4.5
 
 // The test checks schedule(simd:runtime)
 // in combination with OMP_SCHEDULE=static[,chunk]

Modified: openmp/trunk/runtime/test/worksharing/for/omp_doacross.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/worksharing/for/omp_doacross.c?rev=349260&r1=349259&r2=349260&view=diff
==============================================================================
--- openmp/trunk/runtime/test/worksharing/for/omp_doacross.c (original)
+++ openmp/trunk/runtime/test/worksharing/for/omp_doacross.c Sat Dec 15 01:23:39 2018
@@ -1,4 +1,5 @@
 // RUN: %libomp-compile-and-run
+// REQUIRES: openmp-4.5
 // XFAIL: gcc-4, gcc-5, clang-3.7, clang-3.8, icc-15, icc-16
 #include <stdio.h>
 #include <stdlib.h>




More information about the Openmp-commits mailing list