gcc/libgomp/testsuite/libgomp.oacc-c-c++-common/f-asyncwait-2.c
Tom de Vries a7cf26127a Add libgomp.oacc-c-c++-common/f-asyncwait-{1,2,3}.c
2017-11-15  Tom de Vries  <tom@codesourcery.com>

	* testsuite/libgomp.oacc-c-c++-common/f-asyncwait-1.c: New test, copied
	from asyncwait-1.f90.  Rewrite into C.  Rewrite from float to int.
	* testsuite/libgomp.oacc-c-c++-common/f-asyncwait-2.c: New test, copied
	from asyncwait-2.f90.  Rewrite into C.  Rewrite from float to int.
	* testsuite/libgomp.oacc-c-c++-common/f-asyncwait-3.c: New test, copied
	from asyncwait-3.f90.  Rewrite into C.  Rewrite from float to int.

From-SVN: r254769
2017-11-15 13:40:58 +00:00

62 lines
1.1 KiB
C

/* { dg-do run } */
/* Based on asyncwait-2.f90. */
#include <stdlib.h>
#define N 64
int *a, *b, *c;
int
main (void)
{
a = (int *)malloc (N * sizeof (*a));
b = (int *)malloc (N * sizeof (*b));
c = (int *)malloc (N * sizeof (*c));
#pragma acc parallel copy (a[0:N]) async (0)
#pragma acc loop
for (int i = 0; i < N; ++i)
a[i] = 1;
#pragma acc parallel copy (b[0:N]) async (1)
#pragma acc loop
for (int i = 0; i < N; ++i)
b[i] = 1;
#pragma acc parallel copy (a[0:N], b[0:N], c[0:N]) wait (0, 1)
#pragma acc loop
for (int i = 0; i < N; ++i)
c[i] = a[i] + b[i];
for (int i = 0; i < N; ++i)
if (c[i] != 2)
abort ();
#if 1
#pragma acc kernels copy (a[0:N]) async (0)
#pragma acc loop
for (int i = 0; i < N; ++i)
a[i] = 1;
#pragma acc kernels copy (b[0:N]) async (1)
#pragma acc loop
for (int i = 0; i < N; ++i)
b[i] = 1;
#pragma acc kernels copy (a[0:N], b[0:N], c[0:N]) wait (0, 1)
#pragma acc loop
for (int i = 0; i < N; ++i)
c[i] = a[i] + b[i];
for (int i = 0; i < N; ++i)
if (c[i] != 2)
abort ();
#endif
free (a);
free (b);
free (c);
}