1 /* { dg-do run { target openacc_nvidia_accel_selected } } */
2 /* { dg-additional-options "-lcuda" } */
3 /* { dg-require-effective-target openacc_cuda } */
13 main (int argc
, char **argv
)
15 const int N
= 1024 * 1024;
20 struct timeval start
, stop
;
24 acc_init (acc_device_nvidia
);
26 h
= (unsigned char *) malloc (N
);
28 for (i
= 0; i
< N
; i
++)
35 acc_map_data (h
, d
, N
);
37 gettimeofday (&start
, NULL
);
39 for (i
= 0; i
< 100; i
++)
41 #pragma acc update device(h[0:N])
44 gettimeofday (&stop
, NULL
);
46 sync
= (float) (stop
.tv_sec
- start
.tv_sec
);
47 sync
+= (float) ((stop
.tv_usec
- start
.tv_usec
) / 1000000.0);
49 gettimeofday (&start
, NULL
);
51 r
= cuStreamCreate (&s
, CU_STREAM_DEFAULT
);
52 if (r
!= CUDA_SUCCESS
)
54 fprintf (stderr
, "cuStreamCreate failed: %d\n", r
);
58 if (!acc_set_cuda_stream (0, s
))
61 for (i
= 0; i
< 100; i
++)
63 #pragma acc update device(h[0:N]) async(0)
68 gettimeofday (&stop
, NULL
);
70 async
= (float) (stop
.tv_sec
- start
.tv_sec
);
71 async
+= (float) ((stop
.tv_usec
- start
.tv_usec
) / 1000000.0);
73 if (async
> (sync
* 1.5))
82 acc_shutdown (acc_device_nvidia
);
87 /* { dg-output "" } */