Extend key to host ptr fragments container

use separated entries per root device

Related-To: NEO-3691

Change-Id: I26b85b8852b23e6a4d290da689174c59343536b3
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2020-07-07 08:41:26 +02:00
committed by sys_ocldev
parent c3a1880492
commit 1a1b4b1c26
15 changed files with 378 additions and 264 deletions

View File

@ -13,25 +13,35 @@
namespace NEO {
using HostPtrFragmentsContainer = std::map<const void *, FragmentStorage>;
struct HostPtrEntryKey {
const void *ptr = nullptr;
uint32_t rootDeviceIndex = std::numeric_limits<uint32_t>::max();
bool operator<(const HostPtrEntryKey &key) const {
return rootDeviceIndex < key.rootDeviceIndex ||
((ptr < key.ptr) && (rootDeviceIndex == key.rootDeviceIndex));
}
};
using HostPtrFragmentsContainer = std::map<HostPtrEntryKey, FragmentStorage>;
class MemoryManager;
class HostPtrManager {
public:
FragmentStorage *getFragment(const void *inputPtr);
FragmentStorage *getFragment(HostPtrEntryKey key);
OsHandleStorage prepareOsStorageForAllocation(MemoryManager &memoryManager, size_t size, const void *ptr, uint32_t rootDeviceIndex);
void releaseHandleStorage(OsHandleStorage &fragments);
bool releaseHostPtr(const void *ptr);
void storeFragment(AllocationStorageData &storageData);
void storeFragment(FragmentStorage &fragment);
void releaseHandleStorage(uint32_t rootDeviceIndex, OsHandleStorage &fragments);
bool releaseHostPtr(uint32_t rootDeviceIndex, const void *ptr);
void storeFragment(uint32_t rootDeviceIndex, AllocationStorageData &storageData);
void storeFragment(uint32_t rootDeviceIndex, FragmentStorage &fragment);
std::unique_lock<std::recursive_mutex> obtainOwnership();
protected:
static AllocationRequirements getAllocationRequirements(const void *inputPtr, size_t size);
static AllocationRequirements getAllocationRequirements(uint32_t rootDeviceIndex, const void *inputPtr, size_t size);
OsHandleStorage populateAlreadyAllocatedFragments(AllocationRequirements &requirements);
FragmentStorage *getFragmentAndCheckForOverlaps(const void *inputPtr, size_t size, OverlapStatus &overlappingStatus);
FragmentStorage *getFragmentAndCheckForOverlaps(uint32_t rootDeviceIndex, const void *inputPtr, size_t size, OverlapStatus &overlappingStatus);
RequirementsStatus checkAllocationsForOverlapping(MemoryManager &memoryManager, AllocationRequirements *requirements);
HostPtrFragmentsContainer::iterator findElement(const void *ptr);
HostPtrFragmentsContainer::iterator findElement(HostPtrEntryKey key);
HostPtrFragmentsContainer partialAllocations;
std::recursive_mutex allocationsMutex;
};