intel / llvm

Intel staging area for llvm.org contribution. Home for Intel LLVM-based projects.
Other
1.25k stars 738 forks source link

different macros are defined during AOT compilation for CUDA targets #15545

Closed AuroraPerego closed 1 month ago

AuroraPerego commented 1 month ago

Describe the bug

When compiling AOT for a specific target the corresponding macro is set to 1, while the macros for all the other targets are set to 0. However, for the CUDA backend, the macro that are set to 0 by the compiler end with *_SM**__, while those that correspond to the target we are compiling for end with *_SM_**__. As an example, when compiling for NVIDIA Pascal architecture the macro defined are:

...
#define __SYCL_TARGET_NVIDIA_GPU_SM50__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM52__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM53__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM60__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM61__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM62__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM70__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM72__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM75__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM80__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM86__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM87__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM89__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM90__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM_60__ 1
...

To reproduce

  1. Include code snippet as short as possible

    test.cpp

    #include <sycl/sycl.hpp>
    int main()
    {
    return 0;
    }
  2. Specify the command which should be used to compile the program
    icpx -fsycl -fsycl-targets=nvidia_gpu_sm_60 -dM -E test.cpp | grep "60__"
  3. Indicate what is wrong and what was expected The output is:
    #define __SYCL_TARGET_NVIDIA_GPU_SM60__ 0
    #define __SYCL_TARGET_NVIDIA_GPU_SM_60__ 1

    while only one of the two should exist.

Environment

Additional context

The problem may be related to the definitions in the file /opt/intel/oneapi/compiler/latest/include/sycl/ext/oneapi/experimental/device_architecture.hpp.

AuroraPerego commented 1 month ago

FYI @fwyzard @ivorobts

GeorgeWeb commented 1 month ago

Thanks for the issue. Nice catch!

AuroraPerego commented 1 month ago

@GeorgeWeb I've checked the nightly-2024-10-14 and the issue seems fixed. Thanks!

$ clang++ -fsycl -fsycl-targets=nvidia_gpu_sm_60 -dM -E test.cpp | grep "NVIDIA"
#define __SYCL_TARGET_NVIDIA_GPU_SM_50__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM_52__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM_53__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM_60__ 1
#define __SYCL_TARGET_NVIDIA_GPU_SM_61__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM_62__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM_70__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM_72__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM_75__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM_80__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM_86__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM_87__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM_89__ 0
#define __SYCL_TARGET_NVIDIA_GPU_SM_90__ 0
GeorgeWeb commented 1 month ago

Closing as https://github.com/intel/llvm/pull/15615 fixed it.