From cb4e7b6be6159e94d2d66d8c3cf6f0c754e12c54 Mon Sep 17 00:00:00 2001
From: foreman
Date: Wed, 28 Aug 2019 18:09:33 -0400
Subject: [PATCH] P4 to Git Change 1990620 by gandryey@gera-win10 on 2019/08/28
18:04:54
SWDEV-200422 - Teamcity built OpenCL ignores all options from LC backend
- Disable default arguments for ParseAllOptions() to avoid incorrect values
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#609 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/program.cpp#104 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/program.hpp#48 edit
---
rocclr/runtime/device/gpu/gpudevice.cpp | 5 ++-
rocclr/runtime/platform/program.cpp | 46 +++++++++++++++----------
rocclr/runtime/platform/program.hpp | 2 +-
3 files changed, 32 insertions(+), 21 deletions(-)
diff --git a/rocclr/runtime/device/gpu/gpudevice.cpp b/rocclr/runtime/device/gpu/gpudevice.cpp
index 2ed35fef6c..3a4a618067 100644
--- a/rocclr/runtime/device/gpu/gpudevice.cpp
+++ b/rocclr/runtime/device/gpu/gpudevice.cpp
@@ -252,7 +252,10 @@ bool NullDevice::isHsailProgram(amd::option::Options* options) {
isInputOptions = true;
}
amd::option::Options parsedOptions;
- if (!amd::Program::ParseAllOptions("", parsedOptions)) {
+ constexpr bool OptionChangable = true;
+ constexpr bool LinkOptsOnly = false;
+ constexpr bool IsLC = false;
+ if (!amd::Program::ParseAllOptions("", parsedOptions, OptionChangable, LinkOptsOnly, IsLC)) {
return NULL;
}
optvec.push_back(&parsedOptions);
diff --git a/rocclr/runtime/platform/program.cpp b/rocclr/runtime/platform/program.cpp
index 41249a211e..9e86c3309d 100644
--- a/rocclr/runtime/platform/program.cpp
+++ b/rocclr/runtime/platform/program.cpp
@@ -155,7 +155,8 @@ cl_int Program::addDeviceProgram(Device& device, const void* image, size_t lengt
// load the compiler options from the binary if it is not provided
std::string sBinOptions = program->compileOptions();
if (!sBinOptions.empty() && emptyOptions) {
- if (!amd::option::parseAllOptions(sBinOptions, *options, false, isLC())) {
+ if (!amd::option::parseAllOptions(sBinOptions, *options, false,
+ device.settings().useLightning_)) {
programLog_ = options->optionsLog();
LogError("Parsing compilation options from binary failed.");
return CL_INVALID_COMPILER_OPTIONS;
@@ -205,12 +206,6 @@ cl_int Program::compile(const std::vector& devices, size_t numHeaders,
}
remove_g_option(cppstr);
}
- option::Options parsedOptions;
- if (!ParseAllOptions(cppstr, parsedOptions, optionChangable)) {
- programLog_ = parsedOptions.optionsLog();
- LogError("Parsing compile options failed.");
- return CL_INVALID_COMPILER_OPTIONS;
- }
std::vector headers(numHeaders);
for (size_t i = 0; i < numHeaders; ++i) {
@@ -220,6 +215,14 @@ cl_int Program::compile(const std::vector& devices, size_t numHeaders,
// Compile the program programs associated with the given devices.
for (const auto& it : devices) {
+ option::Options parsedOptions;
+ constexpr bool LinkOptsOnly = false;
+ if (!ParseAllOptions(cppstr, parsedOptions, optionChangable, LinkOptsOnly,
+ it->settings().useLightning_)) {
+ programLog_ = parsedOptions.optionsLog();
+ LogError("Parsing compile options failed.");
+ return CL_INVALID_COMPILER_OPTIONS;
+ }
device::Program* devProgram = getDeviceProgram(*it);
if (devProgram == NULL) {
const binary_t& bin = binary(*it);
@@ -290,15 +293,17 @@ cl_int Program::link(const std::vector& devices, size_t numInputs,
}
remove_g_option(cppstr);
}
- option::Options parsedOptions;
- if (!ParseAllOptions(cppstr, parsedOptions, optionChangable, true)) {
- programLog_ = parsedOptions.optionsLog();
- LogError("Parsing link options failed.");
- return CL_INVALID_LINKER_OPTIONS;
- }
// Link the program programs associated with the given devices.
for (const auto& it : devices) {
+ option::Options parsedOptions;
+ constexpr bool LinkOptsOnly = true;
+ if (!ParseAllOptions(cppstr, parsedOptions, optionChangable, LinkOptsOnly,
+ it->settings().useLightning_)) {
+ programLog_ = parsedOptions.optionsLog();
+ LogError("Parsing link options failed.");
+ return CL_INVALID_LINKER_OPTIONS;
+ }
// find the corresponding device program in each input program
std::vector inputDevPrograms(numInputs);
bool found = false;
@@ -482,15 +487,18 @@ cl_int Program::build(const std::vector& devices, const char* options,
}
remove_g_option(cppstr);
}
- option::Options parsedOptions;
- if (!ParseAllOptions(cppstr, parsedOptions, optionChangable)) {
- programLog_ = parsedOptions.optionsLog();
- LogError("Parsing compile options failed.");
- return CL_INVALID_COMPILER_OPTIONS;
- }
// Build the program programs associated with the given devices.
for (const auto& it : devices) {
+ option::Options parsedOptions;
+ constexpr bool LinkOptsOnly = false;
+ if (!ParseAllOptions(cppstr, parsedOptions, optionChangable, LinkOptsOnly,
+ it->settings().useLightning_)) {
+ programLog_ = parsedOptions.optionsLog();
+ LogError("Parsing compile options failed.");
+ return CL_INVALID_COMPILER_OPTIONS;
+ }
+
device::Program* devProgram = getDeviceProgram(*it);
if (devProgram == NULL) {
const binary_t& bin = binary(*it);
diff --git a/rocclr/runtime/platform/program.hpp b/rocclr/runtime/platform/program.hpp
index 2e1ccd39f2..b459e45409 100644
--- a/rocclr/runtime/platform/program.hpp
+++ b/rocclr/runtime/platform/program.hpp
@@ -182,7 +182,7 @@ class Program : public RuntimeObject {
static int GetOclCVersion(const char* clVer);
bool static ParseAllOptions(const std::string& options, option::Options& parsedOptions,
- bool optionChangable = true, bool linkOptsOnly = false, bool isLC = false);
+ bool optionChangable, bool linkOptsOnly, bool isLC);
void setVarInfoCallBack(VarInfoCallback callback) {
varcallback = callback;