[Openmp-commits] [openmp] r349017 - Fix for bugzilla https://bugs.llvm.org/show_bug.cgi?id=39970

Andrey Churbanov via Openmp-commits openmp-commits at lists.llvm.org
Thu Dec 13 02:04:11 PST 2018


Author: achurbanov
Date: Thu Dec 13 02:04:10 2018
New Revision: 349017

URL: http://llvm.org/viewvc/llvm-project?rev=349017&view=rev
Log:
Fix for bugzilla https://bugs.llvm.org/show_bug.cgi?id=39970

Broken tests fixed

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

Modified:
    openmp/trunk/runtime/test/api/omp_in_parallel.c
    openmp/trunk/runtime/test/flush/omp_flush.c
    openmp/trunk/runtime/test/ompt/misc/api_calls_places.c
    openmp/trunk/runtime/test/parallel/omp_nested.c
    openmp/trunk/runtime/test/tasking/omp_task.c
    openmp/trunk/runtime/test/tasking/omp_taskyield.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/test/api/omp_in_parallel.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/api/omp_in_parallel.c?rev=349017&r1=349016&r2=349017&view=diff
==============================================================================
--- openmp/trunk/runtime/test/api/omp_in_parallel.c (original)
+++ openmp/trunk/runtime/test/api/omp_in_parallel.c Thu Dec 13 02:04:10 2018
@@ -30,6 +30,11 @@ int main()
   int i;
   int num_failed=0;
 
+  // the test requires more than 1 thread to pass
+  omp_set_dynamic(0); // disable dynamic adjustment of threads
+  if (omp_get_max_threads() == 1)
+    omp_set_num_threads(2); // set 2 threads if no HW resources available
+
   for(i = 0; i < REPETITIONS; i++) {
     if(!test_omp_in_parallel()) {
       num_failed++;

Modified: openmp/trunk/runtime/test/flush/omp_flush.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/flush/omp_flush.c?rev=349017&r1=349016&r2=349017&view=diff
==============================================================================
--- openmp/trunk/runtime/test/flush/omp_flush.c (original)
+++ openmp/trunk/runtime/test/flush/omp_flush.c Thu Dec 13 02:04:10 2018
@@ -36,6 +36,11 @@ int main()
   int i;
   int num_failed=0;
 
+  // the test requires more than 1 thread to pass
+  omp_set_dynamic(0); // disable dynamic adjustment of threads
+  if (omp_get_max_threads() == 1)
+    omp_set_num_threads(2); // set 2 threads if no HW resources available
+
   for (i = 0; i < REPETITIONS; i++) {
     if(!test_omp_flush()) {
       num_failed++;

Modified: openmp/trunk/runtime/test/ompt/misc/api_calls_places.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/ompt/misc/api_calls_places.c?rev=349017&r1=349016&r2=349017&view=diff
==============================================================================
--- openmp/trunk/runtime/test/ompt/misc/api_calls_places.c (original)
+++ openmp/trunk/runtime/test/ompt/misc/api_calls_places.c Thu Dec 13 02:04:10 2018
@@ -42,7 +42,7 @@ int main() {
     int omp_nums[omp_nums_size];
     omp_get_partition_place_nums(omp_nums);
     print_list("omp_get_partition_place_nums", omp_nums_size, omp_nums);
-    int ompt_nums_size = ompt_get_partition_place_nums(0, NULL);
+    int ompt_nums_size = ompt_get_partition_place_nums(0, omp_nums);
     int ompt_nums[ompt_nums_size];
     ompt_get_partition_place_nums(ompt_nums_size, ompt_nums);
     print_list("ompt_get_partition_place_nums", ompt_nums_size, ompt_nums);

Modified: openmp/trunk/runtime/test/parallel/omp_nested.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/parallel/omp_nested.c?rev=349017&r1=349016&r2=349017&view=diff
==============================================================================
--- openmp/trunk/runtime/test/parallel/omp_nested.c (original)
+++ openmp/trunk/runtime/test/parallel/omp_nested.c Thu Dec 13 02:04:10 2018
@@ -12,6 +12,8 @@ int test_omp_nested()
 #ifdef _OPENMP
   if (omp_get_max_threads() > 4)
     omp_set_num_threads(4);
+  if (omp_get_max_threads() < 2)
+    omp_set_num_threads(2);
 #endif
 
   int counter = 0;

Modified: openmp/trunk/runtime/test/tasking/omp_task.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/tasking/omp_task.c?rev=349017&r1=349016&r2=349017&view=diff
==============================================================================
--- openmp/trunk/runtime/test/tasking/omp_task.c (original)
+++ openmp/trunk/runtime/test/tasking/omp_task.c Thu Dec 13 02:04:10 2018
@@ -43,6 +43,9 @@ int main()
   int i;
   int num_failed=0;
 
+  if (omp_get_max_threads() < 2)
+    omp_set_num_threads(8);
+
   for(i = 0; i < REPETITIONS; i++) {
     if(!test_omp_task()) {
       num_failed++;

Modified: openmp/trunk/runtime/test/tasking/omp_taskyield.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/tasking/omp_taskyield.c?rev=349017&r1=349016&r2=349017&view=diff
==============================================================================
--- openmp/trunk/runtime/test/tasking/omp_taskyield.c (original)
+++ openmp/trunk/runtime/test/tasking/omp_taskyield.c Thu Dec 13 02:04:10 2018
@@ -49,6 +49,9 @@ int main()
   int i;
   int num_failed=0;
 
+  if (omp_get_max_threads() < 2)
+    omp_set_num_threads(8);
+
   for(i = 0; i < REPETITIONS; i++) {
     if(!test_omp_taskyield()) {
       num_failed++;

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=349017&r1=349016&r2=349017&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 Thu Dec 13 02:04:10 2018
@@ -66,6 +66,7 @@ run_loop(
   int ub;   // Chunk upper bound.
   int st;   // Chunk stride.
   int rc;
+  int nthreads = omp_get_num_threads();
   int tid = omp_get_thread_num();
   int gtid = __kmpc_global_thread_num(&loc);
   int last;
@@ -134,7 +135,7 @@ run_loop(
         printf("Error with iter %d, %d, err %d\n", cur, max, ++err);
       // Update maximum for the next chunk.
       if (last) {
-        if (!no_chunk && cur > ch)
+        if (!no_chunk && cur > ch && nthreads > 1)
           printf("Error: too big last chunk %d (%d), tid %d, err %d\n",
                  (int)cur, ch, tid, ++err);
       } else {

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=349017&r1=349016&r2=349017&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 Thu Dec 13 02:04:10 2018
@@ -74,6 +74,7 @@ run_loop(
   int ub;   // Chunk upper bound.
   int st;   // Chunk stride.
   int rc;
+  int nthreads = omp_get_num_threads();
   int tid = omp_get_thread_num();
   int gtid = __kmpc_global_thread_num(&loc);
   int last;
@@ -144,7 +145,7 @@ run_loop(
       if (!last && cur % ch)
         printf("Error with chunk %d, %d, ch %d, tid %d, err %d\n",
                chunk, (int)cur, ch, tid, ++err);
-      if (last && !no_chunk && cur > ch)
+      if (last && !no_chunk && cur > ch && nthreads > 1)
         printf("Error: too big last chunk %d (%d), tid %d, err %d\n",
                (int)cur, ch, tid, ++err);
       if (cur < max)

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=349017&r1=349016&r2=349017&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 Thu Dec 13 02:04:10 2018
@@ -67,6 +67,7 @@ run_loop(
   int ub;   // Chunk upper bound.
   int st;   // Chunk stride.
   int rc;
+  int nthreads = omp_get_num_threads();
   int tid = omp_get_thread_num();
   int gtid = __kmpc_global_thread_num(&loc);
   int last;
@@ -135,7 +136,7 @@ run_loop(
         printf("Error with iter %d, %d, err %d\n", cur, max, ++err);
       // Update maximum for the next chunk.
       if (last) {
-        if (!no_chunk && cur > ch)
+        if (!no_chunk && cur > ch && nthreads > 1)
           printf("Error: too big last chunk %d (%d), tid %d, err %d\n",
                  (int)cur, ch, tid, ++err);
       } else {

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=349017&r1=349016&r2=349017&view=diff
==============================================================================
--- openmp/trunk/runtime/test/worksharing/for/omp_doacross.c (original)
+++ openmp/trunk/runtime/test/worksharing/for/omp_doacross.c Thu Dec 13 02:04:10 2018
@@ -51,6 +51,8 @@ int test_doacross() {
 int main(int argc, char **argv) {
   int i;
   int num_failed = 0;
+  if (omp_get_max_threads() < 2)
+    omp_set_num_threads(4);
   for (i = 0; i < REPETITIONS; i++) {
     if (!test_doacross()) {
       num_failed++;




More information about the Openmp-commits mailing list