[Openmp-commits] [openmp] 95df674 - [openmp] OpenMP 5.1 omp_display_env function implementation.
via Openmp-commits
openmp-commits at lists.llvm.org
Wed Mar 4 07:16:30 PST 2020
Author: AndreyChurbanov
Date: 2020-03-04T18:15:05+03:00
New Revision: 95df6747cf1978aa1732d8b93af585e34cec4987
URL: https://github.com/llvm/llvm-project/commit/95df6747cf1978aa1732d8b93af585e34cec4987
DIFF: https://github.com/llvm/llvm-project/commit/95df6747cf1978aa1732d8b93af585e34cec4987.diff
LOG: [openmp] OpenMP 5.1 omp_display_env function implementation.
Patch by Michael Klemm.
Differential Revision: https://reviews.llvm.org/D74956
Added:
openmp/runtime/test/api/omp_display_env0.c
Modified:
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
Removed:
################################################################################
diff --git a/openmp/runtime/src/dllexports b/openmp/runtime/src/dllexports
index f76619ec0e3c..45a294b666fa 100644
--- a/openmp/runtime/src/dllexports
+++ b/openmp/runtime/src/dllexports
@@ -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
diff --git a/openmp/runtime/src/include/omp.h.var b/openmp/runtime/src/include/omp.h.var
index dd5b8cec7e6b..f62afc2b693d 100644
--- a/openmp/runtime/src/include/omp.h.var
+++ b/openmp/runtime/src/include/omp.h.var
@@ -355,6 +355,9 @@
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
diff --git a/openmp/runtime/src/include/omp_lib.f.var b/openmp/runtime/src/include/omp_lib.f.var
index d631438f55ad..bf40c78707a8 100644
--- a/openmp/runtime/src/include/omp_lib.f.var
+++ b/openmp/runtime/src/include/omp_lib.f.var
@@ -488,6 +488,11 @@
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
! ***
diff --git a/openmp/runtime/src/include/omp_lib.f90.var b/openmp/runtime/src/include/omp_lib.f90.var
index ac568486d204..fbbb7b9df94d 100644
--- a/openmp/runtime/src/include/omp_lib.f90.var
+++ b/openmp/runtime/src/include/omp_lib.f90.var
@@ -503,6 +503,12 @@
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
! ***
diff --git a/openmp/runtime/src/include/omp_lib.h.var b/openmp/runtime/src/include/omp_lib.h.var
index 8775128157bd..f1b6b03f7725 100644
--- a/openmp/runtime/src/include/omp_lib.h.var
+++ b/openmp/runtime/src/include/omp_lib.h.var
@@ -580,6 +580,11 @@
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
! ***
diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h
index bb1f3edd0331..c9121575ffcf 100644
--- a/openmp/runtime/src/kmp.h
+++ b/openmp/runtime/src/kmp.h
@@ -3908,6 +3908,8 @@ static inline void __kmp_resume_if_hard_paused() {
}
}
+extern void __kmp_omp_display_env(int verbose);
+
#ifdef __cplusplus
}
#endif
diff --git a/openmp/runtime/src/kmp_ftn_entry.h b/openmp/runtime/src/kmp_ftn_entry.h
index 89172c0b704c..ab57907e088e 100644
--- a/openmp/runtime/src/kmp_ftn_entry.h
+++ b/openmp/runtime/src/kmp_ftn_entry.h
@@ -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
diff --git a/openmp/runtime/src/kmp_ftn_os.h b/openmp/runtime/src/kmp_ftn_os.h
index 41cafab12537..cd04914ecbf2 100644
--- a/openmp/runtime/src/kmp_ftn_os.h
+++ b/openmp/runtime/src/kmp_ftn_os.h
@@ -133,6 +133,7 @@
#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 */
@@ -256,6 +257,7 @@
#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 */
@@ -377,6 +379,7 @@
#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 */
@@ -500,6 +503,7 @@
#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 */
diff --git a/openmp/runtime/src/kmp_runtime.cpp b/openmp/runtime/src/kmp_runtime.cpp
index acd157db8e52..4df3fef9ef57 100644
--- a/openmp/runtime/src/kmp_runtime.cpp
+++ b/openmp/runtime/src/kmp_runtime.cpp
@@ -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);
+}
diff --git a/openmp/runtime/src/kmp_settings.cpp b/openmp/runtime/src/kmp_settings.cpp
index c7dec4d218c6..f76e31010ce1 100644
--- a/openmp/runtime/src/kmp_settings.cpp
+++ b/openmp/runtime/src/kmp_settings.cpp
@@ -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
diff --git a/openmp/runtime/src/kmp_settings.h b/openmp/runtime/src/kmp_settings.h
index 3247ffc6af74..d61c40694cf6 100644
--- a/openmp/runtime/src/kmp_settings.h
+++ b/openmp/runtime/src/kmp_settings.h
@@ -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
index 000000000000..afea3b9e3649
--- /dev/null
+++ b/openmp/runtime/test/api/omp_display_env0.c
@@ -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
More information about the Openmp-commits
mailing list