[openmp] OpenMP 5.1 omp_display_env function implementation.
authorAndreyChurbanov <andrey.churbanov@intel.com>
Wed, 4 Mar 2020 15:15:05 +0000 (18:15 +0300)
committerAndreyChurbanov <andrey.churbanov@intel.com>
Wed, 4 Mar 2020 15:15:05 +0000 (18:15 +0300)
Patch by Michael Klemm.

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

12 files changed:
openmp/runtime/src/dllexports
openmp/runtime/src/include/omp.h.var
openmp/runtime/src/include/omp_lib.f.var
openmp/runtime/src/include/omp_lib.f90.var
openmp/runtime/src/include/omp_lib.h.var
openmp/runtime/src/kmp.h
openmp/runtime/src/kmp_ftn_entry.h
openmp/runtime/src/kmp_ftn_os.h
openmp/runtime/src/kmp_runtime.cpp
openmp/runtime/src/kmp_settings.cpp
openmp/runtime/src/kmp_settings.h
openmp/runtime/test/api/omp_display_env0.c [new file with mode: 0644]

index f76619e..45a294b 100644 (file)
@@ -533,6 +533,7 @@ kmp_set_disp_num_buffers                    890
     omp_pause_resource_all                  757
     omp_get_supported_active_levels         758
     omp_fulfill_event                       759
+    omp_display_env                         733
 
     omp_null_allocator                     DATA
     omp_default_mem_alloc                  DATA
index dd5b8ce..f62afc2 100644 (file)
 
     extern int __KAI_KMPC_CONVENTION omp_get_supported_active_levels(void);
 
+    /* OpenMP 5.1 Display Environment */
+    extern void omp_display_env(int verbose);
+
 #   undef __KAI_KMPC_CONVENTION
 #   undef __KMP_IMP
 
index d631438..bf40c78 100644 (file)
             integer (kind=kmp_size_t_kind) omp_capture_affinity
           end function omp_capture_affinity
 
+          subroutine omp_display_env(verbose) bind(c)
+            use omp_lib_kinds
+            logical (kind=omp_logical_kind), value :: verbose
+          end subroutine omp_display_env
+
 !         ***
 !         *** kmp_* entry points
 !         ***
index ac56848..fbbb7b9 100644 (file)
             integer (kind=kmp_size_t_kind) :: omp_capture_affinity
           end function omp_capture_affinity
 
+          subroutine omp_display_env(verbose) bind(c)
+            use omp_lib_kinds
+            logical (kind=omp_logical_kind), value :: verbose
+          end subroutine omp_display_env
+
+
 !         ***
 !         *** kmp_* entry points
 !         ***
index 8775128..f1b6b03 100644 (file)
           integer (kind=kmp_size_t_kind) :: omp_capture_affinity
         end function omp_capture_affinity
 
+        subroutine omp_display_env(verbose) bind(c)
+          import
+          logical (kind=omp_logical_kind), value :: verbose
+        end subroutine omp_display_env
+
 !       ***
 !       *** kmp_* entry points
 !       ***
index bb1f3ed..c912157 100644 (file)
@@ -3908,6 +3908,8 @@ static inline void __kmp_resume_if_hard_paused() {
   }
 }
 
+extern void __kmp_omp_display_env(int verbose);
+
 #ifdef __cplusplus
 }
 #endif
index 89172c0..ab57907 100644 (file)
@@ -1371,6 +1371,13 @@ void FTN_STDCALL FTN_FULFILL_EVENT(kmp_event_t *event) {
 #endif
 }
 
+// display environment variables when requested
+void FTN_STDCALL FTN_DISPLAY_ENV(int verbose) {
+#ifndef KMP_STUB
+  __kmp_omp_display_env(verbose);
+#endif
+}
+
 // GCC compatibility (versioned symbols)
 #ifdef KMP_USE_VERSION_SYMBOLS
 
index 41cafab..cd04914 100644 (file)
 #define FTN_PAUSE_RESOURCE omp_pause_resource
 #define FTN_PAUSE_RESOURCE_ALL omp_pause_resource_all
 #define FTN_GET_SUPPORTED_ACTIVE_LEVELS omp_get_supported_active_levels
+#define FTN_DISPLAY_ENV omp_display_env
 #define FTN_FULFILL_EVENT omp_fulfill_event
 
 #endif /* KMP_FTN_PLAIN */
 #define FTN_PAUSE_RESOURCE omp_pause_resource_
 #define FTN_PAUSE_RESOURCE_ALL omp_pause_resource_all_
 #define FTN_GET_SUPPORTED_ACTIVE_LEVELS omp_get_supported_active_levels_
+#define FTN_DISPLAY_ENV omp_display_env_
 #define FTN_FULFILL_EVENT omp_fulfill_event_
 
 #endif /* KMP_FTN_APPEND */
 #define FTN_PAUSE_RESOURCE OMP_PAUSE_RESOURCE
 #define FTN_PAUSE_RESOURCE_ALL OMP_PAUSE_RESOURCE_ALL
 #define FTN_GET_SUPPORTED_ACTIVE_LEVELS OMP_GET_SUPPORTED_ACTIVE_LEVELS
+#define FTN_DISPLAY_ENV OMP_DISPLAY_ENV
 #define FTN_FULFILL_EVENT OMP_FULFILL_EVENT
 
 #endif /* KMP_FTN_UPPER */
 #define FTN_PAUSE_RESOURCE OMP_PAUSE_RESOURCE_
 #define FTN_PAUSE_RESOURCE_ALL OMP_PAUSE_RESOURCE_ALL_
 #define FTN_GET_SUPPORTED_ACTIVE_LEVELS OMP_GET_SUPPORTED_ACTIVE_LEVELS_
+#define FTN_DISPLAY_ENV OMP_DISPLAY_ENV_
 #define FTN_FULFILL_EVENT OMP_FULFILL_EVENT_
 
 #endif /* KMP_FTN_UAPPEND */
index acd157d..4df3fef 100644 (file)
@@ -8217,7 +8217,6 @@ __kmp_determine_reduction_method(
 
   return (retval);
 }
-
 // this function is for testing set/get/determine reduce method
 kmp_int32 __kmp_get_reduce_method(void) {
   return ((__kmp_entry_thread()->th.th_local.packed_reduction_method) >> 8);
@@ -8297,3 +8296,12 @@ int __kmp_pause_resource(kmp_pause_status_t level) {
     return 1;
   }
 }
+
+
+void __kmp_omp_display_env(int verbose) {
+  __kmp_acquire_bootstrap_lock(&__kmp_initz_lock);
+  if (__kmp_init_serial == 0)
+    __kmp_do_serial_initialize();
+  __kmp_display_env_impl(!verbose, verbose);
+  __kmp_release_bootstrap_lock(&__kmp_initz_lock);
+}
index c7dec4d..f76e310 100644 (file)
@@ -5720,7 +5720,11 @@ void __kmp_env_print() {
 } // __kmp_env_print
 
 void __kmp_env_print_2() {
+  __kmp_display_env_impl(__kmp_display_env, __kmp_display_env_verbose);
+} // __kmp_env_print_2
+
 
+void __kmp_display_env_impl(int display_env, int display_env_verbose) {
   kmp_env_blk_t block;
   kmp_str_buf_t buffer;
 
@@ -5737,9 +5741,9 @@ void __kmp_env_print_2() {
 
   for (int i = 0; i < __kmp_stg_count; ++i) {
     if (__kmp_stg_table[i].print != NULL &&
-        ((__kmp_display_env &&
+        ((display_env &&
           strncmp(__kmp_stg_table[i].name, "OMP_", 4) == 0) ||
-         __kmp_display_env_verbose)) {
+         display_env_verbose)) {
       __kmp_stg_table[i].print(&buffer, __kmp_stg_table[i].name,
                                __kmp_stg_table[i].data);
     }
@@ -5754,7 +5758,6 @@ void __kmp_env_print_2() {
   __kmp_str_buf_free(&buffer);
 
   __kmp_printf("\n");
-
-} // __kmp_env_print_2
+}
 
 // end of file
index 3247ffc..d61c406 100644 (file)
@@ -17,6 +17,7 @@ void __kmp_reset_global_vars(void);
 void __kmp_env_initialize(char const *);
 void __kmp_env_print();
 void __kmp_env_print_2();
+void __kmp_display_env_impl(int display_env, int display_env_verbose);
 
 int __kmp_initial_threads_capacity(int req_nproc);
 void __kmp_init_dflt_team_nth();
diff --git a/openmp/runtime/test/api/omp_display_env0.c b/openmp/runtime/test/api/omp_display_env0.c
new file mode 100644 (file)
index 0000000..afea3b9
--- /dev/null
@@ -0,0 +1,14 @@
+// RUN: %libomp-compile-and-run 2>&1 | FileCheck %s
+// RUN: %libomp-cxx-compile-and-run 2>&1 | FileCheck %s
+#include <stdio.h>
+#include <omp.h>
+int main()
+{
+  omp_display_env(0);
+  printf("passed\n");
+  return 0;
+}
+
+// CHECK: OPENMP DISPLAY ENVIRONMENT BEGIN
+// CHECK: _OPENMP
+// CHECK: OPENMP DISPLAY ENVIRONMENT END