diff --git a/opencl/test/unit_test/test_files/igdrcl.config b/opencl/test/unit_test/test_files/igdrcl.config index 7b5f2b7ef3..0f2277aaa1 100644 --- a/opencl/test/unit_test/test_files/igdrcl.config +++ b/opencl/test/unit_test/test_files/igdrcl.config @@ -369,6 +369,7 @@ Force2dImageAsArray = -1 ForceExtendedBufferSize = -1 ForceExtendedUSMBufferSize = -1 MakeIndirectAllocationsResidentAsPack = -1 +MakeEachAllocationResident = -1 EnableChipsetUniqueUUID = -1 ForceSimdMessageSizeInWalker = -1 UseNewQueryTopoIoctl = 1 diff --git a/shared/source/command_stream/command_stream_receiver.cpp b/shared/source/command_stream/command_stream_receiver.cpp index 40769b860e..94244da688 100644 --- a/shared/source/command_stream/command_stream_receiver.cpp +++ b/shared/source/command_stream/command_stream_receiver.cpp @@ -115,7 +115,16 @@ void CommandStreamReceiver::makeResident(MultiGraphicsAllocation &gfxAllocation) void CommandStreamReceiver::makeResident(GraphicsAllocation &gfxAllocation) { auto submissionTaskCount = this->taskCount + 1; if (gfxAllocation.isResidencyTaskCountBelow(submissionTaskCount, osContext->getContextId())) { - this->getResidencyAllocations().push_back(&gfxAllocation); + auto pushAllocations = true; + + if (DebugManager.flags.MakeEachAllocationResident.get() != -1) { + pushAllocations = !DebugManager.flags.MakeEachAllocationResident.get(); + } + + if (pushAllocations) { + this->getResidencyAllocations().push_back(&gfxAllocation); + } + checkForNewResources(submissionTaskCount, gfxAllocation.getTaskCount(osContext->getContextId()), gfxAllocation); gfxAllocation.updateTaskCount(submissionTaskCount, osContext->getContextId()); if (!gfxAllocation.isResident(osContext->getContextId())) { diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index b09e7fb2b4..570aeb64b4 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -242,6 +242,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, OverrideKernelSizeLimitForSmallDispatch, -1, "-1 DECLARE_DEBUG_VARIABLE(int32_t, OverrideUseKmdWaitFunction, -1, "-1: default (L0: disabled), 0: disabled, 1: enabled. It uses only busy loop to wait or busy loop with KMD wait function, when KMD fallback is enabled") DECLARE_DEBUG_VARIABLE(int32_t, ResolveDependenciesViaPipeControls, -1, "-1: default , 0: disabled, 1: enabled. If enabled, instead of programming semaphores, dependencies are resolved using task levels") DECLARE_DEBUG_VARIABLE(int32_t, MakeIndirectAllocationsResidentAsPack, -1, "-1: default, 0:disabled, 1: enabled. If enabled, driver handles all indirect allocations as one pack instead of making them resident individually.") +DECLARE_DEBUG_VARIABLE(int32_t, MakeEachAllocationResident, -1, "-1: default, 0: disabled, 1: bind every allocation at creation time, 2: bind all created allocations in flush") /*DIRECT SUBMISSION FLAGS*/ DECLARE_DEBUG_VARIABLE(bool, DirectSubmissionPrintBuffers, false, "Print address of submitted command buffers") diff --git a/shared/source/os_interface/linux/drm_memory_manager.cpp b/shared/source/os_interface/linux/drm_memory_manager.cpp index 3f9b21632e..925240ab6d 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.cpp +++ b/shared/source/os_interface/linux/drm_memory_manager.cpp @@ -1046,15 +1046,28 @@ std::vector &DrmMemoryManager::getLocalMemAllocs(uint32_t return this->localMemAllocs[rootDeviceIndex]; } +void DrmMemoryManager::makeAllocationResident(GraphicsAllocation *allocation) { + if (DebugManager.flags.MakeEachAllocationResident.get() == 1) { + auto drmAllocation = static_cast(allocation); + for (uint32_t i = 0; getDrm(allocation->getRootDeviceIndex()).getVirtualMemoryAddressSpace(i) > 0u; i++) { + drmAllocation->makeBOsResident(registeredEngines[defaultEngineIndex[allocation->getRootDeviceIndex()]].osContext, i, nullptr, true); + getDrm(allocation->getRootDeviceIndex()).waitForBind(i); + } + } +} + void DrmMemoryManager::registerSysMemAlloc(GraphicsAllocation *allocation) { + makeAllocationResident(allocation); std::lock_guard lock(this->allocMutex); this->sysMemAllocs.push_back(allocation); } void DrmMemoryManager::registerLocalMemAlloc(GraphicsAllocation *allocation, uint32_t rootDeviceIndex) { + makeAllocationResident(allocation); std::lock_guard lock(this->allocMutex); this->localMemAllocs[rootDeviceIndex].push_back(allocation); } + void DrmMemoryManager::unregisterAllocation(GraphicsAllocation *allocation) { std::lock_guard lock(this->allocMutex); sysMemAllocs.erase(std::remove(sysMemAllocs.begin(), sysMemAllocs.end(), allocation), diff --git a/shared/source/os_interface/linux/drm_memory_manager.h b/shared/source/os_interface/linux/drm_memory_manager.h index afd5eda5a5..64e07b97ee 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.h +++ b/shared/source/os_interface/linux/drm_memory_manager.h @@ -123,6 +123,7 @@ class DrmMemoryManager : public MemoryManager { void registerAllocationInOs(GraphicsAllocation *allocation) override; void waitOnCompletionFence(GraphicsAllocation *allocation); bool allocationTypeForCompletionFence(AllocationType allocationType); + void makeAllocationResident(GraphicsAllocation *allocation); Drm &getDrm(uint32_t rootDeviceIndex) const; uint32_t getRootDeviceIndex(const Drm *drm); diff --git a/shared/source/os_interface/linux/drm_memory_operations_handler_bind.cpp b/shared/source/os_interface/linux/drm_memory_operations_handler_bind.cpp index 24a7f18966..8e3afea6b0 100644 --- a/shared/source/os_interface/linux/drm_memory_operations_handler_bind.cpp +++ b/shared/source/os_interface/linux/drm_memory_operations_handler_bind.cpp @@ -104,7 +104,15 @@ MemoryOperationsStatus DrmMemoryOperationsHandlerBind::isResident(Device *device } MemoryOperationsStatus DrmMemoryOperationsHandlerBind::mergeWithResidencyContainer(OsContext *osContext, ResidencyContainer &residencyContainer) { - MemoryOperationsStatus retVal = this->makeResidentWithinOsContext(osContext, ArrayRef(residencyContainer), true); + if (DebugManager.flags.MakeEachAllocationResident.get() == 2) { + auto memoryManager = static_cast(this->rootDeviceEnvironment.executionEnvironment.memoryManager.get()); + + auto allocLock = memoryManager->acquireAllocLock(); + this->makeResidentWithinOsContext(osContext, ArrayRef(memoryManager->getSysMemAllocs()), true); + this->makeResidentWithinOsContext(osContext, ArrayRef(memoryManager->getLocalMemAllocs(this->rootDeviceIndex)), true); + } + + auto retVal = this->makeResidentWithinOsContext(osContext, ArrayRef(residencyContainer), true); if (retVal != MemoryOperationsStatus::SUCCESS) { return retVal; }