[Openmp-commits] [openmp] aa6e7e8 - [OpenMP] libomp: move warnings to after library initialization

via Openmp-commits openmp-commits at lists.llvm.org
Fri May 21 13:47:48 PDT 2021


Author: AndreyChurbanov
Date: 2021-05-21T23:47:23+03:00
New Revision: aa6e7e8da8f5a2706f0b330718df203b3650408e

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

LOG: [OpenMP] libomp: move warnings to after library initialization

Warnings on deprecated api cannot be suppressed if the library is not initialized.
With this change it is possible to set KMP_WARNINGS=false to suppress the warnings.

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

Added: 
    openmp/runtime/test/api/omp_deprecated.c

Modified: 
    openmp/runtime/src/kmp_ftn_entry.h

Removed: 
    


################################################################################
diff  --git a/openmp/runtime/src/kmp_ftn_entry.h b/openmp/runtime/src/kmp_ftn_entry.h
index 9bd31d31dec30..cdd2344b51f61 100644
--- a/openmp/runtime/src/kmp_ftn_entry.h
+++ b/openmp/runtime/src/kmp_ftn_entry.h
@@ -595,13 +595,13 @@ int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_NUM_PROCS)(void) {
 }
 
 void FTN_STDCALL KMP_EXPAND_NAME(FTN_SET_NESTED)(int KMP_DEREF flag) {
-  KMP_INFORM(APIDeprecated, "omp_set_nested", "omp_set_max_active_levels");
 #ifdef KMP_STUB
   __kmps_set_nested(KMP_DEREF flag);
 #else
   kmp_info_t *thread;
   /* For the thread-private internal controls implementation */
   thread = __kmp_entry_thread();
+  KMP_INFORM(APIDeprecated, "omp_set_nested", "omp_set_max_active_levels");
   __kmp_save_internal_controls(thread);
   // Somewhat arbitrarily decide where to get a value for max_active_levels
   int max_active_levels = get__max_active_levels(thread);
@@ -612,12 +612,12 @@ void FTN_STDCALL KMP_EXPAND_NAME(FTN_SET_NESTED)(int KMP_DEREF flag) {
 }
 
 int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_NESTED)(void) {
-  KMP_INFORM(APIDeprecated, "omp_get_nested", "omp_get_max_active_levels");
 #ifdef KMP_STUB
   return __kmps_get_nested();
 #else
   kmp_info_t *thread;
   thread = __kmp_entry_thread();
+  KMP_INFORM(APIDeprecated, "omp_get_nested", "omp_get_max_active_levels");
   return get__max_active_levels(thread) > 1;
 #endif
 }

diff  --git a/openmp/runtime/test/api/omp_deprecated.c b/openmp/runtime/test/api/omp_deprecated.c
new file mode 100644
index 0000000000000..cb8bbb69ed505
--- /dev/null
+++ b/openmp/runtime/test/api/omp_deprecated.c
@@ -0,0 +1,18 @@
+// RUN: %libomp-compile && env KMP_WARNINGS=false %libomp-run 2>&1 | FileCheck %s
+// The test checks that KMP_WARNINGS=false suppresses library warnings
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <omp.h>
+int main(int argc, char** argv) {
+  omp_set_nested(1);
+  if (!omp_get_nested()) {
+    printf("error: omp_set_nested(1) failed\n");
+    return 1;
+  }
+  printf("passed\n");
+  return 0;
+}
+
+// CHECK-NOT: omp_set_nested routine deprecated
+// CHECK-NOT: omp_get_nested routine deprecated


        


More information about the Openmp-commits mailing list