P4 to Git Change 1305360 by lmoriche@lmoriche_opencl_dev on 2016/08/21 17:34:39
SWDEV-94640 - Set the O# level and cl-std from the command args or default settings.
Select the correct header (CL1.2/C2.0) from the given cl-std.
Reorder the linked libraries in reverse order of dependency (was failing linking).
Make the built-in library objects depend on the pre-compiled header.
Disable the timestamp on the pre-compiled header.
Disable image support reporting.
Affected files ...
... //depot/stg/opencl/drivers/opencl/make/amdgcn.git/headers/build/Makefile.headers#7 edit
... //depot/stg/opencl/drivers/opencl/make/amdgcn.git/irif/build/Makefile.irif#4 edit
... //depot/stg/opencl/drivers/opencl/make/amdgcn.git/ockl/build/Makefile.ockl#5 edit
... //depot/stg/opencl/drivers/opencl/make/amdgcn.git/oclc/build/Makefile.oclc#5 edit
... //depot/stg/opencl/drivers/opencl/make/amdgcn.git/ocml/build/Makefile.ocml#5 edit
... //depot/stg/opencl/drivers/opencl/make/amdgcn.git/opencl/build/Makefile.opencl#6 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccompiler.cpp#8 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#10 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.cpp#11 edit
[ROCm/clr commit: 9674e8eb01]
Αυτή η υποβολή περιλαμβάνεται σε:
@@ -40,14 +40,17 @@ HSAILProgram::compileImpl_LC(const std::string& sourceCode,
|
|||||||
const char** headerIncludeNames,
|
const char** headerIncludeNames,
|
||||||
amd::option::Options* options)
|
amd::option::Options* options)
|
||||||
{
|
{
|
||||||
std::vector<amd::opencl_driver::Data*> inputs;
|
using namespace amd::opencl_driver;
|
||||||
amd::opencl_driver::Data* src = device().compiler()->NewBufferReference(
|
std::vector<Data*> inputs;
|
||||||
amd::opencl_driver::DT_CL,sourceCode.c_str(),
|
|
||||||
sourceCode.length());
|
Data* src = device().compiler()->NewBufferReference(DT_CL,
|
||||||
|
sourceCode.c_str(), sourceCode.length());
|
||||||
|
|
||||||
if (src == NULL) {
|
if (src == NULL) {
|
||||||
buildLog_ += "Error while creating data from source code";
|
buildLog_ += "Error while creating data from source code";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inputs.push_back(src);
|
inputs.push_back(src);
|
||||||
|
|
||||||
//Find the temp folder for the OS
|
//Find the temp folder for the OS
|
||||||
@@ -94,9 +97,8 @@ HSAILProgram::compileImpl_LC(const std::string& sourceCode,
|
|||||||
f.write(headers[i]->c_str(), headers[i]->length());
|
f.write(headers[i]->c_str(), headers[i]->length());
|
||||||
f.close();
|
f.close();
|
||||||
|
|
||||||
amd::opencl_driver::Data* inc = device().compiler()->NewFileReference(
|
Data* inc = device().compiler()->NewFileReference(DT_CL_HEADER,
|
||||||
amd::opencl_driver::DT_CL_HEADER,
|
headerFileNames[i]);
|
||||||
headerFileNames[i]);
|
|
||||||
inputs.push_back(inc);
|
inputs.push_back(inc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,30 +110,53 @@ HSAILProgram::compileImpl_LC(const std::string& sourceCode,
|
|||||||
compileOptions_.append(tempFolder);
|
compileOptions_.append(tempFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add only for CL2.0 and later
|
const char* xLang = options->oVariables->XLang;
|
||||||
if (options->oVariables->CLStd[2] >= '2') {
|
if (xLang != NULL && strcmp(xLang, "cl")) {
|
||||||
|
buildLog_ += "Unsupported OpenCL language.\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
//FIXME_Nikolay: the program manager should be setting the language
|
||||||
|
//compileOptions_.append(" -x cl");
|
||||||
|
//FIXME_Nikolay: the program manager shouls be setting the cl-std. -Xclang
|
||||||
|
//is not necessary, we add it to overridde the flag set in the comp driver.
|
||||||
|
compileOptions_.append(" -Xclang -cl-std=").append(options->oVariables->CLStd);
|
||||||
|
|
||||||
|
std::ostringstream optLevel;
|
||||||
|
optLevel << " -O" << options->oVariables->OptLevel;
|
||||||
|
compileOptions_.append(optLevel.str());
|
||||||
|
|
||||||
|
//FIXME_lmoriche: has the CL option been validated?
|
||||||
|
uint clVer = (options->oVariables->CLStd[2] - '0') * 100
|
||||||
|
+ (options->oVariables->CLStd[4] - '0') * 10;
|
||||||
|
|
||||||
|
std::pair<const void*, size_t> hdr;
|
||||||
|
switch(clVer) {
|
||||||
|
case 120: hdr = std::make_pair(opencl1_2_c_amdgcn, opencl1_2_c_amdgcn_size); break;
|
||||||
|
case 200: hdr = std::make_pair(opencl2_0_c_amdgcn, opencl2_0_c_amdgcn_size); break;
|
||||||
|
default:
|
||||||
|
buildLog_ += "Unsupported requested OpenCL C version (-cl-std).\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
File* pch = device().compiler()->NewTempFile(DT_CL_HEADER);
|
||||||
|
if (pch == NULL || !pch->WriteData((const char*) hdr.first, hdr.second)) {
|
||||||
|
buildLog_ += "Error while opening the opencl-c header ";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
compileOptions_.append(" -Xclang -include-pch -Xclang " + pch->Name());
|
||||||
|
compileOptions_.append(" -Xclang -fno-validate-pch");
|
||||||
|
|
||||||
|
compileOptions_.append(hsailOptions());
|
||||||
|
if (clVer >= 200) {
|
||||||
std::stringstream opts;
|
std::stringstream opts;
|
||||||
|
//Add only for CL2.0 and later
|
||||||
opts << " -D" << "CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE="
|
opts << " -D" << "CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE="
|
||||||
<< device().info().maxGlobalVariableSize_;
|
<< device().info().maxGlobalVariableSize_;
|
||||||
compileOptions_.append(opts.str());
|
compileOptions_.append(opts.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
amd::opencl_driver::File* pch = device().compiler()->NewTempFile(
|
Buffer* output = device().compiler()->NewBuffer(DT_LLVM_BC);
|
||||||
amd::opencl_driver::DT_CL_HEADER);
|
|
||||||
if (pch == NULL || !pch->WriteData((const char*) opencl2_0_c_amdgcn,
|
|
||||||
opencl2_0_c_amdgcn_size)) {
|
|
||||||
buildLog_ += "Error while opening the opencl-c header ";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME_lmoriche: Force OpenCL-C 2.0, since the built-ins are built that way.
|
|
||||||
compileOptions_.append(" -Xclang -cl-std=CL2.0");
|
|
||||||
compileOptions_.append(" -Xclang -include-pch -Xclang " + pch->Name());
|
|
||||||
compileOptions_.append(" -Xclang -fno-validate-pch");
|
|
||||||
|
|
||||||
compileOptions_.append(hsailOptions());
|
|
||||||
|
|
||||||
amd::opencl_driver::Buffer* output = device().compiler()->NewBuffer(amd::opencl_driver::DT_LLVM_BC);
|
|
||||||
if (output == NULL) {
|
if (output == NULL) {
|
||||||
buildLog_ += "Error while creating buffer for the LLVM bitcode";
|
buildLog_ += "Error while creating buffer for the LLVM bitcode";
|
||||||
return false;
|
return false;
|
||||||
@@ -146,8 +171,7 @@ HSAILProgram::compileImpl_LC(const std::string& sourceCode,
|
|||||||
bool ret = device().compiler()->CompileToLLVMBitcode(inputs, output, optionsvec);
|
bool ret = device().compiler()->CompileToLLVMBitcode(inputs, output, optionsvec);
|
||||||
buildLog_ += device().compiler()->Output().c_str();
|
buildLog_ += device().compiler()->Output().c_str();
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
buildLog_ += "Error while compiling \
|
buildLog_ += "Error while compiling opencl source: Compiling CL to IR";
|
||||||
opencl source: Compiling CL to IR";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -882,6 +882,9 @@ Device::populateOCLDeviceConstants()
|
|||||||
|
|
||||||
assert(HSA_EXTENSION_IMAGES < 8);
|
assert(HSA_EXTENSION_IMAGES < 8);
|
||||||
const bool image_is_supported =
|
const bool image_is_supported =
|
||||||
|
#if defined(WITH_LIGHTNING_COMPILER)
|
||||||
|
false && // FIXME_lmoriche: Enable this when the LC is ready.
|
||||||
|
#endif // defined(WITH_LIGHTNING_COMPILER)
|
||||||
((hsa_extensions[0] & (1 << HSA_EXTENSION_IMAGES)) != 0);
|
((hsa_extensions[0] & (1 << HSA_EXTENSION_IMAGES)) != 0);
|
||||||
if (image_is_supported) {
|
if (image_is_supported) {
|
||||||
// Images
|
// Images
|
||||||
|
|||||||
@@ -638,10 +638,10 @@ namespace roc {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inputs.push_back(irif_bc);
|
|
||||||
inputs.push_back(ocml_bc); // depends on irif
|
|
||||||
inputs.push_back(ockl_bc); // depends on irif
|
|
||||||
inputs.push_back(opencl_bc); // depends on oclm & ockl
|
inputs.push_back(opencl_bc); // depends on oclm & ockl
|
||||||
|
inputs.push_back(ockl_bc); // depends on irif
|
||||||
|
inputs.push_back(ocml_bc); // depends on irif
|
||||||
|
inputs.push_back(irif_bc);
|
||||||
|
|
||||||
// open the control functions
|
// open the control functions
|
||||||
std::pair<const void*, size_t> isa_version;
|
std::pair<const void*, size_t> isa_version;
|
||||||
@@ -734,6 +734,10 @@ namespace roc {
|
|||||||
optionsstr.append(" -mcpu=");
|
optionsstr.append(" -mcpu=");
|
||||||
optionsstr.append(dev().deviceInfo().machineTarget_);
|
optionsstr.append(dev().deviceInfo().machineTarget_);
|
||||||
|
|
||||||
|
std::ostringstream optLevel;
|
||||||
|
optLevel << " -O" << options->oVariables->OptLevel;
|
||||||
|
optionsstr.append(optLevel.str());
|
||||||
|
|
||||||
// Tokenize the options string into a vector of strings
|
// Tokenize the options string into a vector of strings
|
||||||
std::istringstream strstr(optionsstr);
|
std::istringstream strstr(optionsstr);
|
||||||
std::istream_iterator<std::string> sit(strstr), end;
|
std::istream_iterator<std::string> sit(strstr), end;
|
||||||
|
|||||||
Αναφορά σε νέο ζήτημα
Block a user