SWDEV-437702 - implement hipGetProcAddress
This should be used in place of dlsym or GetProcAddress (linux and windows respectively)
Change-Id: I5501b538e03892e8e5a2282678d848fcaf21d911
[ROCm/clr commit: 0479cdb3dd]
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "hip_internal.hpp"
|
||||
#include "hip_mempool_impl.hpp"
|
||||
#include "hip_platform.hpp"
|
||||
|
||||
#undef hipGetDeviceProperties
|
||||
#undef hipDeviceProp_t
|
||||
@@ -584,6 +585,44 @@ hipError_t hipGetDevicePropertiesR0000(hipDeviceProp_tR0000* prop, int device) {
|
||||
HIP_RETURN(hipSuccess);
|
||||
}
|
||||
|
||||
hipError_t hipGetProcAddress(const char* symbol, void** pfn, int hipVersion, uint64_t flags,
|
||||
hipDriverProcAddressQueryResult* symbolStatus = nullptr) {
|
||||
HIP_INIT_API(hipGetProcAddress, symbol, pfn, hipVersion, flags, symbolStatus);
|
||||
|
||||
std::string symbolString = symbol;
|
||||
if(symbol == nullptr || symbolString == "" || *pfn == nullptr){
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
if (symbolString == "hipGetDeviceProperties"){
|
||||
if (hipVersion >= 600){
|
||||
symbolString = "hipGetDevicePropertiesR0600";
|
||||
}
|
||||
} else if (symbolString == "hipChooseDevice") {
|
||||
if (hipVersion >= 600){
|
||||
symbolString = "hipChooseDeviceR0600";
|
||||
}
|
||||
}
|
||||
|
||||
void* handle = hip::PlatformState::instance().getDynamicLibraryHandle();
|
||||
if (handle == nullptr){
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
*pfn = amd::Os::getSymbol(handle, symbolString.c_str());
|
||||
if (!(*pfn)) {
|
||||
if (symbolStatus != nullptr) {
|
||||
*symbolStatus = HIP_GET_PROC_ADDRESS_SYMBOL_NOT_FOUND;
|
||||
}
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
if (symbolStatus != nullptr) {
|
||||
*symbolStatus = HIP_GET_PROC_ADDRESS_SUCCESS;
|
||||
}
|
||||
HIP_RETURN(hipSuccess);
|
||||
}
|
||||
|
||||
} // namespace hip
|
||||
|
||||
extern "C" hipError_t hipGetDeviceProperties(hipDeviceProp_tR0000* props, hipDevice_t device) {
|
||||
|
||||
Reference in New Issue
Block a user