| 1 |
/* Verify expected nvptx plugin behavior for "acc_set_cuda_stream" for |
| 2 |
"acc_async_sync". */ |
| 3 |
|
| 4 |
/* { dg-do run { target openacc_nvidia_accel_selected } } */ |
| 5 |
/* { dg-set-target-env-var GOMP_DEBUG "1" } */ |
| 6 |
|
| 7 |
#undef NDEBUG |
| 8 |
#include <assert.h> |
| 9 |
#include <openacc.h> |
| 10 |
|
| 11 |
int main(void) |
| 12 |
{ |
| 13 |
int async = 42; |
| 14 |
|
| 15 |
/* Initialize. */ |
| 16 |
#pragma acc parallel async(acc_async_sync) |
| 17 |
; |
| 18 |
#pragma acc parallel async(async) |
| 19 |
; |
| 20 |
#pragma acc wait |
| 21 |
|
| 22 |
void *cuda_stream_sync = acc_get_cuda_stream (acc_async_sync); |
| 23 |
assert (cuda_stream_sync == NULL); |
| 24 |
void *cuda_stream_async = acc_get_cuda_stream (async); |
| 25 |
assert (cuda_stream_async != NULL); |
| 26 |
int ret = acc_set_cuda_stream (acc_async_sync, cuda_stream_async); |
| 27 |
assert (ret == 0); |
| 28 |
void *cuda_stream_sync_ = acc_get_cuda_stream (acc_async_sync); |
| 29 |
assert (cuda_stream_sync_ == cuda_stream_sync); |
| 30 |
void *cuda_stream_async_ = acc_get_cuda_stream (async); |
| 31 |
assert (cuda_stream_async_ == cuda_stream_async); |
| 32 |
|
| 33 |
#pragma acc parallel async(acc_async_sync) |
| 34 |
; |
| 35 |
#pragma acc parallel async(async) |
| 36 |
; |
| 37 |
#pragma acc wait |
| 38 |
|
| 39 |
return 0; |
| 40 |
} |
| 41 |
|
| 42 |
/* { dg-output "Refusing request to set CUDA stream associated with \"acc_async_sync\"" } */ |