diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp index 089c2bba9fc..0f4eb6fd4ff 100644 --- a/libgomp/testsuite/lib/libgomp.exp +++ b/libgomp/testsuite/lib/libgomp.exp @@ -479,3 +479,56 @@ proc check_effective_target_openacc_radeon_accel_selected { } { return 0; } +# Return 1 if cuda.h and -lcuda are available. + +proc check_effective_target_openacc_cuda { } { + return [check_no_compiler_messages openacc_cuda executable { +#include +int main() { + CUdevice dev; + CUresult r = cuDeviceGet (&dev, 0); + if (r != CUDA_SUCCESS) + return 1; + return 0; +} } "-lcuda" ] +} + +# Return 1 if cublas_v2.h and -lcublas are available. + +proc check_effective_target_openacc_cublas { } { + return [check_no_compiler_messages openacc_cublas executable { +#include +#include +int main() { + cublasStatus_t s; + cublasHandle_t h; + CUdevice dev; + CUresult r = cuDeviceGet (&dev, 0); + if (r != CUDA_SUCCESS) + return 1; + s = cublasCreate (&h); + if (s != CUBLAS_STATUS_SUCCESS) + return 1; + return 0; +} } "-lcuda -lcublas" ] +} + +# Return 1 if cuda_runtime_api.h and -lcudart are available. + +proc check_effective_target_openacc_cudart { } { + return [check_no_compiler_messages openacc_cudart executable { +#include +#include +int main() { + cudaError_t e; + int devn; + CUdevice dev; + CUresult r = cuDeviceGet (&dev, 0); + if (r != CUDA_SUCCESS) + return 1; + e = cudaGetDevice (&devn); + if (e != cudaSuccess) + return 1; + return 0; +} } "-lcuda -lcudart" ] +} diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/acc_get_property-nvptx.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/acc_get_property-nvptx.c index 6334cfdd2f7..82239010d0f 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/acc_get_property-nvptx.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/acc_get_property-nvptx.c @@ -4,6 +4,7 @@ /* { dg-additional-sources acc_get_property-aux.c } */ /* { dg-additional-options "-lcuda -lcudart" } */ /* { dg-do run { target openacc_nvidia_accel_selected } } */ +/* { dg-require-effective-target openacc_cudart } */ #include #include diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/asyncwait-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/asyncwait-1.c index e780845a793..e91642c162e 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/asyncwait-1.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/asyncwait-1.c @@ -1,9 +1,10 @@ /* { dg-do run } */ -/* { dg-additional-options "-lcuda" { target openacc_nvidia_accel_selected } } */ +/* { dg-additional-options "-DUSE_CUDA_H" { target openacc_cuda } } */ +/* { dg-additional-options "-lcuda" { target { openacc_nvidia_accel_selected && openacc_cuda } } } */ #include #include -#if defined ACC_DEVICE_TYPE_nvidia +#if defined ACC_DEVICE_TYPE_nvidia && defined USE_CUDA_H #include "cuda.h" #endif @@ -13,7 +14,7 @@ int main (int argc, char **argv) { -#if defined ACC_DEVICE_TYPE_nvidia +#if defined ACC_DEVICE_TYPE_nvidia && defined USE_CUDA_H CUresult r; CUstream stream1; #endif @@ -22,7 +23,7 @@ main (int argc, char **argv) int i; int nbytes; -#if defined ACC_DEVICE_TYPE_nvidia +#if defined ACC_DEVICE_TYPE_nvidia && defined USE_CUDA_H acc_init (acc_device_nvidia); #endif @@ -216,7 +217,7 @@ main (int argc, char **argv) } -#if defined ACC_DEVICE_TYPE_nvidia +#if defined ACC_DEVICE_TYPE_nvidia && defined USE_CUDA_H r = cuStreamCreate (&stream1, CU_STREAM_NON_BLOCKING); if (r != CUDA_SUCCESS) { @@ -650,7 +651,7 @@ main (int argc, char **argv) } -#if defined ACC_DEVICE_TYPE_nvidia +#if defined ACC_DEVICE_TYPE_nvidia && defined USE_CUDA_H r = cuStreamCreate (&stream1, CU_STREAM_NON_BLOCKING); if (r != CUDA_SUCCESS) { @@ -902,7 +903,7 @@ main (int argc, char **argv) abort (); } -#if defined ACC_DEVICE_TYPE_nvidia +#if defined ACC_DEVICE_TYPE_nvidia && defined USE_CUDA_H acc_shutdown (acc_device_nvidia); #endif diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/context-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/context-1.c index 2e3b62ebbd2..3479fc7e549 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/context-1.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/context-1.c @@ -1,5 +1,7 @@ /* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-additional-options "-lcuda -lcublas -lcudart" } */ +/* { dg-require-effective-target openacc_cublas } */ +/* { dg-require-effective-target openacc_cudart } */ #include #include diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/context-2.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/context-2.c index 6bdcfe7d429..db82b9097f6 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/context-2.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/context-2.c @@ -1,5 +1,7 @@ /* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-additional-options "-lcuda -lcublas -lcudart" } */ +/* { dg-require-effective-target openacc_cublas } */ +/* { dg-require-effective-target openacc_cudart } */ #include #include diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/context-3.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/context-3.c index 8f14560ea8b..b96f661cb7c 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/context-3.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/context-3.c @@ -1,5 +1,7 @@ /* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-additional-options "-lcuda -lcublas -lcudart" } */ +/* { dg-require-effective-target openacc_cublas } */ +/* { dg-require-effective-target openacc_cudart } */ #include #include diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/context-4.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/context-4.c index b403a5cf5cb..7bfd216136b 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/context-4.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/context-4.c @@ -1,5 +1,7 @@ /* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-additional-options "-lcuda -lcublas -lcudart" } */ +/* { dg-require-effective-target openacc_cublas } */ +/* { dg-require-effective-target openacc_cudart } */ #include #include diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/host_data-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/host_data-1.c index 21d2139af27..20f7f049dcc 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/host_data-1.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/host_data-1.c @@ -1,5 +1,7 @@ /* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-additional-options "-lm -lcuda -lcublas -lcudart -Wall -Wextra" } */ +/* { dg-require-effective-target openacc_cublas } */ +/* { dg-require-effective-target openacc_cudart } */ #include #include diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-69.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-69.c index c10bebaab13..00e0ca89f17 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-69.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-69.c @@ -1,5 +1,6 @@ /* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-additional-options "-lcuda" } */ +/* { dg-require-effective-target openacc_cuda } */ #include #include diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-70.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-70.c index 912b266ec39..a2918c08a12 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-70.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-70.c @@ -1,5 +1,6 @@ /* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-additional-options "-lcuda" } */ +/* { dg-require-effective-target openacc_cuda } */ #include #include diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-72.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-72.c index e383ba04d69..99b62f1132a 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-72.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-72.c @@ -1,5 +1,6 @@ /* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-additional-options "-lcuda" } */ +/* { dg-require-effective-target openacc_cuda } */ #include #include diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-73.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-73.c index 43a8b7e6395..5b4b3fdde31 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-73.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-73.c @@ -1,5 +1,6 @@ /* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-additional-options "-lcuda" } */ +/* { dg-require-effective-target openacc_cuda } */ #include #include diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-74.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-74.c index 0efcf0d5222..939f255f26c 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-74.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-74.c @@ -1,5 +1,6 @@ /* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-additional-options "-lcuda" } */ +/* { dg-require-effective-target openacc_cuda } */ #include #include diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-75.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-75.c index 19422118748..804ee3938ac 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-75.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-75.c @@ -1,5 +1,6 @@ /* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-additional-options "-lcuda" } */ +/* { dg-require-effective-target openacc_cuda } */ #include #include diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-76.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-76.c index 11d9d621f87..f9045266f1c 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-76.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-76.c @@ -1,5 +1,6 @@ /* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-additional-options "-lcuda" } */ +/* { dg-require-effective-target openacc_cuda } */ #include #include diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-78.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-78.c index 4f58fb23cfe..d8cba4db538 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-78.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-78.c @@ -1,5 +1,6 @@ /* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-additional-options "-lcuda" } */ +/* { dg-require-effective-target openacc_cuda } */ #include #include diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-79.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-79.c index b2e2687e4e7..b805d5f9b81 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-79.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-79.c @@ -1,5 +1,6 @@ /* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-additional-options "-lcuda" } */ +/* { dg-require-effective-target openacc_cuda } */ #include #include diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-81.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-81.c index d5f18f00319..958672c45e5 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-81.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-81.c @@ -1,5 +1,6 @@ /* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-additional-options "-lcuda" } */ +/* { dg-require-effective-target openacc_cuda } */ #include #include diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-82.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-82.c index 9cf73b31964..a36f8e69a18 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-82.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-82.c @@ -1,5 +1,6 @@ /* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-additional-options "-lcuda" } */ +/* { dg-require-effective-target openacc_cuda } */ #include #include diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-83.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-83.c index 51b7ee73b9c..44ef1dbdc17 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-83.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-83.c @@ -1,5 +1,6 @@ /* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-additional-options "-lcuda" } */ +/* { dg-require-effective-target openacc_cuda } */ #include #include diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-84.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-84.c index d793c743630..c1ff76372fc 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-84.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-84.c @@ -1,5 +1,6 @@ /* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-additional-options "-lcuda" } */ +/* { dg-require-effective-target openacc_cuda } */ #include #include diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-85.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-85.c index 141c83b53dd..db250657ac5 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-85.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-85.c @@ -1,5 +1,6 @@ /* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-additional-options "-lcuda" } */ +/* { dg-require-effective-target openacc_cuda } */ #include #include diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-90.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-90.c index d17755bf3eb..5ca550585e9 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-90.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-90.c @@ -1,5 +1,6 @@ /* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-additional-options "-lcuda" } */ +/* { dg-require-effective-target openacc_cuda } */ #include #include diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-91.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-91.c index 36fff089b83..d14226c026e 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-91.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-91.c @@ -1,5 +1,6 @@ /* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-additional-options "-lcuda" } */ +/* { dg-require-effective-target openacc_cuda } */ #include #include diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/pr87835.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/pr87835.c index 88c2c7763cc..e48f3074d58 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/pr87835.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/pr87835.c @@ -1,5 +1,6 @@ /* { dg-do run { target openacc_nvidia_accel_selected } } */ /* { dg-additional-options "-lcuda" } */ +/* { dg-require-effective-target openacc_cuda } */ #include #include diff --git a/libgomp/testsuite/libgomp.oacc-fortran/host_data-2.f90 b/libgomp/testsuite/libgomp.oacc-fortran/host_data-2.f90 index ab70e4e8dea..fe1ae8ab50a 100644 --- a/libgomp/testsuite/libgomp.oacc-fortran/host_data-2.f90 +++ b/libgomp/testsuite/libgomp.oacc-fortran/host_data-2.f90 @@ -3,6 +3,7 @@ ! { dg-do run { target openacc_nvidia_accel_selected } } ! { dg-additional-options "-lcublas -Wall -Wextra" } +! { dg-require-effective-target openacc_cublas } program test implicit none diff --git a/libgomp/testsuite/libgomp.oacc-fortran/host_data-3.f b/libgomp/testsuite/libgomp.oacc-fortran/host_data-3.f index 434c18c9889..912bac68de7 100644 --- a/libgomp/testsuite/libgomp.oacc-fortran/host_data-3.f +++ b/libgomp/testsuite/libgomp.oacc-fortran/host_data-3.f @@ -2,6 +2,7 @@ ! { dg-do run { target openacc_nvidia_accel_selected } } ! { dg-additional-options "-lcublas -Wall -Wextra" } +! { dg-require-effective-target openacc_cublas } include "cublas-fixed.h" diff --git a/libgomp/testsuite/libgomp.oacc-fortran/host_data-4.f90 b/libgomp/testsuite/libgomp.oacc-fortran/host_data-4.f90 index e81a8b292c1..0daba8bfcdc 100644 --- a/libgomp/testsuite/libgomp.oacc-fortran/host_data-4.f90 +++ b/libgomp/testsuite/libgomp.oacc-fortran/host_data-4.f90 @@ -2,6 +2,7 @@ ! { dg-do run { target openacc_nvidia_accel_selected } } ! { dg-additional-options "-lcublas -Wall -Wextra" } +! { dg-require-effective-target openacc_cublas } module cublas interface