SWDEV-291787 - Fix persistent direct map

Change-Id: Ic1507cc6d63e9ed574e8e169bce7bf56f4792c19
This commit is contained in:
jujiang
2021-07-13 19:44:02 -04:00
committed by Maneesh Gupta
parent 2babcfbdbb
commit 84b971c7c1
6 changed files with 32 additions and 11 deletions
+10 -4
View File
@@ -786,12 +786,16 @@ void* Memory::allocMapTarget(const amd::Coord3D& origin, const amd::Coord3D& reg
mapAddress = reinterpret_cast<address>(owner()->getHostMem());
}
// If resource is a persistent allocation, we can use it directly
else if (isPersistentDirectMap()) {
else if ((isPersistentDirectMap(mapFlags & CL_MAP_WRITE) && (getMapCount() == 0)) ||
isPersistentMapped()) {
if (nullptr == map(nullptr)) {
LogError("Could not map target persistent resource");
decIndMapCount();
return nullptr;
}
if (getMapCount() == 1) {
setPersistentMapFlag(true);
}
mapAddress = data();
}
// Otherwise we can use a remote resource:
@@ -1046,14 +1050,17 @@ void* Image::allocMapTarget(const amd::Coord3D& origin, const amd::Coord3D& regi
//! runtime can't use it directly,
//! because CAL volume map doesn't work properly.
//! @todo arrays can be added for persistent lock with some CAL changes
else if (isPersistentDirectMap()) {
else if((isPersistentDirectMap(mapFlags & CL_MAP_WRITE) && (getMapCount() == 0)) ||
isPersistentMapped()) {
if (nullptr == map(nullptr)) {
useRemoteResource = true;
LogError("Could not map target persistent resource, try remote resource");
} else {
useRemoteResource = false;
mapAddress = data();
if (getMapCount() == 1) {
setPersistentMapFlag(true);
}
// Calculate the offset in bytes
offset *= elementSize();
@@ -1075,7 +1082,6 @@ void* Image::allocMapTarget(const amd::Coord3D& origin, const amd::Coord3D& regi
const static bool SysMem = true;
bool failed = false;
amd::Memory* memory;
// Search for a possible indirect resource
memory = dev().findMapTarget(owner()->getSize());