SWDEV-546285 - add hipGetDriverEntryPoint (#855)

[ROCm/clr commit: 789e2029ca]
This commit is contained in:
Li, Todd tiantuo
2025-08-15 20:08:21 -07:00
committad av GitHub
förälder 405061b019
incheckning ad9eb56dd4
9 ändrade filer med 134 tillägg och 3 borttagningar
+3 -1
Visa fil
@@ -505,4 +505,6 @@ hipModuleLoadFatBinary
hipMemcpyBatchAsync
hipMemcpy3DBatchAsync
hipMemcpy3DPeer
hipMemcpy3DPeerAsync
hipMemcpy3DPeerAsync
hipGetDriverEntryPoint
hipGetDriverEntryPoint_spt
+9 -1
Visa fil
@@ -186,6 +186,10 @@ hipError_t hipGetDeviceCount(int* count);
hipError_t hipGetDeviceFlags(unsigned int* flags);
hipError_t hipGetDevicePropertiesR0600(hipDeviceProp_tR0600* prop, int deviceId);
hipError_t hipGetDevicePropertiesR0000(hipDeviceProp_tR0000* prop, int device);
hipError_t hipGetDriverEntryPoint(const char* symbol, void** funcPtr, unsigned long long flags,
hipDriverEntryPointQueryResult* status);
hipError_t hipGetDriverEntryPoint_spt(const char* symbol, void** funcPtr, unsigned long long flags,
hipDriverEntryPointQueryResult* status);
const char* hipGetErrorName(hipError_t hip_error);
const char* hipGetErrorString(hipError_t hipError);
hipError_t hipGetLastError(void);
@@ -1340,6 +1344,8 @@ void UpdateDispatchTable(HipDispatchTable* ptrDispatchTable) {
ptrDispatchTable->hipGetStreamDeviceId_fn = hip::hipGetStreamDeviceId;
ptrDispatchTable->hipDrvGraphAddMemsetNode_fn = hip::hipDrvGraphAddMemsetNode;
ptrDispatchTable->hipGetDevicePropertiesR0000_fn = hip::hipGetDevicePropertiesR0000;
ptrDispatchTable->hipGetDriverEntryPoint_fn = hip::hipGetDriverEntryPoint;
ptrDispatchTable->hipGetDriverEntryPoint_spt_fn = hip::hipGetDriverEntryPoint_spt;
ptrDispatchTable->hipExtGetLastError_fn = hip::hipExtGetLastError;
ptrDispatchTable->hipTexRefGetBorderColor_fn = hip::hipTexRefGetBorderColor;
ptrDispatchTable->hipTexRefGetArray_fn = hip::hipTexRefGetArray;
@@ -2042,13 +2048,15 @@ HIP_ENFORCE_ABI(HipDispatchTable, hipMemcpyBatchAsync_fn, 487);
HIP_ENFORCE_ABI(HipDispatchTable, hipMemcpy3DBatchAsync_fn, 488);
HIP_ENFORCE_ABI(HipDispatchTable, hipMemcpy3DPeer_fn, 489);
HIP_ENFORCE_ABI(HipDispatchTable, hipMemcpy3DPeerAsync_fn, 490);
HIP_ENFORCE_ABI(HipDispatchTable, hipGetDriverEntryPoint_fn, 491);
HIP_ENFORCE_ABI(HipDispatchTable, hipGetDriverEntryPoint_spt_fn, 492);
// 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, 491)
HIP_ENFORCE_ABI_VERSIONING(HipDispatchTable, 493)
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 "
@@ -21,6 +21,7 @@
#include <hip/hip_runtime.h>
#include "hip_internal.hpp"
#include "hip_platform.hpp"
#undef hipChooseDevice
#undef hipDeviceProp_t
@@ -716,6 +717,60 @@ hipError_t hipGetDeviceFlags(unsigned int* flags) {
HIP_RETURN(hipSuccess);
}
hipError_t hipGetDriverEntryPoint_common(const char* symbol, void** funcPtr, unsigned long long flags,
hipDriverEntryPointQueryResult* status) {
std::string symbolString = symbol;
if (symbol == nullptr || symbolString == "" || funcPtr == nullptr) {
return hipErrorInvalidValue;
}
if (flags != hipEnableDefault && flags != hipEnableLegacyStream
&& flags != hipEnablePerThreadDefaultStream) {
return hipErrorInvalidValue;
}
void* handle = hip::PlatformState::instance().getDynamicLibraryHandle();
if (handle == nullptr) {
return hipErrorInvalidValue;
}
if (flags == hipEnablePerThreadDefaultStream) {
symbolString += "_spt";
}
*funcPtr = amd::Os::getSymbol(handle, symbolString.c_str());
if (funcPtr == nullptr) {
if (flags == hipEnablePerThreadDefaultStream) {
*funcPtr = amd::Os::getSymbol(handle, symbol);
}
if (funcPtr == nullptr) {
if (status != nullptr) {
*status = hipDriverEntryPointSymbolNotFound;
}
return hipErrorInvalidValue;
}
}
if (status != nullptr) {
*status = hipDriverEntryPointSuccess;
}
return hipSuccess;
}
hipError_t hipGetDriverEntryPoint(const char* symbol, void** funcPtr, unsigned long long flags,
hipDriverEntryPointQueryResult* status) {
HIP_INIT_API(hipGetDriverEntryPoint, symbol, funcPtr, flags, status);
HIP_RETURN(hipGetDriverEntryPoint_common(symbol, funcPtr, flags, status));
}
hipError_t hipGetDriverEntryPoint_spt(const char* symbol, void** funcPtr, unsigned long long flags,
hipDriverEntryPointQueryResult* status) {
HIP_INIT_API(hipGetDriverEntryPoint, symbol, funcPtr, flags, status);
flags = (flags == hipEnableDefault) ? hipEnablePerThreadDefaultStream : flags;
HIP_RETURN(hipGetDriverEntryPoint_common(symbol, funcPtr, flags, status));
}
hipError_t hipSetDevice(int device) {
HIP_INIT_API_NO_RETURN(hipSetDevice, device);
+2
Visa fil
@@ -622,6 +622,8 @@ global:
hipMemcpy3DBatchAsync;
hipMemcpy3DPeer;
hipMemcpy3DPeerAsync;
hipGetDriverEntryPoint;
hipGetDriverEntryPoint_spt;
local:
*;
} hip_6.5;
@@ -419,6 +419,16 @@ extern "C" hipError_t hipGetDevicePropertiesR0600(hipDeviceProp_tR0600* prop, in
extern "C" hipError_t hipGetDevicePropertiesR0000(hipDeviceProp_tR0000* prop, int device) {
return hip::GetHipDispatchTable()->hipGetDevicePropertiesR0000_fn(prop, device);
}
hipError_t hipGetDriverEntryPoint(const char* symbol, void** funcPtr, unsigned long long flags,
hipDriverEntryPointQueryResult* status) {
return hip::GetHipDispatchTable()->hipGetDriverEntryPoint_fn(symbol, funcPtr, flags,
status);
}
hipError_t hipGetDriverEntryPoint_spt(const char* symbol, void** funcPtr, unsigned long long flags,
hipDriverEntryPointQueryResult* status) {
return hip::GetHipDispatchTable()->hipGetDriverEntryPoint_spt_fn(symbol, funcPtr, flags,
status);
}
const char* hipGetErrorName(hipError_t hip_error) {
return hip::GetHipDispatchTable()->hipGetErrorName_fn(hip_error);
}