SWDEV-546178 - hipModuleLoadFatBinary implementation (#785)

* SWDEV-546178 - hipModuleLoadFatBinary implementation

* SWDEV-546178 - hipModuleLoadFatBinary CHANGELOG update

* SWDEV-546178 - fix roctracer build issue due to hip_prof_str.h
This commit is contained in:
GunaShekar, Ajay
2025-08-15 13:06:24 -07:00
committed by GitHub
parent 0f49c4a97f
commit f6736d57a5
8 changed files with 42 additions and 2 deletions
+1
View File
@@ -16,6 +16,7 @@ Full documentation for HIP is available at [rocm.docs.amd.com](https://rocm.docs
- `hipMemsetD2D32Async` Used for setting 2D memory range with specified 32-bit values asynchronously
- `hipStreamSetAttribute` sets attributes such as synchronization policy for a given stream
- `hipStreamGetAttribute` returns attributes such as priority for a given stream
- `hipModuleLoadFatBinary` loads fatbin binary to a module
## HIP 7.0 for ROCm 7.0
@@ -1063,6 +1063,7 @@ typedef hipError_t (*t_hipStreamSetAttribute)(hipStream_t stream, hipStreamAttrI
const hipStreamAttrValue *value);
typedef hipError_t (*t_hipStreamGetAttribute)(hipStream_t stream, hipStreamAttrID attr,
hipStreamAttrValue *value_out);
typedef hipError_t (*t_hipModuleLoadFatBinary)(hipModule_t* module, const void* fatbin);
// HIP Compiler dispatch table
struct HipCompilerDispatchTable {
@@ -1615,6 +1616,7 @@ struct HipDispatchTable {
t_hipMemsetD2D32Async hipMemsetD2D32Async_fn;
t_hipStreamGetAttribute hipStreamGetAttribute_fn;
t_hipStreamSetAttribute hipStreamSetAttribute_fn;
t_hipModuleLoadFatBinary hipModuleLoadFatBinary_fn;
// HIP_RUNTIME_API_TABLE_STEP_VERSION = 14
// removed HIP_MEMSET_NODE_PARAMS replaced by hipMemsetParams
+25 -1
View File
@@ -447,7 +447,8 @@ enum hip_api_id_t {
HIP_API_ID_hipMemsetD2D8Async = 427,
HIP_API_ID_hipStreamGetAttribute = 428,
HIP_API_ID_hipStreamSetAttribute = 429,
HIP_API_ID_LAST = 429,
HIP_API_ID_hipModuleLoadFatBinary = 430,
HIP_API_ID_LAST = 430,
HIP_API_ID_hipChooseDevice = HIP_API_ID_CONCAT(HIP_API_ID_,hipChooseDevice),
HIP_API_ID_hipGetDeviceProperties = HIP_API_ID_CONCAT(HIP_API_ID_,hipGetDeviceProperties),
@@ -829,6 +830,7 @@ static inline const char* hip_api_name(const uint32_t id) {
case HIP_API_ID_hipModuleLaunchCooperativeKernel: return "hipModuleLaunchCooperativeKernel";
case HIP_API_ID_hipModuleLaunchCooperativeKernelMultiDevice: return "hipModuleLaunchCooperativeKernelMultiDevice";
case HIP_API_ID_hipModuleLaunchKernel: return "hipModuleLaunchKernel";
case HIP_API_ID_hipModuleLoadFatBinary: return "hipModuleLoadFatBinary";
case HIP_API_ID_hipModuleLoad: return "hipModuleLoad";
case HIP_API_ID_hipModuleLoadData: return "hipModuleLoadData";
case HIP_API_ID_hipModuleLoadDataEx: return "hipModuleLoadDataEx";
@@ -1253,6 +1255,7 @@ static inline uint32_t hipApiIdByName(const char* name) {
if (strcmp("hipModuleLaunchCooperativeKernel", name) == 0) return HIP_API_ID_hipModuleLaunchCooperativeKernel;
if (strcmp("hipModuleLaunchCooperativeKernelMultiDevice", name) == 0) return HIP_API_ID_hipModuleLaunchCooperativeKernelMultiDevice;
if (strcmp("hipModuleLaunchKernel", name) == 0) return HIP_API_ID_hipModuleLaunchKernel;
if (strcmp("hipModuleLoadFatBinary", name) == 0) return HIP_API_ID_hipModuleLoadFatBinary;
if (strcmp("hipModuleLoad", name) == 0) return HIP_API_ID_hipModuleLoad;
if (strcmp("hipModuleLoadData", name) == 0) return HIP_API_ID_hipModuleLoadData;
if (strcmp("hipModuleLoadDataEx", name) == 0) return HIP_API_ID_hipModuleLoadDataEx;
@@ -3416,6 +3419,11 @@ typedef struct hip_api_data_s {
void** extra;
void* extra__val;
} hipModuleLaunchKernel;
struct {
hipModule_t* module;
hipModule_t module__val;
const void* fatbin;
} hipModuleLoadFatBinary;
struct {
hipModule_t* module;
hipModule_t module__val;
@@ -5964,6 +5972,11 @@ typedef struct hip_api_data_s {
cb_data.args.hipModuleLaunchKernel.kernelParams = (void**)kernelParams; \
cb_data.args.hipModuleLaunchKernel.extra = (void**)extra; \
};
// hipModuleLoadFatBinary[('hipModule_t*', 'module'), ('const void*', 'fatbin')]
#define INIT_hipModuleLoadFatBinary_CB_ARGS_DATA(cb_data) { \
cb_data.args.hipModuleLoadFatBinary.module = (hipModule_t*)module; \
cb_data.args.hipModuleLoadFatBinary.fatbin = (const void*)fatbin; \
};
// hipModuleLoad[('hipModule_t*', 'module'), ('const char*', 'fname')]
#define INIT_hipModuleLoad_CB_ARGS_DATA(cb_data) { \
cb_data.args.hipModuleLoad.module = (hipModule_t*)module; \
@@ -7786,6 +7799,10 @@ static inline void hipApiArgsInit(hip_api_id_t id, hip_api_data_t* data) {
if (data->args.hipModuleLaunchKernel.kernelParams) data->args.hipModuleLaunchKernel.kernelParams__val = *(data->args.hipModuleLaunchKernel.kernelParams);
if (data->args.hipModuleLaunchKernel.extra) data->args.hipModuleLaunchKernel.extra__val = *(data->args.hipModuleLaunchKernel.extra);
break;
// hipModuleLoadFatBinary[('hipModule_t*', 'module'), ('const void*', 'fatbin')]
case HIP_API_ID_hipModuleLoadFatBinary:
if (data->args.hipModuleLoadFatBinary.module) data->args.hipModuleLoadFatBinary.module__val = *(data->args.hipModuleLoadFatBinary.module);
break;
// hipModuleLoad[('hipModule_t*', 'module'), ('const char*', 'fname')]
case HIP_API_ID_hipModuleLoad:
if (data->args.hipModuleLoad.module) data->args.hipModuleLoad.module__val = *(data->args.hipModuleLoad.module);
@@ -10873,6 +10890,13 @@ static inline const char* hipApiString(hip_api_id_t id, const hip_api_data_t* da
else { oss << ", extra="; roctracer::hip_support::detail::operator<<(oss, data->args.hipModuleLaunchKernel.extra__val); }
oss << ")";
break;
case HIP_API_ID_hipModuleLoadFatBinary:
oss << "hipModuleLoadFatBinary(";
if (data->args.hipModuleLoadFatBinary.module == NULL) oss << "module=NULL";
else { oss << "module="; roctracer::hip_support::detail::operator<<(oss, data->args.hipModuleLoadFatBinary.module__val); }
oss << ", fatbin="; roctracer::hip_support::detail::operator<<(oss, data->args.hipModuleLoadFatBinary.fatbin);
oss << ")";
break;
case HIP_API_ID_hipModuleLoad:
oss << "hipModuleLoad(";
if (data->args.hipModuleLoad.module == NULL) oss << "module=NULL";
+1
View File
@@ -501,3 +501,4 @@ hipMemsetD2D32
hipMemsetD2D32Async
hipStreamGetAttribute
hipStreamSetAttribute
hipModuleLoadFatBinary
+4 -1
View File
@@ -535,6 +535,7 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, unsigned int gridDimX, unsigne
unsigned int blockDimY, unsigned int blockDimZ,
unsigned int sharedMemBytes, hipStream_t stream,
void** kernelParams, void** extra);
hipError_t hipModuleLoadFatBinary(hipModule_t* module, const void* fatbin);
hipError_t hipModuleLoad(hipModule_t* module, const char* fname);
hipError_t hipModuleLoadData(hipModule_t* module, const void* image);
hipError_t hipModuleLoadDataEx(hipModule_t* module, const void* image, unsigned int numOptions,
@@ -1197,6 +1198,7 @@ void UpdateDispatchTable(HipDispatchTable* ptrDispatchTable) {
ptrDispatchTable->hipModuleLaunchCooperativeKernelMultiDevice_fn =
hip::hipModuleLaunchCooperativeKernelMultiDevice;
ptrDispatchTable->hipModuleLaunchKernel_fn = hip::hipModuleLaunchKernel;
ptrDispatchTable->hipModuleLoadFatBinary_fn = hip::hipModuleLoadFatBinary;
ptrDispatchTable->hipModuleLoad_fn = hip::hipModuleLoad;
ptrDispatchTable->hipModuleLoadData_fn = hip::hipModuleLoadData;
ptrDispatchTable->hipModuleLoadDataEx_fn = hip::hipModuleLoadDataEx;
@@ -2024,13 +2026,14 @@ HIP_ENFORCE_ABI(HipDispatchTable, hipMemsetD2D32_fn, 482);
HIP_ENFORCE_ABI(HipDispatchTable, hipMemsetD2D32Async_fn, 483);
HIP_ENFORCE_ABI(HipDispatchTable, hipStreamGetAttribute_fn, 484);
HIP_ENFORCE_ABI(HipDispatchTable, hipStreamSetAttribute_fn, 485);
HIP_ENFORCE_ABI(HipDispatchTable, hipModuleLoadFatBinary_fn, 486);
// if HIP_ENFORCE_ABI entries are added for each new function pointer in the table, the number below
// will be +1 of the number in the last HIP_ENFORCE_ABI line. E.g.:
//
// HIP_ENFORCE_ABI(<table>, <functor>, 8)
//
// HIP_ENFORCE_ABI_VERSIONING(<table>, 9) <- 8 + 1 = 9
HIP_ENFORCE_ABI_VERSIONING(HipDispatchTable, 486)
HIP_ENFORCE_ABI_VERSIONING(HipDispatchTable, 487)
static_assert(HIP_RUNTIME_API_TABLE_MAJOR_VERSION == 0 && HIP_RUNTIME_API_TABLE_STEP_VERSION == 14,
"If you get this error, add new HIP_ENFORCE_ABI(...) code for the new function "
+1
View File
@@ -617,6 +617,7 @@ global:
hipMemsetD2D32Async;
hipStreamGetAttribute;
hipStreamSetAttribute;
hipModuleLoadFatBinary;
local:
*;
} hip_6.5;
+5
View File
@@ -48,6 +48,11 @@ hipError_t hipModuleUnload(hipModule_t hmod) {
CHECK_STREAM_CAPTURE_SUPPORTED();
HIP_RETURN(PlatformState::instance().unloadModule(hmod));
}
hipError_t hipModuleLoadFatBinary(hipModule_t* module, const void* fatbin) {
HIP_INIT_API(hipModuleLoadFatBinary, module, fatbin);
HIP_RETURN(PlatformState::instance().loadModule(module, 0, fatbin));
HIP_RETURN(hipSuccess);
}
hipError_t hipModuleLoad(hipModule_t* module, const char* fname) {
HIP_INIT_API(hipModuleLoad, module, fname);
+3
View File
@@ -1254,6 +1254,9 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, unsigned int gridDimX, unsigne
f, gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ, sharedMemBytes, stream,
kernelParams, extra);
}
hipError_t hipModuleLoadFatBinary(hipModule_t* module, const void* fatbin) {
return hip::GetHipDispatchTable()->hipModuleLoadFatBinary_fn(module, fatbin);
}
hipError_t hipModuleLoad(hipModule_t* module, const char* fname) {
return hip::GetHipDispatchTable()->hipModuleLoad_fn(module, fname);
}