From e52e05fe565a087b8e44d90711bc04357f28f2df Mon Sep 17 00:00:00 2001
From: foreman
Date: Mon, 12 Sep 2016 17:30:21 -0400
Subject: [PATCH] P4 to Git Change 1313477 by lmoriche@lmoriche_opencl_dev on
2016/09/12 17:22:37
SWDEV-94610 - Split the HSAILProgram::hsailOptions into preprocessorOptions amd codegenOptions. Pass the codegenOptions to the IR->ISA stage (linkImpl).
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccompiler.cpp#15 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.cpp#31 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.hpp#13 edit
[ROCm/clr commit: 64ed800f46c9902e89efb27691e1464919bcc8b1]
---
.../runtime/device/rocm/roccompiler.cpp | 7 +--
.../rocclr/runtime/device/rocm/rocprogram.cpp | 47 +++++++++++--------
.../rocclr/runtime/device/rocm/rocprogram.hpp | 3 +-
3 files changed, 34 insertions(+), 23 deletions(-)
diff --git a/projects/clr/rocclr/runtime/device/rocm/roccompiler.cpp b/projects/clr/rocclr/runtime/device/rocm/roccompiler.cpp
index db77254aaa..e29adf0333 100644
--- a/projects/clr/rocclr/runtime/device/rocm/roccompiler.cpp
+++ b/projects/clr/rocclr/runtime/device/rocm/roccompiler.cpp
@@ -181,7 +181,7 @@ HSAILProgram::compileImpl_LC(
driverOptions.append(" -include-pch " + pch->Name());
driverOptions.append(" -Xclang -fno-validate-pch");
- driverOptions.append(hsailOptions(options));
+ driverOptions.append(preprocessorOptions(options));
if (clVer >= 200) {
std::stringstream opts;
//Add only for CL2.0 and later
@@ -197,7 +197,7 @@ HSAILProgram::compileImpl_LC(
}
// Tokenize the options string into a vector of strings
- std::istringstream istrstr(driverOptions);
+ std::istringstream istrstr(driverOptions + codegenOptions(options));
std::istream_iterator sit(istrstr), end;
std::vector params(sit, end);
@@ -347,7 +347,8 @@ HSAILProgram::compileImpl(
}
//Compile source to IR
- this->compileOptions_.append(hsailOptions(options));
+ this->compileOptions_.append(preprocessorOptions(options));
+ this->compileOptions_.append(codegenOptions(options));
errorCode = g_complibApi._aclCompile(device().compiler(),
binaryElf_,
diff --git a/projects/clr/rocclr/runtime/device/rocm/rocprogram.cpp b/projects/clr/rocclr/runtime/device/rocm/rocprogram.cpp
index 7e3a94d1c1..ee4417db4f 100644
--- a/projects/clr/rocclr/runtime/device/rocm/rocprogram.cpp
+++ b/projects/clr/rocclr/runtime/device/rocm/rocprogram.cpp
@@ -914,7 +914,7 @@ HSAILProgram::linkImpl_LC(amd::option::Options *options)
codegenOptions.append(" ").append(optLevel.str());
// Tokenize the options string into a vector of strings
- std::istringstream strstr(codegenOptions);
+ std::istringstream strstr(codegenOptions + this->codegenOptions(options));
std::istream_iterator sit(strstr), end;
std::vector params(sit, end);
@@ -1141,7 +1141,8 @@ HSAILProgram::linkImpl(amd::option::Options *options)
return false;
}
#else // !defined(WITH_LIGHTNING_COMPILER)
- std::string curOptions = options->origOptionStr + hsailOptions(options);
+ std::string curOptions = options->origOptionStr
+ + preprocessorOptions(options) + commonOptions(options);
errorCode = g_complibApi._aclCompile(device().compiler(), binaryElf_,
curOptions.c_str(), continueCompileFrom, ACL_TYPE_CG, logFunction);
buildLog_ += g_complibApi._aclGetCompilerLog(device().compiler());
@@ -1433,41 +1434,49 @@ HSAILProgram::releaseClBinary()
}
std::string
-HSAILProgram::hsailOptions(amd::option::Options* options)
+HSAILProgram::codegenOptions(amd::option::Options* options)
{
- std::string hsailOptions;
+ std::string optionsStr;
+
+ if (dev().deviceInfo().gfxipVersion_ < 900) {
+ optionsStr.append(" -cl-denorms-are-zero");
+ }
+
+ //check if the host is 64 bit or 32 bit
+ LP64_ONLY(optionsStr.append(" -m64"));
+
+ return optionsStr;
+}
+
+std::string
+HSAILProgram::preprocessorOptions(amd::option::Options* options)
+{
+ std::string optionsStr;
//Set options for the standard device specific options
- hsailOptions.append(" -D__AMD__");
+ optionsStr.append(" -D__AMD__");
int major, minor;
::sscanf(device().info().version_, "OpenCL %d.%d ", &major, &minor);
std::stringstream ss;
ss << " -D__OPENCL_VERSION__=" << (major * 100 + minor * 10);
- hsailOptions.append(ss.str());
+ optionsStr.append(ss.str());
if (device().info().imageSupport_ && options->oVariables->ImageSupport) {
- hsailOptions.append(" -D__IMAGE_SUPPORT__");
+ optionsStr.append(" -D__IMAGE_SUPPORT__");
}
//This is just for legacy compiler code
// All our devices support these options now
if (options->oVariables->FastFMA) {
- hsailOptions.append(" -DFP_FAST_FMA");
+ optionsStr.append(" -DFP_FAST_FMA");
}
if (options->oVariables->FastFMAF) {
- hsailOptions.append(" -DFP_FAST_FMAF");
+ optionsStr.append(" -DFP_FAST_FMAF");
}
- if (dev().deviceInfo().gfxipVersion_ < 900) {
- hsailOptions.append(" -cl-denorms-are-zero");
- }
-
- //check if the host is 64 bit or 32 bit
- LP64_ONLY(hsailOptions.append(" -m64"));
-
//Now append each extension supported by the device
// one by one
std::string token;
@@ -1481,11 +1490,11 @@ HSAILProgram::hsailOptions(amd::option::Options* options)
if (options->oVariables->CLStd[2] >= '2'
&& token == "cl_khr_depth_images") continue;
#endif // defined(WITH_LIGHTHNING_COMPILER)
- hsailOptions.append(" -D");
- hsailOptions.append(token);
+ optionsStr.append(" -D");
+ optionsStr.append(token);
}
}
- return hsailOptions;
+ return optionsStr;
}
} // namespace roc
diff --git a/projects/clr/rocclr/runtime/device/rocm/rocprogram.hpp b/projects/clr/rocclr/runtime/device/rocm/rocprogram.hpp
index b5067873b1..b5780a484e 100644
--- a/projects/clr/rocclr/runtime/device/rocm/rocprogram.hpp
+++ b/projects/clr/rocclr/runtime/device/rocm/rocprogram.hpp
@@ -158,7 +158,8 @@ private:
//! Returns all the options to be appended while passing to the
//compiler
- std::string hsailOptions(amd::option::Options* options);
+ std::string preprocessorOptions(amd::option::Options* options);
+ std::string codegenOptions(amd::option::Options* options);
// aclBinary and aclCompiler - for the compiler library
aclBinary* binaryElf_; //!< Binary for the new compiler library