P4 to Git Change 1787806 by yaxunl@yaxunl-lc10 on 2019/05/27 10:53:56

SWDEV-145570 - Support loading fat binary generated through --genco by hipModuleLoad.

	hip-clang --genco generates fat binary instead of code object. To support that
	we need to extract code object from fat binary in hipModuleLoadData. This is
	needed for hipRTC since multiple GPU archs may be passed.

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/hip/hip_module.cpp#27 edit
... //depot/stg/opencl/drivers/opencl/api/hip/hip_platform.cpp#31 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/devprogram.cpp#42 edit
... //depot/stg/opencl/drivers/opencl/runtime/utils/flags.hpp#308 edit
This commit is contained in:
foreman
2019-05-27 20:11:08 -04:00
parent 09621adaca
commit c166e2513c
2 changed files with 16 additions and 0 deletions
+14
View File
@@ -1403,6 +1403,17 @@ bool Program::linkImpl(amd::option::Options* options) {
}
}
static void dumpCodeObject(const std::string& image) {
char fname[30];
static std::atomic<int> index;
sprintf(fname, "_code_object%04d.o", index++);
LogPrintfInfo("Code object saved in %s\n", fname);
std::ofstream ofs;
ofs.open(fname, std::ios::binary);
ofs << image;
ofs.close();
}
// ================================================================================================
#if defined(USE_COMGR_LIBRARY)
bool Program::linkImplLC(amd::option::Options* options) {
@@ -1445,6 +1456,9 @@ bool Program::linkImplLC(amd::option::Options* options) {
case ACL_TYPE_ISA: {
amd::Comgr::destroy_data_set(inputs);
binary_t isaBinary = binary();
if (OCL_DUMP_CODE_OBJECT) {
dumpCodeObject(std::string{(const char*)isaBinary.first, isaBinary.second});
}
return setKernels(options, const_cast<void *>(isaBinary.first), isaBinary.second);
break;
}