Retro68/gcc/libgomp/testsuite/libgomp.oacc-c-c++-common/declare-3.c
Wolfgang Thaller 6fbf4226da gcc-9.1
2019-06-20 20:10:10 +02:00

62 lines
778 B
C

/* { dg-do run { target openacc_nvidia_accel_selected } } */
#include <stdlib.h>
#include <openacc.h>
float *b;
#pragma acc declare deviceptr (b)
#pragma acc routine
float *
subr2 (void)
{
return b;
}
float
subr1 (float a)
{
float b;
#pragma acc declare present_or_copy (b)
float c;
#pragma acc declare present_or_copyin (c)
float d;
#pragma acc declare present_or_create (d)
float e;
#pragma acc declare present_or_copyout (e)
#pragma acc parallel copy (a)
{
b = a;
c = b;
d = c;
e = d;
a = e;
}
return a;
}
int
main (int argc, char **argv)
{
float a;
float *c;
a = 2.0;
a = subr1 (a);
if (a != 2.0)
abort ();
b = (float *) acc_malloc (sizeof (float));
c = subr2 ();
if (b != c)
abort ();
return 0;
}