Adjust formatting of acc_get_property tests
[gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / gang-static-2.c
index 6de739ae99fa3bf3b2b3e37f5ff176bc140f7917..e273a797b8e3bb67b2e98cd0b5aa3899a5f2663a 100644 (file)
@@ -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);