Add copy engine support for USM shared migration

Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
Jaime Arteaga
2021-09-28 01:57:51 +00:00
committed by Compute-Runtime-Automation
parent 604a680f11
commit 91e9587a07
12 changed files with 176 additions and 43 deletions

View File

@@ -104,8 +104,8 @@ struct CommandListCoreFamily : CommandListImp {
ze_result_t appendMemoryCopy(void *dstptr, const void *srcptr, size_t size,
ze_event_handle_t hSignalEvent, uint32_t numWaitEvents,
ze_event_handle_t *phWaitEvents) override;
ze_result_t appendPageFaultCopy(NEO::GraphicsAllocation *dstptr,
NEO::GraphicsAllocation *srcptr,
ze_result_t appendPageFaultCopy(NEO::GraphicsAllocation *dstAllocation,
NEO::GraphicsAllocation *srcAllocation,
size_t size,
bool flushHost) override;
ze_result_t appendMemoryCopyRegion(void *dstPtr,

View File

@@ -958,8 +958,8 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendCopyImageBlit(NEO::Graph
}
template <GFXCORE_FAMILY gfxCoreFamily>
ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendPageFaultCopy(NEO::GraphicsAllocation *dstptr,
NEO::GraphicsAllocation *srcptr,
ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendPageFaultCopy(NEO::GraphicsAllocation *dstAllocation,
NEO::GraphicsAllocation *srcAllocation,
size_t size, bool flushHost) {
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
@@ -972,32 +972,45 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendPageFaultCopy(NEO::Graph
isStateless = true;
}
uint64_t dstAddress = dstptr->getGpuAddress();
uint64_t srcAddress = srcptr->getGpuAddress();
ze_result_t ret = appendMemoryCopyKernelWithGA(reinterpret_cast<void *>(&dstAddress),
dstptr, 0,
reinterpret_cast<void *>(&srcAddress),
srcptr, 0,
size - rightSize,
middleElSize,
Builtin::CopyBufferToBufferMiddle,
nullptr,
isStateless);
if (ret == ZE_RESULT_SUCCESS && rightSize) {
appendMemoryCopyKernelWithGA(reinterpret_cast<void *>(&dstAddress),
dstptr, size - rightSize,
reinterpret_cast<void *>(&srcAddress),
srcptr, size - rightSize,
rightSize, 1UL,
Builtin::CopyBufferToBufferSide,
nullptr,
isStateless);
}
uintptr_t dstAddress = static_cast<uintptr_t>(dstAllocation->getGpuAddress());
uintptr_t srcAddress = static_cast<uintptr_t>(srcAllocation->getGpuAddress());
ze_result_t ret = ZE_RESULT_ERROR_UNKNOWN;
if (isCopyOnly()) {
ret = appendMemoryCopyBlit(dstAddress, dstAllocation, 0u,
srcAddress, srcAllocation, 0u,
size - rightSize);
if (NEO::MemorySynchronizationCommands<GfxFamily>::isDcFlushAllowed()) {
if (flushHost) {
NEO::PipeControlArgs args(true);
NEO::MemorySynchronizationCommands<GfxFamily>::addPipeControl(*commandContainer.getCommandStream(), args);
if (ret == ZE_RESULT_SUCCESS && rightSize) {
ret = appendMemoryCopyBlit(dstAddress, dstAllocation, size - rightSize,
srcAddress, srcAllocation, size - rightSize,
rightSize);
}
} else {
ret = appendMemoryCopyKernelWithGA(reinterpret_cast<void *>(&dstAddress),
dstAllocation, 0,
reinterpret_cast<void *>(&srcAddress),
srcAllocation, 0,
size - rightSize,
middleElSize,
Builtin::CopyBufferToBufferMiddle,
nullptr,
isStateless);
if (ret == ZE_RESULT_SUCCESS && rightSize) {
ret = appendMemoryCopyKernelWithGA(reinterpret_cast<void *>(&dstAddress),
dstAllocation, size - rightSize,
reinterpret_cast<void *>(&srcAddress),
srcAllocation, size - rightSize,
rightSize, 1UL,
Builtin::CopyBufferToBufferSide,
nullptr,
isStateless);
}
if (NEO::MemorySynchronizationCommands<GfxFamily>::isDcFlushAllowed()) {
if (flushHost) {
NEO::PipeControlArgs args(true);
NEO::MemorySynchronizationCommands<GfxFamily>::addPipeControl(*commandContainer.getCommandStream(), args);
}
}
}

View File

@@ -65,7 +65,8 @@ struct CommandListCoreFamilyImmediate : public CommandListCoreFamily<gfxCoreFami
ze_result_t appendEventReset(ze_event_handle_t hEvent) override;
ze_result_t appendPageFaultCopy(NEO::GraphicsAllocation *dstptr, NEO::GraphicsAllocation *srcptr,
ze_result_t appendPageFaultCopy(NEO::GraphicsAllocation *dstAllocation,
NEO::GraphicsAllocation *srcAllocation,
size_t size, bool flushHost) override;
ze_result_t appendWaitOnEvents(uint32_t numEvents, ze_event_handle_t *phEvent) override;

View File

@@ -331,13 +331,15 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendEventReset(ze_e
}
template <GFXCORE_FAMILY gfxCoreFamily>
ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendPageFaultCopy(NEO::GraphicsAllocation *dstptr, NEO::GraphicsAllocation *srcptr, size_t size, bool flushHost) {
ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendPageFaultCopy(NEO::GraphicsAllocation *dstAllocation,
NEO::GraphicsAllocation *srcAllocation,
size_t size, bool flushHost) {
if (this->isFlushTaskSubmissionEnabled) {
checkAvailableSpace();
}
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendPageFaultCopy(dstptr, srcptr, size, flushHost);
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendPageFaultCopy(dstAllocation, srcAllocation, size, flushHost);
if (ret == ZE_RESULT_SUCCESS) {
if (this->isFlushTaskSubmissionEnabled) {
executeCommandListImmediateWithFlushTask(false);

View File

@@ -103,7 +103,11 @@ CommandList *CommandList::createImmediate(uint32_t productFamily, Device *device
NEO::CommandStreamReceiver *csr = nullptr;
auto deviceImp = static_cast<DeviceImp *>(device);
if (internalUsage) {
csr = deviceImp->neoDevice->getInternalEngine().commandStreamReceiver;
if (NEO::EngineGroupType::Copy == engineGroupType && deviceImp->getActiveDevice()->getInternalCopyEngine()) {
csr = deviceImp->getActiveDevice()->getInternalCopyEngine()->commandStreamReceiver;
} else {
csr = deviceImp->getActiveDevice()->getInternalEngine().commandStreamReceiver;
}
} else {
device->getCsrForOrdinalAndIndex(&csr, desc->ordinal, desc->index);
}

View File

@@ -768,7 +768,7 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, uint3
ze_result_t resultValue = ZE_RESULT_SUCCESS;
device->pageFaultCommandList =
CommandList::createImmediate(
device->neoDevice->getHardwareInfo().platform.eProductFamily, device, &cmdQueueDesc, true, NEO::EngineGroupType::RenderCompute, resultValue);
device->neoDevice->getHardwareInfo().platform.eProductFamily, device, &cmdQueueDesc, true, NEO::EngineGroupType::Copy, resultValue);
}
if (device->getSourceLevelDebugger()) {