diff --git a/opencl/source/kernel/kernel.cpp b/opencl/source/kernel/kernel.cpp index 62c72aca21..fc9a12c2f4 100644 --- a/opencl/source/kernel/kernel.cpp +++ b/opencl/source/kernel/kernel.cpp @@ -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); diff --git a/opencl/test/unit_test/kernel/kernel_arg_svm_tests.cpp b/opencl/test/unit_test/kernel/kernel_arg_svm_tests.cpp index d742051b5b..d0851fad45 100644 --- a/opencl/test/unit_test/kernel/kernel_arg_svm_tests.cpp +++ b/opencl/test/unit_test/kernel/kernel_arg_svm_tests.cpp @@ -119,6 +119,35 @@ TEST_F(KernelArgSvmTest, GivenValidSvmAllocWhenSettingKernelArgThenArgumentsAreS delete[] svmPtr; } +TEST_F(KernelArgSvmTest, GivenSvmAllocWithUncacheableWhenSettingKernelArgThenKernelHasUncacheableArgs) { + auto svmPtr = std::make_unique(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(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]; diff --git a/shared/source/memory_manager/graphics_allocation.h b/shared/source/memory_manager/graphics_allocation.h index 807bb07731..0c6aa6c272 100644 --- a/shared/source/memory_manager/graphics_allocation.h +++ b/shared/source/memory_manager/graphics_allocation.h @@ -166,6 +166,7 @@ class GraphicsAllocation : public IDNode { 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; }