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
Этот коммит содержится в:
@@ -769,4 +769,161 @@ void Kernel::InitParameters(const aclArgData* aclArg, uint32_t argBufferSize) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(WITH_LIGHTNING_COMPILER)
|
||||
void Kernel::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";
|
||||
}
|
||||
// ]
|
||||
}
|
||||
}
|
||||
#endif // defined(WITH_LIGHTNING_COMPILER)
|
||||
#if defined(WITH_COMPILER_LIB) || !defined(WITH_LIGHTNING_COMPILER)
|
||||
void Kernel::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;
|
||||
bool need_nl = true;
|
||||
for (size_t pos = 0; pos < pfmt.size(); ++pos) {
|
||||
char symbol = pfmt[pos];
|
||||
need_nl = true;
|
||||
if (symbol == '\\') {
|
||||
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();
|
||||
}
|
||||
}
|
||||
#endif // defined(WITH_COMPILER_LIB)
|
||||
|
||||
}
|
||||
Ссылка в новой задаче
Block a user