1 /* { dg-do run { target openacc_nvidia_accel_selected } } */
2 /* { dg-additional-options "-lcuda" } */
3 /* { dg-require-effective-target openacc_cuda } */
4
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <unistd.h>
8 #include <openacc.h>
9 #include <cuda.h>
10 #include <sys/time.h>
11
12 int
13 main (int argc, char **argv)
14 {
15 CUstream stream;
16 CUresult r;
17 struct timeval tv1, tv2;
18 time_t t1;
19
20 acc_init (acc_device_nvidia);
21
22 stream = (CUstream) acc_get_cuda_stream (0);
23 if (stream != NULL)
24 abort ();
25
26 r = cuStreamCreate (&stream, CU_STREAM_DEFAULT);
27 if (r != CUDA_SUCCESS)
28 {
29 fprintf (stderr, "cuStreamCreate failed: %d\n", r);
30 abort ();
31 }
32
33 if (!acc_set_cuda_stream (0, stream))
34 abort ();
35
36 gettimeofday (&tv1, NULL);
37
38 acc_wait_all_async (0);
39
40 acc_wait (0);
41
42 gettimeofday (&tv2, NULL);
43
44 t1 = ((tv2.tv_sec - tv1.tv_sec) * 1000000) + (tv2.tv_usec - tv1.tv_usec);
45
46 if (t1 > 1000)
47 {
48 fprintf (stderr, "too long\n");
49 abort ();
50 }
51
52 acc_shutdown (acc_device_nvidia);
53
54 exit (0);
55 }
56
57 /* { dg-output "" } */