summaryrefslogtreecommitdiff
path: root/libgomp
diff options
context:
space:
mode:
authorTom de Vries <tom@codesourcery.com>2018-05-02 17:53:29 +0000
committerTom de Vries <vries@gcc.gnu.org>2018-05-02 17:53:29 +0000
commit1f62d6375bb12008bb152af13eab7eb83b458a1e (patch)
tree9c5ae5ae8708baf16f73a2e5208f1e7daf96482f /libgomp
parentf7584c811623675be258da5195d8e8daeb562975 (diff)
downloadgcc-1f62d6375bb12008bb152af13eab7eb83b458a1e.tar.gz
[openacc] Add __builtin_goacc_parlevel_{id,size}
2018-05-02 Tom de Vries <tom@codesourcery.com> PR libgomp/82428 * builtins.def (DEF_GOACC_BUILTIN_ONLY): Define. * omp-builtins.def (BUILT_IN_GOACC_PARLEVEL_ID) (BUILT_IN_GOACC_PARLEVEL_SIZE): New builtin. * builtins.c (expand_builtin_goacc_parlevel_id_size): New function. (expand_builtin): Call expand_builtin_goacc_parlevel_id_size. * doc/extend.texi (Other Builtins): Add __builtin_goacc_parlevel_id and __builtin_goacc_parlevel_size. * f95-lang.c (DEF_GOACC_BUILTIN_ONLY): Define. * c-c++-common/goacc/builtin-goacc-parlevel-id-size-2.c: New test. * c-c++-common/goacc/builtin-goacc-parlevel-id-size.c: New test. * testsuite/libgomp.oacc-c-c++-common/gang-static-2.c: Use __builtin_goacc_parlevel_{id,size}. * testsuite/libgomp.oacc-c-c++-common/loop-auto-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-g-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-g-2.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-gwv-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-red-g-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-red-gwv-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-red-v-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-red-v-2.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-red-w-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-red-w-2.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-red-wv-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-v-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-w-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/loop-wv-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/parallel-dims.c: Same. * testsuite/libgomp.oacc-c-c++-common/routine-g-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/routine-gwv-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/routine-v-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/routine-w-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/routine-wv-1.c: Same. * testsuite/libgomp.oacc-c-c++-common/routine-wv-2.c: Same. * testsuite/libgomp.oacc-c-c++-common/tile-1.c: Same. From-SVN: r259850
Diffstat (limited to 'libgomp')
-rw-r--r--libgomp/ChangeLog29
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/gang-static-2.c21
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/loop-auto-1.c18
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c14
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/loop-g-1.c17
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/loop-g-2.c16
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/loop-gwv-1.c17
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-g-1.c16
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-gwv-1.c16
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-v-1.c16
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-v-2.c16
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-w-1.c16
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-w-2.c16
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-wv-1.c12
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/loop-v-1.c16
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/loop-w-1.c16
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/loop-wv-1.c16
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/parallel-dims.c19
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/routine-g-1.c18
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/routine-gwv-1.c18
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/routine-v-1.c18
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/routine-w-1.c18
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/routine-wv-1.c18
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/routine-wv-2.c19
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/tile-1.c15
25 files changed, 201 insertions, 230 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 958f92bc4c7..669f9f1e59f 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,5 +1,34 @@
2018-05-02 Tom de Vries <tom@codesourcery.com>
+ PR libgomp/82428
+ * testsuite/libgomp.oacc-c-c++-common/gang-static-2.c: Use
+ __builtin_goacc_parlevel_{id,size}.
+ * testsuite/libgomp.oacc-c-c++-common/loop-auto-1.c: Same.
+ * testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c: Same.
+ * testsuite/libgomp.oacc-c-c++-common/loop-g-1.c: Same.
+ * testsuite/libgomp.oacc-c-c++-common/loop-g-2.c: Same.
+ * testsuite/libgomp.oacc-c-c++-common/loop-gwv-1.c: Same.
+ * testsuite/libgomp.oacc-c-c++-common/loop-red-g-1.c: Same.
+ * testsuite/libgomp.oacc-c-c++-common/loop-red-gwv-1.c: Same.
+ * testsuite/libgomp.oacc-c-c++-common/loop-red-v-1.c: Same.
+ * testsuite/libgomp.oacc-c-c++-common/loop-red-v-2.c: Same.
+ * testsuite/libgomp.oacc-c-c++-common/loop-red-w-1.c: Same.
+ * testsuite/libgomp.oacc-c-c++-common/loop-red-w-2.c: Same.
+ * testsuite/libgomp.oacc-c-c++-common/loop-red-wv-1.c: Same.
+ * testsuite/libgomp.oacc-c-c++-common/loop-v-1.c: Same.
+ * testsuite/libgomp.oacc-c-c++-common/loop-w-1.c: Same.
+ * testsuite/libgomp.oacc-c-c++-common/loop-wv-1.c: Same.
+ * testsuite/libgomp.oacc-c-c++-common/parallel-dims.c: Same.
+ * testsuite/libgomp.oacc-c-c++-common/routine-g-1.c: Same.
+ * testsuite/libgomp.oacc-c-c++-common/routine-gwv-1.c: Same.
+ * testsuite/libgomp.oacc-c-c++-common/routine-v-1.c: Same.
+ * testsuite/libgomp.oacc-c-c++-common/routine-w-1.c: Same.
+ * testsuite/libgomp.oacc-c-c++-common/routine-wv-1.c: Same.
+ * testsuite/libgomp.oacc-c-c++-common/routine-wv-2.c: Same.
+ * testsuite/libgomp.oacc-c-c++-common/tile-1.c: Same.
+
+2018-05-02 Tom de Vries <tom@codesourcery.com>
+
PR testsuite/85106
* testsuite/lib/libgomp.exp: Include scanltranstree.exp.
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/gang-static-2.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/gang-static-2.c
index 6de739ae99f..e273a797b8e 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/gang-static-2.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/gang-static-2.c
@@ -1,25 +1,23 @@
-/* { dg-do run { target openacc_nvidia_accel_selected } } */
-/* 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" } { "" } } */
-
#include <assert.h>
#include <openacc.h>
+#include <gomp-constants.h>
#define N 100
#define GANG_ID(I) \
- (acc_on_device (acc_device_nvidia) \
- ? ({unsigned __r; \
- __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (__r)); \
- __r; }) : (I))
+ (acc_on_device (acc_device_not_host) \
+ ? __builtin_goacc_parlevel_id (GOMP_DIM_GANG) \
+ : (I))
void
test_static(int *a, int num_gangs, int sarg)
{
int i, j;
- if (sarg == 0)
+ if (acc_on_device (acc_device_host))
+ return;
+
+ if (sarg == 0)
sarg = 1;
for (i = 0; i < N / sarg; i++)
@@ -32,6 +30,9 @@ test_nonstatic(int *a, int gangs)
{
int i, j;
+ if (acc_on_device (acc_device_host))
+ return;
+
for (i = 0; i < N; i+=gangs)
for (j = 0; j < gangs; j++)
assert (a[i+j] == i/gangs);
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-auto-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-auto-1.c
index 863b6b38c34..34bc57e51f5 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-auto-1.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-auto-1.c
@@ -1,11 +1,8 @@
-/* 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-additional-options "-fopenacc-dim=32" } */
#include <stdio.h>
#include <openacc.h>
+#include <gomp-constants.h>
int check (const int *ary, int size, int gp, int wp, int vp)
{
@@ -79,15 +76,12 @@ static int __attribute__((noinline)) place ()
{
int r = 0;
- if (acc_on_device (acc_device_nvidia))
- {
- int g = 0, w = 0, v = 0;
+ int g = 0, w = 0, v = 0;
+ g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
+ w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
+ v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
+ r = (g << 16) | (w << 8) | v;
- __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
- __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
- __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
- r = (g << 16) | (w << 8) | v;
- }
return r;
}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c
index e2b08c3e0bc..dd8107c1acc 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c
@@ -1,25 +1,23 @@
-/* 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-additional-options "-fopenacc-dim=16:16" } */
#include <openacc.h>
#include <alloca.h>
#include <string.h>
#include <stdio.h>
+#include <gomp-constants.h>
#pragma acc routine
static int __attribute__ ((noinline)) coord ()
{
int res = 0;
- if (acc_on_device (acc_device_nvidia))
+ if (acc_on_device (acc_device_not_host))
{
- int g = 0, w = 0, v = 0;
+ int g, w, v;
- __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
- __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
- __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
+ g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
+ w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
+ v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
res = (1 << 24) | (g << 16) | (w << 8) | v;
}
return res;
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-g-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-g-1.c
index ae1d588db8f..98f02e9840a 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-g-1.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-g-1.c
@@ -1,8 +1,6 @@
-/* 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" } { "" } } */
-
#include <stdio.h>
+#include <openacc.h>
+#include <gomp-constants.h>
#define N (32*32*32+17)
int main ()
@@ -20,13 +18,12 @@ int main ()
#pragma acc loop gang
for (unsigned ix = 0; ix < N; ix++)
{
- if (__builtin_acc_on_device (5))
+ if (acc_on_device (acc_device_not_host))
{
- int g = 0, w = 0, v = 0;
-
- __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
- __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
- __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
+ int g, w, v;
+ g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
+ w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
+ v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
ary[ix] = (g << 16) | (w << 8) | v;
ondev = 1;
}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-g-2.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-g-2.c
index c06d861b07d..4152a4e6c82 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-g-2.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-g-2.c
@@ -1,8 +1,6 @@
-/* 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" } { "" } } */
-
#include <stdio.h>
+#include <openacc.h>
+#include <gomp-constants.h>
#define N (32*32*32+17)
int main ()
@@ -20,13 +18,13 @@ int main ()
#pragma acc loop gang (static:1)
for (unsigned ix = 0; ix < N; ix++)
{
- if (__builtin_acc_on_device (5))
+ if (acc_on_device (acc_device_not_host))
{
- int g = 0, w = 0, v = 0;
+ int g, w, v;
- __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
- __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
- __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
+ g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
+ w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
+ v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
ary[ix] = (g << 16) | (w << 8) | v;
ondev = 1;
}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-gwv-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-gwv-1.c
index 42b612a29d8..766e5782b46 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-gwv-1.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-gwv-1.c
@@ -1,8 +1,6 @@
-/* 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" } { "" } } */
-
#include <stdio.h>
+#include <openacc.h>
+#include <gomp-constants.h>
#define N (32*32*32+17)
int main ()
@@ -20,13 +18,14 @@ int main ()
#pragma acc loop gang worker vector
for (unsigned ix = 0; ix < N; ix++)
{
- if (__builtin_acc_on_device (5))
+ if (acc_on_device (acc_device_not_host))
{
- int g = 0, w = 0, v = 0;
+ int g, w, v;
+
+ g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
+ w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
+ v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
- __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
- __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
- __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
ary[ix] = (g << 16) | (w << 8) | v;
ondev = 1;
}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-g-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-g-1.c
index 929e01c447a..7107502e070 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-g-1.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-g-1.c
@@ -1,8 +1,6 @@
-/* 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" } { "" } } */
-
#include <stdio.h>
+#include <openacc.h>
+#include <gomp-constants.h>
#define N (32*32*32+17)
int main ()
@@ -18,13 +16,13 @@ int main ()
{
int val = ix;
- if (__builtin_acc_on_device (5))
+ if (acc_on_device (acc_device_not_host))
{
- int g = 0, w = 0, v = 0;
+ int g, w, v;
- __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
- __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
- __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
+ g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
+ w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
+ v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
val = (g << 16) | (w << 8) | v;
ondev = 1;
}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-gwv-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-gwv-1.c
index 4ae4b7c1246..0bec6e19510 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-gwv-1.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-gwv-1.c
@@ -1,8 +1,6 @@
-/* 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" } { "" } } */
-
#include <stdio.h>
+#include <openacc.h>
+#include <gomp-constants.h>
#define N (32*32*32+17)
int main ()
@@ -18,13 +16,13 @@ int main ()
{
int val = ix;
- if (__builtin_acc_on_device (5))
+ if (acc_on_device (acc_device_not_host))
{
- int g = 0, w = 0, v = 0;
+ int g, w, v;
- __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
- __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
- __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
+ g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
+ w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
+ v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
val = (g << 16) | (w << 8) | v;
ondev = 1;
}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-v-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-v-1.c
index 0556455d62f..da4921d15f9 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-v-1.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-v-1.c
@@ -1,8 +1,6 @@
-/* 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" } { "" } } */
-
#include <stdio.h>
+#include <openacc.h>
+#include <gomp-constants.h>
#define N (32*32*32+17)
@@ -19,13 +17,13 @@ int main ()
{
int val = ix;
- if (__builtin_acc_on_device (5))
+ if (acc_on_device (acc_device_not_host))
{
- int g = 0, w = 0, v = 0;
+ int g, w, v;
- __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
- __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
- __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
+ g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
+ w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
+ v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
val = (g << 16) | (w << 8) | v;
ondev = 1;
}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-v-2.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-v-2.c
index 16d8f9fbf2c..15e2bc2f83b 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-v-2.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-v-2.c
@@ -1,8 +1,6 @@
-/* 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" } { "" } } */
-
#include <stdio.h>
+#include <openacc.h>
+#include <gomp-constants.h>
#define N (32*32*32+17)
@@ -21,13 +19,13 @@ int main ()
{
int val = ix;
- if (__builtin_acc_on_device (5))
+ if (acc_on_device (acc_device_not_host))
{
- int g = 0, w = 0, v = 0;
+ int g, w, v;
- __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
- __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
- __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
+ g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
+ w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
+ v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
val = (g << 16) | (w << 8) | v;
ondev = 1;
}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-w-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-w-1.c
index 19021d9d062..6bbd04fffea 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-w-1.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-w-1.c
@@ -1,8 +1,6 @@
-/* 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" } { "" } } */
-
#include <stdio.h>
+#include <openacc.h>
+#include <gomp-constants.h>
#define N (32*32*32+17)
int main ()
@@ -18,13 +16,13 @@ int main ()
{
int val = ix;
- if (__builtin_acc_on_device (5))
+ if (acc_on_device (acc_device_not_host))
{
- int g = 0, w = 0, v = 0;
+ int g, w, v;
- __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
- __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
- __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
+ g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
+ w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
+ v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
val = (g << 16) | (w << 8) | v;
ondev = 1;
}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-w-2.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-w-2.c
index f0c9d8182e8..c63a5d4f808 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-w-2.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-w-2.c
@@ -1,8 +1,6 @@
-/* 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" } { "" } } */
-
#include <stdio.h>
+#include <openacc.h>
+#include <gomp-constants.h>
#define N (32*32*32+17)
int main ()
@@ -20,13 +18,13 @@ int main ()
{
int val = ix;
- if (__builtin_acc_on_device (5))
+ if (acc_on_device (acc_device_not_host))
{
- int g = 0, w = 0, v = 0;
+ int g, w, v;
- __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
- __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
- __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
+ g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
+ w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
+ v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
val = (g << 16) | (w << 8) | v;
ondev = 1;
}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-wv-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-wv-1.c
index 0fec2dcfd9c..6743afaca6a 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-wv-1.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-red-wv-1.c
@@ -2,6 +2,8 @@
/* { dg-additional-options "-O2" } */
#include <stdio.h>
+#include <openacc.h>
+#include <gomp-constants.h>
#define N (32*32*32+17)
int main ()
@@ -17,13 +19,13 @@ int main ()
{
int val = ix;
- if (__builtin_acc_on_device (5))
+ if (acc_on_device (acc_device_not_host))
{
- int g = 0, w = 0, v = 0;
+ int g, w, v;
- __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
- __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
- __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
+ g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
+ w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
+ v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
val = (g << 16) | (w << 8) | v;
ondev = 1;
}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-v-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-v-1.c
index 2974807925a..6010cd2498a 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-v-1.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-v-1.c
@@ -1,8 +1,6 @@
-/* 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" } { "" } } */
-
#include <stdio.h>
+#include <openacc.h>
+#include <gomp-constants.h>
#define N (32*32*32+17)
int main ()
@@ -20,13 +18,13 @@ int main ()
#pragma acc loop vector
for (unsigned ix = 0; ix < N; ix++)
{
- if (__builtin_acc_on_device (5))
+ if (acc_on_device (acc_device_not_host))
{
- int g = 0, w = 0, v = 0;
+ int g, w, v;
- __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
- __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
- __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
+ g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
+ w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
+ v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
ary[ix] = (g << 16) | (w << 8) | v;
ondev = 1;
}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-w-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-w-1.c
index 33b6eae9e44..fa6fb9164e6 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-w-1.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-w-1.c
@@ -1,8 +1,6 @@
-/* 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" } { "" } } */
-
#include <stdio.h>
+#include <openacc.h>
+#include <gomp-constants.h>
#define N (32*32*32+17)
int main ()
@@ -20,13 +18,13 @@ int main ()
#pragma acc loop worker
for (unsigned ix = 0; ix < N; ix++)
{
- if (__builtin_acc_on_device (5))
+ if (acc_on_device (acc_device_not_host))
{
- int g = 0, w = 0, v = 0;
+ int g, w, v;
- __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
- __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
- __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
+ g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
+ w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
+ v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
ary[ix] = (g << 16) | (w << 8) | v;
ondev = 1;
}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-wv-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-wv-1.c
index 578cfadd4d1..cd4cc994b82 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-wv-1.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-wv-1.c
@@ -1,8 +1,6 @@
-/* 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" } { "" } } */
-
#include <stdio.h>
+#include <openacc.h>
+#include <gomp-constants.h>
#define N (32*32*32+17)
int main ()
@@ -20,13 +18,13 @@ int main ()
#pragma acc loop worker vector
for (unsigned ix = 0; ix < N; ix++)
{
- if (__builtin_acc_on_device (5))
+ if (acc_on_device (acc_device_not_host))
{
- int g = 0, w = 0, v = 0;
+ int g, w, v;
- __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
- __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
- __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
+ g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
+ w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
+ v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
ary[ix] = (g << 16) | (w << 8) | v;
ondev = 1;
}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/parallel-dims.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/parallel-dims.c
index 8308f7c541f..4a9854662cc 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/parallel-dims.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/parallel-dims.c
@@ -3,6 +3,7 @@
#include <limits.h>
#include <openacc.h>
+#include <gomp-constants.h>
/* TODO: "(int) acc_device_*" casts because of the C++ acc_on_device wrapper
not behaving as expected for -O0. */
@@ -12,11 +13,7 @@ static unsigned int __attribute__ ((optimize ("O2"))) acc_gang ()
if (acc_on_device ((int) acc_device_host))
return 0;
else if (acc_on_device ((int) acc_device_nvidia))
- {
- unsigned int r;
- asm volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (r));
- return r;
- }
+ return __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
else
__builtin_abort ();
}
@@ -27,11 +24,7 @@ static unsigned int __attribute__ ((optimize ("O2"))) acc_worker ()
if (acc_on_device ((int) acc_device_host))
return 0;
else if (acc_on_device ((int) acc_device_nvidia))
- {
- unsigned int r;
- asm volatile ("mov.u32 %0,%%tid.y;" : "=r" (r));
- return r;
- }
+ return __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
else
__builtin_abort ();
}
@@ -42,11 +35,7 @@ static unsigned int __attribute__ ((optimize ("O2"))) acc_vector ()
if (acc_on_device ((int) acc_device_host))
return 0;
else if (acc_on_device ((int) acc_device_nvidia))
- {
- unsigned int r;
- asm volatile ("mov.u32 %0,%%tid.x;" : "=r" (r));
- return r;
- }
+ return __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
else
__builtin_abort ();
}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-g-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-g-1.c
index b6ab7134c0b..a164f576bc3 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-g-1.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-g-1.c
@@ -1,8 +1,6 @@
-/* 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" } { "" } } */
-
#include <stdio.h>
+#include <openacc.h>
+#include <gomp-constants.h>
#define N (32*32*32+17)
@@ -12,13 +10,13 @@ void __attribute__ ((noinline)) gang (int ary[N])
#pragma acc loop gang
for (unsigned ix = 0; ix < N; ix++)
{
- if (__builtin_acc_on_device (5))
+ if (acc_on_device (acc_device_not_host))
{
- int g = 0, w = 0, v = 0;
+ int g, w, v;
- __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
- __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
- __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
+ g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
+ w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
+ v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
ary[ix] = (g << 16) | (w << 8) | v;
}
else
@@ -38,7 +36,7 @@ int main ()
#pragma acc parallel num_gangs(32) copy(ary) copy(ondev)
{
- ondev = __builtin_acc_on_device (5);
+ ondev = acc_on_device (acc_device_not_host);
gang (ary);
}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-gwv-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-gwv-1.c
index ace2f499b1f..a97e046b687 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-gwv-1.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-gwv-1.c
@@ -1,8 +1,6 @@
-/* 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" } { "" } } */
-
#include <stdio.h>
+#include <openacc.h>
+#include <gomp-constants.h>
#define N (32*32*32+17)
@@ -12,13 +10,13 @@ void __attribute__ ((noinline)) gang (int ary[N])
#pragma acc loop gang worker vector
for (unsigned ix = 0; ix < N; ix++)
{
- if (__builtin_acc_on_device (5))
+ if (acc_on_device (acc_device_not_host))
{
- int g = 0, w = 0, v = 0;
+ int g, w, v;
- __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
- __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
- __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
+ g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
+ w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
+ v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
ary[ix] = (g << 16) | (w << 8) | v;
}
else
@@ -38,7 +36,7 @@ int main ()
#pragma acc parallel num_gangs(32) num_workers(32) vector_length(32) copy(ary) copy(ondev)
{
- ondev = __builtin_acc_on_device (5);
+ ondev = acc_on_device (acc_device_not_host);
gang (ary);
}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-v-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-v-1.c
index 2503e8d7d9d..b1e3e3a596a 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-v-1.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-v-1.c
@@ -1,8 +1,6 @@
-/* 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" } { "" } } */
-
#include <stdio.h>
+#include <openacc.h>
+#include <gomp-constants.h>
#define N (32*32*32+17)
@@ -12,13 +10,13 @@ void __attribute__ ((noinline)) vector (int ary[N])
#pragma acc loop vector
for (unsigned ix = 0; ix < N; ix++)
{
- if (__builtin_acc_on_device (5))
+ if (acc_on_device (acc_device_not_host))
{
- int g = 0, w = 0, v = 0;
+ int g, w, v;
- __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
- __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
- __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
+ g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
+ w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
+ v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
ary[ix] = (g << 16) | (w << 8) | v;
}
else
@@ -38,7 +36,7 @@ int main ()
#pragma acc parallel vector_length(32) copy(ary) copy(ondev)
{
- ondev = __builtin_acc_on_device (5);
+ ondev = acc_on_device (acc_device_not_host);
vector (ary);
}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-w-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-w-1.c
index 80cd4620b09..81f1e0361c0 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-w-1.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-w-1.c
@@ -1,8 +1,6 @@
-/* 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" } { "" } } */
-
#include <stdio.h>
+#include <openacc.h>
+#include <gomp-constants.h>
#define N (32*32*32+17)
@@ -12,13 +10,13 @@ void __attribute__ ((noinline)) worker (int ary[N])
#pragma acc loop worker
for (unsigned ix = 0; ix < N; ix++)
{
- if (__builtin_acc_on_device (5))
+ if (acc_on_device (acc_device_not_host))
{
- int g = 0, w = 0, v = 0;
+ int g, w, v;
- __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
- __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
- __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
+ g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
+ w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
+ v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
ary[ix] = (g << 16) | (w << 8) | v;
}
else
@@ -38,7 +36,7 @@ int main ()
#pragma acc parallel num_workers(32) vector_length(32) copy(ary) copy(ondev)
{
- ondev = __builtin_acc_on_device (5);
+ ondev = acc_on_device (acc_device_not_host);
worker (ary);
}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-wv-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-wv-1.c
index 5e45fad176f..23dbc1ae401 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-wv-1.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-wv-1.c
@@ -1,8 +1,6 @@
-/* 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" } { "" } } */
-
#include <stdio.h>
+#include <openacc.h>
+#include <gomp-constants.h>
#define N (32*32*32+17)
@@ -12,13 +10,13 @@ void __attribute__ ((noinline)) worker (int ary[N])
#pragma acc loop worker vector
for (unsigned ix = 0; ix < N; ix++)
{
- if (__builtin_acc_on_device (5))
+ if (acc_on_device (acc_device_not_host))
{
- int g = 0, w = 0, v = 0;
+ int g, w, v;
- __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
- __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
- __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
+ g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
+ w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
+ v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
ary[ix] = (g << 16) | (w << 8) | v;
}
else
@@ -38,7 +36,7 @@ int main ()
#pragma acc parallel num_workers(32) vector_length(32) copy(ary) copy(ondev)
{
- ondev = __builtin_acc_on_device (5);
+ ondev = acc_on_device (acc_device_not_host);
worker (ary);
}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-wv-2.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-wv-2.c
index b5cbc9014d6..886214843f1 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-wv-2.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-wv-2.c
@@ -1,9 +1,6 @@
-/* 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" } { "" } } */
-
#include <stdio.h>
#include <openacc.h>
+#include <gomp-constants.h>
#define NUM_WORKERS 16
#define NUM_VECTORS 32
@@ -11,15 +8,13 @@
#define HEIGHT 32
#define WORK_ID(I,N) \
- (acc_on_device (acc_device_nvidia) \
- ? ({unsigned __r; \
- __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (__r)); \
- __r; }) : (I % N))
+ (acc_on_device (acc_device_not_host) \
+ ? __builtin_goacc_parlevel_id (GOMP_DIM_WORKER) \
+ : (I % N))
#define VEC_ID(I,N) \
- (acc_on_device (acc_device_nvidia) \
- ? ({unsigned __r; \
- __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (__r)); \
- __r; }) : (I % N))
+ (acc_on_device (acc_device_not_host) \
+ ? __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR) \
+ : (I % N))
#pragma acc routine worker
void __attribute__ ((noinline))
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/tile-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/tile-1.c
index 8dcb956c59f..5130591dd81 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/tile-1.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/tile-1.c
@@ -1,11 +1,8 @@
-/* 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-additional-options "-fopenacc-dim=32" } */
#include <stdio.h>
#include <openacc.h>
+#include <gomp-constants.h>
static int check (const int *ary, int size, int gp, int wp, int vp)
{
@@ -79,13 +76,13 @@ static int __attribute__((noinline)) place ()
{
int r = 0;
- if (acc_on_device (acc_device_nvidia))
+ if (acc_on_device (acc_device_not_host))
{
- int g = 0, w = 0, v = 0;
+ int g, w, v;
- __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
- __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
- __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
+ g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
+ w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
+ v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
r = (g << 16) | (w << 8) | v;
}
return r;