diff --git a/opencl/source/kernel/kernel.cpp b/opencl/source/kernel/kernel.cpp index 56d5d743bb..c4e021831f 100644 --- a/opencl/source/kernel/kernel.cpp +++ b/opencl/source/kernel/kernel.cpp @@ -938,7 +938,6 @@ cl_int Kernel::setArgSvm(uint32_t argIndex, size_t svmAllocSize, void *svmPtr, G if (svmPtr != nullptr && isBuiltIn == false) { this->anyKernelArgumentUsingSystemMemory |= true; } - addAllocationToCacheFlushVector(argIndex, svmAlloc); return CL_SUCCESS; } @@ -1001,7 +1000,6 @@ cl_int Kernel::setArgSvmAlloc(uint32_t argIndex, void *svmPtr, GraphicsAllocatio this->anyKernelArgumentUsingSystemMemory |= true; } } - addAllocationToCacheFlushVector(argIndex, svmAlloc); return CL_SUCCESS; } @@ -1546,14 +1544,6 @@ cl_int Kernel::setArgBuffer(uint32_t argIndex, kernelArguments[argIndex].isStatelessUncacheable = argAsPtr.isPureStateful() ? false : buffer->isMemObjUncacheable(); - auto allocationForCacheFlush = graphicsAllocation; - - // if we make object uncacheable for surface state and there are only stateful accesses, then don't flush caches - if (buffer->isMemObjUncacheableForSurfaceState() && argAsPtr.isPureStateful()) { - allocationForCacheFlush = nullptr; - } - - addAllocationToCacheFlushVector(argIndex, allocationForCacheFlush); return CL_SUCCESS; } else { storeKernelArg(argIndex, BUFFER_OBJ, nullptr, argVal, argSize); @@ -1693,7 +1683,6 @@ cl_int Kernel::setArgImageWithMipLevel(uint32_t argIndex, patch((imageDesc.image_height * pixelSize) - 1, crossThreadData, argAsImg.metadataPayload.flatHeight); patch(imageDesc.image_row_pitch - 1, crossThreadData, argAsImg.metadataPayload.flatPitch); - addAllocationToCacheFlushVector(argIndex, graphicsAllocation); retVal = CL_SUCCESS; } diff --git a/opencl/test/unit_test/api/cl_mem_locally_uncached_resource_tests.cpp b/opencl/test/unit_test/api/cl_mem_locally_uncached_resource_tests.cpp index b58279f742..d9d6d2a944 100644 --- a/opencl/test/unit_test/api/cl_mem_locally_uncached_resource_tests.cpp +++ b/opencl/test/unit_test/api/cl_mem_locally_uncached_resource_tests.cpp @@ -349,40 +349,4 @@ HWCMDTEST_F(IGFX_GEN8_CORE, clMemLocallyUncachedResourceFixture, WhenUnsettingUn EXPECT_EQ(mocsUncacheable, cmdQueueMocs(pCmdQ)); } -HWCMDTEST_F(IGFX_GEN8_CORE, clMemLocallyUncachedResourceFixture, givenBuffersThatAreUncachedInSurfaceStateAndAreNotUsedInStatelessFashionThenThoseResourcesAreNotRegistredAsResourcesForCacheFlush) { - DebugManagerStateRestore restorer; - DebugManager.flags.CreateMultipleSubDevices.set(2); - auto context = std::make_unique(); - cl_int retVal = CL_SUCCESS; - MockKernelWithInternals mockKernel(*context->getDevice(0), context.get(), true); - auto kernel = mockKernel.mockKernel; - auto pMultiDeviceKernel = mockKernel.mockMultiDeviceKernel; - mockKernel.kernelInfo.setBufferStateful(0); - mockKernel.kernelInfo.setBufferStateful(1); - - auto bufferCacheable = clCreateBufferWithPropertiesINTEL(context.get(), propertiesCacheable, 0, n * sizeof(float), nullptr, nullptr); - - auto bufferUncacheableInSurfaceState = clCreateBufferWithPropertiesINTEL(context.get(), propertiesUncacheableInSurfaceState, 0, n * sizeof(float), nullptr, nullptr); - auto bufferUncacheable = clCreateBufferWithPropertiesINTEL(context.get(), propertiesUncacheable, 0, n * sizeof(float), nullptr, nullptr); - - retVal = clSetKernelArg(pMultiDeviceKernel, 0, sizeof(cl_mem), &bufferUncacheableInSurfaceState); - EXPECT_EQ(CL_SUCCESS, retVal); - - EXPECT_EQ(nullptr, kernel->kernelArgRequiresCacheFlush[0]); - - retVal = clSetKernelArg(pMultiDeviceKernel, 0, sizeof(cl_mem), &bufferCacheable); - EXPECT_EQ(CL_SUCCESS, retVal); - - EXPECT_NE(nullptr, kernel->kernelArgRequiresCacheFlush[0]); - - retVal = clSetKernelArg(pMultiDeviceKernel, 0, sizeof(cl_mem), &bufferUncacheable); - EXPECT_EQ(CL_SUCCESS, retVal); - - EXPECT_EQ(nullptr, kernel->kernelArgRequiresCacheFlush[0]); - - clReleaseMemObject(bufferUncacheableInSurfaceState); - clReleaseMemObject(bufferUncacheable); - clReleaseMemObject(bufferCacheable); -} - } // namespace clMemLocallyUncachedResourceTests diff --git a/opencl/test/unit_test/helpers/hardware_commands_helper_tests.cpp b/opencl/test/unit_test/helpers/hardware_commands_helper_tests.cpp index 75950b820c..2f6827fdec 100644 --- a/opencl/test/unit_test/helpers/hardware_commands_helper_tests.cpp +++ b/opencl/test/unit_test/helpers/hardware_commands_helper_tests.cpp @@ -1232,34 +1232,6 @@ TEST_F(HardwareCommandsTest, givenCacheFlushAfterWalkerEnabledWhenPlatformNotSup using KernelCacheFlushTests = Test>; -HWTEST_F(KernelCacheFlushTests, givenLocallyUncachedBufferWhenGettingAllocationsForFlushThenEmptyVectorIsReturned) { - DebugManagerStateRestore dbgRestore; - DebugManager.flags.EnableCacheFlushAfterWalker.set(-1); - DebugManager.flags.CreateMultipleSubDevices.set(2); - auto context = std::make_unique(); - auto kernel = std::unique_ptr(Kernel::create(pProgram, pProgram->getKernelInfoForKernel("CopyBuffer"), *context->getDevice(0), retVal)); - ASSERT_EQ(CL_SUCCESS, retVal); - - cl_mem_properties_intel bufferPropertiesUncachedResource[] = {CL_MEM_FLAGS_INTEL, CL_MEM_LOCALLY_UNCACHED_RESOURCE, 0}; - auto bufferLocallyUncached = clCreateBufferWithPropertiesINTEL(context.get(), bufferPropertiesUncachedResource, 0, 1, nullptr, nullptr); - kernel->setArg(0, sizeof(bufferLocallyUncached), &bufferLocallyUncached); - - using CacheFlushAllocationsVec = StackVec; - CacheFlushAllocationsVec cacheFlushVec; - kernel->getAllocationsForCacheFlush(cacheFlushVec); - EXPECT_EQ(0u, cacheFlushVec.size()); - - auto bufferRegular = clCreateBufferWithPropertiesINTEL(context.get(), nullptr, 0, 1, nullptr, nullptr); - kernel->setArg(1, sizeof(bufferRegular), &bufferRegular); - - kernel->getAllocationsForCacheFlush(cacheFlushVec); - size_t expectedCacheFlushVecSize = (hardwareInfo.capabilityTable.supportCacheFlushAfterWalker ? 1u : 0u); - EXPECT_EQ(expectedCacheFlushVecSize, cacheFlushVec.size()); - - clReleaseMemObject(bufferLocallyUncached); - clReleaseMemObject(bufferRegular); -} - struct HardwareCommandsImplicitArgsTests : Test { void SetUp() override { diff --git a/opencl/test/unit_test/kernel/cache_flush_tests.inl b/opencl/test/unit_test/kernel/cache_flush_tests.inl index 94cace2a12..86a90677ff 100644 --- a/opencl/test/unit_test/kernel/cache_flush_tests.inl +++ b/opencl/test/unit_test/kernel/cache_flush_tests.inl @@ -246,7 +246,7 @@ class GivenCacheFlushAfterWalkerEnabledAndProperSteppingIsSetWhenAllocationRequi mockKernel.kernelInfo.kernelAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties(pDevice->getRootDeviceIndex(), true, MemoryConstants::pageSize, AllocationType::INTERNAL_HEAP)); mockKernel.mockKernel->kernelArgRequiresCacheFlush.resize(1); - mockKernel.mockKernel->setArgSvmAlloc(0, svm, svmAllocation, 0u); + mockKernel.mockKernel->kernelArgRequiresCacheFlush[0] = svmAllocation; cmdQ->getUltCommandStreamReceiver().timestampPacketWriteEnabled = false; diff --git a/opencl/test/unit_test/kernel/kernel_arg_buffer_tests.cpp b/opencl/test/unit_test/kernel/kernel_arg_buffer_tests.cpp index 9c9dd91fd2..e2b2e62a4c 100644 --- a/opencl/test/unit_test/kernel/kernel_arg_buffer_tests.cpp +++ b/opencl/test/unit_test/kernel/kernel_arg_buffer_tests.cpp @@ -284,45 +284,6 @@ TEST_F(KernelArgBufferTest, given32BitDeviceWhenArgPassedIsNullThenOnly4BytesAre EXPECT_NE(expValue, *pKernelArg64bit); } -TEST_F(KernelArgBufferTest, givenWritableBufferWhenSettingAsArgThenDoNotExpectAllocationInCacheFlushVector) { - auto buffer = std::make_unique(); - buffer->mockGfxAllocation.setMemObjectsAllocationWithWritableFlags(true); - buffer->mockGfxAllocation.setFlushL3Required(false); - - auto val = static_cast(buffer.get()); - auto pVal = &val; - - auto retVal = pKernel->setArg(0, sizeof(cl_mem *), pVal); - EXPECT_EQ(CL_SUCCESS, retVal); - EXPECT_EQ(nullptr, pKernel->kernelArgRequiresCacheFlush[0]); -} - -TEST_F(KernelArgBufferTest, givenCacheFlushBufferWhenSettingAsArgThenExpectAllocationInCacheFlushVector) { - auto buffer = std::make_unique(); - buffer->mockGfxAllocation.setMemObjectsAllocationWithWritableFlags(false); - buffer->mockGfxAllocation.setFlushL3Required(true); - - auto val = static_cast(buffer.get()); - auto pVal = &val; - - auto retVal = pKernel->setArg(0, sizeof(cl_mem *), pVal); - EXPECT_EQ(CL_SUCCESS, retVal); - EXPECT_EQ(&buffer->mockGfxAllocation, pKernel->kernelArgRequiresCacheFlush[0]); -} - -TEST_F(KernelArgBufferTest, givenNoCacheFlushBufferWhenSettingAsArgThenNotExpectAllocationInCacheFlushVector) { - auto buffer = std::make_unique(); - buffer->mockGfxAllocation.setMemObjectsAllocationWithWritableFlags(false); - buffer->mockGfxAllocation.setFlushL3Required(false); - - auto val = static_cast(buffer.get()); - auto pVal = &val; - - auto retVal = pKernel->setArg(0, sizeof(cl_mem *), pVal); - EXPECT_EQ(CL_SUCCESS, retVal); - EXPECT_EQ(nullptr, pKernel->kernelArgRequiresCacheFlush[0]); -} - TEST_F(KernelArgBufferTest, givenBufferWhenHasDirectStatelessAccessToHostMemoryIsCalledThenReturnFalse) { MockBuffer buffer; buffer.getGraphicsAllocation(mockRootDeviceIndex)->setAllocationType(AllocationType::BUFFER); 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 020178311b..cd064ea6f8 100644 --- a/opencl/test/unit_test/kernel/kernel_arg_svm_tests.cpp +++ b/opencl/test/unit_test/kernel/kernel_arg_svm_tests.cpp @@ -488,46 +488,6 @@ TEST_F(KernelArgSvmTest, givenWritableSvmAllocationWhenSettingAsArgThenDoNotExpe alignedFree(svmPtr); } -TEST_F(KernelArgSvmTest, givenCacheFlushSvmAllocationWhenSettingAsArgThenExpectAllocationInCacheFlushVector) { - const ClDeviceInfo &devInfo = pClDevice->getDeviceInfo(); - if (devInfo.svmCapabilities == 0) { - GTEST_SKIP(); - } - - size_t svmSize = 4096; - void *svmPtr = alignedMalloc(svmSize, MemoryConstants::pageSize); - MockGraphicsAllocation svmAlloc(svmPtr, svmSize); - - svmAlloc.setMemObjectsAllocationWithWritableFlags(false); - svmAlloc.setFlushL3Required(true); - - auto retVal = pKernel->setArgSvmAlloc(0, svmPtr, &svmAlloc, 0u); - EXPECT_EQ(CL_SUCCESS, retVal); - EXPECT_EQ(&svmAlloc, pKernel->kernelArgRequiresCacheFlush[0]); - - alignedFree(svmPtr); -} - -TEST_F(KernelArgSvmTest, givenNoCacheFlushSvmAllocationWhenSettingAsArgThenNotExpectAllocationInCacheFlushVector) { - const ClDeviceInfo &devInfo = pClDevice->getDeviceInfo(); - if (devInfo.svmCapabilities == 0) { - GTEST_SKIP(); - } - - size_t svmSize = 4096; - void *svmPtr = alignedMalloc(svmSize, MemoryConstants::pageSize); - MockGraphicsAllocation svmAlloc(svmPtr, svmSize); - - svmAlloc.setMemObjectsAllocationWithWritableFlags(false); - svmAlloc.setFlushL3Required(false); - - auto retVal = pKernel->setArgSvmAlloc(0, svmPtr, &svmAlloc, 0u); - EXPECT_EQ(CL_SUCCESS, retVal); - EXPECT_EQ(nullptr, pKernel->kernelArgRequiresCacheFlush[0]); - - alignedFree(svmPtr); -} - TEST_F(KernelArgSvmTest, givenWritableSvmAllocationWhenSettingKernelExecInfoThenDoNotExpectSvmFlushFlagTrue) { const ClDeviceInfo &devInfo = pClDevice->getDeviceInfo(); if (devInfo.svmCapabilities == 0) { diff --git a/opencl/test/unit_test/kernel/kernel_image_arg_tests.cpp b/opencl/test/unit_test/kernel/kernel_image_arg_tests.cpp index e8d40dd8f9..e04fd0524f 100644 --- a/opencl/test/unit_test/kernel/kernel_image_arg_tests.cpp +++ b/opencl/test/unit_test/kernel/kernel_image_arg_tests.cpp @@ -330,18 +330,6 @@ TEST_F(KernelImageArgTest, givenWritableImageWhenSettingAsArgThenDoNotExpectAllo EXPECT_EQ(nullptr, pKernel->kernelArgRequiresCacheFlush[0]); } -TEST_F(KernelImageArgTest, givenCacheFlushImageWhenSettingAsArgThenExpectAllocationInCacheFlushVector) { - MockImageBase image; - image.graphicsAllocation->setMemObjectsAllocationWithWritableFlags(false); - image.graphicsAllocation->setFlushL3Required(true); - - cl_mem imageObj = ℑ - - pKernel->setArg(0, sizeof(imageObj), &imageObj); - EXPECT_EQ(CL_SUCCESS, retVal); - EXPECT_EQ(image.graphicsAllocation, pKernel->kernelArgRequiresCacheFlush[0]); -} - TEST_F(KernelImageArgTest, givenNoCacheFlushImageWhenSettingAsArgThenExpectAllocationInCacheFlushVector) { MockImageBase image; image.graphicsAllocation->setMemObjectsAllocationWithWritableFlags(false);