MCPcopy Create free account
hub / github.com/ROCm/clr / trySubstObjFile

Method trySubstObjFile

rocclr/device/devprogram.cpp:1238–1285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1236}
1237
1238bool Program::trySubstObjFile(const char* SubstCfgFile, const std::string& sourceCode,
1239 const amd::option::Options* options) {
1240 std::string buffer;
1241 std::ostringstream str(buffer);
1242
1243 size_t srcHash = getOCLSourceHash(sourceCode);
1244 size_t optHash = getOCLOptionsHash(*options);
1245 auto substRes = getSubstBinFileName(SubstCfgFile, srcHash, optHash);
1246 if (substRes.first.empty()) {
1247 switch (substRes.second) {
1248 default:
1249 break;
1250 case 1:
1251 str << "Subst failure: cannot open config file " << SubstCfgFile << std::endl;
1252 break;
1253 }
1254 buildLog_ += str.str();
1255 return false;
1256 }
1257
1258 uint8_t* binary = nullptr;
1259 size_t binSize = 0;
1260 std::ifstream binFile(substRes.first, std::ios::binary | std::ios::ate);
1261 if (binFile.good()) {
1262 binSize = binFile.tellg();
1263 binFile.seekg(0, std::ios::beg);
1264 binary = new (std::nothrow) uint8_t[binSize];
1265 if (binary && !binFile.read(reinterpret_cast<char*>(binary), binSize)) {
1266 delete[] binary;
1267 binary = nullptr;
1268 }
1269 }
1270
1271 if (!binary) {
1272 buildStatus_ = CL_BUILD_ERROR;
1273 buildError_ = CL_BUILD_PROGRAM_FAILURE;
1274 str << "Subst failure: cannot read binary file " << substRes.first << '\n';
1275 } else {
1276 if (setKernels(binary, binSize)) {
1277 buildStatus_ = CL_BUILD_SUCCESS;
1278 buildError_ = 0;
1279 str << "Substituted program hash 0x" << std::setbase(16) << substRes.second << " with "
1280 << substRes.first << '\n';
1281 }
1282 }
1283 buildLog_ += str.str();
1284 return true;
1285}
1286
1287int32_t Program::build(const std::string& sourceCode, const char* origOptions,
1288 amd::option::Options* options) {

Callers

nothing calls this directly

Calls 4

getOCLSourceHashFunction · 0.85
getOCLOptionsHashFunction · 0.85
getSubstBinFileNameFunction · 0.85
emptyMethod · 0.80

Tested by

no test coverage detected