mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 21:18:24 +08:00
Prefetch kmd-migrated shared allocation to multiple subdevices
Related-To: NEO-6740 Signed-off-by: Slawomir Milczarek <slawomir.milczarek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
145f249f0c
commit
ba003dd7dc
@@ -179,6 +179,21 @@ int DrmAllocation::bindBOs(OsContext *osContext, uint32_t vmHandleId, std::vecto
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool DrmAllocation::prefetchBO(BufferObject *bo, uint32_t subDeviceId) {
|
||||
auto drm = bo->peekDrm();
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
auto memoryClassDevice = ioctlHelper->getDrmParamValue(DrmParam::MemoryClassDevice);
|
||||
auto region = static_cast<uint32_t>((memoryClassDevice << 16u) | subDeviceId);
|
||||
auto vmId = drm->getVirtualMemoryAddressSpace(subDeviceId);
|
||||
|
||||
auto result = ioctlHelper->setVmPrefetch(bo->peekAddress(), bo->peekSize(), region, vmId);
|
||||
|
||||
PRINT_DEBUG_STRING(DebugManager.flags.PrintBOPrefetchingResult.get(), stdout,
|
||||
"prefetch BO=%d to VM %u, range: %llx - %llx, size: %lld, region: %x, result: %d\n",
|
||||
bo->peekHandle(), vmId, bo->peekAddress(), ptrOffset(bo->peekAddress(), bo->peekSize()), bo->peekSize(), region, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void DrmAllocation::registerBOBindExtHandle(Drm *drm) {
|
||||
if (!drm->resourceRegistrationEnabled()) {
|
||||
return;
|
||||
@@ -318,15 +333,18 @@ bool DrmAllocation::setMemAdvise(Drm *drm, MemAdviseFlags flags) {
|
||||
|
||||
bool DrmAllocation::setMemPrefetch(Drm *drm, uint32_t subDeviceId) {
|
||||
bool success = true;
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
auto memoryClassDevice = ioctlHelper->getDrmParamValue(DrmParam::MemoryClassDevice);
|
||||
auto vmId = drm->getVirtualMemoryAddressSpace(subDeviceId);
|
||||
auto numHandles = GraphicsAllocation::getNumHandlesForKmdSharedAllocation(storageInfo.getNumBanks());
|
||||
|
||||
for (auto bo : bufferObjects) {
|
||||
if (bo != nullptr) {
|
||||
auto region = static_cast<uint32_t>((memoryClassDevice << 16u) | subDeviceId);
|
||||
success &= ioctlHelper->setVmPrefetch(bo->peekAddress(), bo->peekSize(), region, vmId);
|
||||
if (numHandles > 1) {
|
||||
for (uint8_t subDeviceId = 0u; subDeviceId < EngineLimits::maxHandleCount; subDeviceId++) {
|
||||
if (storageInfo.memoryBanks.test(subDeviceId)) {
|
||||
auto bo = this->getBOs()[subDeviceId];
|
||||
success &= prefetchBO(bo, subDeviceId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
auto bo = this->getBO();
|
||||
success = prefetchBO(bo, subDeviceId);
|
||||
}
|
||||
|
||||
return success;
|
||||
|
||||
@@ -109,6 +109,7 @@ class DrmAllocation : public GraphicsAllocation {
|
||||
MOCKABLE_VIRTUAL int makeBOsResident(OsContext *osContext, uint32_t vmHandleId, std::vector<BufferObject *> *bufferObjects, bool bind);
|
||||
MOCKABLE_VIRTUAL int bindBO(BufferObject *bo, OsContext *osContext, uint32_t vmHandleId, std::vector<BufferObject *> *bufferObjects, bool bind);
|
||||
MOCKABLE_VIRTUAL int bindBOs(OsContext *osContext, uint32_t vmHandleId, std::vector<BufferObject *> *bufferObjects, bool bind);
|
||||
MOCKABLE_VIRTUAL bool prefetchBO(BufferObject *bo, uint32_t subDeviceId);
|
||||
MOCKABLE_VIRTUAL void registerBOBindExtHandle(Drm *drm);
|
||||
void freeRegisteredBOBindExtHandles(Drm *drm);
|
||||
void linkWithRegisteredHandle(uint32_t handle);
|
||||
|
||||
@@ -1859,15 +1859,12 @@ GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const
|
||||
BufferObjects bos{};
|
||||
auto currentAddress = cpuPointer;
|
||||
auto remainingSize = size;
|
||||
auto getNumHandles = [](uint32_t numBanks) -> uint32_t {
|
||||
return (numBanks > 1) && (DebugManager.flags.CreateKmdMigratedSharedAllocationWithMultipleBOs.get() != 0) ? numBanks : 1u;
|
||||
};
|
||||
auto numHandles = GraphicsAllocation::getNumHandlesForKmdSharedAllocation(allocationData.storageInfo.getNumBanks());
|
||||
|
||||
auto handles = getNumHandles(allocationData.storageInfo.getNumBanks());
|
||||
for (auto handleId = 0u; handleId < handles; handleId++) {
|
||||
for (auto handleId = 0u; handleId < numHandles; handleId++) {
|
||||
uint32_t handle = 0;
|
||||
|
||||
auto currentSize = alignUp(remainingSize / (handles - handleId), MemoryConstants::pageSize64k);
|
||||
auto currentSize = alignUp(remainingSize / (numHandles - handleId), MemoryConstants::pageSize64k);
|
||||
if (currentSize == 0) {
|
||||
break;
|
||||
}
|
||||
@@ -1917,7 +1914,7 @@ GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
if (handles > 1) {
|
||||
if (numHandles > 1) {
|
||||
allocation->storageInfo = allocationData.storageInfo;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user