diff options
author | Tom de Vries <tom@codesourcery.com> | 2018-05-02 17:53:56 +0000 |
---|---|---|
committer | Tom de Vries <vries@gcc.gnu.org> | 2018-05-02 17:53:56 +0000 |
commit | ec00d3faf4e3d20906e8e6038299343f960dc49e (patch) | |
tree | f1fb8130e22dfe8536682621accc8592a7e27936 /libgomp/env.c | |
parent | 92243e7ceab627026b4c63604acb5b2e6486f8a3 (diff) | |
download | gcc-ec00d3faf4e3d20906e8e6038299343f960dc49e.zip gcc-ec00d3faf4e3d20906e8e6038299343f960dc49e.tar.gz gcc-ec00d3faf4e3d20906e8e6038299343f960dc49e.tar.bz2 |
[openacc] Move GOMP_OPENACC_DIM parsing out of nvptx plugin
2018-05-02 Tom de Vries <tom@codesourcery.com>
PR libgomp/85411
* plugin/plugin-nvptx.c (nvptx_exec): Move parsing of
GOMP_OPENACC_DIM ...
* env.c (parse_gomp_openacc_dim): ... here. New function.
(initialize_env): Call parse_gomp_openacc_dim.
(goacc_default_dims): Define.
* libgomp.h (goacc_default_dims): Declare.
* oacc-plugin.c (GOMP_PLUGIN_acc_default_dim): New function.
* oacc-plugin.h (GOMP_PLUGIN_acc_default_dim): Declare.
* libgomp.map: New version "GOMP_PLUGIN_1.2". Add
GOMP_PLUGIN_acc_default_dim.
* testsuite/libgomp.oacc-c-c++-common/loop-default-runtime.c: New test.
* testsuite/libgomp.oacc-c-c++-common/loop-default.h: New test.
From-SVN: r259852
Diffstat (limited to 'libgomp/env.c')
-rw-r--r-- | libgomp/env.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/libgomp/env.c b/libgomp/env.c index 871a3e4..18c90bb 100644 --- a/libgomp/env.c +++ b/libgomp/env.c @@ -90,6 +90,7 @@ int gomp_debug_var; unsigned int gomp_num_teams_var; char *goacc_device_type; int goacc_device_num; +int goacc_default_dims[GOMP_DIM_MAX]; #ifndef LIBGOMP_OFFLOADED_ONLY @@ -1066,6 +1067,36 @@ parse_acc_device_type (void) } static void +parse_gomp_openacc_dim (void) +{ + /* The syntax is the same as for the -fopenacc-dim compilation option. */ + const char *var_name = "GOMP_OPENACC_DIM"; + const char *env_var = getenv (var_name); + if (!env_var) + return; + + const char *pos = env_var; + int i; + for (i = 0; *pos && i != GOMP_DIM_MAX; i++) + { + if (i && *pos++ != ':') + break; + + if (*pos == ':') + continue; + + const char *eptr; + errno = 0; + long val = strtol (pos, (char **)&eptr, 10); + if (errno || val < 0 || (unsigned)val != val) + break; + + goacc_default_dims[i] = (int)val; + pos = eptr; + } +} + +static void handle_omp_display_env (unsigned long stacksize, int wait_policy) { const char *env; @@ -1336,6 +1367,7 @@ initialize_env (void) goacc_device_num = 0; parse_acc_device_type (); + parse_gomp_openacc_dim (); goacc_runtime_initialize (); } |