]> git.ipfire.org Git - thirdparty/gcc.git/blob - libgomp/testsuite/libgomp.oacc-c-c++-common/lib-84.c
Merge current set of OpenACC changes from gomp-4_0-branch.
[thirdparty/gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / lib-84.c
1 /* { dg-do run { target openacc_nvidia_accel_selected } } */
2 /* { dg-additional-options "-lcuda" } */
3
4 #include <stdlib.h>
5 #include <unistd.h>
6 #include <stdio.h>
7 #include <openacc.h>
8 #include <cuda.h>
9
10 int
11 main (int argc, char **argv)
12 {
13 const int N = 100;
14 int i;
15 CUstream *streams;
16 CUstream s;
17 CUresult r;
18
19 acc_init (acc_device_nvidia);
20
21 (void) acc_get_device_num (acc_device_nvidia);
22
23 streams = (CUstream *) malloc (N * sizeof (void *));
24
25 for (i = 0; i < N; i++)
26 {
27 streams[i] = (CUstream) acc_get_cuda_stream (i);
28 if (streams[i] != NULL)
29 abort ();
30
31 r = cuStreamCreate (&streams[i], CU_STREAM_DEFAULT);
32 if (r != CUDA_SUCCESS)
33 {
34 fprintf (stderr, "cuStreamCreate failed: %d\n", r);
35 abort ();
36 }
37
38 if (!acc_set_cuda_stream (i, streams[i]))
39 abort ();
40 }
41
42 for (i = 0; i < N; i++)
43 {
44 int j;
45 int cnt;
46
47 cnt = 0;
48
49 s = streams[i];
50
51 for (j = 0; j < N; j++)
52 {
53 if (s == streams[j])
54 cnt++;
55 }
56
57 if (cnt != 1)
58 abort ();
59 }
60
61 acc_shutdown (acc_device_nvidia);
62
63 exit (0);
64 }
65
66 /* { dg-output "" } */