]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Default compute dimensions (compile time)
authorJulian Brown <julian@codesourcery.com>
Tue, 26 Feb 2019 22:12:06 +0000 (14:12 -0800)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Tue, 21 Jun 2022 13:11:10 +0000 (14:11 +0100)
Typo fix relative to last posted version.

2018-10-05  Nathan Sidwell  <nathan@acm.org>
    Tom de Vries  <tdevries@suse.de>
    Thomas Schwinge  <thomas@codesourcery.com>
    Julian Brown  <julian@codesourcery.com>

gcc/
* doc/invoke.texi (fopenacc-dim): Update.
* omp-offload.cc (oacc_parse_default_dims): Update.

gcc/testsuite/
* c-c++-common/goacc/acc-icf.c: Update.
* c-c++-common/goacc/parallel-dims-1.c: Likewise.
* gfortran.dg/goacc/routine-4.f90: Likewise.
* gfortran.dg/goacc/routine-multiple-directives-1.f90: Likewise.

libgomp/
* testsuite/libgomp.oacc-c-c++-common/loop-default-compile.c: New.
* testsuite/libgomp.oacc-c-c++-common/loop-warn-1.c: New.
* testsuite/libgomp.oacc-c-c++-common/parallel-dims.c: Update.

gcc/ChangeLog.omp
gcc/doc/invoke.texi
gcc/omp-offload.cc
gcc/testsuite/ChangeLog.omp
gcc/testsuite/c-c++-common/goacc/acc-icf.c
gcc/testsuite/c-c++-common/goacc/parallel-dims-1.c
gcc/testsuite/gfortran.dg/goacc/routine-4.f90
gcc/testsuite/gfortran.dg/goacc/routine-multiple-directives-1.f90
libgomp/ChangeLog.omp
libgomp/testsuite/libgomp.oacc-c-c++-common/loop-default-compile.c [new file with mode: 0644]
libgomp/testsuite/libgomp.oacc-c-c++-common/loop-warn-1.c [new file with mode: 0644]

index ec14b9c60a00194395bcb4ec430458051985e6a0..ea0d696347fffbd6178f57973466dd240a80f8e4 100644 (file)
@@ -1,3 +1,11 @@
+2018-10-05  Nathan Sidwell  <nathan@acm.org>
+           Tom de Vries  <tdevries@suse.de>
+           Thomas Schwinge  <thomas@codesourcery.com>
+           Julian Brown  <julian@codesourcery.com>
+
+       * doc/invoke.texi (fopenacc-dim): Update.
+       * omp-offload.cc (oacc_parse_default_dims): Update.
+
 2019-09-20  Chung-Lin Tang <cltang@codesourcery.com>
            Cesar Philippidis  <cesar@codesourcery.com>
 
index 07b440190c3aabc6b1caee675c0f35c5628f2184..3b19eb80212d70b73a5ef3730c377ac0006a7ad8 100644 (file)
@@ -2720,8 +2720,12 @@ have support for @option{-pthread}.
 @cindex OpenACC accelerator programming
 Specify default compute dimensions for parallel offload regions that do
 not explicitly specify.  The @var{geom} value is a triple of
-':'-separated sizes, in order 'gang', 'worker' and, 'vector'.  A size
-can be omitted, to use a target-specific default value.
+':'-separated sizes, in order 'gang', 'worker' and, 'vector'.  If a size
+is to be deferred until execution '-' can be used, alternatively a size
+can be omitted to use a target-specific default value.  When deferring
+to runtime, the environment variable @var{GOMP_OPENACC_DIM} can be set.
+It has the same format as the option value, except that '-' is not
+permitted.
 
 @item -fopenmp
 @opindex fopenmp
index 78c2982da5e2f7d3fac857298eeee17676f76a72..6131479b16f0715b6bdea44e2b35bfd50acabe14 100644 (file)
@@ -845,8 +845,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.  */
@@ -881,14 +882,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;
            }
        }
index 52910f0e42252653f1fd62ff702699382700edea..4108c8dedc6239ee1020e05b4171dd2694c043dd 100644 (file)
@@ -1,3 +1,13 @@
+2018-10-05  Nathan Sidwell  <nathan@acm.org>
+           Tom de Vries  <tdevries@suse.de>
+           Thomas Schwinge  <thomas@codesourcery.com>
+           Julian Brown  <julian@codesourcery.com>
+
+       * c-c++-common/goacc/acc-icf.c: Update.
+       * c-c++-common/goacc/parallel-dims-1.c: Likewise.
+       * gfortran.dg/goacc/routine-4.f90: Likewise.
+       * gfortran.dg/goacc/routine-multiple-directives-1.f90: Likewise.
+
 2019-09-20  Chung-Lin Tang <cltang@codesourcery.com>
            Cesar Philippidis  <cesar@codesourcery.com>
 
index 9cf119bf89c7c4404a4bc5cfa71309411671ce27..bc2e0fd19b9220b9ac2069396fb7a3f5b08be178 100644 (file)
@@ -9,7 +9,7 @@
 /* { dg-bogus "warning: region is worker partitioned but does not contain worker partitioned code" "TODO default 'gang' 'vector'" { xfail *-*-* } .+3 }
    TODO It's the compiler's own decision to not use 'worker' parallelism here, so it doesn't make sense to bother the user about it.  */
 int
-routine1 (int n)
+routine1 (int n) /* { dg-bogus "region is worker partitioned but does not contain worker partitioned code" "" { xfail *-*-* } } */
 {
   int i;
 
@@ -24,7 +24,7 @@ routine1 (int n)
 /* { dg-bogus "warning: region is worker partitioned but does not contain worker partitioned code" "TODO default 'gang' 'vector'" { xfail *-*-* } .+3 }
    TODO It's the compiler's own decision to not use 'worker' parallelism here, so it doesn't make sense to bother the user about it.  */
 int
-routine2 (int n)
+routine2 (int n) /* { dg-bogus "region is worker partitioned but does not contain worker partitioned code" "" { xfail *-*-* } } */
 {
   int i;
 
index 2a8d35d493de324c770e2ce775b27c50d3b5e4f6..6b1e7b22451016032f61dd10143f0c33b090ae8d 100644 (file)
@@ -6,7 +6,8 @@
 
 void f(int i)
 {
-#pragma acc kernels num_gangs(i) num_workers(i) vector_length(i)
+#pragma acc kernels \
+  num_gangs(i) num_workers(i) vector_length(i)
   ;
 
 #pragma acc parallel num_gangs(i) num_workers(i) vector_length(i)
index 53b1fbe5039fa882b17eac4d78bda3d99674a7d7..85fd50fb334489fcefe824dad113ce61bf5bcfdc 100644 (file)
@@ -129,6 +129,7 @@ contains
     integer, intent (inout) :: a(N)
     integer :: i
 
+    !$acc loop gang worker vector
     do i = 1, N
        a(i) = a(i) - a(i)
     end do
@@ -141,6 +142,7 @@ contains
     integer, intent (inout) :: a(N)
     integer :: i
 
+    !$acc loop worker vector
     do i = 1, N
        a(i) = a(i) - a(i)
     end do
@@ -152,6 +154,7 @@ contains
     integer, intent (inout) :: a(N)
     integer :: i
 
+    !$acc loop vector
     do i = 1, N
        a(i) = a(i) - a(i)
     end do
@@ -162,6 +165,7 @@ contains
     integer, intent (inout) :: a(N)
     integer :: i
 
+    !$acc loop seq
     do i = 1, N
        a(i) = a(i) - a(i)
     end do
index 42bcb0e8d63b553225d38a7b16aeb939bfea98ff..4249b404962cb644405f5b0b9c178f703d8398bd 100644 (file)
@@ -38,7 +38,7 @@
       ! { dg-final { scan-tree-dump-times "(?n)OpenACC routine 's_2_nh' has 'nohost' clause" 1 "oaccloops" { target { ! offloading_enabled } } } }
       ! { dg-final { scan-tree-dump-times "(?n)OpenACC routine 's_2_nh_' has 'nohost' clause" 1 "oaccloops" { target offloading_enabled } } }
 
-      SUBROUTINE v_1
+      SUBROUTINE v_1 ! { dg-warning "region is vector partitioned but does not contain vector partitioned code" }
 !$ACC ROUTINE VECTOR
 !$ACC ROUTINE VECTOR
 !$ACC ROUTINE(v_1) VECTOR
@@ -58,7 +58,7 @@
       ! { dg-final { scan-tree-dump-times "(?n)OpenACC routine 'v_1_nh' has 'nohost' clause" 1 "oaccloops" { target { ! offloading_enabled } } } }
       ! { dg-final { scan-tree-dump-times "(?n)OpenACC routine 'v_1_nh_' has 'nohost' clause" 1 "oaccloops" { target offloading_enabled } } }
 
-      SUBROUTINE v_2
+      SUBROUTINE v_2 ! { dg-warning "region is vector partitioned but does not contain vector partitioned code" }
 !$ACC ROUTINE(v_2) VECTOR
 !$ACC ROUTINE VECTOR
 !$ACC ROUTINE(v_2) VECTOR
index 7534515873622d2fe7536f2253de71f58491bc3b..3179b778c690da823495fb8a8d531217946155f4 100644 (file)
@@ -1,3 +1,12 @@
+2018-10-05  Nathan Sidwell  <nathan@acm.org>
+           Tom de Vries  <tdevries@suse.de>
+           Thomas Schwinge  <thomas@codesourcery.com>
+           Julian Brown  <julian@codesourcery.com>
+
+       * testsuite/libgomp.oacc-c-c++-common/loop-default-compile.c: New.
+       * testsuite/libgomp.oacc-c-c++-common/loop-warn-1.c: New.
+       * testsuite/libgomp.oacc-c-c++-common/parallel-dims.c: Likewise.
+
 2018-10-22  James Norris  <jnorris@codesourcery.com>
            Cesar Philippidis  <cesar@codesourcery.com>
            Tom de Vries  <tom@codesourcery.com>
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-default-compile.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-default-compile.c
new file mode 100644 (file)
index 0000000..6c479e4
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-additional-options "-fopenacc-dim=16:16" } */
+/* This code uses nvptx inline assembly guarded with acc_on_device, which is
+   not optimized away at -O0, and then confuses the target assembler.
+   { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
+/* { dg-set-target-env-var "GOMP_OPENACC_DIM" "8:8" } */
+
+#include "loop-default.h"
+
+int main ()
+{
+  /* Environment should be ignored.  */
+  return test_1 (16, 16, 32);
+}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-warn-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-warn-1.c
new file mode 100644 (file)
index 0000000..20a022f
--- /dev/null
@@ -0,0 +1,37 @@
+
+/* Check warnings about suboptimal partitioning choices.  */
+
+int main ()
+{
+  int ary[10];
+
+#pragma acc parallel copy(ary) num_gangs (1) /* { dg-warning "is not gang partitioned" } */
+  {
+    #pragma acc loop gang
+    for (int  i = 0; i < 10; i++)
+      ary[i] = i;
+  }
+
+#pragma acc parallel copy(ary) num_workers (1) /* { dg-warning "is not worker partitioned" } */
+  {
+    #pragma acc loop worker
+    for (int  i = 0; i < 10; i++)
+      ary[i] = i;
+  }
+
+#pragma acc parallel copy(ary) num_gangs (8) /* { dg-warning "is gang partitioned" } */
+  {
+    #pragma acc loop worker
+    for (int  i = 0; i < 10; i++)
+      ary[i] = i;
+  }
+
+#pragma acc parallel copy(ary) num_workers (8) /* { dg-warning "is worker partitioned" } */
+  {
+    #pragma acc loop gang
+    for (int  i = 0; i < 10; i++)
+      ary[i] = i;
+  }
+
+  return 0;
+}