Commit dde76623 by Tom de Vries Committed by Tom de Vries

Allow asyncwait-1.c to run for non-nvidia devices

2017-11-14  Tom de Vries  <tom@codesourcery.com>

	* testsuite/libgomp.oacc-c-c++-common/asyncwait-1.c: Allow to run for
	non-nvidia devices.

From-SVN: r254723
parent 3d8d3012
2017-11-14 Tom de Vries <tom@codesourcery.com>
* testsuite/libgomp.oacc-c-c++-common/asyncwait-1.c: Allow to run for
non-nvidia devices.
2017-11-07 Jakub Jelinek <jakub@redhat.com> 2017-11-07 Jakub Jelinek <jakub@redhat.com>
PR c++/82835 PR c++/82835
......
/* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-do run } */
/* { dg-additional-options "-lcuda" } */ /* { dg-additional-options "-lcuda" { target openacc_nvidia_accel_selected } } */
#include <openacc.h> #include <openacc.h>
#include <stdlib.h> #include <stdlib.h>
#if defined ACC_DEVICE_TYPE_nvidia
#include "cuda.h" #include "cuda.h"
#endif
#include <stdio.h> #include <stdio.h>
#include <sys/time.h> #include <sys/time.h>
...@@ -11,14 +13,18 @@ ...@@ -11,14 +13,18 @@
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
#if defined ACC_DEVICE_TYPE_nvidia
CUresult r; CUresult r;
CUstream stream1; CUstream stream1;
#endif
int N = 128; //1024 * 1024; int N = 128; //1024 * 1024;
float *a, *b, *c, *d, *e; float *a, *b, *c, *d, *e;
int i; int i;
int nbytes; int nbytes;
#if defined ACC_DEVICE_TYPE_nvidia
acc_init (acc_device_nvidia); acc_init (acc_device_nvidia);
#endif
nbytes = N * sizeof (float); nbytes = N * sizeof (float);
...@@ -210,6 +216,7 @@ main (int argc, char **argv) ...@@ -210,6 +216,7 @@ main (int argc, char **argv)
} }
#if defined ACC_DEVICE_TYPE_nvidia
r = cuStreamCreate (&stream1, CU_STREAM_NON_BLOCKING); r = cuStreamCreate (&stream1, CU_STREAM_NON_BLOCKING);
if (r != CUDA_SUCCESS) if (r != CUDA_SUCCESS)
{ {
...@@ -218,6 +225,7 @@ main (int argc, char **argv) ...@@ -218,6 +225,7 @@ main (int argc, char **argv)
} }
acc_set_cuda_stream (1, stream1); acc_set_cuda_stream (1, stream1);
#endif
for (i = 0; i < N; i++) for (i = 0; i < N; i++)
{ {
...@@ -642,6 +650,7 @@ main (int argc, char **argv) ...@@ -642,6 +650,7 @@ main (int argc, char **argv)
} }
#if defined ACC_DEVICE_TYPE_nvidia
r = cuStreamCreate (&stream1, CU_STREAM_NON_BLOCKING); r = cuStreamCreate (&stream1, CU_STREAM_NON_BLOCKING);
if (r != CUDA_SUCCESS) if (r != CUDA_SUCCESS)
{ {
...@@ -650,6 +659,7 @@ main (int argc, char **argv) ...@@ -650,6 +659,7 @@ main (int argc, char **argv)
} }
acc_set_cuda_stream (1, stream1); acc_set_cuda_stream (1, stream1);
#endif
for (i = 0; i < N; i++) for (i = 0; i < N; i++)
{ {
...@@ -892,7 +902,9 @@ main (int argc, char **argv) ...@@ -892,7 +902,9 @@ main (int argc, char **argv)
abort (); abort ();
} }
#if defined ACC_DEVICE_TYPE_nvidia
acc_shutdown (acc_device_nvidia); acc_shutdown (acc_device_nvidia);
#endif
return 0; return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment