Kernel refactor.

- Change function names to indicate they work on SVM allocations.
- Remove one function used only in tests.

Change-Id: I9b18d9fee3d4f2a46a7f458ca73d39b3863ce6d3
Signed-off-by: Mrozek, Michal <michal.mrozek@intel.com>
This commit is contained in:
Mrozek, Michal
2019-06-14 07:10:45 +02:00
committed by sys_ocldev
parent 8e969684f1
commit be48b56732
7 changed files with 23 additions and 27 deletions

View File

@ -4002,7 +4002,7 @@ cl_int CL_API_CALL clSetKernelExecInfo(cl_kernel kernel,
return CL_INVALID_VALUE;
}
pKernel->clearKernelExecInfo();
pKernel->clearSvmKernelExecInfo();
for (uint32_t i = 0; i < numPointers; i++) {
auto svmData = pKernel->getContext().getSVMAllocsManager()->getSVMAlloc((const void *)pSvmPtrList[i]);
if (svmData == nullptr) {
@ -4011,7 +4011,7 @@ cl_int CL_API_CALL clSetKernelExecInfo(cl_kernel kernel,
return retVal;
}
GraphicsAllocation *svmAlloc = svmData->gpuAllocation;
pKernel->setKernelExecInfo(svmAlloc);
pKernel->setSvmKernelExecInfo(svmAlloc);
}
break;
}

View File

@ -929,14 +929,14 @@ const Kernel::SimpleKernelArgInfo &Kernel::getKernelArgInfo(uint32_t argIndex) c
return kernelArguments[argIndex];
}
void Kernel::setKernelExecInfo(GraphicsAllocation *argValue) {
void Kernel::setSvmKernelExecInfo(GraphicsAllocation *argValue) {
kernelSvmGfxAllocations.push_back(argValue);
if (allocationForCacheFlush(argValue)) {
svmAllocationsRequireCacheFlush = true;
}
}
void Kernel::clearKernelExecInfo() {
void Kernel::clearSvmKernelExecInfo() {
kernelSvmGfxAllocations.clear();
svmAllocationsRequireCacheFlush = false;
}

View File

@ -130,8 +130,8 @@ class Kernel : public BaseObject<_cl_kernel> {
cl_int setArgSvm(uint32_t argIndex, size_t svmAllocSize, void *svmPtr, GraphicsAllocation *svmAlloc, cl_mem_flags svmFlags);
cl_int setArgSvmAlloc(uint32_t argIndex, void *svmPtr, GraphicsAllocation *svmAlloc);
void setKernelExecInfo(GraphicsAllocation *argValue);
void clearKernelExecInfo();
void setSvmKernelExecInfo(GraphicsAllocation *argValue);
void clearSvmKernelExecInfo();
cl_int getInfo(cl_kernel_info paramName, size_t paramValueSize,
void *paramValue, size_t *paramValueSizeRet) const;
@ -174,10 +174,6 @@ class Kernel : public BaseObject<_cl_kernel> {
return kernelArguments;
}
const std::vector<GraphicsAllocation *> &getKernelSvmGfxAllocations() const {
return kernelSvmGfxAllocations;
}
size_t getKernelArgsNumber() const {
return kernelInfo.kernelArgInfo.size();
}

View File

@ -150,7 +150,7 @@ TEST_F(clSetKernelExecInfoTests, success_SvmPtrListWithSinglePointer) {
);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(1u, pMockKernel->getKernelSvmGfxAllocations().size());
EXPECT_EQ(1u, pMockKernel->kernelSvmGfxAllocations.size());
}
}
@ -173,7 +173,7 @@ TEST_F(clSetKernelExecInfoTests, success_SvmPtrListWithMultiplePointers) {
);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(3u, pMockKernel->getKernelSvmGfxAllocations().size());
EXPECT_EQ(3u, pMockKernel->kernelSvmGfxAllocations.size());
EXPECT_TRUE(pMockKernel->svmAllocationsRequireCacheFlush);
clSVMFree(pContext, ptrSvm1);
@ -200,7 +200,7 @@ TEST_F(clSetKernelExecInfoTests, givenReadOnlySvmPtrListWhenUsedAsKernelPointers
);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(2u, pMockKernel->getKernelSvmGfxAllocations().size());
EXPECT_EQ(2u, pMockKernel->kernelSvmGfxAllocations.size());
EXPECT_FALSE(pMockKernel->svmAllocationsRequireCacheFlush);
clSVMFree(pContext, ptrSvm1);
@ -221,7 +221,7 @@ TEST_F(clSetKernelExecInfoTests, success_MultipleSetKernelExecInfo) {
);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(1u, pMockKernel->getKernelSvmGfxAllocations().size());
EXPECT_EQ(1u, pMockKernel->kernelSvmGfxAllocations.size());
retVal = clSetKernelExecInfo(
pMockKernel, // cl_kernel kernel
@ -231,7 +231,7 @@ TEST_F(clSetKernelExecInfoTests, success_MultipleSetKernelExecInfo) {
);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(1u, pMockKernel->getKernelSvmGfxAllocations().size());
EXPECT_EQ(1u, pMockKernel->kernelSvmGfxAllocations.size());
}
}
} // namespace ULT

View File

@ -604,9 +604,9 @@ TEST_F(EnqueueSvmTest, enqueueTaskWithKernelExecInfo_success) {
std::unique_ptr<Program> program(Program::create("FillBufferBytes", context, *pDevice, true, &retVal));
cl_device_id device = pDevice;
program->build(1, &device, nullptr, nullptr, nullptr, false);
std::unique_ptr<Kernel> kernel(Kernel::create<MockKernel>(program.get(), *program->getKernelInfo("FillBufferBytes"), &retVal));
std::unique_ptr<MockKernel> kernel(Kernel::create<MockKernel>(program.get(), *program->getKernelInfo("FillBufferBytes"), &retVal));
kernel->setKernelExecInfo(pSvmAlloc);
kernel->setSvmKernelExecInfo(pSvmAlloc);
size_t offset = 0;
size_t size = 1;
@ -621,7 +621,7 @@ TEST_F(EnqueueSvmTest, enqueueTaskWithKernelExecInfo_success) {
nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(1u, kernel->getKernelSvmGfxAllocations().size());
EXPECT_EQ(1u, kernel->kernelSvmGfxAllocations.size());
}
TEST_F(EnqueueSvmTest, givenEnqueueTaskBlockedOnUserEventWhenItIsEnqueuedThenSurfacesAreMadeResident) {
@ -639,7 +639,7 @@ TEST_F(EnqueueSvmTest, givenEnqueueTaskBlockedOnUserEventWhenItIsEnqueuedThenSur
kernel->getResidency(allSurfaces);
EXPECT_EQ(1u, allSurfaces.size());
kernel->setKernelExecInfo(pSvmAlloc);
kernel->setSvmKernelExecInfo(pSvmAlloc);
auto uEvent = make_releaseable<UserEvent>();
cl_event eventWaitList[] = {uEvent.get()};
@ -662,7 +662,7 @@ TEST_F(EnqueueSvmTest, givenEnqueueTaskBlockedOnUserEventWhenItIsEnqueuedThenSur
for (auto &surface : allSurfaces)
delete surface;
EXPECT_EQ(1u, kernel->getKernelSvmGfxAllocations().size());
EXPECT_EQ(1u, kernel->kernelSvmGfxAllocations.size());
uEvent->setStatus(-1);
}

View File

@ -520,15 +520,15 @@ TEST_F(CloneKernelTest, cloneKernelWithExecInfo) {
GraphicsAllocation *pSvmAlloc = svmData->gpuAllocation;
ASSERT_NE(nullptr, pSvmAlloc);
pSourceKernel->setKernelExecInfo(pSvmAlloc);
pSourceKernel->setSvmKernelExecInfo(pSvmAlloc);
EXPECT_EQ(1u, pSourceKernel->getKernelSvmGfxAllocations().size());
EXPECT_EQ(1u, pSourceKernel->kernelSvmGfxAllocations.size());
retVal = pClonedKernel->cloneKernel(pSourceKernel);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(pSourceKernel->getKernelSvmGfxAllocations().size(), pClonedKernel->getKernelSvmGfxAllocations().size());
EXPECT_EQ(pSourceKernel->getKernelSvmGfxAllocations().at(0), pClonedKernel->getKernelSvmGfxAllocations().at(0));
EXPECT_EQ(pSourceKernel->kernelSvmGfxAllocations.size(), pClonedKernel->kernelSvmGfxAllocations.size());
EXPECT_EQ(pSourceKernel->kernelSvmGfxAllocations.at(0), pClonedKernel->kernelSvmGfxAllocations.at(0));
pContext->getSVMAllocsManager()->freeSVMAlloc(ptrSVM);
}

View File

@ -467,7 +467,7 @@ TEST_F(KernelArgSvmTest, givenWritableSvmAllocationWhenSettingKernelExecInfoThen
svmAlloc.setMemObjectsAllocationWithWritableFlags(true);
svmAlloc.setFlushL3Required(false);
pKernel->setKernelExecInfo(&svmAlloc);
pKernel->setSvmKernelExecInfo(&svmAlloc);
EXPECT_FALSE(pKernel->svmAllocationsRequireCacheFlush);
alignedFree(svmPtr);
@ -481,7 +481,7 @@ TEST_F(KernelArgSvmTest, givenCacheFlushSvmAllocationWhenSettingKernelExecInfoTh
svmAlloc.setMemObjectsAllocationWithWritableFlags(false);
svmAlloc.setFlushL3Required(true);
pKernel->setKernelExecInfo(&svmAlloc);
pKernel->setSvmKernelExecInfo(&svmAlloc);
EXPECT_TRUE(pKernel->svmAllocationsRequireCacheFlush);
alignedFree(svmPtr);
@ -495,7 +495,7 @@ TEST_F(KernelArgSvmTest, givenNoCacheFlushReadOnlySvmAllocationWhenSettingKernel
svmAlloc.setMemObjectsAllocationWithWritableFlags(false);
svmAlloc.setFlushL3Required(false);
pKernel->setKernelExecInfo(&svmAlloc);
pKernel->setSvmKernelExecInfo(&svmAlloc);
EXPECT_FALSE(pKernel->svmAllocationsRequireCacheFlush);
alignedFree(svmPtr);