mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-25 21:42:53 +08:00
feature: Add CPU side USM allocation to trim candidate list on page fault
Enable eviction of CPU side USM allocation for UMD migrations on Windows. Reverts incorrect auto-revert commit 218de586a4f28b1de3e983b9006e7a99d3a4d10e. Related-To: NEO-8015 Signed-off-by: Milczarek, Slawomir <slawomir.milczarek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
6656e23b86
commit
027c51d396
@@ -5,11 +5,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
#include "shared/source/memory_manager/unified_memory_manager.h"
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
#include "shared/source/page_fault_manager/cpu_page_fault_manager.h"
|
||||
|
||||
#include "opencl/source/command_queue/command_queue.h"
|
||||
#include "opencl/source/command_queue/csr_selection_args.h"
|
||||
|
||||
namespace NEO {
|
||||
void PageFaultManager::transferToCpu(void *ptr, size_t size, void *cmdQ) {
|
||||
@@ -26,6 +30,19 @@ void PageFaultManager::transferToGpu(void *ptr, void *cmdQ) {
|
||||
UNRECOVERABLE_IF(retVal);
|
||||
|
||||
auto allocData = memoryData[ptr].unifiedMemoryManager->getSVMAlloc(ptr);
|
||||
UNRECOVERABLE_IF(allocData == nullptr);
|
||||
this->evictMemoryAfterImplCopy(allocData->cpuAllocation, &commandQueue->getDevice());
|
||||
}
|
||||
void PageFaultManager::allowCPUMemoryEviction(void *ptr, PageFaultData &pageFaultData) {
|
||||
auto commandQueue = static_cast<CommandQueue *>(pageFaultData.cmdQ);
|
||||
|
||||
auto allocData = memoryData[ptr].unifiedMemoryManager->getSVMAlloc(ptr);
|
||||
UNRECOVERABLE_IF(allocData == nullptr);
|
||||
CsrSelectionArgs csrSelectionArgs{CL_COMMAND_READ_BUFFER, &allocData->gpuAllocations, {}, commandQueue->getDevice().getRootDeviceIndex(), nullptr};
|
||||
auto &csr = commandQueue->selectCsrForBuiltinOperation(csrSelectionArgs);
|
||||
auto osInterface = commandQueue->getDevice().getRootDeviceEnvironment().osInterface.get();
|
||||
|
||||
allowCPUMemoryEvictionImpl(ptr, csr, osInterface);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -105,3 +105,34 @@ TEST_F(PageFaultManagerTest, givenUnifiedMemoryAllocWhenGpuTransferIsInvokedThen
|
||||
svmAllocsManager->freeSVMAlloc(alloc);
|
||||
cmdQ->device = nullptr;
|
||||
}
|
||||
|
||||
TEST_F(PageFaultManagerTest, givenUnifiedMemoryAllocWhenAllowCPUMemoryEvictionIsCalledThenSelectCorrectCsrWithOsContextForEviction) {
|
||||
MockExecutionEnvironment executionEnvironment;
|
||||
REQUIRE_SVM_OR_SKIP(executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo());
|
||||
|
||||
auto memoryManager = std::make_unique<MockMemoryManager>(executionEnvironment);
|
||||
auto svmAllocsManager = std::make_unique<SVMAllocsManager>(memoryManager.get(), false);
|
||||
auto device = std::unique_ptr<MockClDevice>(new MockClDevice{MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr)});
|
||||
auto rootDeviceIndex = device->getRootDeviceIndex();
|
||||
RootDeviceIndicesContainer rootDeviceIndices = {rootDeviceIndex};
|
||||
std::map<uint32_t, DeviceBitfield> deviceBitfields{{rootDeviceIndex, device->getDeviceBitfield()}};
|
||||
void *alloc = svmAllocsManager->createSVMAlloc(256, {}, rootDeviceIndices, deviceBitfields);
|
||||
auto cmdQ = std::make_unique<CommandQueueMock>();
|
||||
cmdQ->device = device.get();
|
||||
pageFaultManager->insertAllocation(alloc, 256, svmAllocsManager.get(), cmdQ.get(), {});
|
||||
|
||||
NEO::PageFaultManager::PageFaultData pageData;
|
||||
pageData.cmdQ = cmdQ.get();
|
||||
|
||||
pageFaultManager->baseAllowCPUMemoryEviction(alloc, pageData);
|
||||
EXPECT_EQ(pageFaultManager->allowCPUMemoryEvictionImplCalled, 1);
|
||||
|
||||
auto allocData = svmAllocsManager->getSVMAlloc(alloc);
|
||||
CsrSelectionArgs csrSelectionArgs{CL_COMMAND_READ_BUFFER, &allocData->gpuAllocations, {}, cmdQ->getDevice().getRootDeviceIndex(), nullptr};
|
||||
auto &csr = cmdQ->selectCsrForBuiltinOperation(csrSelectionArgs);
|
||||
EXPECT_EQ(pageFaultManager->engineType, csr.getOsContext().getEngineType());
|
||||
EXPECT_EQ(pageFaultManager->engineUsage, csr.getOsContext().getEngineUsage());
|
||||
|
||||
svmAllocsManager->freeSVMAlloc(alloc);
|
||||
cmdQ->device = nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user