mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-24 11:24:05 +08:00
libgomp: Add openacc_{cuda,cublas,cudart} effective targets and use them in openacc testsuite
When gcc is configured for nvptx offloading with --without-cuda-driver and full CUDA isn't installed, many libgomp.oacc-*/* tests fail, some of them because cuda.h header can't be found, others because the tests can't be linked against -lcuda, -lcudart or -lcublas. I usually only have akmod-nvidia and xorg-x11-drv-nvidia-cuda rpms installed, so libcuda.so.1 can be dlopened and the offloading works, but linking against those libraries isn't possible nor are the headers around (for the plugin itself there is the fallback libgomp/plugin/cuda/cuda.h). The following patch adds 3 new effective targets and uses them in tests that needs those. 2021-05-27 Jakub Jelinek <jakub@redhat.com> * testsuite/lib/libgomp.exp (check_effective_target_openacc_cuda, check_effective_target_openacc_cublas, check_effective_target_openacc_cudart): New. * testsuite/libgomp.oacc-fortran/host_data-4.f90: Require effective target openacc_cublas. * testsuite/libgomp.oacc-fortran/host_data-2.f90: Likewise. * testsuite/libgomp.oacc-fortran/host_data-3.f: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-91.c: Require effective target openacc_cuda. * testsuite/libgomp.oacc-c-c++-common/lib-70.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-90.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-75.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-69.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-74.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-81.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-72.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-85.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/pr87835.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-82.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-73.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-83.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-78.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-76.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-84.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-79.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/host_data-1.c: Require effective targets openacc_cublas and openacc_cudart. * testsuite/libgomp.oacc-c-c++-common/context-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/context-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/context-3.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/context-4.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/acc_get_property-nvptx.c: Require effective target openacc_cudart. * testsuite/libgomp.oacc-c-c++-common/asyncwait-1.c: Add -DUSE_CUDA_H for effective target openacc_cuda and add && defined USE_CUDA_H to preprocessor conditionals. Guard -lcuda also on openacc_cuda effective target.
This commit is contained in:
parent
a617e5d516
commit
79e3f7d54b
@ -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 <cuda.h>
|
||||
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 <cuda.h>
|
||||
#include <cublas_v2.h>
|
||||
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 <cuda.h>
|
||||
#include <cuda_runtime_api.h>
|
||||
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" ]
|
||||
}
|
||||
|
@ -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 <openacc.h>
|
||||
#include <cuda.h>
|
||||
|
@ -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 <openacc.h>
|
||||
#include <stdlib.h>
|
||||
#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
|
||||
|
||||
|
@ -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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -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 <stdlib.h>
|
||||
#include <math.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* { dg-do run { target openacc_nvidia_accel_selected } } */
|
||||
/* { dg-additional-options "-lcuda" } */
|
||||
/* { dg-require-effective-target openacc_cuda } */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* { dg-do run { target openacc_nvidia_accel_selected } } */
|
||||
/* { dg-additional-options "-lcuda" } */
|
||||
/* { dg-require-effective-target openacc_cuda } */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* { dg-do run { target openacc_nvidia_accel_selected } } */
|
||||
/* { dg-additional-options "-lcuda" } */
|
||||
/* { dg-require-effective-target openacc_cuda } */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* { dg-do run { target openacc_nvidia_accel_selected } } */
|
||||
/* { dg-additional-options "-lcuda" } */
|
||||
/* { dg-require-effective-target openacc_cuda } */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* { dg-do run { target openacc_nvidia_accel_selected } } */
|
||||
/* { dg-additional-options "-lcuda" } */
|
||||
/* { dg-require-effective-target openacc_cuda } */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* { dg-do run { target openacc_nvidia_accel_selected } } */
|
||||
/* { dg-additional-options "-lcuda" } */
|
||||
/* { dg-require-effective-target openacc_cuda } */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* { dg-do run { target openacc_nvidia_accel_selected } } */
|
||||
/* { dg-additional-options "-lcuda" } */
|
||||
/* { dg-require-effective-target openacc_cuda } */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* { dg-do run { target openacc_nvidia_accel_selected } } */
|
||||
/* { dg-additional-options "-lcuda" } */
|
||||
/* { dg-require-effective-target openacc_cuda } */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* { dg-do run { target openacc_nvidia_accel_selected } } */
|
||||
/* { dg-additional-options "-lcuda" } */
|
||||
/* { dg-require-effective-target openacc_cuda } */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* { dg-do run { target openacc_nvidia_accel_selected } } */
|
||||
/* { dg-additional-options "-lcuda" } */
|
||||
/* { dg-require-effective-target openacc_cuda } */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* { dg-do run { target openacc_nvidia_accel_selected } } */
|
||||
/* { dg-additional-options "-lcuda" } */
|
||||
/* { dg-require-effective-target openacc_cuda } */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* { dg-do run { target openacc_nvidia_accel_selected } } */
|
||||
/* { dg-additional-options "-lcuda" } */
|
||||
/* { dg-require-effective-target openacc_cuda } */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* { dg-do run { target openacc_nvidia_accel_selected } } */
|
||||
/* { dg-additional-options "-lcuda" } */
|
||||
/* { dg-require-effective-target openacc_cuda } */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* { dg-do run { target openacc_nvidia_accel_selected } } */
|
||||
/* { dg-additional-options "-lcuda" } */
|
||||
/* { dg-require-effective-target openacc_cuda } */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* { dg-do run { target openacc_nvidia_accel_selected } } */
|
||||
/* { dg-additional-options "-lcuda" } */
|
||||
/* { dg-require-effective-target openacc_cuda } */
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* { dg-do run { target openacc_nvidia_accel_selected } } */
|
||||
/* { dg-additional-options "-lcuda" } */
|
||||
/* { dg-require-effective-target openacc_cuda } */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* { dg-do run { target openacc_nvidia_accel_selected } } */
|
||||
/* { dg-additional-options "-lcuda" } */
|
||||
/* { dg-require-effective-target openacc_cuda } */
|
||||
|
||||
#include <openacc.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user