[PATCH] D105221: [openmp][nfc] Simplify macros guarding math complex headers

Joachim Meyer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 1 08:35:57 PDT 2021


fodinabor requested changes to this revision.
fodinabor added a comment.
This revision now requires changes to proceed.

citing from https://reviews.llvm.org/rG7f1e6fcff9427adfa8efa3bfeeeac801da788b87:

> Due to recent changes we cannot use OpenMP in CUDA files anymore (PR45533) as the math handling of CUDA is different when _OPENMP is defined. We actually want this different behavior only if we are offloading with OpenMP to NVIDIA, thus generating NVPTX.

`_OPENMP` is defined even when only the CPU backend is targeted, when using `-fopenmp`. But then e.g. the OpenMP `__nv_isnand` variant is chosen for `_ISNANd` which is not defined if using CPU OpenMP and CUDA.

Applying this patch thus leads to this bunch of errors for `clang -x cuda -fopenmp /dev/null -o /dev/null --cuda-gpu-arch=sm_70`

  In file included from <built-in>:1:
  In file included from /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:98:7: error: no matching function for call to '__nv_isnand'
    if (_ISNANd(__real__(z)) && _ISNANd(__imag__(z))) {
        ^~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:66:17: note: expanded from macro '_ISNANd'
  #define _ISNANd __nv_isnand
                  ^~~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:226:16: note: candidate function not viable: call to __device__ function from __host__ function
  __DEVICE__ int __nv_isnand(double __a);
                 ^
  In file included from <built-in>:1:
  In file included from /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:98:31: error: no matching function for call to '__nv_isnand'
    if (_ISNANd(__real__(z)) && _ISNANd(__imag__(z))) {
                                ^~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:66:17: note: expanded from macro '_ISNANd'
  #define _ISNANd __nv_isnand
                  ^~~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:226:16: note: candidate function not viable: call to __device__ function from __host__ function
  __DEVICE__ int __nv_isnand(double __a);
                 ^
  In file included from <built-in>:1:
  In file included from /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:100:9: error: no matching function for call to '__nv_isinfd'
      if (_ISINFd(__a) || _ISINFd(__b)) {
          ^~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:68:17: note: expanded from macro '_ISINFd'
  #define _ISINFd __nv_isinfd
                  ^~~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:224:16: note: candidate function not viable: call to __device__ function from __host__ function
  __DEVICE__ int __nv_isinfd(double __a);
                 ^
  In file included from <built-in>:1:
  In file included from /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:100:25: error: no matching function for call to '__nv_isinfd'
      if (_ISINFd(__a) || _ISINFd(__b)) {
                          ^~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:68:17: note: expanded from macro '_ISINFd'
  #define _ISINFd __nv_isinfd
                  ^~~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:224:16: note: candidate function not viable: call to __device__ function from __host__ function
  __DEVICE__ int __nv_isinfd(double __a);
                 ^
  In file included from <built-in>:1:
  In file included from /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:101:24: error: no matching function for call to '__nv_isinfd'
        __a = _COPYSIGNd(_ISINFd(__a) ? 1 : 0, __a);
                         ^~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:68:17: note: expanded from macro '_ISINFd'
  #define _ISINFd __nv_isinfd
                  ^~~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:224:16: note: candidate function not viable: call to __device__ function from __host__ function
  __DEVICE__ int __nv_isinfd(double __a);
                 ^
  In file included from <built-in>:1:
  In file included from /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:101:13: error: no matching function for call to '__nv_copysign'
        __a = _COPYSIGNd(_ISINFd(__a) ? 1 : 0, __a);
              ^~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:72:20: note: expanded from macro '_COPYSIGNd'
  #define _COPYSIGNd __nv_copysign
                     ^~~~~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:47:19: note: candidate function not viable: call to __device__ function from __host__ function
  __DEVICE__ double __nv_copysign(double __a, double __b);
                    ^
  In file included from <built-in>:1:
  In file included from /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:102:24: error: no matching function for call to '__nv_isinfd'
        __b = _COPYSIGNd(_ISINFd(__b) ? 1 : 0, __b);
                         ^~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:68:17: note: expanded from macro '_ISINFd'
  #define _ISINFd __nv_isinfd
                  ^~~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:224:16: note: candidate function not viable: call to __device__ function from __host__ function
  __DEVICE__ int __nv_isinfd(double __a);
                 ^
  In file included from <built-in>:1:
  In file included from /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:102:13: error: no matching function for call to '__nv_copysign'
        __b = _COPYSIGNd(_ISINFd(__b) ? 1 : 0, __b);
              ^~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:72:20: note: expanded from macro '_COPYSIGNd'
  #define _COPYSIGNd __nv_copysign
                     ^~~~~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:47:19: note: candidate function not viable: call to __device__ function from __host__ function
  __DEVICE__ double __nv_copysign(double __a, double __b);
                    ^
  In file included from <built-in>:1:
  In file included from /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:103:11: error: no matching function for call to '__nv_isnand'
        if (_ISNANd(__c))
            ^~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:66:17: note: expanded from macro '_ISNANd'
  #define _ISNANd __nv_isnand
                  ^~~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:226:16: note: candidate function not viable: call to __device__ function from __host__ function
  __DEVICE__ int __nv_isnand(double __a);
                 ^
  In file included from <built-in>:1:
  In file included from /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:104:15: error: no matching function for call to '__nv_copysign'
          __c = _COPYSIGNd(0, __c);
                ^~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:72:20: note: expanded from macro '_COPYSIGNd'
  #define _COPYSIGNd __nv_copysign
                     ^~~~~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:47:19: note: candidate function not viable: call to __device__ function from __host__ function
  __DEVICE__ double __nv_copysign(double __a, double __b);
                    ^
  In file included from <built-in>:1:
  In file included from /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:105:11: error: no matching function for call to '__nv_isnand'
        if (_ISNANd(__d))
            ^~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:66:17: note: expanded from macro '_ISNANd'
  #define _ISNANd __nv_isnand
                  ^~~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:226:16: note: candidate function not viable: call to __device__ function from __host__ function
  __DEVICE__ int __nv_isnand(double __a);
                 ^
  In file included from <built-in>:1:
  In file included from /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:106:15: error: no matching function for call to '__nv_copysign'
          __d = _COPYSIGNd(0, __d);
                ^~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:72:20: note: expanded from macro '_COPYSIGNd'
  #define _COPYSIGNd __nv_copysign
                     ^~~~~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:47:19: note: candidate function not viable: call to __device__ function from __host__ function
  __DEVICE__ double __nv_copysign(double __a, double __b);
                    ^
  In file included from <built-in>:1:
  In file included from /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:109:9: error: no matching function for call to '__nv_isinfd'
      if (_ISINFd(__c) || _ISINFd(__d)) {
          ^~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:68:17: note: expanded from macro '_ISINFd'
  #define _ISINFd __nv_isinfd
                  ^~~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:224:16: note: candidate function not viable: call to __device__ function from __host__ function
  __DEVICE__ int __nv_isinfd(double __a);
                 ^
  In file included from <built-in>:1:
  In file included from /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:109:25: error: no matching function for call to '__nv_isinfd'
      if (_ISINFd(__c) || _ISINFd(__d)) {
                          ^~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:68:17: note: expanded from macro '_ISINFd'
  #define _ISINFd __nv_isinfd
                  ^~~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:224:16: note: candidate function not viable: call to __device__ function from __host__ function
  __DEVICE__ int __nv_isinfd(double __a);
                 ^
  In file included from <built-in>:1:
  In file included from /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:110:24: error: no matching function for call to '__nv_isinfd'
        __c = _COPYSIGNd(_ISINFd(__c) ? 1 : 0, __c);
                         ^~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:68:17: note: expanded from macro '_ISINFd'
  #define _ISINFd __nv_isinfd
                  ^~~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:224:16: note: candidate function not viable: call to __device__ function from __host__ function
  __DEVICE__ int __nv_isinfd(double __a);
                 ^
  In file included from <built-in>:1:
  In file included from /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:110:13: error: no matching function for call to '__nv_copysign'
        __c = _COPYSIGNd(_ISINFd(__c) ? 1 : 0, __c);
              ^~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:72:20: note: expanded from macro '_COPYSIGNd'
  #define _COPYSIGNd __nv_copysign
                     ^~~~~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:47:19: note: candidate function not viable: call to __device__ function from __host__ function
  __DEVICE__ double __nv_copysign(double __a, double __b);
                    ^
  In file included from <built-in>:1:
  In file included from /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:111:24: error: no matching function for call to '__nv_isinfd'
        __d = _COPYSIGNd(_ISINFd(__d) ? 1 : 0, __d);
                         ^~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:68:17: note: expanded from macro '_ISINFd'
  #define _ISINFd __nv_isinfd
                  ^~~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:224:16: note: candidate function not viable: call to __device__ function from __host__ function
  __DEVICE__ int __nv_isinfd(double __a);
                 ^
  In file included from <built-in>:1:
  In file included from /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:111:13: error: no matching function for call to '__nv_copysign'
        __d = _COPYSIGNd(_ISINFd(__d) ? 1 : 0, __d);
              ^~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:72:20: note: expanded from macro '_COPYSIGNd'
  #define _COPYSIGNd __nv_copysign
                     ^~~~~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:47:19: note: candidate function not viable: call to __device__ function from __host__ function
  __DEVICE__ double __nv_copysign(double __a, double __b);
                    ^
  In file included from <built-in>:1:
  In file included from /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:112:11: error: no matching function for call to '__nv_isnand'
        if (_ISNANd(__a))
            ^~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:66:17: note: expanded from macro '_ISNANd'
  #define _ISNANd __nv_isnand
                  ^~~~~~~~~~~
  /home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:226:16: note: candidate function not viable: call to __device__ function from __host__ function
  __DEVICE__ int __nv_isnand(double __a);
                 ^
  fatal error: too many errors emitted, stopping now [-ferror-limit=]
  20 errors generated when compiling for host.

I will try to bring up a patch with a regression test for this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105221/new/

https://reviews.llvm.org/D105221



More information about the cfe-commits mailing list