mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-18 22:08:53 +08:00
refactor: add check if allocation imported required
Related-To: NEO-13163 Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
ed70ba181a
commit
d1d3e34d11
@@ -354,7 +354,8 @@ struct CommandListCoreFamily : public CommandListImp {
|
||||
void dispatchEventPostSyncOperation(Event *event, void **syncCmdBuffer, CommandToPatchContainer *outListCommands, uint32_t value, bool omitFirstOperation, bool useMax, bool useLastPipeControl,
|
||||
bool skipPartitionOffsetProgramming, bool copyOperation);
|
||||
|
||||
constexpr bool isAllocationImported(NEO::GraphicsAllocation *gpuAllocation, NEO::SVMAllocsManager *svmManager) const;
|
||||
bool isAllocationImported(NEO::GraphicsAllocation *gpuAllocation, NEO::SVMAllocsManager *svmManager) const;
|
||||
static constexpr bool checkIfAllocationImportedRequired();
|
||||
|
||||
bool isKernelUncachedMocsRequired(bool kernelState) {
|
||||
this->containsStatelessUncachedResource |= kernelState;
|
||||
|
||||
@@ -1074,7 +1074,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendImageCopyToMemoryExt(voi
|
||||
(dstAllocationType == NEO::AllocationType::bufferHostMemory) ||
|
||||
(dstAllocationType == NEO::AllocationType::externalHostPtr);
|
||||
|
||||
launchParams.isDestinationAllocationImported = this->isAllocationImported(allocationStruct.alloc, device->getDriverHandle()->getSvmAllocsManager());
|
||||
if constexpr (checkIfAllocationImportedRequired()) {
|
||||
launchParams.isDestinationAllocationImported = this->isAllocationImported(allocationStruct.alloc, device->getDriverHandle()->getSvmAllocsManager());
|
||||
}
|
||||
|
||||
ret = CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernel(builtinKernel->toHandle(), kernelArgs,
|
||||
event, numWaitEvents, phWaitEvents, launchParams, relaxedOrderingDispatch);
|
||||
@@ -1357,8 +1359,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMemoryCopyKernelWithGA(v
|
||||
(dstAllocationType == NEO::AllocationType::svmCpu) ||
|
||||
(dstAllocationType == NEO::AllocationType::externalHostPtr);
|
||||
|
||||
launchParams.isDestinationAllocationImported = this->isAllocationImported(dstPtrAlloc, device->getDriverHandle()->getSvmAllocsManager());
|
||||
|
||||
if constexpr (checkIfAllocationImportedRequired()) {
|
||||
launchParams.isDestinationAllocationImported = this->isAllocationImported(dstPtrAlloc, device->getDriverHandle()->getSvmAllocsManager());
|
||||
}
|
||||
return CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernelSplit(builtinKernel, dispatchKernelArgs, signalEvent, launchParams);
|
||||
}
|
||||
|
||||
@@ -1926,8 +1929,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMemoryCopyKernel3d(Align
|
||||
(dstAllocationType == NEO::AllocationType::bufferHostMemory) ||
|
||||
(dstAllocationType == NEO::AllocationType::externalHostPtr);
|
||||
|
||||
launchParams.isDestinationAllocationImported = this->isAllocationImported(dstAlignedAllocation->alloc, device->getDriverHandle()->getSvmAllocsManager());
|
||||
|
||||
if constexpr (checkIfAllocationImportedRequired()) {
|
||||
launchParams.isDestinationAllocationImported = this->isAllocationImported(dstAlignedAllocation->alloc, device->getDriverHandle()->getSvmAllocsManager());
|
||||
}
|
||||
return CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernel(builtinKernel->toHandle(), dispatchKernelArgs, signalEvent, numWaitEvents,
|
||||
phWaitEvents, launchParams, relaxedOrderingDispatch);
|
||||
}
|
||||
@@ -1996,8 +2000,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMemoryCopyKernel2d(Align
|
||||
(dstAllocationType == NEO::AllocationType::bufferHostMemory) ||
|
||||
(dstAllocationType == NEO::AllocationType::externalHostPtr);
|
||||
|
||||
launchParams.isDestinationAllocationImported = this->isAllocationImported(dstAlignedAllocation->alloc, device->getDriverHandle()->getSvmAllocsManager());
|
||||
|
||||
if constexpr (CommandListCoreFamily<gfxCoreFamily>::checkIfAllocationImportedRequired()) {
|
||||
launchParams.isDestinationAllocationImported = this->isAllocationImported(dstAlignedAllocation->alloc, device->getDriverHandle()->getSvmAllocsManager());
|
||||
}
|
||||
return CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernel(builtinKernel->toHandle(),
|
||||
dispatchKernelArgs, signalEvent,
|
||||
numWaitEvents,
|
||||
@@ -2144,8 +2149,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMemoryFill(void *ptr,
|
||||
|
||||
launchParams.isBuiltInKernel = true;
|
||||
launchParams.isDestinationAllocationInSystemMemory = hostPointerNeedsFlush;
|
||||
launchParams.isDestinationAllocationImported = this->isAllocationImported(dstAllocation.alloc, device->getDriverHandle()->getSvmAllocsManager());
|
||||
|
||||
if constexpr (checkIfAllocationImportedRequired()) {
|
||||
launchParams.isDestinationAllocationImported = this->isAllocationImported(dstAllocation.alloc, device->getDriverHandle()->getSvmAllocsManager());
|
||||
}
|
||||
CmdListFillKernelArguments fillArguments = {};
|
||||
setupFillKernelArguments(dstAllocation.offset, patternSize, size, fillArguments, builtinKernel);
|
||||
|
||||
@@ -3266,8 +3272,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendQueryKernelTimestamps(
|
||||
(dstAllocationType == NEO::AllocationType::bufferHostMemory) ||
|
||||
(dstAllocationType == NEO::AllocationType::externalHostPtr);
|
||||
|
||||
launchParams.isDestinationAllocationImported = this->isAllocationImported(dstPtrAllocationStruct.alloc, device->getDriverHandle()->getSvmAllocsManager());
|
||||
|
||||
if constexpr (checkIfAllocationImportedRequired()) {
|
||||
launchParams.isDestinationAllocationImported = this->isAllocationImported(dstPtrAllocationStruct.alloc, device->getDriverHandle()->getSvmAllocsManager());
|
||||
}
|
||||
auto appendResult = appendLaunchKernel(builtinKernel->toHandle(), dispatchKernelArgs, hSignalEvent, numWaitEvents,
|
||||
phWaitEvents, launchParams, false);
|
||||
if (appendResult != ZE_RESULT_SUCCESS) {
|
||||
@@ -4494,4 +4501,17 @@ void CommandListCoreFamily<gfxCoreFamily>::dispatchInOrderPostOperationBarrier(E
|
||||
}
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
bool CommandListCoreFamily<gfxCoreFamily>::isAllocationImported(NEO::GraphicsAllocation *gpuAllocation, NEO::SVMAllocsManager *svmManager) const {
|
||||
|
||||
if (svmManager) {
|
||||
NEO::SvmAllocationData *allocData = svmManager->getSVMAlloc(reinterpret_cast<void *>(gpuAllocation->getGpuAddress()));
|
||||
if (allocData && allocData->isImportedAllocation) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace L0 {
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
constexpr bool CommandListCoreFamily<gfxCoreFamily>::isAllocationImported(NEO::GraphicsAllocation *gpuAllocation, NEO::SVMAllocsManager *svmManager) const {
|
||||
constexpr bool CommandListCoreFamily<gfxCoreFamily>::checkIfAllocationImportedRequired() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernelWithParams(K
|
||||
auto svmManager = device->getDriverHandle() ? device->getDriverHandle()->getSvmAllocsManager() : nullptr;
|
||||
|
||||
if (!launchParams.isBuiltInKernel) {
|
||||
auto verifyKernelUsingSystemAllocations = [&isKernelUsingSystemAllocation, &isKernelUsingExternalAllocation, svmManager, this](const NEO::ResidencyContainer &kernelResidencyContainer) {
|
||||
auto verifyKernelUsingSystemAllocations = [&](const NEO::ResidencyContainer &kernelResidencyContainer) {
|
||||
for (const auto &allocation : kernelResidencyContainer) {
|
||||
if (allocation == nullptr) {
|
||||
continue;
|
||||
@@ -235,7 +235,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernelWithParams(K
|
||||
isKernelUsingSystemAllocation = true;
|
||||
}
|
||||
|
||||
isKernelUsingExternalAllocation = this->isAllocationImported(allocation, svmManager);
|
||||
if constexpr (checkIfAllocationImportedRequired()) {
|
||||
isKernelUsingExternalAllocation = this->isAllocationImported(allocation, svmManager);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -94,6 +94,7 @@ struct WhiteBox<::L0::CommandListCoreFamily<gfxCoreFamily>>
|
||||
using BaseClass::inOrderPatchCmds;
|
||||
using BaseClass::internalUsage;
|
||||
using BaseClass::interruptEvents;
|
||||
using BaseClass::isAllocationImported;
|
||||
using BaseClass::isFlushTaskSubmissionEnabled;
|
||||
using BaseClass::isInOrderNonWalkerSignalingRequired;
|
||||
using BaseClass::isQwordInOrderCounter;
|
||||
|
||||
@@ -3056,5 +3056,14 @@ HWTEST2_F(CommandListCreateTests, givenDummyBlitNotRequiredWhenEncodeMiFlushThen
|
||||
EXPECT_EQ(commandContainer.getResidencyContainer().size(), 0u);
|
||||
}
|
||||
|
||||
HWTEST2_F(CommandListCreateTests, givenEmptySvmManagerWhenIsAllocationImportedThenFalseIsReturned, MatchAny) {
|
||||
auto commandListCore = std::make_unique<WhiteBox<L0::CommandListCoreFamily<gfxCoreFamily>>>();
|
||||
commandListCore->initialize(device, NEO::EngineGroupType::compute, 0u);
|
||||
|
||||
NEO::SVMAllocsManager *svmManager = nullptr;
|
||||
|
||||
EXPECT_FALSE(commandListCore->isAllocationImported(nullptr, svmManager));
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
||||
Reference in New Issue
Block a user