From 74f98554f92dabb4c1be7db9e1712f060f3cdbca Mon Sep 17 00:00:00 2001 From: Andrey Churbanov Date: Thu, 13 Dec 2018 10:04:10 +0000 Subject: [PATCH] Fix for bugzilla https://bugs.llvm.org/show_bug.cgi?id=39970 Broken tests fixed Differential Revision: https://reviews.llvm.org/D55598 llvm-svn: 349017 --- openmp/runtime/test/api/omp_in_parallel.c | 5 +++++ openmp/runtime/test/flush/omp_flush.c | 5 +++++ openmp/runtime/test/ompt/misc/api_calls_places.c | 2 +- openmp/runtime/test/parallel/omp_nested.c | 2 ++ openmp/runtime/test/tasking/omp_task.c | 3 +++ openmp/runtime/test/tasking/omp_taskyield.c | 3 +++ .../runtime/test/worksharing/for/kmp_sch_simd_runtime_api.c | 3 ++- .../test/worksharing/for/kmp_sch_simd_runtime_guided.c | 3 ++- .../test/worksharing/for/kmp_sch_simd_runtime_static.c | 3 ++- openmp/runtime/test/worksharing/for/omp_doacross.c | 2 ++ 10 files changed, 27 insertions(+), 4 deletions(-) diff --git a/openmp/runtime/test/api/omp_in_parallel.c b/openmp/runtime/test/api/omp_in_parallel.c index d09313eab150a..5e9e635fa1558 100644 --- a/openmp/runtime/test/api/omp_in_parallel.c +++ b/openmp/runtime/test/api/omp_in_parallel.c @@ -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++; diff --git a/openmp/runtime/test/flush/omp_flush.c b/openmp/runtime/test/flush/omp_flush.c index 3fd3cdfbc2181..95a406d3eadcb 100644 --- a/openmp/runtime/test/flush/omp_flush.c +++ b/openmp/runtime/test/flush/omp_flush.c @@ -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++; diff --git a/openmp/runtime/test/ompt/misc/api_calls_places.c b/openmp/runtime/test/ompt/misc/api_calls_places.c index ad338a750f4d3..3385c9c62abf8 100644 --- a/openmp/runtime/test/ompt/misc/api_calls_places.c +++ b/openmp/runtime/test/ompt/misc/api_calls_places.c @@ -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); diff --git a/openmp/runtime/test/parallel/omp_nested.c b/openmp/runtime/test/parallel/omp_nested.c index 8b78088901533..d2d5b085ba79a 100644 --- a/openmp/runtime/test/parallel/omp_nested.c +++ b/openmp/runtime/test/parallel/omp_nested.c @@ -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; diff --git a/openmp/runtime/test/tasking/omp_task.c b/openmp/runtime/test/tasking/omp_task.c index c534abe081d51..5703225932d8f 100644 --- a/openmp/runtime/test/tasking/omp_task.c +++ b/openmp/runtime/test/tasking/omp_task.c @@ -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++; diff --git a/openmp/runtime/test/tasking/omp_taskyield.c b/openmp/runtime/test/tasking/omp_taskyield.c index 5bb6984451815..7f85413a1288f 100644 --- a/openmp/runtime/test/tasking/omp_taskyield.c +++ b/openmp/runtime/test/tasking/omp_taskyield.c @@ -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++; diff --git a/openmp/runtime/test/worksharing/for/kmp_sch_simd_runtime_api.c b/openmp/runtime/test/worksharing/for/kmp_sch_simd_runtime_api.c index bb538d10fd293..987a5c0d45945 100644 --- a/openmp/runtime/test/worksharing/for/kmp_sch_simd_runtime_api.c +++ b/openmp/runtime/test/worksharing/for/kmp_sch_simd_runtime_api.c @@ -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 { diff --git a/openmp/runtime/test/worksharing/for/kmp_sch_simd_runtime_guided.c b/openmp/runtime/test/worksharing/for/kmp_sch_simd_runtime_guided.c index d137831d170ab..5dfaf24185e76 100644 --- a/openmp/runtime/test/worksharing/for/kmp_sch_simd_runtime_guided.c +++ b/openmp/runtime/test/worksharing/for/kmp_sch_simd_runtime_guided.c @@ -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) diff --git a/openmp/runtime/test/worksharing/for/kmp_sch_simd_runtime_static.c b/openmp/runtime/test/worksharing/for/kmp_sch_simd_runtime_static.c index 4cb15d6539da5..d76046bac1f80 100644 --- a/openmp/runtime/test/worksharing/for/kmp_sch_simd_runtime_static.c +++ b/openmp/runtime/test/worksharing/for/kmp_sch_simd_runtime_static.c @@ -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 { diff --git a/openmp/runtime/test/worksharing/for/omp_doacross.c b/openmp/runtime/test/worksharing/for/omp_doacross.c index 41871121d1a5e..364430675d647 100644 --- a/openmp/runtime/test/worksharing/for/omp_doacross.c +++ b/openmp/runtime/test/worksharing/for/omp_doacross.c @@ -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++;