P4 to Git Change 1316785 by lmoriche@lmoriche_opencl_dev on 2016/09/20 20:47:40

SWDEV-94610 - Add gfx700 to the list of suported targets in HSAILProgram::linkImpl_LC. When dumping the source (-save-temps), print the options actually sent to clang as well as the options passed to OpenCL.

Affected files ...

... //depot/stg/opencl/drivers/opencl/library/build/Makefile.library#56 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/amdgpu_metadata.cpp#5 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccompiler.cpp#18 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.cpp#36 edit


[ROCm/clr commit: 383e97425b]
Šī revīzija ir iekļauta:
foreman
2016-09-20 20:53:50 -04:00
vecāks 69fc4580e8
revīzija 70acf47d09
3 mainīti faili ar 70 papildinājumiem un 62 dzēšanām
@@ -211,8 +211,11 @@ namespace code {
if (kind == Image || kind == Pipe) {
out << " Access: " << AccessQualToString(accQual);
}
if (kind == GlobalBuffer || kind == DynamicSharedPointer) {
out
<< " Address: " << (unsigned) addrQual;
}
out
<< " Address: " << (unsigned) addrQual
<< " Size: " << size
<< " Align: " << align;
if (kind == DynamicSharedPointer) {
@@ -55,17 +55,6 @@ HSAILProgram::compileImpl_LC(
std::auto_ptr<Compiler> C(newCompilerInstance());
std::vector<Data*> inputs;
if (options->isDumpFlagSet(amd::option::DUMP_CL)) {
std::ofstream f(options->getDumpFileName(".cl").c_str(), std::ios::trunc);
if(f.is_open()) {
f << "/* Compiler options:\n" << options->origOptionStr
<< "\n*/\n\n" << sourceCode;
} else {
buildLog_ +=
"Warning: opening the file to dump the OpenCL source failed.\n";
}
}
Data* input = C->NewBufferReference(DT_CL,
sourceCode.c_str(), sourceCode.length());
if (input == NULL) {
@@ -147,20 +136,50 @@ HSAILProgram::compileImpl_LC(
//FIXME_Nikolay: the program manager should be setting the language
//driverOptions.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.
driverOptions.append(" -Xclang -cl-std=").append(options->oVariables->CLStd);
driverOptions.append(" -cl-std=").append(options->oVariables->CLStd);
// Set the -O#
std::ostringstream optLevel;
optLevel << " -O" << options->oVariables->OptLevel;
driverOptions.append(optLevel.str());
//FIXME_lmoriche: has the CL option been validated?
uint clVer = (options->oVariables->CLStd[2] - '0') * 100
uint clcStd = (options->oVariables->CLStd[2] - '0') * 100
+ (options->oVariables->CLStd[4] - '0') * 10;
driverOptions.append(preprocessorOptions(options));
Buffer* output = C->NewBuffer(DT_LLVM_BC);
if (output == NULL) {
buildLog_ += "Error while creating buffer for the LLVM bitcode";
return false;
}
// Set fp32-denormals and fp64-denormals
bool fp32Denormals = !options->oVariables->DenormsAreZero
&& dev().deviceInfo().gfxipVersion_ >= 900;
driverOptions.append(" -Xclang -target-feature -Xclang ");
driverOptions.append(fp32Denormals ? "+" : "-")
.append("fp32-denormals,+fp64-denormals");
if (options->isDumpFlagSet(amd::option::DUMP_CL)) {
std::ofstream f(options->getDumpFileName(".cl").c_str(), std::ios::trunc);
if(f.is_open()) {
f << "/* Original options: " << options->origOptionStr
<< "\n Generated options:\n"
<< " -c -emit-llvm -target amdgcn--amdhsa -x cl"
<< " -include opencl-c.h " << driverOptions
<< "\n*/\n\n" << sourceCode;
} else {
buildLog_ +=
"Warning: opening the file to dump the OpenCL source failed.\n";
}
}
std::pair<const void*, size_t> hdr;
switch(clVer) {
switch(clcStd) {
case 120:
hdr = std::make_pair(opencl1_2_c_amdgcn, opencl1_2_c_amdgcn_size);
break;
@@ -181,29 +200,6 @@ HSAILProgram::compileImpl_LC(
driverOptions.append(" -include-pch " + pch->Name());
driverOptions.append(" -Xclang -fno-validate-pch");
driverOptions.append(preprocessorOptions(options));
if (clVer >= 200) {
std::stringstream opts;
//Add only for CL2.0 and later
opts << " -D" << "CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE="
<< device().info().maxGlobalVariableSize_;
driverOptions.append(opts.str());
}
Buffer* output = C->NewBuffer(DT_LLVM_BC);
if (output == NULL) {
buildLog_ += "Error while creating buffer for the LLVM bitcode";
return false;
}
// Set fp32-denormals and fp64-denormals
bool fp32Denormals = !options->oVariables->DenormsAreZero
&& dev().deviceInfo().gfxipVersion_ >= 900;
driverOptions.append(" -Xclang -target-feature -Xclang ");
driverOptions.append(fp32Denormals ? "+" : "-")
.append("fp32-denormals,+fp64-denormals");
// Tokenize the options string into a vector of strings
std::istringstream istrstr(driverOptions);
std::istream_iterator<std::string> sit(istrstr), end;
@@ -800,28 +800,25 @@ HSAILProgram::linkImpl_LC(amd::option::Options *options)
// open the control functions
std::pair<const void*, size_t> isa_version;
switch (dev().deviceInfo().gfxipVersion_) {
case 701:
isa_version = std::make_pair(
case 700: isa_version = std::make_pair(
oclc_isa_version_700_amdgcn, oclc_isa_version_700_amdgcn_size);
break;
case 701: isa_version = std::make_pair(
oclc_isa_version_701_amdgcn, oclc_isa_version_701_amdgcn_size);
break;
case 800:
isa_version = std::make_pair(
case 800: isa_version = std::make_pair(
oclc_isa_version_800_amdgcn, oclc_isa_version_800_amdgcn_size);
break;
case 801:
isa_version = std::make_pair(
case 801: isa_version = std::make_pair(
oclc_isa_version_801_amdgcn, oclc_isa_version_801_amdgcn_size);
break;
case 802:
isa_version = std::make_pair(
case 802: isa_version = std::make_pair(
oclc_isa_version_802_amdgcn, oclc_isa_version_802_amdgcn_size);
break;
case 803:
isa_version = std::make_pair(
case 803: isa_version = std::make_pair(
oclc_isa_version_803_amdgcn, oclc_isa_version_803_amdgcn_size);
break;
case 810:
isa_version = std::make_pair(
case 810: isa_version = std::make_pair(
oclc_isa_version_810_amdgcn, oclc_isa_version_810_amdgcn_size);
break;
default:
@@ -919,9 +916,6 @@ HSAILProgram::linkImpl_LC(amd::option::Options *options)
}
}
std::ostringstream optLevel;
optLevel << "-O" << options->oVariables->OptLevel;
inputs.clear();
inputs.push_back(linked_bc);
@@ -938,6 +932,8 @@ HSAILProgram::linkImpl_LC(amd::option::Options *options)
codegenOptions.append(dev().deviceInfo().machineTarget_);
// Set the -O#
std::ostringstream optLevel;
optLevel << "-O" << options->oVariables->OptLevel;
codegenOptions.append(" ").append(optLevel.str());
// Tokenize the options string into a vector of strings
@@ -953,7 +949,7 @@ HSAILProgram::linkImpl_LC(amd::option::Options *options)
}
if (options->isDumpFlagSet(amd::option::DUMP_O)) {
std::ofstream f(options->getDumpFileName(".co").c_str(), std::ios::trunc);
std::ofstream f(options->getDumpFileName(".so").c_str(), std::ios::trunc);
if(f.is_open()) {
f.write(out_exec->Buf().data(), out_exec->Size());
} else {
@@ -1499,7 +1495,10 @@ HSAILProgram::preprocessorOptions(amd::option::Options* options)
//Set options for the standard device specific options
optionsStr.append(" -D__AMD__");
optionsStr.append(" -D__AMD__=1");
optionsStr.append(" -D__").append(device().info().name_).append("__=1");
optionsStr.append(" -D__").append(device().info().name_).append("=1");
int major, minor;
::sscanf(device().info().version_, "OpenCL %d.%d ", &major, &minor);
@@ -1509,16 +1508,27 @@ HSAILProgram::preprocessorOptions(amd::option::Options* options)
optionsStr.append(ss.str());
if (device().info().imageSupport_ && options->oVariables->ImageSupport) {
optionsStr.append(" -D__IMAGE_SUPPORT__");
optionsStr.append(" -D__IMAGE_SUPPORT__=1");
}
//This is just for legacy compiler code
// All our devices support these options now
if (options->oVariables->FastFMA) {
optionsStr.append(" -DFP_FAST_FMA");
optionsStr.append(" -DFP_FAST_FMA=1");
}
if (options->oVariables->FastFMAF) {
optionsStr.append(" -DFP_FAST_FMAF");
optionsStr.append(" -DFP_FAST_FMAF=1");
}
uint clcStd = (options->oVariables->CLStd[2] - '0') * 100
+ (options->oVariables->CLStd[4] - '0') * 10;
if (clcStd >= 200) {
std::stringstream opts;
//Add only for CL2.0 and later
opts << " -D" << "CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE="
<< device().info().maxGlobalVariableSize_;
optionsStr.append(opts.str());
}
//Now append each extension supported by the device
@@ -1534,8 +1544,7 @@ HSAILProgram::preprocessorOptions(amd::option::Options* options)
if (options->oVariables->CLStd[2] >= '2'
&& token == "cl_khr_depth_images") continue;
#endif // defined(WITH_LIGHTHNING_COMPILER)
optionsStr.append(" -D");
optionsStr.append(token);
optionsStr.append(" -D").append(token).append("=1");
}
}
return optionsStr;