[Openmp-commits] [openmp] ce0911b - [OpenMP][Tests] Fix compiler warnings in OpenMP runtime tests

Joachim Protze via Openmp-commits openmp-commits at lists.llvm.org
Wed Nov 11 11:15:50 PST 2020


Author: Joachim Protze
Date: 2020-11-11T20:13:21+01:00
New Revision: ce0911b3e9199a3a2a96dd3d1dec2309ea22b248

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

LOG: [OpenMP][Tests] Fix compiler warnings in OpenMP runtime tests

This patch allows to pass the OpenMP runtime tests after configuring with
`cmake . -DOPENMP_TEST_FLAGS:STRING="-Werror"`.
The warnings for OMPT tests are addressed in D90752.

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

Added: 
    

Modified: 
    openmp/runtime/test/affinity/format/api2.c
    openmp/runtime/test/api/omp_alloc_def_fb.c
    openmp/runtime/test/api/omp_alloc_hbw.c
    openmp/runtime/test/api/omp_alloc_null_fb.c
    openmp/runtime/test/api/omp_display_env0.c
    openmp/runtime/test/env/omp_target_offload.c
    openmp/runtime/test/lit.cfg
    openmp/runtime/test/misc_bugs/omp_foreign_thread_team_reuse.c
    openmp/runtime/test/worksharing/for/kmp_sch_simd_guided.c
    openmp/runtime/test/worksharing/for/kmp_sch_simd_runtime_api.c
    openmp/runtime/test/worksharing/for/kmp_sch_simd_runtime_guided.c
    openmp/runtime/test/worksharing/for/kmp_sch_simd_runtime_static.c

Removed: 
    


################################################################################
diff  --git a/openmp/runtime/test/affinity/format/api2.c b/openmp/runtime/test/affinity/format/api2.c
index c32da938f8d9..cda3a628d0c4 100644
--- a/openmp/runtime/test/affinity/format/api2.c
+++ b/openmp/runtime/test/affinity/format/api2.c
@@ -13,8 +13,8 @@
 
 #define check(condition)                                                       \
   if (!(condition)) {                                                          \
-    fprintf(stderr, "error: %s: %d: " STR(condition) "\n", __FILE__,           \
-            __LINE__);                                                         \
+    fprintf(stderr, "error: %s: %d: %s\n", __FILE__, __LINE__,                 \
+            STR(condition));                                                   \
     exit(1);                                                                   \
   }
 

diff  --git a/openmp/runtime/test/api/omp_alloc_def_fb.c b/openmp/runtime/test/api/omp_alloc_def_fb.c
index cf1578366828..d75366d84949 100644
--- a/openmp/runtime/test/api/omp_alloc_def_fb.c
+++ b/openmp/runtime/test/api/omp_alloc_def_fb.c
@@ -12,8 +12,8 @@ int main() {
   at[1].key = omp_atk_fallback;
   at[1].value = omp_atv_default_mem_fb;
   a = omp_init_allocator(omp_large_cap_mem_space, 2, at);
-  printf("allocator large created: %p\n", a);
-  #pragma omp parallel num_threads(2)
+  printf("allocator large created: %p\n", (void *)a);
+#pragma omp parallel num_threads(2)
   {
     int i = omp_get_thread_num();
     p[i] = omp_alloc(1024 * 1024, a);

diff  --git a/openmp/runtime/test/api/omp_alloc_hbw.c b/openmp/runtime/test/api/omp_alloc_hbw.c
index d28a9b51f387..2aca26c102c4 100644
--- a/openmp/runtime/test/api/omp_alloc_hbw.c
+++ b/openmp/runtime/test/api/omp_alloc_hbw.c
@@ -12,8 +12,8 @@ int main() {
   at[1].key = omp_atk_fallback;
   at[1].value = omp_atv_null_fb;
   a = omp_init_allocator(omp_high_bw_mem_space, 2, at);
-  printf("allocator hbw created: %p\n", a);
-  #pragma omp parallel num_threads(2)
+  printf("allocator hbw created: %p\n", (void *)a);
+#pragma omp parallel num_threads(2)
   {
     int i = omp_get_thread_num();
     p[i] = omp_alloc(1024 * 1024, a);

diff  --git a/openmp/runtime/test/api/omp_alloc_null_fb.c b/openmp/runtime/test/api/omp_alloc_null_fb.c
index c75e5c510e6a..e08456e7ae2c 100644
--- a/openmp/runtime/test/api/omp_alloc_null_fb.c
+++ b/openmp/runtime/test/api/omp_alloc_null_fb.c
@@ -12,8 +12,8 @@ int main() {
   at[1].key = omp_atk_fallback;
   at[1].value = omp_atv_null_fb;
   a = omp_init_allocator(omp_large_cap_mem_space, 2, at);
-  printf("allocator large created: %p\n", a);
-  #pragma omp parallel num_threads(2)
+  printf("allocator large created: %p\n", (void *)a);
+#pragma omp parallel num_threads(2)
   {
     int i = omp_get_thread_num();
     #pragma omp barrier

diff  --git a/openmp/runtime/test/api/omp_display_env0.c b/openmp/runtime/test/api/omp_display_env0.c
index afea3b9e3649..85d085ecd6f7 100644
--- a/openmp/runtime/test/api/omp_display_env0.c
+++ b/openmp/runtime/test/api/omp_display_env0.c
@@ -1,5 +1,5 @@
 // RUN: %libomp-compile-and-run 2>&1 | FileCheck %s
-// RUN: %libomp-cxx-compile-and-run 2>&1 | FileCheck %s
+// RUN: %libomp-cxx-compile-c && %libomp-run 2>&1 | FileCheck %s
 #include <stdio.h>
 #include <omp.h>
 int main()

diff  --git a/openmp/runtime/test/env/omp_target_offload.c b/openmp/runtime/test/env/omp_target_offload.c
index 91ce108b55b0..4771e3c75dc7 100644
--- a/openmp/runtime/test/env/omp_target_offload.c
+++ b/openmp/runtime/test/env/omp_target_offload.c
@@ -9,6 +9,7 @@ enum kmp_target_offload_kind {
 };
 
 extern int __kmpc_get_target_offload();
+extern void kmp_set_defaults(char const *str);
 
 const char *disabled_examples[] = {
     // Allowed inputs

diff  --git a/openmp/runtime/test/lit.cfg b/openmp/runtime/test/lit.cfg
index 357b18a205d0..e133ef095a2a 100644
--- a/openmp/runtime/test/lit.cfg
+++ b/openmp/runtime/test/lit.cfg
@@ -116,6 +116,8 @@ config.substitutions.append(("%libomp-compile-and-run", \
     "%libomp-compile && %libomp-run"))
 config.substitutions.append(("%libomp-cxx-compile-and-run", \
     "%libomp-cxx-compile && %libomp-run"))
+config.substitutions.append(("%libomp-cxx-compile-c", \
+    "%clangXX %openmp_flags %flags -std=c++14 -x c++ %s -o %t" + libs))
 config.substitutions.append(("%libomp-cxx-compile", \
     "%clangXX %openmp_flags %flags -std=c++14 %s -o %t" + libs))
 config.substitutions.append(("%libomp-compile", \

diff  --git a/openmp/runtime/test/misc_bugs/omp_foreign_thread_team_reuse.c b/openmp/runtime/test/misc_bugs/omp_foreign_thread_team_reuse.c
index a8400e4541bf..ec85f890b3b7 100644
--- a/openmp/runtime/test/misc_bugs/omp_foreign_thread_team_reuse.c
+++ b/openmp/runtime/test/misc_bugs/omp_foreign_thread_team_reuse.c
@@ -37,6 +37,7 @@ void* thread_function(void* arg) {
       a++;
     }
   }
+  return NULL;
 }
 
 int test_omp_team_reuse()

diff  --git a/openmp/runtime/test/worksharing/for/kmp_sch_simd_guided.c b/openmp/runtime/test/worksharing/for/kmp_sch_simd_guided.c
index 5c6f94bc729a..cfc2d870f1a8 100644
--- a/openmp/runtime/test/worksharing/for/kmp_sch_simd_guided.c
+++ b/openmp/runtime/test/worksharing/for/kmp_sch_simd_guided.c
@@ -128,7 +128,7 @@ int run_loop_64(i64 loop_lb, i64 loop_ub, i64 loop_st, int loop_chunk) {
       // Guided scheduling uses FP computations, so current chunk may
       // be a bit bigger (+1) than allowed maximum
       if (!(cur <= max + 1)) {
-        printf("Error with iter %d, %d\n", cur, max);
+        printf("Error with iter %llu, %llu\n", cur, max);
         err++;
       }
       // Update maximum for the next chunk
@@ -280,7 +280,7 @@ int run_loop_32(int loop_lb, int loop_ub, int loop_st, int loop_chunk) {
       // Guided scheduling uses FP computations, so current chunk may
       // be a bit bigger (+1) than allowed maximum
       if (!(cur <= max + 1)) {
-        printf("Error with iter %d, %d\n", cur, max);
+        printf("Error with iter %llu, %llu\n", cur, max);
         err++;
       }
       // Update maximum for the next chunk

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 987a5c0d4594..85c9af025bf2 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
@@ -132,7 +132,7 @@ run_loop(
       // Guided scheduling uses FP computations, so current chunk may
       // be a bit bigger (+1) than allowed maximum.
       if (!( cur <= max + 1))
-        printf("Error with iter %d, %d, err %d\n", cur, max, ++err);
+        printf("Error with iter %llu, %llu, err %d\n", cur, max, ++err);
       // Update maximum for the next chunk.
       if (last) {
         if (!no_chunk && cur > ch && nthreads > 1)

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 5dfaf24185e7..99b22ab20d70 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
@@ -140,7 +140,7 @@ run_loop(
       // Guided scheduling uses FP computations, so current chunk may
       // be a bit bigger (+1) than allowed maximum.
       if (!( cur <= max + 1))
-        printf("Error with iter %d, %d, err %d\n", cur, max, ++err);
+        printf("Error with iter %llu, %llu, err %d\n", cur, max, ++err);
       // Update maximum for the next chunk.
       if (!last && cur % ch)
         printf("Error with chunk %d, %d, ch %d, tid %d, err %d\n",

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 d76046bac1f8..2048c278e1b7 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
@@ -5,6 +5,7 @@
 // in combination with OMP_SCHEDULE=static[,chunk]
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <omp.h>
 
 #if defined(WIN32) || defined(_WIN32)
@@ -133,7 +134,7 @@ run_loop(
       // Guided scheduling uses FP computations, so current chunk may
       // be a bit bigger (+1) than allowed maximum.
       if (!( cur <= max + 1))
-        printf("Error with iter %d, %d, err %d\n", cur, max, ++err);
+        printf("Error with iter %llu, %llu, err %d\n", cur, max, ++err);
       // Update maximum for the next chunk.
       if (last) {
         if (!no_chunk && cur > ch && nthreads > 1)


        


More information about the Openmp-commits mailing list