Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCL] [HIP] __CUDA_ARCH__ defined when compiling for HIP backend #7720

Closed
AuroraPerego opened this issue Dec 9, 2022 · 0 comments · Fixed by #7977
Closed

[SYCL] [HIP] __CUDA_ARCH__ defined when compiling for HIP backend #7720

AuroraPerego opened this issue Dec 9, 2022 · 0 comments · Fixed by #7977
Labels
bug Something isn't working hip Issues related to execution on HIP backend.

Comments

@AuroraPerego
Copy link

AuroraPerego commented Dec 9, 2022

Describe the bug
I noticed that __CUDA_ARCH__ is defined when compiling ahead of time for the HIP backend.
I don't know if this is wanted, but for example using Eigen I get an error because it tries to include CUDA libraries (the workaround here is to define EIGEN_NO_CUDA).

As an example, compiling a file that just includes the Eigen library gives this:

In file included from include_eigen.cpp:3:
In file included from eigen/Eigen/Core:160:
eigen/Eigen/src/Core/util/Meta.h:21:12: fatal error: 'math_constants.h' file not found
  #include <math_constants.h>
           ^~~~~~~~~~~~~~~~~~

To Reproduce

$ clang++ -fsycl -std=c++17 dummy.cpp -dM -E  -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=gfx900 --rocm-path=/opt/rocm-5.0.2 | grep CUDA_ARCH
#define __CUDA_ARCH__ 1

where dummy.cpp is just

#include <CL/sycl.hpp>

int main(){
    return 0;
}

Environment (please complete the following information):

  • OS: Linux
  • Target device and vendor: AMD GPU Radeon PRO WX 9100
  • clang version: 16.0.0 (https://github.com/intel/llvm 0f579ba)
    release 2022-09 (but it tried also with the sycl-nightly/20221208 and the behaviour is the same)
@AuroraPerego AuroraPerego added the bug Something isn't working label Dec 9, 2022
@AlexeySachkov AlexeySachkov added the hip Issues related to execution on HIP backend. label Dec 12, 2022
WeiqunZhang pushed a commit to AMReX-Codes/amrex that referenced this issue Jan 9, 2023
## Summary

The changes in these two commits, although apparently redundant, guard
SYCL compilations targeting CUDA or HIP devices by preventing the
compiler from seeing the CUDA/HIP code already in AMReX.

## Additional background

The 'vanilla' version of LLVM, which is used by hipSYCL for example,
enables `__CUDA_ARCH__` and `__HIP_DEVICE_COMPILE__` when compiling
device code, for both
[CUDA](https://llvm.org/docs/CompileCudaWithLLVM.html#detecting-clang-vs-nvcc-from-code)
and [HIP](https://reviews.llvm.org/D45441), respectively. Intel's
version of LLVM is also moving in the same direction with
[CUDA](intel/llvm#7722) and
[HIP](intel/llvm#7720), although the latter is
off to a rocky start.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hip Issues related to execution on HIP backend.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants