Fix OCL MOCS index with UNCACHED flag

Related-To: NEO-5742

Signed-off-by: Konstanty Misiak <konstanty.misiak@intel.com>
This commit is contained in:
Konstanty Misiak 2021-04-28 11:51:38 +00:00 committed by Compute-Runtime-Automation
parent 75e427f2e8
commit c4502ccf66
3 changed files with 34 additions and 0 deletions

View File

@ -907,6 +907,10 @@ cl_int Kernel::setArgSvmAlloc(uint32_t argIndex, void *svmPtr, GraphicsAllocatio
forceNonAuxMode = true;
}
bool argWasUncacheable = kernelArguments[argIndex].isStatelessUncacheable;
bool argIsUncacheable = svmAlloc ? svmAlloc->isUncacheable() : false;
statelessUncacheableArgsCount += (argIsUncacheable ? 1 : 0) - (argWasUncacheable ? 1 : 0);
void *ptrToPatch = patchBufferOffset(argAsPtr, svmPtr, svmAlloc);
if (isValidOffset(argAsPtr.bindful)) {
auto surfaceState = ptrOffset(getSurfaceStateHeap(), argAsPtr.bindful);

View File

@ -119,6 +119,35 @@ TEST_F(KernelArgSvmTest, GivenValidSvmAllocWhenSettingKernelArgThenArgumentsAreS
delete[] svmPtr;
}
TEST_F(KernelArgSvmTest, GivenSvmAllocWithUncacheableWhenSettingKernelArgThenKernelHasUncacheableArgs) {
auto svmPtr = std::make_unique<char[]>(256);
MockGraphicsAllocation svmAlloc(svmPtr.get(), 256);
svmAlloc.setUncacheable(true);
auto retVal = pKernel->setArgSvmAlloc(0, svmPtr.get(), &svmAlloc);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(pKernel->hasUncacheableStatelessArgs());
}
TEST_F(KernelArgSvmTest, GivenSvmAllocWithoutUncacheableAndKenelWithUncachebleArgWhenSettingKernelArgThenKernelDoesNotHaveUncacheableArgs) {
auto svmPtr = std::make_unique<char[]>(256);
MockGraphicsAllocation svmAlloc(svmPtr.get(), 256);
svmAlloc.setUncacheable(true);
auto retVal = pKernel->setArgSvmAlloc(0, svmPtr.get(), &svmAlloc);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(pKernel->hasUncacheableStatelessArgs());
svmAlloc.setUncacheable(false);
pKernel->kernelArguments[0].isStatelessUncacheable = true;
retVal = pKernel->setArgSvmAlloc(0, svmPtr.get(), &svmAlloc);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_FALSE(pKernel->hasUncacheableStatelessArgs());
}
HWTEST_F(KernelArgSvmTest, GivenValidSvmAllocStatefulWhenSettingKernelArgThenArgumentsAreSetCorrectly) {
char *svmPtr = new char[256];

View File

@ -166,6 +166,7 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
bool isFlushL3Required() const { return allocationInfo.flags.flushL3Required; }
void setFlushL3Required(bool flushL3Required) { allocationInfo.flags.flushL3Required = flushL3Required; }
bool isUncacheable() const { return allocationInfo.flags.uncacheable; }
void setUncacheable(bool uncacheable) { allocationInfo.flags.uncacheable = uncacheable; }
bool is32BitAllocation() const { return allocationInfo.flags.is32BitAllocation; }
void set32BitAllocation(bool is32BitAllocation) { allocationInfo.flags.is32BitAllocation = is32BitAllocation; }