aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2025-04-14 16:38:55 +0000
committerSandra Loosemore <sloosemore@baylibre.com>2025-05-15 20:25:45 +0000
commite25ce4d65f69cefd36f625ebabf13c0b41638954 (patch)
tree8574f5fbbc7ceb85199dade3ce544179406be023 /gcc
parent9f379125df4a72ba99fa8e5804146a056069fd24 (diff)
downloadgcc-e25ce4d65f69cefd36f625ebabf13c0b41638954.zip
gcc-e25ce4d65f69cefd36f625ebabf13c0b41638954.tar.gz
gcc-e25ce4d65f69cefd36f625ebabf13c0b41638954.tar.bz2
Default compute dimensions (compile time)
This patch was previously combined with an unrelated change and testcases that was upstreamed separately ("Add '-Wopenacc-parallelism'", 22cff118f7526bec195ed6e41452980820fdf3a8). gcc/ChangeLog * doc/invoke.texi (fopenacc-dim): Document syntax for using runtime value from environment variable. * omp-offload.cc (oacc_parse_default_dims): Implement it. libgomp/ChangeLog * testsuite/libgomp.oacc-c-c++-common/loop-default-compile.c: New. Co-Authored-By: Tom de Vries <tdevries@suse.de> Co-Authored-By: Thomas Schwinge <thomas@codesourcery.com> Co-Authored-By: Julian Brown <julian@codesourcery.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/doc/invoke.texi6
-rw-r--r--gcc/omp-offload.cc25
2 files changed, 21 insertions, 10 deletions
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 617a3d8..f55f789 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -5249,7 +5249,11 @@ have support for @option{-pthread}.
Specify default compute dimensions for parallel offload regions that do
not explicitly specify them. The @var{geom} value is a triple of
@samp{:}-separated sizes, in order @var{gang}, @var{worker}, and @var{vector}.
-A size can be omitted, to use a target-specific default value.
+If a size is to be deferred until execution @samp{-} can be used;
+alternatively a size can be omitted to use a target-specific default value.
+When deferring to runtime, the environment variable @env{GOMP_OPENACC_DIM}
+can be set. It has the same format as the option value, except that
+@samp{-} is not permitted.
@opindex fopenmp
@cindex OpenMP parallel
diff --git a/gcc/omp-offload.cc b/gcc/omp-offload.cc
index de9b063..536bfb7 100644
--- a/gcc/omp-offload.cc
+++ b/gcc/omp-offload.cc
@@ -875,8 +875,9 @@ oacc_get_min_dim (int dim)
}
/* Parse the default dimension parameter. This is a set of
- :-separated optional compute dimensions. Each specified dimension
- is a positive integer. When device type support is added, it is
+ :-separated optional compute dimensions. Each dimension is either
+ a positive integer, or '-' for a dynamic value computed at
+ runtime. When device type support is added, it is
planned to be a comma separated list of such compute dimensions,
with all but the first prefixed by the colon-terminated device
type. */
@@ -911,14 +912,20 @@ oacc_parse_default_dims (const char *dims)
if (*pos != ':')
{
- long val;
- const char *eptr;
+ long val = 0;
- errno = 0;
- val = strtol (pos, CONST_CAST (char **, &eptr), 10);
- if (errno || val <= 0 || (int) val != val)
- goto malformed;
- pos = eptr;
+ if (*pos == '-')
+ pos++;
+ else
+ {
+ const char *eptr;
+
+ errno = 0;
+ val = strtol (pos, CONST_CAST (char **, &eptr), 10);
+ if (errno || val <= 0 || (int) val != val)
+ goto malformed;
+ pos = eptr;
+ }
oacc_default_dims[ix] = (int) val;
}
}