diff --git a/rocclr/runtime/CMakeLists.txt b/rocclr/runtime/CMakeLists.txt index 4076bd318d..7437a53fec 100644 --- a/rocclr/runtime/CMakeLists.txt +++ b/rocclr/runtime/CMakeLists.txt @@ -1,5 +1,12 @@ set(CMAKE_CXX_FLAGS "-std=c++11") +option(GENERIC_IS_ZERO "Teach LLVM/Clang that generic address space IS address space 0 for AMDGPU target" OFF) +if (GENERIC_IS_ZERO) + add_definitions(-DAMDGCN_TRIPLE=amdgcn-amd-amdhsa-amdgizcl) +else (GENERIC_IS_ZERO) + add_definitions(-DAMDGCN_TRIPLE=amdgcn-amd-amdhsa-opencl) +endif (GENERIC_IS_ZERO) + add_definitions(-DLINUX -D__x86_64__ -D__AMD64__ -DUNIX_OS -DqLittleEndian -DOPENCL_MAJOR=2 -DOPENCL_MINOR=0 -DWITH_AQL -DWITH_ONLINE_COMPILER -DATI_OS_LINUX -DATI_ARCH_X86 -DLITTLEENDIAN_CPU -DATI_BITS_64 -DATI_COMP_GCC -DWITH_HSA_DEVICE -DWITH_TARGET_AMDGCN -DOPENCL_EXPORTS -DCL_USE_DEPRECATED_OPENCL_1_0_APIS -DCL_USE_DEPRECATED_OPENCL_1_1_APIS -DCL_USE_DEPRECATED_OPENCL_1_2_APIS -DCL_USE_DEPRECATED_OPENCL_2_0_APIS -DVEGA10_ONLY=false -DWITH_LIGHTNING_COMPILER) include_directories(${ROCR_INCLUDE_DIRS}) diff --git a/rocclr/runtime/device/rocm/roccompiler.cpp b/rocclr/runtime/device/rocm/roccompiler.cpp index fad26f6af8..aed90cdc2f 100644 --- a/rocclr/runtime/device/rocm/roccompiler.cpp +++ b/rocclr/runtime/device/rocm/roccompiler.cpp @@ -26,6 +26,12 @@ #include #endif // defined(ATI_OS_LINUX) +#define QUOTE(s) #s +#define STRING(s) QUOTE(s) +#ifndef AMDGCN_TRIPLE +#define AMDGCN_TRIPLE amdgcn-amd-amdhsa-opencl +#endif + #if defined(WITH_LIGHTNING_COMPILER) static std::string llvmBin_(amd::Os::getEnvironment("LLVM_BIN")); #endif // defined(WITH_LIGHTNING_COMPILER) @@ -158,7 +164,7 @@ bool HSAILProgram::compileImpl_LC(const std::string& sourceCode, std::ofstream f(options->getDumpFileName(".cl").c_str(), std::ios::trunc); if (f.is_open()) { f << "/* Compiler options:\n" - "-c -emit-llvm -target amdgcn-amd-amdhsa-opencl -x cl " + "-c -emit-llvm -target " STRING(AMDGCN_TRIPLE) " -x cl " << driverOptions << " -include opencl-c.h " << "\n*/\n\n" << sourceCode;