From ec00d3faf4e3d20906e8e6038299343f960dc49e Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Wed, 2 May 2018 17:53:56 +0000 Subject: [openacc] Move GOMP_OPENACC_DIM parsing out of nvptx plugin 2018-05-02 Tom de Vries 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 --- libgomp/env.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'libgomp/env.c') 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 (); } -- cgit v1.1