SWDEV-236178 - Store texture reference metadata for dynamically loaded modules.
Change-Id: I99ecc80da7e29c691341a01a09e4532972f1e3e5
[ROCm/clr commit: 0b788c4c67]
This commit is contained in:
committed by
Karthik Jayaprakash
orang tua
fb0c0122af
melakukan
1ed6d978a8
@@ -533,7 +533,7 @@ hipError_t hipModuleGetTexRef(textureReference** texRef, hipModule_t hmod, const
|
||||
}
|
||||
|
||||
/* Get address and size for the global symbol */
|
||||
if (!PlatformState::instance().getDynTexRef(name, hmod, texRef)) {
|
||||
if (hipSuccess != PlatformState::instance().getDynTexRef(name, hmod, texRef)) {
|
||||
DevLogPrintfError("Cannot get texRef for name: %s at module:0x%x \n",
|
||||
name, hmod);
|
||||
HIP_RETURN(hipErrorNotFound);
|
||||
@@ -543,5 +543,7 @@ hipError_t hipModuleGetTexRef(textureReference** texRef, hipModule_t hmod, const
|
||||
// have the default read mode set to normalized float.
|
||||
(*texRef)->readMode = hipReadModeNormalizedFloat;
|
||||
|
||||
PlatformState::instance().registerTexRef(*texRef, hmod, std::string(name));
|
||||
|
||||
HIP_RETURN(hipSuccess);
|
||||
}
|
||||
|
||||
@@ -955,6 +955,15 @@ hipError_t PlatformState::unloadModule(hipModule_t hmod) {
|
||||
delete it->second;
|
||||
dynCO_map_.erase(hmod);
|
||||
|
||||
auto tex_it = texRef_map_.begin();
|
||||
while (tex_it != texRef_map_.end()) {
|
||||
if (tex_it->second.first == hmod) {
|
||||
tex_it = texRef_map_.erase(tex_it);
|
||||
} else {
|
||||
++tex_it;
|
||||
}
|
||||
}
|
||||
|
||||
return hipSuccess;
|
||||
}
|
||||
|
||||
@@ -989,6 +998,37 @@ hipError_t PlatformState::getDynGlobalVar(const char* hostVar, int deviceId, hip
|
||||
return hipSuccess;
|
||||
}
|
||||
|
||||
hipError_t PlatformState::registerTexRef(textureReference* texRef, hipModule_t hmod,
|
||||
std::string name) {
|
||||
amd::ScopedLock lock(lock_);
|
||||
texRef_map_.insert(std::make_pair(texRef, std::make_pair(hmod, name)));
|
||||
return hipSuccess;
|
||||
}
|
||||
|
||||
hipError_t PlatformState::getDynTexGlobalVar(textureReference* texRef, int deviceId,
|
||||
hipDeviceptr_t* dev_ptr, size_t* size_ptr) {
|
||||
amd::ScopedLock lock(lock_);
|
||||
|
||||
auto tex_it = texRef_map_.find(texRef);
|
||||
if (tex_it == texRef_map_.end()) {
|
||||
DevLogPrintfError("Cannot find the texRef Entry: 0x%x", texRef);
|
||||
return hipErrorNotFound;
|
||||
}
|
||||
|
||||
auto it = dynCO_map_.find(tex_it->second.first);
|
||||
if (it == dynCO_map_.end()) {
|
||||
DevLogPrintfError("Cannot find the module: 0x%x", tex_it->second.first);
|
||||
return hipErrorNotFound;
|
||||
}
|
||||
|
||||
hip::DeviceVar* dvar = nullptr;
|
||||
IHIP_RETURN_ONFAIL(it->second->getDeviceVar(&dvar, tex_it->second.second, deviceId));
|
||||
*dev_ptr = dvar->device_ptr();
|
||||
*size_ptr = dvar->size();
|
||||
|
||||
return hipSuccess;
|
||||
}
|
||||
|
||||
hipError_t PlatformState::getDynTexRef(const char* hostVar, hipModule_t hmod, textureReference** texRef) {
|
||||
amd::ScopedLock lock(lock_);
|
||||
|
||||
|
||||
@@ -52,6 +52,9 @@ public:
|
||||
hipDeviceptr_t* dev_ptr, size_t* size_ptr);
|
||||
hipError_t getDynTexRef(const char* hostVar, hipModule_t hmod, textureReference** texRef);
|
||||
|
||||
hipError_t registerTexRef(textureReference* texRef, hipModule_t hmod, std::string name);
|
||||
hipError_t getDynTexGlobalVar(textureReference* texRef, int deviceId, hipDeviceptr_t* dev_ptr, size_t* size_ptr);
|
||||
|
||||
/* Singleton instance */
|
||||
static PlatformState& instance() {
|
||||
if (platform_ == nullptr) {
|
||||
@@ -90,4 +93,5 @@ private:
|
||||
std::unordered_map<hipModule_t, hip::DynCO*> dynCO_map_;
|
||||
hip::StatCO statCO_; //Static Code object var
|
||||
bool initialized_{false};
|
||||
std::unordered_map<textureReference*, std::pair<hipModule_t, std::string>> texRef_map_;
|
||||
};
|
||||
|
||||
@@ -802,8 +802,9 @@ hipError_t hipTexRefSetArray(textureReference* texRef,
|
||||
|
||||
hipDeviceptr_t refDevPtr = nullptr;
|
||||
size_t refDevSize = 0;
|
||||
HIP_RETURN_ONFAIL(PlatformState::instance().getStatGlobalVar(texRef, ihipGetDevice(), &refDevPtr,
|
||||
&refDevSize));
|
||||
|
||||
HIP_RETURN_ONFAIL(PlatformState::instance().getDynTexGlobalVar(texRef, ihipGetDevice(),
|
||||
&refDevPtr, &refDevSize));
|
||||
assert(refDevSize == sizeof(textureReference));
|
||||
|
||||
// Any previous address or HIP array state associated with the texture reference is superseded by this function.
|
||||
@@ -878,8 +879,8 @@ hipError_t hipTexRefSetAddress(size_t* ByteOffset,
|
||||
|
||||
hipDeviceptr_t refDevPtr = nullptr;
|
||||
size_t refDevSize = 0;
|
||||
HIP_RETURN_ONFAIL(PlatformState::instance().getStatGlobalVar(texRef, ihipGetDevice(), &refDevPtr,
|
||||
&refDevSize));
|
||||
HIP_RETURN_ONFAIL(PlatformState::instance().getDynTexGlobalVar(texRef, ihipGetDevice(),
|
||||
&refDevPtr, &refDevSize));
|
||||
assert(refDevSize == sizeof(textureReference));
|
||||
|
||||
// Any previous address or HIP array state associated with the texture reference is superseded by this function.
|
||||
@@ -923,8 +924,8 @@ hipError_t hipTexRefSetAddress2D(textureReference* texRef,
|
||||
|
||||
hipDeviceptr_t refDevPtr = nullptr;
|
||||
size_t refDevSize = 0;
|
||||
HIP_RETURN_ONFAIL(PlatformState::instance().getStatGlobalVar(texRef, ihipGetDevice(), &refDevPtr,
|
||||
&refDevSize));
|
||||
HIP_RETURN_ONFAIL(PlatformState::instance().getDynTexGlobalVar(texRef, ihipGetDevice(),
|
||||
&refDevPtr, &refDevSize));
|
||||
assert(refDevSize == sizeof(textureReference));
|
||||
|
||||
// Any previous address or HIP array state associated with the texture reference is superseded by this function.
|
||||
@@ -1201,8 +1202,8 @@ hipError_t hipTexRefSetMipmappedArray(textureReference* texRef,
|
||||
|
||||
hipDeviceptr_t refDevPtr = nullptr;
|
||||
size_t refDevSize = 0;
|
||||
HIP_RETURN_ONFAIL(PlatformState::instance().getStatGlobalVar(texRef, ihipGetDevice(), &refDevPtr,
|
||||
&refDevSize));
|
||||
HIP_RETURN_ONFAIL(PlatformState::instance().getDynTexGlobalVar(texRef, ihipGetDevice(),
|
||||
&refDevPtr, &refDevSize));
|
||||
assert(refDevSize == sizeof(textureReference));
|
||||
|
||||
// Any previous address or HIP array state associated with the texture reference is superseded by this function.
|
||||
|
||||
Reference in New Issue
Block a user