aboutsummaryrefslogtreecommitdiff
path: root/libgomp/env.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2021-07-27 21:08:41 +0200
committerUlrich Drepper <drepper@gmail.com>2021-07-27 21:08:41 +0200
commit7123ae2455b5a1a2f19f13fa82c377cfda157f23 (patch)
tree34c38adcc3e4f5af739a6d72b34186c3b9c78991 /libgomp/env.c
parent0853f392a213ef2cecc71ef5349aab079e30f5a0 (diff)
downloadgcc-7123ae2455b5a1a2f19f13fa82c377cfda157f23.zip
gcc-7123ae2455b5a1a2f19f13fa82c377cfda157f23.tar.gz
gcc-7123ae2455b5a1a2f19f13fa82c377cfda157f23.tar.bz2
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.
Diffstat (limited to 'libgomp/env.c')
-rw-r--r--libgomp/env.c88
1 files changed, 48 insertions, 40 deletions
diff --git a/libgomp/env.c b/libgomp/env.c
index a24deab..5220877 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. */