P4 to Git Change 1599194 by gandryey@gera-w8 on 2018/08/28 18:38:33
SWDEV-79445 - OCL generic changes and code clean-up
- Move printf setup in the kernels to the abstraction layer
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/devkernel.cpp#2 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/devkernel.hpp#2 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpukernel.cpp#329 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpukernel.hpp#131 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprintf.cpp#47 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprintf.hpp#16 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.cpp#238 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.hpp#71 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palkernel.cpp#62 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palkernel.hpp#21 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprintf.cpp#10 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprintf.hpp#4 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rockernel.cpp#41 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rockernel.hpp#25 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprintf.cpp#11 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprintf.hpp#6 edit
[ROCm/clr commit: ef83d84899]
This commit is contained in:
@@ -68,73 +68,6 @@ bool HSAILKernel::aqlCreateHWInfo(amd::hsa::loader::Symbol* sym) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void HSAILKernel::initPrintf(const aclPrintfFmt* aclPrintf) {
|
||||
PrintfInfo info;
|
||||
uint index = 0;
|
||||
for (; aclPrintf->struct_size != 0; aclPrintf++) {
|
||||
index = aclPrintf->ID;
|
||||
if (printf_.size() <= index) {
|
||||
printf_.resize(index + 1);
|
||||
}
|
||||
std::string pfmt = aclPrintf->fmtStr;
|
||||
info.fmtString_.clear();
|
||||
bool need_nl = true;
|
||||
for (size_t pos = 0; pos < pfmt.size(); ++pos) {
|
||||
char symbol = pfmt[pos];
|
||||
need_nl = true;
|
||||
if (symbol == '\\') {
|
||||
// Rest of the C escape sequences (e.g. \') are handled correctly
|
||||
// by the MDParser, we are not sure exactly how!
|
||||
switch (pfmt[pos + 1]) {
|
||||
case 'a':
|
||||
pos++;
|
||||
symbol = '\a';
|
||||
break;
|
||||
case 'b':
|
||||
pos++;
|
||||
symbol = '\b';
|
||||
break;
|
||||
case 'f':
|
||||
pos++;
|
||||
symbol = '\f';
|
||||
break;
|
||||
case 'n':
|
||||
pos++;
|
||||
symbol = '\n';
|
||||
need_nl = false;
|
||||
break;
|
||||
case 'r':
|
||||
pos++;
|
||||
symbol = '\r';
|
||||
break;
|
||||
case 'v':
|
||||
pos++;
|
||||
symbol = '\v';
|
||||
break;
|
||||
case '7':
|
||||
if (pfmt[pos + 2] == '2') {
|
||||
pos += 2;
|
||||
symbol = '\72';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
info.fmtString_.push_back(symbol);
|
||||
}
|
||||
if (need_nl) {
|
||||
info.fmtString_ += "\n";
|
||||
}
|
||||
uint32_t* tmp_ptr = const_cast<uint32_t*>(aclPrintf->argSizes);
|
||||
for (uint i = 0; i < aclPrintf->numSizes; i++, tmp_ptr++) {
|
||||
info.arguments_.push_back(*tmp_ptr);
|
||||
}
|
||||
printf_[index] = info;
|
||||
info.arguments_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
HSAILKernel::HSAILKernel(std::string name, HSAILProgram* prog, std::string compileOptions)
|
||||
: device::Kernel(name),
|
||||
compileOptions_(compileOptions),
|
||||
@@ -247,7 +180,7 @@ bool HSAILKernel::init(amd::hsa::loader::Symbol* sym, bool finalize) {
|
||||
}
|
||||
|
||||
// Set the PrintfList
|
||||
initPrintf(reinterpret_cast<aclPrintfFmt*>(aclPrintfList));
|
||||
InitPrintf(reinterpret_cast<aclPrintfFmt*>(aclPrintfList));
|
||||
delete[] aclPrintfList;
|
||||
}
|
||||
|
||||
@@ -561,96 +494,6 @@ const LightningProgram& LightningKernel::prog() const {
|
||||
return reinterpret_cast<const LightningProgram&>(prog_);
|
||||
}
|
||||
|
||||
void LightningKernel::initPrintf(const std::vector<std::string>& printfInfoStrings) {
|
||||
for (auto str : printfInfoStrings) {
|
||||
std::vector<std::string> tokens;
|
||||
|
||||
size_t end, pos = 0;
|
||||
do {
|
||||
end = str.find_first_of(':', pos);
|
||||
tokens.push_back(str.substr(pos, end - pos));
|
||||
pos = end + 1;
|
||||
} while (end != std::string::npos);
|
||||
|
||||
if (tokens.size() < 2) {
|
||||
LogPrintfWarning("Invalid PrintInfo string: \"%s\"", str.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
pos = 0;
|
||||
size_t printfInfoID = std::stoi(tokens[pos++]);
|
||||
if (printf_.size() <= printfInfoID) {
|
||||
printf_.resize(printfInfoID + 1);
|
||||
}
|
||||
PrintfInfo& info = printf_[printfInfoID];
|
||||
|
||||
size_t numSizes = std::stoi(tokens[pos++]);
|
||||
end = pos + numSizes;
|
||||
|
||||
// ensure that we have the correct number of tokens
|
||||
if (tokens.size() < end + 1 /*last token is the fmtString*/) {
|
||||
LogPrintfWarning("Invalid PrintInfo string: \"%s\"", str.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
// push the argument sizes
|
||||
while (pos < end) {
|
||||
info.arguments_.push_back(std::stoi(tokens[pos++]));
|
||||
}
|
||||
|
||||
// FIXME: We should not need this! [
|
||||
std::string& fmt = tokens[pos];
|
||||
bool need_nl = true;
|
||||
|
||||
for (pos = 0; pos < fmt.size(); ++pos) {
|
||||
char symbol = fmt[pos];
|
||||
need_nl = true;
|
||||
if (symbol == '\\') {
|
||||
switch (fmt[pos + 1]) {
|
||||
case 'a':
|
||||
pos++;
|
||||
symbol = '\a';
|
||||
break;
|
||||
case 'b':
|
||||
pos++;
|
||||
symbol = '\b';
|
||||
break;
|
||||
case 'f':
|
||||
pos++;
|
||||
symbol = '\f';
|
||||
break;
|
||||
case 'n':
|
||||
pos++;
|
||||
symbol = '\n';
|
||||
need_nl = false;
|
||||
break;
|
||||
case 'r':
|
||||
pos++;
|
||||
symbol = '\r';
|
||||
break;
|
||||
case 'v':
|
||||
pos++;
|
||||
symbol = '\v';
|
||||
break;
|
||||
case '7':
|
||||
if (fmt[pos + 2] == '2') {
|
||||
pos += 2;
|
||||
symbol = '\72';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
info.fmtString_.push_back(symbol);
|
||||
}
|
||||
if (need_nl) {
|
||||
info.fmtString_ += "\n";
|
||||
}
|
||||
// ]
|
||||
}
|
||||
}
|
||||
|
||||
static const KernelMD* FindKernelMetadata(const CodeObjectMD* programMD, const std::string& name) {
|
||||
for (const KernelMD& kernelMD : programMD->mKernels) {
|
||||
if (kernelMD.mName == name) {
|
||||
@@ -704,7 +547,7 @@ bool LightningKernel::init(amd::hsa::loader::Symbol* symbol) {
|
||||
return false;
|
||||
}
|
||||
|
||||
initPrintf(programMD->mPrintf);
|
||||
InitPrintf(programMD->mPrintf);
|
||||
|
||||
/*FIXME_lmoriche:
|
||||
size_t sizeOfWavesPerSimdHint = sizeof(workGroupInfo_.wavesPerSimdHint_);
|
||||
|
||||
Reference in New Issue
Block a user