gcc/libgomp/testsuite/libgomp.oacc-c-c++-common/pr87835.c
Thomas Schwinge da2d30c199 Address compiler diagnostics in libgomp.oacc-c-c++-common/pr87835.c
source-gcc/libgomp/testsuite/libgomp.oacc-c-c++-common/pr87835.c: In function 'main':
    source-gcc/libgomp/testsuite/libgomp.oacc-c-c++-common/pr87835.c:45: warning: ignoring #pragma loop gang [-Wunknown-pragmas]
       45 |     #pragma loop gang
          |
    source-gcc/libgomp/testsuite/libgomp.oacc-c-c++-common/pr87835.c:19:7: warning: unused variable 'b' [-Wunused-variable]
       19 |   int b[n];
          |       ^

	libgomp/
	PR target/87835
	* testsuite/libgomp.oacc-c-c++-common/pr87835.c: Update.

From-SVN: r271004
2019-05-08 12:01:30 +02:00

62 lines
1.0 KiB
C

/* { dg-do run { target openacc_nvidia_accel_selected } } */
/* { dg-additional-options "-lcuda" } */
#include <openacc.h>
#include <stdlib.h>
#include "cuda.h"
#include <stdio.h>
#define n 128
int
main (void)
{
CUresult r;
CUstream stream1;
int N = n;
int a[n];
int c[n];
acc_init (acc_device_nvidia);
r = cuStreamCreate (&stream1, CU_STREAM_NON_BLOCKING);
if (r != CUDA_SUCCESS)
{
fprintf (stderr, "cuStreamCreate failed: %d\n", r);
abort ();
}
acc_set_cuda_stream (1, stream1);
for (int i = 0; i < n; i++)
{
a[i] = 3;
c[i] = 0;
}
#pragma acc data copy (a, c) copyin (N)
{
#pragma acc parallel async (1)
;
#pragma acc parallel async (1) num_gangs (320)
#pragma acc loop gang
for (int ii = 0; ii < N; ii++)
c[ii] = (a[ii] + a[N - ii - 1]);
#pragma acc parallel async (1)
#pragma acc loop seq
for (int ii = 0; ii < n; ii++)
a[ii] = 6;
#pragma acc wait (1)
}
for (int i = 0; i < n; i++)
if (c[i] != 6)
abort ();
return 0;
}