public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-11] Implement OpenMP 5.1 section 3.15: omp_display_env
@ 2021-07-30 12:07 Tobias Burnus
  0 siblings, 0 replies; only message in thread
From: Tobias Burnus @ 2021-07-30 12:07 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:a62988913bb85a0ce71436f27ffac60eaa562a3c

commit a62988913bb85a0ce71436f27ffac60eaa562a3c
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Fri Jul 30 13:57:50 2021 +0200

    Implement OpenMP 5.1 section 3.15: omp_display_env
    
    This is a new interface which is easily implemented using the
    already existing code for the handling of the OMP_DISPLAY_ENV
    environment variable.
    
    libgomp/
            * env.c (wait_policy, stacksize): New static variables,
            move out of handle_omp_display_env.
            (omp_display_env): New function.  The meat of the old
            handle_omp_display_env function.
            (handle_omp_display_env): Change to not take parameters
            and instead use the global variables.  Only perform
            parsing, defer to omp_display_env for the implementation.
            (initialize_env): Remove local variables wait_policy and
            stacksize.  Don't pass parameters to handle_omp_display_env.
            * fortran.c: Add ialias_redirect for omp_display_env.
            (omp_display_env_, omp_display_env_8_): New functions.
            * libgomp.map (OMP_5.1): New version.  Add omp_display_env,
            omp_display_env_, and omp_display_env_8_.
            * omp.h.in: Declare omp_display_env.
            * omp_lib.f90.in: Likewise.
            * omp_lib.h.in: Likewise.
    
    (cherry picked from commit 7123ae2455b5a1a2f19f13fa82c377cfda157f23)

Diff:
---
 libgomp/ChangeLog.omp  | 22 +++++++++++++
 libgomp/env.c          | 88 +++++++++++++++++++++++++++-----------------------
 libgomp/fortran.c      | 13 ++++++++
 libgomp/libgomp.map    |  7 ++++
 libgomp/omp.h.in       |  2 ++
 libgomp/omp_lib.f90.in |  9 ++++++
 libgomp/omp_lib.h.in   |  2 ++
 7 files changed, 103 insertions(+), 40 deletions(-)

diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 8fbf1bf1664..d0fa553c79a 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,3 +1,25 @@
+2021-06-30  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backported from master:
+	2021-06-29  Ulrich Drepper  <drepper@gmail.com>
+
+	* env.c (wait_policy, stacksize): New static variables,
+	move out of handle_omp_display_env.
+	(omp_display_env): New function.  The meat of the old
+	handle_omp_display_env function.
+	(handle_omp_display_env): Change to not take parameters
+	and instead use the global variables.  Only perform
+	parsing, defer to omp_display_env for the implementation.
+	(initialize_env): Remove local variables wait_policy and
+	stacksize.  Don't pass parameters to handle_omp_display_env.
+	* fortran.c: Add ialias_redirect for omp_display_env.
+	(omp_display_env_, omp_display_env_8_): New functions.
+	* libgomp.map (OMP_5.1): New version.  Add omp_display_env,
+	omp_display_env_, and omp_display_env_8_.
+	* omp.h.in: Declare omp_display_env.
+	* omp_lib.f90.in: Likewise.
+	* omp_lib.h.in: Likewise.
+
 2021-06-29  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backported from master:
diff --git a/libgomp/env.c b/libgomp/env.c
index a24deabcd58..5220877d533 100644
--- a/libgomp/env.c
+++ b/libgomp/env.c
@@ -99,6 +99,9 @@ int goacc_default_dims[GOMP_DIM_MAX];
 
 #ifndef LIBGOMP_OFFLOADED_ONLY
 
+static int wait_policy;
+static unsigned long stacksize = GOMP_DEFAULT_STACKSIZE;
+
 /* Parse the OMP_SCHEDULE environment variable.  */
 
 static void
@@ -1210,46 +1213,11 @@ parse_gomp_openacc_dim (void)
     }
 }
 
-static void
-handle_omp_display_env (unsigned long stacksize, int wait_policy)
+void
+omp_display_env (int verbose)
 {
-  const char *env;
-  bool display = false;
-  bool verbose = false;
   int i;
 
-  env = getenv ("OMP_DISPLAY_ENV");
-  if (env == NULL)
-    return;
-
-  while (isspace ((unsigned char) *env))
-    ++env;
-  if (strncasecmp (env, "true", 4) == 0)
-    {
-      display = true;
-      env += 4;
-    }
-  else if (strncasecmp (env, "false", 5) == 0)
-    {
-      display = false;
-      env += 5;
-    }
-  else if (strncasecmp (env, "verbose", 7) == 0)
-    {
-      display = true;
-      verbose = true;
-      env += 7;
-    }
-  else
-    env = "X";
-  while (isspace ((unsigned char) *env))
-    ++env;
-  if (*env != '\0')
-    gomp_error ("Invalid value for environment variable OMP_DISPLAY_ENV");
-
-  if (!display)
-    return;
-
   fputs ("\nOPENMP DISPLAY ENVIRONMENT BEGIN\n", stderr);
 
   fputs ("  _OPENMP = '201511'\n", stderr);
@@ -1408,14 +1376,54 @@ handle_omp_display_env (unsigned long stacksize, int wait_policy)
 
   fputs ("OPENMP DISPLAY ENVIRONMENT END\n", stderr);
 }
+ialias (omp_display_env)
+
+static void
+handle_omp_display_env (void)
+{
+  const char *env;
+  bool display = false;
+  bool verbose = false;
+
+  env = getenv ("OMP_DISPLAY_ENV");
+  if (env == NULL)
+    return;
+
+  while (isspace ((unsigned char) *env))
+    ++env;
+  if (strncasecmp (env, "true", 4) == 0)
+    {
+      display = true;
+      env += 4;
+    }
+  else if (strncasecmp (env, "false", 5) == 0)
+    {
+      display = false;
+      env += 5;
+    }
+  else if (strncasecmp (env, "verbose", 7) == 0)
+    {
+      display = true;
+      verbose = true;
+      env += 7;
+    }
+  else
+    env = "X";
+  while (isspace ((unsigned char) *env))
+    ++env;
+  if (*env != '\0')
+    gomp_error ("Invalid value for environment variable OMP_DISPLAY_ENV");
+
+  if (display)
+    omp_display_env (verbose);
+}
 
 
 static void __attribute__((constructor))
 initialize_env (void)
 {
-  unsigned long thread_limit_var, stacksize = GOMP_DEFAULT_STACKSIZE;
+  unsigned long thread_limit_var;
   unsigned long max_active_levels_var;
-  int wait_policy;
 
   /* Do a compile time check that mkomp_h.pl did good job.  */
   omp_check_defines ();
@@ -1546,7 +1554,7 @@ initialize_env (void)
 	gomp_error ("Stack size change failed: %s", strerror (err));
     }
 
-  handle_omp_display_env (stacksize, wait_policy);
+  handle_omp_display_env ();
 
   /* OpenACC.  */
 
diff --git a/libgomp/fortran.c b/libgomp/fortran.c
index 4ec39c4e61b..76285d4376b 100644
--- a/libgomp/fortran.c
+++ b/libgomp/fortran.c
@@ -94,6 +94,7 @@ ialias_redirect (omp_init_allocator)
 ialias_redirect (omp_destroy_allocator)
 ialias_redirect (omp_set_default_allocator)
 ialias_redirect (omp_get_default_allocator)
+ialias_redirect (omp_display_env)
 #endif
 
 #ifndef LIBGOMP_GNU_SYMBOL_VERSIONING
@@ -736,3 +737,15 @@ omp_get_default_allocator_ ()
 {
   return (intptr_t) omp_get_default_allocator ();
 }
+
+void
+omp_display_env_ (const int32_t *verbose)
+{
+  omp_display_env (*verbose);
+}
+
+void
+omp_display_env_8_ (const int64_t *verbose)
+{
+  omp_display_env (!!*verbose);
+}
diff --git a/libgomp/libgomp.map b/libgomp/libgomp.map
index 4ad190a52af..8cbeb13f3ea 100644
--- a/libgomp/libgomp.map
+++ b/libgomp/libgomp.map
@@ -199,6 +199,13 @@ OMP_5.0.1 {
 	omp_fulfill_event_;
 } OMP_5.0;
 
+OMP_5.1 {
+  global:
+	omp_display_env;
+	omp_display_env_;
+	omp_display_env_8_;
+} OMP_5.0.1;
+
 GOMP_1.0 {
   global:
 	GOMP_atomic_end;
diff --git a/libgomp/omp.h.in b/libgomp/omp.h.in
index 69f96f09124..c93db968d2e 100644
--- a/libgomp/omp.h.in
+++ b/libgomp/omp.h.in
@@ -293,6 +293,8 @@ extern void omp_free (void *,
 		      omp_allocator_handle_t __GOMP_DEFAULT_NULL_ALLOCATOR)
   __GOMP_NOTHROW;
 
+extern void omp_display_env (int) __GOMP_NOTHROW;
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/libgomp/omp_lib.f90.in b/libgomp/omp_lib.f90.in
index 851f85f5316..5fc6587e49e 100644
--- a/libgomp/omp_lib.f90.in
+++ b/libgomp/omp_lib.f90.in
@@ -653,6 +653,15 @@
           end function
         end interface
 
+        interface omp_display_env
+          subroutine omp_display_env (verbose)
+            logical (4),intent (in) :: verbose
+          end subroutine omp_display_env
+          subroutine omp_display_env_8 (verbose)
+            logical (8),intent (in) :: verbose
+          end subroutine omp_display_env_8
+        end interface
+
 #if _OPENMP >= 201811
 !GCC$ ATTRIBUTES DEPRECATED :: omp_get_nested, omp_set_nested
 #endif
diff --git a/libgomp/omp_lib.h.in b/libgomp/omp_lib.h.in
index 06d17b5fcdc..9873cea9ac1 100644
--- a/libgomp/omp_lib.h.in
+++ b/libgomp/omp_lib.h.in
@@ -264,3 +264,5 @@
       external omp_set_default_allocator
       external omp_get_default_allocator
       integer (omp_allocator_handle_kind) omp_get_default_allocator
+
+      external omp_display_env


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-30 12:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-30 12:07 [gcc/devel/omp/gcc-11] Implement OpenMP 5.1 section 3.15: omp_display_env Tobias Burnus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).