openmp-target.cu 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // RUN: %clang_cc1 -triple x86_64 -verify=expected,dev \
  2. // RUN: -verify-ignore-unexpected=note \
  3. // RUN: -fopenmp -fopenmp-version=50 -o - %s
  4. // RUN: %clang_cc1 -triple x86_64 -verify -verify-ignore-unexpected=note\
  5. // RUN: -fopenmp -fopenmp-version=50 -o - -x c++ %s
  6. // RUN: %clang_cc1 -triple x86_64 -verify=dev -verify-ignore-unexpected=note\
  7. // RUN: -fcuda-is-device -o - %s
  8. #if __CUDA__
  9. #include "Inputs/cuda.h"
  10. __device__ void cu_devf();
  11. #endif
  12. void bazz() {}
  13. #pragma omp declare target to(bazz) device_type(nohost)
  14. void bazzz() {bazz();}
  15. #pragma omp declare target to(bazzz) device_type(nohost)
  16. void any() {bazz();} // expected-error {{function with 'device_type(nohost)' is not available on host}}
  17. void host1() {bazz();}
  18. #pragma omp declare target to(host1) device_type(host)
  19. void host2() {bazz();}
  20. #pragma omp declare target to(host2)
  21. void device() {host1();}
  22. #pragma omp declare target to(device) device_type(nohost)
  23. void host3() {host1();}
  24. #pragma omp declare target to(host3)
  25. #pragma omp declare target
  26. void any1() {any();}
  27. void any2() {host1();}
  28. void any3() {device();} // expected-error {{function with 'device_type(nohost)' is not available on host}}
  29. void any4() {any2();}
  30. #pragma omp end declare target
  31. void any5() {any();}
  32. void any6() {host1();}
  33. void any7() {device();} // expected-error {{function with 'device_type(nohost)' is not available on host}}
  34. void any8() {any2();}
  35. #if __CUDA__
  36. void cu_hostf() { cu_devf(); } // dev-error {{no matching function for call to 'cu_devf'}}
  37. __device__ void cu_devf2() { cu_hostf(); } // dev-error{{no matching function for call to 'cu_hostf'}}
  38. #endif