SWDEV-546179 - hipModuleGetFunctionCount AMD impl (#782)

* SWDEV-546179 - hipModuleGetFunctionCount AMD impl

* SWDEV-546179 - return invalid for count ptr

* SWDEV-546179 - hipModuleGetFunctionCount CHANGELOG.md update

[ROCm/clr commit: dfb46db2fb]
Этот коммит содержится в:
GunaShekar, Ajay
2025-08-13 20:28:12 -07:00
коммит произвёл GitHub
родитель 5c412edcd1
Коммит 76328ecfde
12 изменённых файлов: 87 добавлений и 5 удалений
+1
Просмотреть файл
@@ -492,3 +492,4 @@ hipLinkCreate
hipLinkDestroy
hipLaunchKernelExC
hipDrvLaunchKernelEx
hipModuleGetFunctionCount
+6 -2
Просмотреть файл
@@ -519,6 +519,7 @@ hipError_t hipMipmappedArrayDestroy(hipMipmappedArray_t hMipmappedArray);
hipError_t hipMipmappedArrayGetLevel(hipArray_t* pLevelArray, hipMipmappedArray_t hMipMappedArray,
unsigned int level);
hipError_t hipModuleGetFunction(hipFunction_t* function, hipModule_t module, const char* kname);
hipError_t hipModuleGetFunctionCount(unsigned int* count, hipModule_t mod);
hipError_t hipModuleGetGlobal(hipDeviceptr_t* dptr, size_t* bytes, hipModule_t hmod,
const char* name);
hipError_t hipModuleGetTexRef(textureReference** texRef, hipModule_t hmod, const char* name);
@@ -1174,6 +1175,7 @@ void UpdateDispatchTable(HipDispatchTable* ptrDispatchTable) {
ptrDispatchTable->hipMipmappedArrayDestroy_fn = hip::hipMipmappedArrayDestroy;
ptrDispatchTable->hipMipmappedArrayGetLevel_fn = hip::hipMipmappedArrayGetLevel;
ptrDispatchTable->hipModuleGetFunction_fn = hip::hipModuleGetFunction;
ptrDispatchTable->hipModuleGetFunctionCount_fn = hip::hipModuleGetFunctionCount;
ptrDispatchTable->hipModuleGetGlobal_fn = hip::hipModuleGetGlobal;
ptrDispatchTable->hipModuleGetTexRef_fn = hip::hipModuleGetTexRef;
ptrDispatchTable->hipModuleLaunchCooperativeKernel_fn = hip::hipModuleLaunchCooperativeKernel;
@@ -1989,15 +1991,17 @@ HIP_ENFORCE_ABI(HipDispatchTable, hipLaunchKernelExC_fn, 474);
HIP_ENFORCE_ABI(HipDispatchTable, hipDrvLaunchKernelEx_fn, 475);
// HIP_RUNTIME_API_TABLE_STEP_VERSION == 12
HIP_ENFORCE_ABI(HipDispatchTable, hipMemGetHandleForAddressRange_fn, 476);
// HIP_RUNTIME_API_TABLE_STEP_VERSION == 13
HIP_ENFORCE_ABI(HipDispatchTable, hipModuleGetFunctionCount_fn, 477);
// 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, 477)
HIP_ENFORCE_ABI_VERSIONING(HipDispatchTable, 478)
static_assert(HIP_RUNTIME_API_TABLE_MAJOR_VERSION == 0 && HIP_RUNTIME_API_TABLE_STEP_VERSION == 13,
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 "
"pointers and then update this check so it is true");
#endif
+9
Просмотреть файл
@@ -124,6 +124,15 @@ hipError_t DynCO::getDynFunc(hipFunction_t* hfunc, std::string func_name) {
return it->second->getDynFunc(hfunc, module_);
}
hipError_t DynCO::getFuncCount(unsigned int* count) {
amd::ScopedLock lock(dclock_);
if (count == nullptr) {
return hipErrorInvalidValue;
}
*count = functions_.size();
return hipSuccess;
}
bool DynCO::isValidDynFunc(const void* hfunc) {
amd::ScopedLock lock(dclock_);
return std::any_of(functions_.begin(), functions_.end(),
+1
Просмотреть файл
@@ -111,6 +111,7 @@ public:
//Gets GlobalVar/Functions from a dynamically loaded code object
hipError_t getDynFunc(hipFunction_t* hfunc, std::string func_name);
hipError_t getFuncCount(unsigned int* count);
bool isValidDynFunc(const void* hfunc);
hipError_t getDeviceVar(DeviceVar** dvar, std::string var_name);
+7
Просмотреть файл
@@ -605,3 +605,10 @@ global:
local:
*;
} hip_6.4;
hip_7.1 {
global:
hipModuleGetFunctionCount;
local:
*;
} hip_6.5;
+9
Просмотреть файл
@@ -89,6 +89,15 @@ hipError_t hipModuleGetFunction(hipFunction_t* hfunc, hipModule_t hmod, const ch
HIP_RETURN(hipSuccess);
}
hipError_t hipModuleGetFunctionCount(unsigned int* count, hipModule_t mod) {
HIP_INIT_API(hipModuleGetFunctionCount, count, mod);
if (mod == nullptr) {
HIP_RETURN(hipErrorInvalidResourceHandle);
}
HIP_RETURN(PlatformState::instance().getFuncCount(count, mod););
}
hipError_t hipModuleGetGlobal(hipDeviceptr_t* dptr, size_t* bytes, hipModule_t hmod,
const char* name) {
HIP_INIT_API(hipModuleGetGlobal, dptr, bytes, hmod, name);
+11
Просмотреть файл
@@ -834,6 +834,17 @@ hipError_t PlatformState::getDynFunc(hipFunction_t* hfunc, hipModule_t hmod,
return it->second->getDynFunc(hfunc, func_name);
}
hipError_t PlatformState::getFuncCount(unsigned int* count, hipModule_t hmod) {
amd::ScopedLock lock(lock_);
auto it = dynCO_map_.find(hmod);
if (it == dynCO_map_.end()) {
LogPrintfError("Cannot find the module: 0x%x", hmod);
return hipErrorNotFound;
}
return it->second->getFuncCount(count);
}
bool PlatformState::isValidDynFunc(const void* hfunc) {
amd::ScopedLock lock(lock_);
return std::any_of(dynCO_map_.begin(), dynCO_map_.end(),
+1
Просмотреть файл
@@ -63,6 +63,7 @@ class PlatformState {
hipError_t unloadModule(hipModule_t hmod);
bool isValidDynFunc(const void* hfunc);
hipError_t getDynFunc(hipFunction_t* hfunc, hipModule_t hmod, const char* func_name);
hipError_t getFuncCount(unsigned int* count, hipModule_t hmod);
hipError_t getDynGlobalVar(const char* hostVar, hipModule_t hmod, hipDeviceptr_t* dev_ptr,
size_t* size_ptr);
hipError_t getDynTexRef(const char* hostVar, hipModule_t hmod, textureReference** texRef);
+3
Просмотреть файл
@@ -1220,6 +1220,9 @@ hipError_t hipMipmappedArrayGetLevel(hipArray_t* pLevelArray, hipMipmappedArray_
hipError_t hipModuleGetFunction(hipFunction_t* function, hipModule_t module, const char* kname) {
return hip::GetHipDispatchTable()->hipModuleGetFunction_fn(function, module, kname);
}
hipError_t hipModuleGetFunctionCount(unsigned int* count, hipModule_t mod) {
return hip::GetHipDispatchTable()->hipModuleGetFunctionCount_fn(count, mod);
}
hipError_t hipModuleGetGlobal(hipDeviceptr_t* dptr, size_t* bytes, hipModule_t hmod,
const char* name) {
return hip::GetHipDispatchTable()->hipModuleGetGlobal_fn(dptr, bytes, hmod, name);