Handle SVM allocations from multi root device contexts

Related-To: NEO-5001, NEO-3691
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2021-03-23 10:16:23 +00:00
committed by Compute-Runtime-Automation
parent 56b2686f0d
commit d6bbe48175
7 changed files with 144 additions and 48 deletions

View File

@@ -4828,7 +4828,7 @@ cl_int CL_API_CALL clSetKernelArgSVMPointer(cl_kernel kernel,
}
}
GraphicsAllocation *pSvmAlloc = nullptr;
MultiGraphicsAllocation *pSvmAllocs = nullptr;
if (argValue != nullptr) {
auto svmManager = pMultiDeviceKernel->getContext().getSVMAllocsManager();
auto svmData = svmManager->getSVMAlloc(argValue);
@@ -4841,11 +4841,11 @@ cl_int CL_API_CALL clSetKernelArgSVMPointer(cl_kernel kernel,
}
}
} else {
pSvmAlloc = svmData->gpuAllocations.getGraphicsAllocation(pMultiDeviceKernel->getDevices()[0]->getRootDeviceIndex());
pSvmAllocs = &svmData->gpuAllocations;
}
}
retVal = pMultiDeviceKernel->setArgSvmAlloc(argIndex, const_cast<void *>(argValue), pSvmAlloc);
retVal = pMultiDeviceKernel->setArgSvmAlloc(argIndex, const_cast<void *>(argValue), pSvmAllocs);
TRACING_EXIT(clSetKernelArgSVMPointer, &retVal);
return retVal;
}
@@ -4916,12 +4916,12 @@ cl_int CL_API_CALL clSetKernelExecInfo(cl_kernel kernel,
TRACING_EXIT(clSetKernelExecInfo, &retVal);
return retVal;
}
GraphicsAllocation *svmAlloc = svmData->gpuAllocations.getGraphicsAllocation(pMultiDeviceKernel->getDevices()[0]->getRootDeviceIndex());
auto &svmAllocs = svmData->gpuAllocations;
if (paramName == CL_KERNEL_EXEC_INFO_SVM_PTRS) {
pMultiDeviceKernel->setSvmKernelExecInfo(svmAlloc);
pMultiDeviceKernel->setSvmKernelExecInfo(svmAllocs);
} else {
pMultiDeviceKernel->setUnifiedMemoryExecInfo(svmAlloc);
pMultiDeviceKernel->setUnifiedMemoryExecInfo(svmAllocs);
}
}
break;

View File

@@ -467,9 +467,12 @@ cl_int Kernel::cloneKernel(Kernel *pSourceKernel) {
}
// copy additional information other than argument values set to source kernel with clSetKernelExecInfo
for (auto gfxAlloc : pSourceKernel->kernelSvmGfxAllocations) {
for (auto &gfxAlloc : pSourceKernel->kernelSvmGfxAllocations) {
kernelSvmGfxAllocations.push_back(gfxAlloc);
}
for (auto &gfxAlloc : pSourceKernel->kernelUnifiedMemoryGfxAllocations) {
kernelUnifiedMemoryGfxAllocations.push_back(gfxAlloc);
}
this->isBuiltIn = pSourceKernel->isBuiltIn;

View File

@@ -48,11 +48,8 @@ bool MultiDeviceKernel::getHasIndirectAccess() const { return defaultKernel->get
cl_int MultiDeviceKernel::checkCorrectImageAccessQualifier(cl_uint argIndex, size_t argSize, const void *argValue) const { return getResultFromEachKernel(&Kernel::checkCorrectImageAccessQualifier, argIndex, argSize, argValue); }
void MultiDeviceKernel::unsetArg(uint32_t argIndex) { callOnEachKernel(&Kernel::unsetArg, argIndex); }
cl_int MultiDeviceKernel::setArg(uint32_t argIndex, size_t argSize, const void *argVal) { return getResultFromEachKernel(&Kernel::setArgument, argIndex, argSize, argVal); }
cl_int MultiDeviceKernel::setArgSvmAlloc(uint32_t argIndex, void *svmPtr, GraphicsAllocation *svmAlloc) { return getResultFromEachKernel(&Kernel::setArgSvmAlloc, argIndex, svmPtr, svmAlloc); }
void MultiDeviceKernel::setUnifiedMemoryProperty(cl_kernel_exec_info infoType, bool infoValue) { callOnEachKernel(&Kernel::setUnifiedMemoryProperty, infoType, infoValue); }
void MultiDeviceKernel::setSvmKernelExecInfo(GraphicsAllocation *argValue) { callOnEachKernel(&Kernel::setSvmKernelExecInfo, argValue); }
void MultiDeviceKernel::clearSvmKernelExecInfo() { callOnEachKernel(&Kernel::clearSvmKernelExecInfo); }
void MultiDeviceKernel::setUnifiedMemoryExecInfo(GraphicsAllocation *argValue) { callOnEachKernel(&Kernel::setUnifiedMemoryExecInfo, argValue); }
void MultiDeviceKernel::clearUnifiedMemoryExecInfo() { callOnEachKernel(&Kernel::clearUnifiedMemoryExecInfo); }
int MultiDeviceKernel::setKernelThreadArbitrationPolicy(uint32_t propertyValue) { return getResultFromEachKernel(&Kernel::setKernelThreadArbitrationPolicy, propertyValue); }
cl_int MultiDeviceKernel::setKernelExecutionType(cl_execution_info_kernel_type_intel executionType) { return getResultFromEachKernel(&Kernel::setKernelExecutionType, executionType); }
@@ -68,4 +65,30 @@ cl_int MultiDeviceKernel::cloneKernel(MultiDeviceKernel *pSourceMultiDeviceKerne
}
return CL_SUCCESS;
}
cl_int MultiDeviceKernel::setArgSvmAlloc(uint32_t argIndex, void *svmPtr, MultiGraphicsAllocation *svmAllocs) {
for (auto rootDeviceIndex = 0u; rootDeviceIndex < kernels.size(); rootDeviceIndex++) {
auto pKernel = getKernel(rootDeviceIndex);
if (pKernel) {
auto svmAlloc = svmAllocs ? svmAllocs->getGraphicsAllocation(rootDeviceIndex) : nullptr;
pKernel->setArgSvmAlloc(argIndex, svmPtr, svmAlloc);
}
}
return CL_SUCCESS;
}
void MultiDeviceKernel::setSvmKernelExecInfo(const MultiGraphicsAllocation &argValue) {
for (auto rootDeviceIndex = 0u; rootDeviceIndex < kernels.size(); rootDeviceIndex++) {
auto pKernel = getKernel(rootDeviceIndex);
if (pKernel) {
pKernel->setSvmKernelExecInfo(argValue.getGraphicsAllocation(rootDeviceIndex));
}
}
}
void MultiDeviceKernel::setUnifiedMemoryExecInfo(const MultiGraphicsAllocation &argValue) {
for (auto rootDeviceIndex = 0u; rootDeviceIndex < kernels.size(); rootDeviceIndex++) {
auto pKernel = getKernel(rootDeviceIndex);
if (pKernel) {
pKernel->setUnifiedMemoryExecInfo(argValue.getGraphicsAllocation(rootDeviceIndex));
}
}
}
} // namespace NEO

View File

@@ -54,12 +54,12 @@ class MultiDeviceKernel : public BaseObject<_cl_kernel> {
const ClDeviceVector &getDevices() const;
size_t getKernelArgsNumber() const;
Context &getContext() const;
cl_int setArgSvmAlloc(uint32_t argIndex, void *svmPtr, GraphicsAllocation *svmAlloc);
cl_int setArgSvmAlloc(uint32_t argIndex, void *svmPtr, MultiGraphicsAllocation *svmAllocs);
bool getHasIndirectAccess() const;
void setUnifiedMemoryProperty(cl_kernel_exec_info infoType, bool infoValue);
void setSvmKernelExecInfo(GraphicsAllocation *argValue);
void setSvmKernelExecInfo(const MultiGraphicsAllocation &argValue);
void clearSvmKernelExecInfo();
void setUnifiedMemoryExecInfo(GraphicsAllocation *argValue);
void setUnifiedMemoryExecInfo(const MultiGraphicsAllocation &argValue);
void clearUnifiedMemoryExecInfo();
int setKernelThreadArbitrationPolicy(uint32_t propertyValue);
cl_int setKernelExecutionType(cl_execution_info_kernel_type_intel executionType);