Check indirect access from igc

Also add workaround for app passing svm pointers by value

Related-To: NEO-7182

Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
Dominik Dabek
2022-07-15 13:07:45 +00:00
committed by Compute-Runtime-Automation
parent 742847bed4
commit e5d63cd303
9 changed files with 174 additions and 14 deletions

View File

@ -258,7 +258,8 @@ cl_int Kernel::initialize() {
this->kernelHasIndirectAccess |= kernelInfo.kernelDescriptor.kernelAttributes.hasNonKernelArgLoad ||
kernelInfo.kernelDescriptor.kernelAttributes.hasNonKernelArgStore ||
kernelInfo.kernelDescriptor.kernelAttributes.hasNonKernelArgAtomic;
kernelInfo.kernelDescriptor.kernelAttributes.hasNonKernelArgAtomic ||
kernelInfo.hasIndirectStatelessAccess;
provideInitializationHints();
// resolve the new kernel info to account for kernel handlers
@ -1119,6 +1120,14 @@ inline void Kernel::makeArgsResident(CommandStreamReceiver &commandStreamReceive
commandStreamReceiver.makeResident(*memObj->getMcsAllocation());
}
}
} else if (kernelArguments[argIndex].svmAllocation) {
auto svmAlloc = kernelArguments[argIndex].svmAllocation;
auto pageFaultManager = executionEnvironment.memoryManager->getPageFaultManager();
if (pageFaultManager &&
this->isUnifiedMemorySyncRequired) {
pageFaultManager->moveAllocationToGpuDomain(reinterpret_cast<void *>(svmAlloc->getGpuAddress()));
}
commandStreamReceiver.makeResident(*svmAlloc);
}
}
}
@ -1251,9 +1260,9 @@ void Kernel::makeResident(CommandStreamReceiver &commandStreamReceiver) {
gtpinNotifyMakeResident(this, &commandStreamReceiver);
if (unifiedMemoryControls.indirectDeviceAllocationsAllowed ||
unifiedMemoryControls.indirectHostAllocationsAllowed ||
unifiedMemoryControls.indirectSharedAllocationsAllowed) {
if (this->kernelHasIndirectAccess && (unifiedMemoryControls.indirectDeviceAllocationsAllowed ||
unifiedMemoryControls.indirectHostAllocationsAllowed ||
unifiedMemoryControls.indirectSharedAllocationsAllowed)) {
this->getContext().getSVMAllocsManager()->makeInternalAllocationsResident(commandStreamReceiver, unifiedMemoryControls.generateMask());
}
}
@ -1635,6 +1644,24 @@ cl_int Kernel::setArgImmediate(uint32_t argIndex,
}
}
if (KernelArgMetadata::AddressSpaceQualifier::AddrPrivate == kernelInfo.getArgDescriptorAt(argIndex).getTraits().getAddressQualifier() &&
sizeof(void *) == argSize &&
isAligned<sizeof(void *)>(argVal)) {
const auto possibleSvmPointer = *static_cast<void *const *>(argVal);
if (possibleSvmPointer && isAligned<sizeof(void *)>(possibleSvmPointer)) {
const auto context = this->program->getContextPtr();
if (context) {
const auto svmManager = context->getSVMAllocsManager();
if (svmManager) {
auto possibleSvmAlloc = svmManager->getSVMAlloc(possibleSvmPointer);
if (possibleSvmAlloc) {
this->kernelArguments[argIndex].svmAllocation = possibleSvmAlloc->gpuAllocations.getGraphicsAllocation(this->getDevice().getRootDeviceIndex());
}
}
}
}
}
retVal = CL_SUCCESS;
}