Handle page faults while accessing unified memory

Related-To: NEO-3330

Change-Id: I7e21f894e9d1c82598954c49342d1f65af07498f
Signed-off-by: Jobczyk, Lukasz <lukasz.jobczyk@intel.com>
This commit is contained in:
Jobczyk, Lukasz
2019-07-04 12:17:42 +02:00
committed by sys_ocldev
parent cf979c3bc0
commit 76fe09c2a9
46 changed files with 1320 additions and 67 deletions

View File

@ -976,6 +976,11 @@ inline void Kernel::makeArgsResident(CommandStreamReceiver &commandStreamReceive
if (kernelArguments[argIndex].object) {
if (kernelArguments[argIndex].type == SVM_ALLOC_OBJ) {
auto pSVMAlloc = (GraphicsAllocation *)kernelArguments[argIndex].object;
auto pageFaultManager = this->getContext().getMemoryManager()->getPageFaultManager();
if (pageFaultManager &&
this->isUnifiedMemorySyncRequired) {
pageFaultManager->moveAllocationToGpuDomain(reinterpret_cast<void *>(pSVMAlloc->getGpuAddress()));
}
commandStreamReceiver.makeResident(*pSVMAlloc);
} else if (Kernel::isMemObj(kernelArguments[argIndex].type)) {
auto clMem = const_cast<cl_mem>(static_cast<const _cl_mem *>(kernelArguments[argIndex].object));
@ -1014,10 +1019,18 @@ void Kernel::makeResident(CommandStreamReceiver &commandStreamReceiver) {
commandStreamReceiver.makeResident(*gfxAlloc);
}
auto pageFaultManager = this->getContext().getMemoryManager()->getPageFaultManager();
for (auto gfxAlloc : kernelUnifiedMemoryGfxAllocations) {
commandStreamReceiver.makeResident(*gfxAlloc);
if (pageFaultManager) {
pageFaultManager->moveAllocationToGpuDomain(reinterpret_cast<void *>(gfxAlloc->getGpuAddress()));
}
}
if (unifiedMemoryControls.indirectSharedAllocationsAllowed && pageFaultManager) {
pageFaultManager->moveAllocationsWithinUMAllocsManagerToGpuDomain(this->getContext().getSVMAllocsManager());
}
makeArgsResident(commandStreamReceiver);
auto kernelIsaAllocation = this->kernelInfo.kernelAllocation;

View File

@ -389,6 +389,9 @@ class Kernel : public BaseObject<_cl_kernel> {
void setAuxTranslationDirection(AuxTranslationDirection auxTranslationDirection) {
this->auxTranslationDirection = auxTranslationDirection;
}
void setUnifiedMemorySyncRequirement(bool isUnifiedMemorySyncRequired) {
this->isUnifiedMemorySyncRequired = isUnifiedMemorySyncRequired;
}
void setUnifiedMemoryProperty(cl_kernel_exec_info infoType, bool infoValue);
void setUnifiedMemoryExecInfo(GraphicsAllocation *argValue);
void clearUnifiedMemoryExecInfo();
@ -524,5 +527,6 @@ class Kernel : public BaseObject<_cl_kernel> {
bool svmAllocationsRequireCacheFlush = false;
std::vector<GraphicsAllocation *> kernelArgRequiresCacheFlush;
UnifiedMemoryControls unifiedMemoryControls;
bool isUnifiedMemorySyncRequired = true;
};
} // namespace NEO