From 9d7807709d27c22a376302a58fb2605803622c25 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Tue, 17 Nov 2020 11:08:06 +0100 Subject: [PATCH] Dont use Device from Kernel 2/n make getDevice method protected Related-To: NEO-5001 Signed-off-by: Mateusz Jablonski --- opencl/source/api/api.cpp | 4 ++-- opencl/source/kernel/kernel.h | 9 +++++---- .../cl_mem_locally_uncached_resource_tests.cpp | 16 ++++++++-------- .../command_queue/command_enqueue_fixture.h | 2 +- .../command_queue/sync_buffer_handler_tests.cpp | 4 ++-- .../enqueue_execution_model_kernel_tests.cpp | 4 ++-- 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/opencl/source/api/api.cpp b/opencl/source/api/api.cpp index 2584a49593..3f993747ec 100644 --- a/opencl/source/api/api.cpp +++ b/opencl/source/api/api.cpp @@ -4611,7 +4611,7 @@ cl_int CL_API_CALL clSetKernelArgSVMPointer(cl_kernel kernel, } } } else { - pSvmAlloc = svmData->gpuAllocations.getGraphicsAllocation(pKernel->getDevice().getRootDeviceIndex()); + pSvmAlloc = svmData->gpuAllocations.getGraphicsAllocation(pKernel->getDevices()[0]->getRootDeviceIndex()); } } @@ -4680,7 +4680,7 @@ cl_int CL_API_CALL clSetKernelExecInfo(cl_kernel kernel, TRACING_EXIT(clSetKernelExecInfo, &retVal); return retVal; } - GraphicsAllocation *svmAlloc = svmData->gpuAllocations.getGraphicsAllocation(pKernel->getDevice().getRootDeviceIndex()); + GraphicsAllocation *svmAlloc = svmData->gpuAllocations.getGraphicsAllocation(pKernel->getDevices()[0]->getRootDeviceIndex()); if (paramName == CL_KERNEL_EXEC_INFO_SVM_PTRS) { pKernel->setSvmKernelExecInfo(svmAlloc); diff --git a/opencl/source/kernel/kernel.h b/opencl/source/kernel/kernel.h index c758a10b58..81d3023819 100644 --- a/opencl/source/kernel/kernel.h +++ b/opencl/source/kernel/kernel.h @@ -188,10 +188,6 @@ class Kernel : public BaseObject<_cl_kernel> { return kernelInfo; } - const ClDevice &getDevice() const { - return *deviceVector[0]; - } - Context &getContext() const { return context ? *context : program->getContext(); } @@ -513,6 +509,11 @@ class Kernel : public BaseObject<_cl_kernel> { void addAllocationToCacheFlushVector(uint32_t argIndex, GraphicsAllocation *argAllocation); bool allocationForCacheFlush(GraphicsAllocation *argAllocation) const; + + const ClDevice &getDevice() const { + return *deviceVector[0]; + } + Program *program; Context *context = nullptr; const ClDeviceVector &deviceVector; 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 4729644a79..8417b075c1 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 @@ -77,8 +77,8 @@ HWCMDTEST_F(IGFX_GEN8_CORE, clMemLocallyUncachedResourceFixture, GivenAtLeastOne auto bufferUncacheable2 = clCreateBufferWithPropertiesINTEL(context, propertiesUncacheable, 0, n * sizeof(float), nullptr, nullptr); auto pBufferUncacheable2 = clUniquePtr(castToObject(bufferUncacheable2)); - auto mocsCacheable = kernel->getDevice().getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); - auto mocsUncacheable = kernel->getDevice().getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED); + auto mocsCacheable = pClDevice->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); + auto mocsUncacheable = pClDevice->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED); retVal = clSetKernelArg(kernel, 0, sizeof(cl_mem), &bufferCacheable1); EXPECT_EQ(CL_SUCCESS, retVal); @@ -155,8 +155,8 @@ HWCMDTEST_F(IGFX_GEN8_CORE, clMemLocallyUncachedResourceFixture, givenBuffersTha auto bufferUncacheable2 = clCreateBufferWithPropertiesINTEL(context, propertiesUncacheableInSurfaceState, 0, n * sizeof(float), nullptr, nullptr); auto pBufferUncacheable2 = clUniquePtr(castToObject(bufferUncacheable2)); - auto mocsCacheable = kernel->getDevice().getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); - auto mocsUncacheable = kernel->getDevice().getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED); + auto mocsCacheable = pClDevice->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); + auto mocsUncacheable = pClDevice->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED); retVal = clSetKernelArg(kernel, 0, sizeof(cl_mem), &bufferCacheable1); EXPECT_EQ(CL_SUCCESS, retVal); @@ -232,8 +232,8 @@ HWCMDTEST_F(IGFX_GEN8_CORE, clMemLocallyUncachedResourceFixture, givenBuffersTha auto bufferUncacheable2 = clCreateBufferWithPropertiesINTEL(context, propertiesUncacheable, 0, n * sizeof(float), nullptr, nullptr); auto pBufferUncacheable2 = clUniquePtr(castToObject(bufferUncacheable2)); - auto mocsCacheable = kernel->getDevice().getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); - auto mocsUncacheable = kernel->getDevice().getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED); + auto mocsCacheable = pClDevice->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); + auto mocsUncacheable = pClDevice->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED); retVal = clSetKernelArg(kernel, 0, sizeof(cl_mem), &bufferCacheable1); EXPECT_EQ(CL_SUCCESS, retVal); @@ -307,8 +307,8 @@ HWCMDTEST_F(IGFX_GEN8_CORE, clMemLocallyUncachedResourceFixture, WhenUnsettingUn auto bufferUncacheable = clCreateBufferWithPropertiesINTEL(context, propertiesUncacheable, 0, n * sizeof(float), nullptr, nullptr); auto pBufferUncacheable = clUniquePtr(castToObject(bufferUncacheable)); - auto mocsCacheable = kernel->getDevice().getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); - auto mocsUncacheable = kernel->getDevice().getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED); + auto mocsCacheable = pClDevice->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); + auto mocsUncacheable = pClDevice->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED); retVal = clSetKernelArg(kernel, 0, sizeof(cl_mem), &bufferCacheable1); EXPECT_EQ(CL_SUCCESS, retVal); diff --git a/opencl/test/unit_test/command_queue/command_enqueue_fixture.h b/opencl/test/unit_test/command_queue/command_enqueue_fixture.h index 7ddbdebf37..a8cc0871de 100644 --- a/opencl/test/unit_test/command_queue/command_enqueue_fixture.h +++ b/opencl/test/unit_test/command_queue/command_enqueue_fixture.h @@ -111,7 +111,7 @@ struct CommandQueueStateful : public CommandQueueHw { void enqueueHandlerHook(const unsigned int commandType, const MultiDispatchInfo &dispatchInfo) override { auto kernel = dispatchInfo.begin()->getKernel(); - auto &device = kernel->getDevice(); + auto &device = dispatchInfo.begin()->getClDevice(); if (!device.areSharedSystemAllocationsAllowed()) { EXPECT_FALSE(kernel->getKernelInfo().patchInfo.executionEnvironment->CompiledForGreaterThan4GBBuffers); if (device.getHardwareCapabilities().isStatelesToStatefullWithOffsetSupported) { diff --git a/opencl/test/unit_test/command_queue/sync_buffer_handler_tests.cpp b/opencl/test/unit_test/command_queue/sync_buffer_handler_tests.cpp index c7369a3c37..f308c2ba2e 100644 --- a/opencl/test/unit_test/command_queue/sync_buffer_handler_tests.cpp +++ b/opencl/test/unit_test/command_queue/sync_buffer_handler_tests.cpp @@ -67,7 +67,7 @@ class SyncBufferHandlerTest : public SyncBufferEnqueueHandlerTest { kernel = kernelInternals->mockKernel; kernel->executionType = KernelExecutionType::Concurrent; commandQueue = reinterpret_cast(new MockCommandQueueHw(context, pClDevice, 0)); - hwHelper = &HwHelper::get(kernel->getDevice().getHardwareInfo().platform.eRenderCoreFamily); + hwHelper = &HwHelper::get(pClDevice->getHardwareInfo().platform.eRenderCoreFamily); } template @@ -93,7 +93,7 @@ class SyncBufferHandlerTest : public SyncBufferEnqueueHandlerTest { } bool isCooperativeDispatchSupported() { - return hwHelper->isCooperativeDispatchSupported(commandQueue->getGpgpuEngine().getEngineType(), kernel->getDevice().getHardwareInfo().platform.eProductFamily); + return hwHelper->isCooperativeDispatchSupported(commandQueue->getGpgpuEngine().getEngineType(), commandQueue->getDevice().getHardwareInfo().platform.eProductFamily); } const cl_uint workDim = 1; diff --git a/opencl/test/unit_test/execution_model/enqueue_execution_model_kernel_tests.cpp b/opencl/test/unit_test/execution_model/enqueue_execution_model_kernel_tests.cpp index 20d9ec9fad..2058067d53 100644 --- a/opencl/test/unit_test/execution_model/enqueue_execution_model_kernel_tests.cpp +++ b/opencl/test/unit_test/execution_model/enqueue_execution_model_kernel_tests.cpp @@ -64,7 +64,7 @@ HWCMDTEST_P(IGFX_GEN8_CORE, ParentKernelEnqueueTest, givenParentKernelWhenEnqueu auto graphicsAllocation = pKernel->getKernelInfo().getGraphicsAllocation(); auto kernelIsaAddress = graphicsAllocation->getGpuAddressToPatch(); - auto &hardwareInfo = pKernel->getDevice().getHardwareInfo(); + auto &hardwareInfo = pClDevice->getHardwareInfo(); auto &hwHelper = HwHelper::get(hardwareInfo.platform.eRenderCoreFamily); if (EngineHelpers::isCcs(pCmdQ->getGpgpuEngine().osContext->getEngineType()) && hwHelper.isOffsetToSkipSetFFIDGPWARequired(hardwareInfo)) { @@ -110,7 +110,7 @@ HWCMDTEST_P(IGFX_GEN8_CORE, ParentKernelEnqueueTest, givenParentKernelWhenEnqueu uint64_t blockKernelAddress = ((uint64_t)idData[blockFirstIndex + i].getKernelStartPointerHigh() << 32) | (uint64_t)idData[blockFirstIndex + i].getKernelStartPointer(); uint64_t expectedBlockKernelAddress = pBlockInfo->getGraphicsAllocation()->getGpuAddressToPatch(); - auto &hardwareInfo = pKernel->getDevice().getHardwareInfo(); + auto &hardwareInfo = pClDevice->getHardwareInfo(); auto &hwHelper = HwHelper::get(hardwareInfo.platform.eRenderCoreFamily); if (EngineHelpers::isCcs(pCmdQ->getGpgpuEngine().osContext->getEngineType()) && hwHelper.isOffsetToSkipSetFFIDGPWARequired(hardwareInfo)) {