1 /* { dg-do run { target openacc_nvidia_accel_selected } } */
2 /* { dg-additional-options "-lcuda" } */
12 main (int argc
, char **argv
)
14 const int N
= 1024 * 1024;
19 struct timeval start
, stop
;
23 acc_init (acc_device_nvidia
);
25 h
= (unsigned char *) malloc (N
);
27 for (i
= 0; i
< N
; i
++)
34 acc_map_data (h
, d
, N
);
36 gettimeofday (&start
, NULL
);
38 for (i
= 0; i
< 100; i
++)
40 #pragma acc update device(h[0:N])
43 gettimeofday (&stop
, NULL
);
45 sync
= (float) (stop
.tv_sec
- start
.tv_sec
);
46 sync
+= (float) ((stop
.tv_usec
- start
.tv_usec
) / 1000000.0);
48 gettimeofday (&start
, NULL
);
50 r
= cuStreamCreate (&s
, CU_STREAM_DEFAULT
);
51 if (r
!= CUDA_SUCCESS
)
53 fprintf (stderr
, "cuStreamCreate failed: %d\n", r
);
57 if (!acc_set_cuda_stream (0, s
))
60 for (i
= 0; i
< 100; i
++)
62 #pragma acc update device(h[0:N]) async(0)
67 gettimeofday (&stop
, NULL
);
69 async
= (float) (stop
.tv_sec
- start
.tv_sec
);
70 async
+= (float) ((stop
.tv_usec
- start
.tv_usec
) / 1000000.0);
72 if (async
> (sync
* 1.5))
81 acc_shutdown (acc_device_nvidia
);
86 /* { dg-output "" } */