From 2cea61199aa14969090d5470b7a23259177bbdab Mon Sep 17 00:00:00 2001
From: foreman
Date: Tue, 23 May 2017 10:30:44 -0400
Subject: [PATCH] P4 to Git Change 1412181 by yaxunl@yaxunl_stg_win50 on
2017/05/20 20:14:34
SWDEV-121585 - [OCL-LC-ROCm] Merge GitHub pull requests
- Merged https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime/pull/8
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/CMakeLists.txt#4 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccompiler.cpp#33 edit
---
rocclr/runtime/CMakeLists.txt | 7 +++++++
rocclr/runtime/device/rocm/roccompiler.cpp | 8 +++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
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;