[GPU] Improve opencl compile error message (#8032)

Show some details on error message by parsing "error" in the message.
This commit is contained in:
Mingyu Kim 2021-10-18 15:44:46 +09:00 committed by GitHub
parent ae2913d3b5
commit 99544d2a43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -377,8 +377,24 @@ void kernels_cache::build_batch(const engine& build_engine, const batch_program&
if (!err_log.empty()) {
GPU_DEBUG_GET_INSTANCE(debug_config);
GPU_DEBUG_IF(debug_config->verbose) {
std::cout << "-------- OpenCL build error" << std::endl;
std::cout << err_log << std::endl;
std::cout << "-------- End of OpenCL build error" << std::endl;
}
std::stringstream err_ss(err_log);
std::string line;
int cnt = 0;
while (std::getline(err_ss, line, '\n')) {
if (line.find("error") != std::string::npos)
cnt = 5;
cnt--;
if (cnt > 0)
std::cout << line << std::endl;
else if (cnt == 0)
std::cout << "...." << std::endl;
}
throw std::runtime_error("Program build failed. You may enable OCL source dump to see the error log.\n");
}
}