diff --git a/opencl/source/context/context.cpp b/opencl/source/context/context.cpp index 0629a30677..a7c5093380 100644 --- a/opencl/source/context/context.cpp +++ b/opencl/source/context/context.cpp @@ -388,8 +388,8 @@ SchedulerKernel &Context::getSchedulerKernel() { auto initializeSchedulerProgramAndKernel = [&] { cl_int retVal = CL_SUCCESS; - auto device = &getDevice(0)->getDevice(); - auto src = SchedulerKernel::loadSchedulerKernel(device); + auto clDevice = getDevice(0); + auto src = SchedulerKernel::loadSchedulerKernel(&clDevice->getDevice()); auto program = Program::createBuiltInFromGenBinary(this, devices, @@ -399,7 +399,7 @@ SchedulerKernel &Context::getSchedulerKernel() { DEBUG_BREAK_IF(retVal != CL_SUCCESS); DEBUG_BREAK_IF(!program); - retVal = program->processGenBinary(device->getRootDeviceIndex()); + retVal = program->processGenBinary(*clDevice); DEBUG_BREAK_IF(retVal != CL_SUCCESS); schedulerBuiltIn->pProgram = program; diff --git a/opencl/source/kernel/kernel.cpp b/opencl/source/kernel/kernel.cpp index 2477706ee4..86e6e884fb 100644 --- a/opencl/source/kernel/kernel.cpp +++ b/opencl/source/kernel/kernel.cpp @@ -391,7 +391,7 @@ cl_int Kernel::initialize() { } if (isParentKernel) { - program->allocateBlockPrivateSurfaces(device.getRootDeviceIndex()); + program->allocateBlockPrivateSurfaces(device); } if (program->isKernelDebugEnabled() && getKernelInfo().patchInfo.pAllocateSystemThreadSurface) { diff --git a/opencl/source/kernel/kernel.h b/opencl/source/kernel/kernel.h index e5c711de7b..6ec1375b67 100644 --- a/opencl/source/kernel/kernel.h +++ b/opencl/source/kernel/kernel.h @@ -80,7 +80,7 @@ class Kernel : public BaseObject<_cl_kernel> { cl_int retVal; kernel_t *pKernel = nullptr; - auto clDevice = program->getDevice().template getSpecializedDevice(); + auto clDevice = program->getDevices()[0]; pKernel = new kernel_t(program, kernelInfo, *clDevice); retVal = pKernel->initialize(); diff --git a/opencl/source/program/build.cpp b/opencl/source/program/build.cpp index 28d1f563b3..1c5c96c229 100644 --- a/opencl/source/program/build.cpp +++ b/opencl/source/program/build.cpp @@ -160,9 +160,9 @@ cl_int Program::build( continue; } if (DebugManager.flags.PrintProgramBinaryProcessingTime.get()) { - retVal = TimeMeasureWrapper::functionExecution(*this, &Program::processGenBinary, clDevice->getRootDeviceIndex()); + retVal = TimeMeasureWrapper::functionExecution(*this, &Program::processGenBinary, *clDevice); } else { - retVal = processGenBinary(clDevice->getRootDeviceIndex()); + retVal = processGenBinary(*clDevice); } if (retVal != CL_SUCCESS) { diff --git a/opencl/source/program/get_info.cpp b/opencl/source/program/get_info.cpp index 17f648062f..599dabba79 100644 --- a/opencl/source/program/get_info.cpp +++ b/opencl/source/program/get_info.cpp @@ -33,6 +33,7 @@ cl_int Program::getInfo(cl_program_info paramName, size_t paramValueSize, cl_uint clFalse = CL_FALSE; std::vector devicesToExpose; StackVec binarySizes; + uint32_t numDevices = static_cast(clDevices.size()); switch (paramName) { case CL_PROGRAM_CONTEXT: diff --git a/opencl/source/program/link.cpp b/opencl/source/program/link.cpp index aa9106fbd3..fd1a0d4be4 100644 --- a/opencl/source/program/link.cpp +++ b/opencl/source/program/link.cpp @@ -160,7 +160,7 @@ cl_int Program::link( this->debugData = std::move(compilerOuput.debugData.mem); this->debugDataSize = compilerOuput.debugData.size; - retVal = processGenBinary(device->getRootDeviceIndex()); + retVal = processGenBinary(*device); if (retVal != CL_SUCCESS) { break; } diff --git a/opencl/source/program/process_device_binary.cpp b/opencl/source/program/process_device_binary.cpp index 7bd9593dd8..b8cab8d2ad 100644 --- a/opencl/source/program/process_device_binary.cpp +++ b/opencl/source/program/process_device_binary.cpp @@ -111,16 +111,17 @@ cl_int Program::linkBinary(Device *pDevice, const void *constantsInitData, const } auto &kernHeapInfo = kernelInfo->heapInfo; auto segmentId = &kernelInfo - &this->kernelInfoArray[0]; - this->pDevice->getMemoryManager()->copyMemoryToAllocation(kernelInfo->getGraphicsAllocation(), 0, - isaSegmentsForPatching[segmentId].hostPointer, - kernHeapInfo.KernelHeapSize); + pDevice->getMemoryManager()->copyMemoryToAllocation(kernelInfo->getGraphicsAllocation(), 0, + isaSegmentsForPatching[segmentId].hostPointer, + kernHeapInfo.KernelHeapSize); } } DBG_LOG(PrintRelocations, NEO::constructRelocationsDebugMessage(this->getSymbols(pDevice->getRootDeviceIndex()))); return CL_SUCCESS; } -cl_int Program::processGenBinary(uint32_t rootDeviceIndex) { +cl_int Program::processGenBinary(const ClDevice &clDevice) { + auto rootDeviceIndex = clDevice.getRootDeviceIndex(); if (nullptr == this->buildInfos[rootDeviceIndex].unpackedDeviceBinary) { return CL_INVALID_BINARY; } @@ -128,8 +129,8 @@ cl_int Program::processGenBinary(uint32_t rootDeviceIndex) { cleanCurrentKernelInfo(); for (auto &buildInfo : buildInfos) { if (buildInfo.constantSurface || buildInfo.globalSurface) { - pDevice->getMemoryManager()->freeGraphicsMemory(buildInfo.constantSurface); - pDevice->getMemoryManager()->freeGraphicsMemory(buildInfo.globalSurface); + clDevice.getMemoryManager()->freeGraphicsMemory(buildInfo.constantSurface); + clDevice.getMemoryManager()->freeGraphicsMemory(buildInfo.globalSurface); buildInfo.constantSurface = nullptr; buildInfo.globalSurface = nullptr; } @@ -154,23 +155,24 @@ cl_int Program::processGenBinary(uint32_t rootDeviceIndex) { return CL_INVALID_BINARY; } - return this->processProgramInfo(programInfo); + return this->processProgramInfo(programInfo, clDevice); } -cl_int Program::processProgramInfo(ProgramInfo &src) { +cl_int Program::processProgramInfo(ProgramInfo &src, const ClDevice &clDevice) { + auto rootDeviceIndex = clDevice.getRootDeviceIndex(); size_t slmNeeded = getMaxInlineSlmNeeded(src); size_t slmAvailable = 0U; NEO::DeviceInfoKernelPayloadConstants deviceInfoConstants; LinkerInput *linkerInput = nullptr; - slmAvailable = static_cast(this->pDevice->getDeviceInfo().localMemSize); - deviceInfoConstants.maxWorkGroupSize = (uint32_t)this->pDevice->getDeviceInfo().maxWorkGroupSize; - deviceInfoConstants.computeUnitsUsedForScratch = this->pDevice->getDeviceInfo().computeUnitsUsedForScratch; - deviceInfoConstants.slmWindowSize = (uint32_t)this->pDevice->getDeviceInfo().localMemSize; + slmAvailable = static_cast(clDevice.getSharedDeviceInfo().localMemSize); + deviceInfoConstants.maxWorkGroupSize = static_cast(clDevice.getSharedDeviceInfo().maxWorkGroupSize); + deviceInfoConstants.computeUnitsUsedForScratch = clDevice.getSharedDeviceInfo().computeUnitsUsedForScratch; + deviceInfoConstants.slmWindowSize = static_cast(clDevice.getSharedDeviceInfo().localMemSize); if (requiresLocalMemoryWindowVA(src)) { deviceInfoConstants.slmWindow = this->executionEnvironment.memoryManager->getReservedMemory(MemoryConstants::slmWindowSize, MemoryConstants::slmWindowAlignment); } linkerInput = src.linkerInput.get(); - setLinkerInput(pDevice->getRootDeviceIndex(), std::move(src.linkerInput)); + setLinkerInput(rootDeviceIndex, std::move(src.linkerInput)); if (slmNeeded > slmAvailable) { return CL_OUT_OF_RESOURCES; @@ -178,17 +180,15 @@ cl_int Program::processProgramInfo(ProgramInfo &src) { this->kernelInfoArray = std::move(src.kernelInfos); auto svmAllocsManager = context ? context->getSVMAllocsManager() : nullptr; - auto rootDeviceIndex = pDevice->getRootDeviceIndex(); if (src.globalConstants.size != 0) { - UNRECOVERABLE_IF(nullptr == pDevice); - buildInfos[rootDeviceIndex].constantSurface = allocateGlobalsSurface(svmAllocsManager, *pDevice, src.globalConstants.size, true, linkerInput, src.globalConstants.initData); + buildInfos[rootDeviceIndex].constantSurface = allocateGlobalsSurface(svmAllocsManager, clDevice.getDevice(), src.globalConstants.size, true, linkerInput, src.globalConstants.initData); } buildInfos[rootDeviceIndex].globalVarTotalSize = src.globalVariables.size; if (src.globalVariables.size != 0) { - buildInfos[rootDeviceIndex].globalSurface = allocateGlobalsSurface(svmAllocsManager, *pDevice, src.globalVariables.size, false, linkerInput, src.globalVariables.initData); - if (pDevice->getSpecializedDevice()->areOcl21FeaturesEnabled() == false) { + buildInfos[rootDeviceIndex].globalSurface = allocateGlobalsSurface(svmAllocsManager, clDevice.getDevice(), src.globalVariables.size, false, linkerInput, src.globalVariables.initData); + if (clDevice.areOcl21FeaturesEnabled() == false) { buildInfos[rootDeviceIndex].globalVarTotalSize = 0u; } } @@ -196,7 +196,7 @@ cl_int Program::processProgramInfo(ProgramInfo &src) { for (auto &kernelInfo : this->kernelInfoArray) { cl_int retVal = CL_SUCCESS; if (kernelInfo->heapInfo.KernelHeapSize) { - retVal = kernelInfo->createKernelAllocation(*this->pDevice) ? CL_SUCCESS : CL_OUT_OF_HOST_MEMORY; + retVal = kernelInfo->createKernelAllocation(clDevice.getDevice()) ? CL_SUCCESS : CL_OUT_OF_HOST_MEMORY; } if (retVal != CL_SUCCESS) { @@ -213,7 +213,7 @@ cl_int Program::processProgramInfo(ProgramInfo &src) { kernelInfo->apply(deviceInfoConstants); } - return linkBinary(this->pDevice, src.globalConstants.initData, src.globalVariables.initData); + return linkBinary(&clDevice.getDevice(), src.globalConstants.initData, src.globalVariables.initData); } void Program::processDebugData() { diff --git a/opencl/source/program/program.cpp b/opencl/source/program/program.cpp index 2657f74b34..e046e18568 100644 --- a/opencl/source/program/program.cpp +++ b/opencl/source/program/program.cpp @@ -38,16 +38,12 @@ namespace NEO { Program::Program(Context *context, bool isBuiltIn, const ClDeviceVector &clDevicesIn) : executionEnvironment(*clDevicesIn[0]->getExecutionEnvironment()), context(context), - pDevice(&clDevicesIn[0]->getDevice()), clDevices(clDevicesIn), isBuiltIn(isBuiltIn) { if (this->context && !this->isBuiltIn) { this->context->incRefInternal(); } blockKernelManager = new BlockKernelManager(); - ClDevice *pClDevice = castToObject(pDevice->getSpecializedDevice()); - - numDevices = static_cast(clDevicesIn.size()); uint32_t maxRootDeviceIndex = 0; @@ -67,7 +63,7 @@ Program::Program(Context *context, bool isBuiltIn, const ClDeviceVector &clDevic } buildInfos.resize(maxRootDeviceIndex + 1); - kernelDebugEnabled = pClDevice->isDebuggerActive(); + kernelDebugEnabled = clDevices[0]->isDebuggerActive(); } void Program::initInternalOptions(std::string &internalOptions) const { auto pClDevice = clDevices[0]; @@ -229,15 +225,16 @@ cl_int Program::setProgramSpecializationConstant(cl_uint specId, size_t specSize static std::mutex mutex; std::lock_guard lock(mutex); + auto &device = clDevices[0]->getDevice(); if (!areSpecializationConstantsInitialized) { - auto pCompilerInterface = this->pDevice->getCompilerInterface(); + auto pCompilerInterface = device.getCompilerInterface(); if (nullptr == pCompilerInterface) { return CL_OUT_OF_HOST_MEMORY; } SpecConstantInfo specConstInfo; - auto retVal = pCompilerInterface->getSpecConstantsInfo(this->getDevice(), ArrayRef(irBinary.get(), irBinarySize), specConstInfo); + auto retVal = pCompilerInterface->getSpecConstantsInfo(device, ArrayRef(irBinary.get(), irBinarySize), specConstInfo); if (retVal != TranslationOutput::ErrorCode::Success) { return CL_INVALID_VALUE; @@ -344,7 +341,8 @@ void Program::separateBlockKernels() { allKernelInfos.clear(); } -void Program::allocateBlockPrivateSurfaces(uint32_t rootDeviceIndex) { +void Program::allocateBlockPrivateSurfaces(const ClDevice &clDevice) { + auto rootDeviceIndex = clDevice.getRootDeviceIndex(); size_t blockCount = blockKernelManager->getCount(); for (uint32_t i = 0; i < blockCount; i++) { @@ -354,9 +352,10 @@ void Program::allocateBlockPrivateSurfaces(uint32_t rootDeviceIndex) { auto perHwThreadPrivateMemorySize = PatchTokenBinary::getPerHwThreadPrivateSurfaceSize(info->patchInfo.pAllocateStatelessPrivateSurface, info->getMaxSimdSize()); if (perHwThreadPrivateMemorySize > 0 && blockKernelManager->getPrivateSurface(i) == nullptr) { - auto privateSize = static_cast(KernelHelper::getPrivateSurfaceSize(perHwThreadPrivateMemorySize, getDevice().getDeviceInfo().computeUnitsUsedForScratch)); + auto privateSize = static_cast(KernelHelper::getPrivateSurfaceSize(perHwThreadPrivateMemorySize, clDevice.getSharedDeviceInfo().computeUnitsUsedForScratch)); - auto *privateSurface = this->executionEnvironment.memoryManager->allocateGraphicsMemoryWithProperties({rootDeviceIndex, privateSize, GraphicsAllocation::AllocationType::PRIVATE_SURFACE, getDevice().getDeviceBitfield()}); + auto *privateSurface = this->executionEnvironment.memoryManager->allocateGraphicsMemoryWithProperties( + {rootDeviceIndex, privateSize, GraphicsAllocation::AllocationType::PRIVATE_SURFACE, clDevice.getDeviceBitfield()}); blockKernelManager->pushPrivateSurface(privateSurface, i); } } diff --git a/opencl/source/program/program.h b/opencl/source/program/program.h index f5322ff2ef..e3eedebf5d 100644 --- a/opencl/source/program/program.h +++ b/opencl/source/program/program.h @@ -132,8 +132,8 @@ class Program : public BaseObject<_cl_program> { cl_int build(const ClDeviceVector &deviceVector, const char *buildOptions, bool enableCaching, std::unordered_map &builtinsMap); - MOCKABLE_VIRTUAL cl_int processGenBinary(uint32_t rootDeviceIndex); - MOCKABLE_VIRTUAL cl_int processProgramInfo(ProgramInfo &dst); + MOCKABLE_VIRTUAL cl_int processGenBinary(const ClDevice &clDevice); + MOCKABLE_VIRTUAL cl_int processProgramInfo(ProgramInfo &dst, const ClDevice &clDevice); cl_int compile(const ClDeviceVector &deviceVector, const char *buildOptions, cl_uint numInputHeaders, const cl_program *inputHeaders, const char **headerIncludeNames); @@ -170,11 +170,6 @@ class Program : public BaseObject<_cl_program> { return executionEnvironment; } - const Device &getDevice() const { - UNRECOVERABLE_IF(pDevice == nullptr); - return *pDevice; - } - cl_int processSpirBinary(const void *pBinary, size_t binarySize, bool isSpirV); cl_int getSource(std::string &binary) const; @@ -209,7 +204,7 @@ class Program : public BaseObject<_cl_program> { return blockKernelManager; } - void allocateBlockPrivateSurfaces(uint32_t rootDeviceIndex); + void allocateBlockPrivateSurfaces(const ClDevice &clDevice); void freeBlockResources(); void cleanCurrentKernelInfo(); @@ -346,8 +341,6 @@ class Program : public BaseObject<_cl_program> { BlockKernelManager *blockKernelManager = nullptr; ExecutionEnvironment &executionEnvironment; Context *context = nullptr; - Device *pDevice = nullptr; - cl_uint numDevices = 0U; ClDeviceVector clDevices; bool isBuiltIn = false; diff --git a/opencl/test/unit_test/api/cl_link_program_tests.inl b/opencl/test/unit_test/api/cl_link_program_tests.inl index 1cc52f25c5..be9687d596 100644 --- a/opencl/test/unit_test/api/cl_link_program_tests.inl +++ b/opencl/test/unit_test/api/cl_link_program_tests.inl @@ -176,7 +176,6 @@ TEST_F(clLinkProgramTests, GivenProgramsWithSpecConstantsThenSpecConstantsAreEmb uint64_t prog2Values[1] = {13}; auto progSrc1 = clUniquePtr(new MockProgram(pContext, false, toClDeviceVector(*pDevice))); - progSrc1->pDevice = pProgram->pDevice; progSrc1->specConstantsValues[prog1Keys[0]] = prog1Values[0]; progSrc1->specConstantsValues[prog1Keys[1]] = prog1Values[1]; progSrc1->areSpecializationConstantsInitialized = true; @@ -185,7 +184,6 @@ TEST_F(clLinkProgramTests, GivenProgramsWithSpecConstantsThenSpecConstantsAreEmb progSrc1->isSpirV = true; auto progSrc2 = clUniquePtr(new MockProgram(pContext, false, toClDeviceVector(*pDevice))); - progSrc2->pDevice = pProgram->pDevice; progSrc2->specConstantsValues[prog2Keys[0]] = prog2Values[0]; progSrc2->areSpecializationConstantsInitialized = true; progSrc2->irBinary = makeCopy(ir2, sizeof(ir2)); @@ -193,13 +191,11 @@ TEST_F(clLinkProgramTests, GivenProgramsWithSpecConstantsThenSpecConstantsAreEmb progSrc2->isSpirV = true; auto progSrc3 = clUniquePtr(new MockProgram(pContext, false, toClDeviceVector(*pDevice))); - progSrc3->pDevice = pProgram->pDevice; progSrc3->irBinary = makeCopy(ir3, sizeof(ir3)); progSrc3->irBinarySize = sizeof(ir3); progSrc3->isSpirV = true; auto progDst = clUniquePtr(new MockProgram(pContext, false, toClDeviceVector(*pDevice))); - progDst->pDevice = pProgram->pDevice; cl_program inputPrograms[3] = {progSrc1.get(), progSrc2.get(), progSrc3.get()}; std::string receivedInput; diff --git a/opencl/test/unit_test/built_ins/built_in_tests.cpp b/opencl/test/unit_test/built_ins/built_in_tests.cpp index 5950c49c0c..cf9335dfcc 100644 --- a/opencl/test/unit_test/built_ins/built_in_tests.cpp +++ b/opencl/test/unit_test/built_ins/built_in_tests.cpp @@ -2012,7 +2012,7 @@ TEST_F(BuiltInTests, WhenGettingSipKernelThenReturnProgramCreatedFromIsaAcquired cl_int errCode = CL_BUILD_PROGRAM_FAILURE; auto p = Program::createBuiltInFromGenBinary(pContext, pContext->getDevices(), mockCompilerInterface->sipKernelBinaryOverride.data(), mockCompilerInterface->sipKernelBinaryOverride.size(), &errCode); ASSERT_EQ(CL_SUCCESS, errCode); - errCode = p->processGenBinary(rootDeviceIndex); + errCode = p->processGenBinary(*pClDevice); ASSERT_EQ(CL_SUCCESS, errCode); const SipKernel &sipKern = mockBuiltins.getSipKernel(SipKernelType::Csr, pContext->getDevice(0)->getDevice()); diff --git a/opencl/test/unit_test/command_queue/blit_enqueue_tests.cpp b/opencl/test/unit_test/command_queue/blit_enqueue_tests.cpp index 1c868626ee..abc6af996d 100644 --- a/opencl/test/unit_test/command_queue/blit_enqueue_tests.cpp +++ b/opencl/test/unit_test/command_queue/blit_enqueue_tests.cpp @@ -1693,7 +1693,7 @@ HWTEST_TEMPLATED_F(BlitCopyTests, givenLocalMemoryAccessNotAllowedWhenGlobalCons EXPECT_EQ(0u, bcsMockContext->bcsCsr->peekTaskCount()); - program.processProgramInfo(programInfo); + program.processProgramInfo(programInfo, *device); EXPECT_EQ(1u, bcsMockContext->bcsCsr->peekTaskCount()); diff --git a/opencl/test/unit_test/fixtures/kernel_data_fixture.cpp b/opencl/test/unit_test/fixtures/kernel_data_fixture.cpp index 007e7ea5eb..90e343b9c9 100644 --- a/opencl/test/unit_test/fixtures/kernel_data_fixture.cpp +++ b/opencl/test/unit_test/fixtures/kernel_data_fixture.cpp @@ -91,7 +91,7 @@ void KernelDataTest::buildAndDecode() { ProgramInfo programInfo; NEO::populateProgramInfo(programInfo, programFromPatchtokens); - error = program->processProgramInfo(programInfo); + error = program->processProgramInfo(programInfo, *pContext->getDevice(0)); EXPECT_EQ(CL_SUCCESS, error); // extract the kernel info diff --git a/opencl/test/unit_test/gtpin/gtpin_tests.cpp b/opencl/test/unit_test/gtpin/gtpin_tests.cpp index 842c2a0588..57d4fd197b 100644 --- a/opencl/test/unit_test/gtpin/gtpin_tests.cpp +++ b/opencl/test/unit_test/gtpin/gtpin_tests.cpp @@ -1028,7 +1028,7 @@ TEST_F(GTPinTests, givenInitializedGTPinInterfaceWhenKernelWithoutSSHIsUsedThenK pProgram->buildInfos[rootDeviceIndex].unpackedDeviceBinary = makeCopy(reinterpret_cast(programTokens.storage.data()), programTokens.storage.size()); pProgram->buildInfos[rootDeviceIndex].unpackedDeviceBinarySize = programTokens.storage.size(); - retVal = pProgram->processGenBinary(rootDeviceIndex); + retVal = pProgram->processGenBinary(*pContext->getDevice(0)); EXPECT_EQ(CL_SUCCESS, retVal); int prevCount = KernelCreateCallbackCount; @@ -1167,7 +1167,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, GTPinTests, givenInitializedGTPinInterfaceWhenKernel pProgram->buildInfos[rootDeviceIndex].unpackedDeviceBinary = makeCopy(&binary[0], binSize); pProgram->buildInfos[rootDeviceIndex].unpackedDeviceBinarySize = binSize; - retVal = pProgram->processGenBinary(rootDeviceIndex); + retVal = pProgram->processGenBinary(*pDevice); EXPECT_EQ(CL_SUCCESS, retVal); // Verify that GT-Pin Kernel Create callback is not called @@ -2113,7 +2113,7 @@ TEST_F(GTPinTests, givenInitializedGTPinInterfaceWhenLowMemoryConditionOccursThe pProgram->buildInfos[rootDeviceIndex].unpackedDeviceBinary = makeCopy(programTokens.storage.data(), programTokens.storage.size()); pProgram->buildInfos[rootDeviceIndex].unpackedDeviceBinarySize = programTokens.storage.size(); - retVal = pProgram->processGenBinary(rootDeviceIndex); + retVal = pProgram->processGenBinary(*pDevice); if (retVal == CL_OUT_OF_HOST_MEMORY) { auto nonFailingAlloc = MemoryManagement::nonfailingAllocation; EXPECT_NE(nonFailingAlloc, failureIndex); diff --git a/opencl/test/unit_test/helpers/dispatch_info_builder_tests.cpp b/opencl/test/unit_test/helpers/dispatch_info_builder_tests.cpp index f3baca7ee9..de2ec43aee 100644 --- a/opencl/test/unit_test/helpers/dispatch_info_builder_tests.cpp +++ b/opencl/test/unit_test/helpers/dispatch_info_builder_tests.cpp @@ -276,8 +276,8 @@ TEST_F(DispatchInfoBuilderTest, WhenGettingLwsThenCorrectValuesAreReturned) { } size_t expectedResult[] = {16u, 16u, 1u}; - const auto &hwInfo = pProgram->getDevice().getHardwareInfo(); - auto isSimulation = pProgram->getDevice().isSimulation(); + const auto &hwInfo = pDevice->getHardwareInfo(); + auto isSimulation = pDevice->isSimulation(); EXPECT_FALSE(isSimulation); diff --git a/opencl/test/unit_test/kernel/kernel_tests.cpp b/opencl/test/unit_test/kernel/kernel_tests.cpp index 7ae33c6019..bf2122416e 100644 --- a/opencl/test/unit_test/kernel/kernel_tests.cpp +++ b/opencl/test/unit_test/kernel/kernel_tests.cpp @@ -3237,7 +3237,11 @@ TEST_F(KernelMultiRootDeviceTest, WhenGettingRootDeviceIndexThenCorrectRootDevic TEST(KernelCreateTest, whenInitFailedThenReturnNull) { struct MockProgram { - Device &getDevice() { return mDevice.getDevice(); } + ClDeviceVector getDevices() { + ClDeviceVector deviceVector; + deviceVector.push_back(&mDevice); + return deviceVector; + } void getSource(std::string &) {} MockClDevice mDevice{new MockDevice}; } mockProgram; diff --git a/opencl/test/unit_test/mocks/mock_program.cpp b/opencl/test/unit_test/mocks/mock_program.cpp index 3ae1afe7bd..d4746b5c29 100644 --- a/opencl/test/unit_test/mocks/mock_program.cpp +++ b/opencl/test/unit_test/mocks/mock_program.cpp @@ -29,7 +29,6 @@ ClDeviceVector toClDeviceVector(ClDevice &clDevice) { return deviceVector; } ProgramInfo *GlobalMockSipProgram::globalSipProgramInfo; -Device *MockProgram::getDevicePtr() { return this->pDevice; } int MockProgram::initInternalOptionsCalled = 0; std::string MockProgram::getCachedFileName() const { diff --git a/opencl/test/unit_test/mocks/mock_program.h b/opencl/test/unit_test/mocks/mock_program.h index 6cc2ad030a..f6b5503690 100644 --- a/opencl/test/unit_test/mocks/mock_program.h +++ b/opencl/test/unit_test/mocks/mock_program.h @@ -51,7 +51,6 @@ class MockProgram : public Program { using Program::isSpirV; using Program::options; using Program::packDeviceBinary; - using Program::pDevice; using Program::Program; using Program::sourceCode; using Program::specConstantsIds; @@ -127,8 +126,6 @@ class MockProgram : public Program { allowNonUniform = allow; } - Device *getDevicePtr(); - bool isFlagOption(ConstStringRef option) override { if (isFlagOptionOverride != -1) { return (isFlagOptionOverride > 0); @@ -158,13 +155,14 @@ class MockProgram : public Program { } Program::replaceDeviceBinary(std::move(newBinary), newBinarySize, rootDeviceIndex); } - cl_int processGenBinary(uint32_t rootDeviceIndex) override { + cl_int processGenBinary(const ClDevice &clDevice) override { + auto rootDeviceIndex = clDevice.getRootDeviceIndex(); if (processGenBinaryCalledPerRootDevice.find(rootDeviceIndex) == processGenBinaryCalledPerRootDevice.end()) { processGenBinaryCalledPerRootDevice.insert({rootDeviceIndex, 1}); } else { processGenBinaryCalledPerRootDevice[rootDeviceIndex]++; } - return Program::processGenBinary(rootDeviceIndex); + return Program::processGenBinary(clDevice); } void initInternalOptions(std::string &internalOptions) const override { diff --git a/opencl/test/unit_test/program/program_data_tests.cpp b/opencl/test/unit_test/program/program_data_tests.cpp index 2a647b175b..e82b746f5e 100644 --- a/opencl/test/unit_test/program/program_data_tests.cpp +++ b/opencl/test/unit_test/program/program_data_tests.cpp @@ -50,7 +50,9 @@ class ProgramDataTestBase : public testing::Test, void SetUp() override { PlatformFixture::SetUp(); - cl_device_id device = pPlatform->getClDevice(0); + pClDevice = pPlatform->getClDevice(0); + cl_device_id device = pClDevice; + ContextFixture::SetUp(1, &device); ProgramFixture::SetUp(); @@ -125,6 +127,7 @@ class ProgramDataTestBase : public testing::Test, uint32_t programPatchListSize; cl_int patchlistDecodeErrorCode = 0; bool allowDecodeFailure = false; + ClDevice *pClDevice = nullptr; }; void ProgramDataTestBase::buildAndDecodeProgramPatchList() { @@ -158,7 +161,7 @@ void ProgramDataTestBase::buildAndDecodeProgramPatchList() { pProgram->buildInfos[rootDeviceIndex].unpackedDeviceBinary = makeCopy(pProgramData, headerSize + programBinaryHeader.PatchListSize); pProgram->buildInfos[rootDeviceIndex].unpackedDeviceBinarySize = headerSize + programBinaryHeader.PatchListSize; - error = pProgram->processGenBinary(rootDeviceIndex); + error = pProgram->processGenBinary(*pClDevice); patchlistDecodeErrorCode = error; if (allowDecodeFailure == false) { EXPECT_EQ(CL_SUCCESS, error); @@ -183,16 +186,16 @@ TEST_F(ProgramDataTest, WhenAllocatingConstantMemorySurfaceThenUnderlyingBufferI } TEST_F(ProgramDataTest, givenProgramWhenAllocatingConstantMemorySurfaceThenProperDeviceBitfieldIsPassed) { - auto executionEnvironment = pProgram->getDevice().getExecutionEnvironment(); + auto executionEnvironment = pClDevice->getExecutionEnvironment(); auto memoryManager = new MockMemoryManager(*executionEnvironment); std::unique_ptr memoryManagerBackup(memoryManager); std::swap(memoryManagerBackup, executionEnvironment->memoryManager); - EXPECT_NE(pProgram->getDevice().getDeviceBitfield(), memoryManager->recentlyPassedDeviceBitfield); + EXPECT_NE(pClDevice->getDeviceBitfield(), memoryManager->recentlyPassedDeviceBitfield); setupConstantAllocation(); buildAndDecodeProgramPatchList(); EXPECT_NE(nullptr, pProgram->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex())); - EXPECT_EQ(pProgram->getDevice().getDeviceBitfield(), memoryManager->recentlyPassedDeviceBitfield); + EXPECT_EQ(pClDevice->getDeviceBitfield(), memoryManager->recentlyPassedDeviceBitfield); std::swap(memoryManagerBackup, executionEnvironment->memoryManager); } @@ -208,7 +211,7 @@ TEST_F(ProgramDataTest, whenGlobalConstantsAreExportedThenAllocateSurfacesAsSvm) std::unique_ptr> mockLinkerInput = std::make_unique>(); mockLinkerInput->traits.exportsGlobalConstants = true; programInfo.linkerInput = std::move(mockLinkerInput); - this->pProgram->processProgramInfo(programInfo); + this->pProgram->processProgramInfo(programInfo, *pClDevice); ASSERT_NE(nullptr, pProgram->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex())); EXPECT_NE(nullptr, this->pContext->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast(pProgram->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex())->getGpuAddress()))); @@ -226,7 +229,7 @@ TEST_F(ProgramDataTest, whenGlobalConstantsAreNotExportedThenAllocateSurfacesAsN std::unique_ptr> mockLinkerInput = std::make_unique>(); mockLinkerInput->traits.exportsGlobalConstants = false; programInfo.linkerInput = std::move(mockLinkerInput); - this->pProgram->processProgramInfo(programInfo); + this->pProgram->processProgramInfo(programInfo, *pClDevice); ASSERT_NE(nullptr, pProgram->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex())); EXPECT_EQ(nullptr, this->pContext->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast( @@ -248,7 +251,7 @@ TEST_F(ProgramDataTest, whenGlobalConstantsAreExportedButContextUnavailableThenA pProgram->context = nullptr; - this->pProgram->processProgramInfo(programInfo); + this->pProgram->processProgramInfo(programInfo, *pClDevice); pProgram->context = pContext; @@ -268,7 +271,7 @@ TEST_F(ProgramDataTest, whenGlobalVariablesAreExportedThenAllocateSurfacesAsSvm) std::unique_ptr> mockLinkerInput = std::make_unique>(); mockLinkerInput->traits.exportsGlobalVariables = true; programInfo.linkerInput = std::move(mockLinkerInput); - this->pProgram->processProgramInfo(programInfo); + this->pProgram->processProgramInfo(programInfo, *pClDevice); ASSERT_NE(nullptr, pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex())); EXPECT_NE(nullptr, this->pContext->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast(pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex())->getGpuAddress()))); @@ -289,7 +292,7 @@ TEST_F(ProgramDataTest, whenGlobalVariablesAreExportedButContextUnavailableThenA pProgram->context = nullptr; - this->pProgram->processProgramInfo(programInfo); + this->pProgram->processProgramInfo(programInfo, *pClDevice); pProgram->context = pContext; @@ -309,7 +312,7 @@ TEST_F(ProgramDataTest, whenGlobalVariablesAreNotExportedThenAllocateSurfacesAsN std::unique_ptr> mockLinkerInput = std::make_unique>(); mockLinkerInput->traits.exportsGlobalVariables = false; programInfo.linkerInput = std::move(mockLinkerInput); - this->pProgram->processProgramInfo(programInfo); + this->pProgram->processProgramInfo(programInfo, *pClDevice); ASSERT_NE(nullptr, pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex())); EXPECT_EQ(nullptr, this->pContext->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast(pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex())->getGpuAddress()))); @@ -371,17 +374,17 @@ TEST_F(ProgramDataTest, WhenAllocatingGlobalMemorySurfaceThenUnderlyingBufferIsS EXPECT_EQ(0, memcmp(globalValue, pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex())->getUnderlyingBuffer(), globalSize)); } TEST_F(ProgramDataTest, givenProgramWhenAllocatingGlobalMemorySurfaceThenProperDeviceBitfieldIsPassed) { - auto executionEnvironment = pProgram->getDevice().getExecutionEnvironment(); + auto executionEnvironment = pClDevice->getExecutionEnvironment(); auto memoryManager = new MockMemoryManager(*executionEnvironment); std::unique_ptr memoryManagerBackup(memoryManager); std::swap(memoryManagerBackup, executionEnvironment->memoryManager); - EXPECT_NE(pProgram->getDevice().getDeviceBitfield(), memoryManager->recentlyPassedDeviceBitfield); + EXPECT_NE(pClDevice->getDeviceBitfield(), memoryManager->recentlyPassedDeviceBitfield); setupGlobalAllocation(); buildAndDecodeProgramPatchList(); EXPECT_NE(nullptr, pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex())); - EXPECT_EQ(pProgram->getDevice().getDeviceBitfield(), memoryManager->recentlyPassedDeviceBitfield); + EXPECT_EQ(pClDevice->getDeviceBitfield(), memoryManager->recentlyPassedDeviceBitfield); std::swap(memoryManagerBackup, executionEnvironment->memoryManager); } @@ -434,7 +437,7 @@ TEST(ProgramScopeMetadataTest, WhenPatchingGlobalSurfaceThenPickProperSourceBuff ProgramInfo programInfo; MockProgram program(toClDeviceVector(device)); NEO::populateProgramInfo(programInfo, decodedProgram); - program.processProgramInfo(programInfo); + program.processProgramInfo(programInfo, device); auto &buildInfo = program.buildInfos[device.getRootDeviceIndex()]; ASSERT_NE(nullptr, buildInfo.globalSurface); ASSERT_NE(nullptr, buildInfo.constantSurface); @@ -473,9 +476,9 @@ TEST_F(ProgramDataTest, GivenProgramWith32bitPointerOptWhenProgramScopeConstantB programInfo.globalConstants.initData = constantSurface.mockGfxAllocation.getUnderlyingBuffer(); - pProgram->setLinkerInput(pProgram->getDevice().getRootDeviceIndex(), std::move(programInfo.linkerInput)); - pProgram->linkBinary(pProgram->pDevice, programInfo.globalConstants.initData, programInfo.globalVariables.initData); - uint32_t expectedAddr = static_cast(constantSurface.getGraphicsAllocation(pProgram->getDevice().getRootDeviceIndex())->getGpuAddressToPatch()); + pProgram->setLinkerInput(pClDevice->getRootDeviceIndex(), std::move(programInfo.linkerInput)); + pProgram->linkBinary(&pClDevice->getDevice(), programInfo.globalConstants.initData, programInfo.globalVariables.initData); + uint32_t expectedAddr = static_cast(constantSurface.getGraphicsAllocation(pClDevice->getRootDeviceIndex())->getGpuAddressToPatch()); EXPECT_EQ(expectedAddr, constantSurfaceStorage[0]); EXPECT_EQ(sentinel, constantSurfaceStorage[1]); constantSurface.mockGfxAllocation.set32BitAllocation(false); @@ -512,9 +515,9 @@ TEST_F(ProgramDataTest, GivenProgramWith32bitPointerOptWhenProgramScopeGlobalPoi programInfo.globalVariables.initData = globalSurface.mockGfxAllocation.getUnderlyingBuffer(); - pProgram->setLinkerInput(pProgram->getDevice().getRootDeviceIndex(), std::move(programInfo.linkerInput)); - pProgram->linkBinary(pProgram->pDevice, programInfo.globalConstants.initData, programInfo.globalVariables.initData); - uint32_t expectedAddr = static_cast(globalSurface.getGraphicsAllocation(pProgram->getDevice().getRootDeviceIndex())->getGpuAddressToPatch()); + pProgram->setLinkerInput(pClDevice->getRootDeviceIndex(), std::move(programInfo.linkerInput)); + pProgram->linkBinary(&pClDevice->getDevice(), programInfo.globalConstants.initData, programInfo.globalVariables.initData); + uint32_t expectedAddr = static_cast(globalSurface.getGraphicsAllocation(pClDevice->getRootDeviceIndex())->getGpuAddressToPatch()); EXPECT_EQ(expectedAddr, globalSurfaceStorage[0]); EXPECT_EQ(sentinel, globalSurfaceStorage[1]); globalSurface.mockGfxAllocation.set32BitAllocation(false); @@ -540,7 +543,7 @@ TEST(ProgramLinkBinaryTest, whenLinkerInputEmptyThenLinkSuccessful) { auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(defaultHwInfo.get())); MockProgram program{nullptr, false, toClDeviceVector(*device)}; program.setLinkerInput(device->getRootDeviceIndex(), std::move(linkerInput)); - auto ret = program.linkBinary(program.pDevice, nullptr, nullptr); + auto ret = program.linkBinary(&device->getDevice(), nullptr, nullptr); EXPECT_EQ(CL_SUCCESS, ret); } @@ -564,7 +567,7 @@ TEST(ProgramLinkBinaryTest, whenLinkerUnresolvedExternalThenLinkFailedAndBuildLo std::string buildLog = program.getBuildLog(device->getRootDeviceIndex()); EXPECT_TRUE(buildLog.empty()); - auto ret = program.linkBinary(program.pDevice, nullptr, nullptr); + auto ret = program.linkBinary(&device->getDevice(), nullptr, nullptr); EXPECT_NE(CL_SUCCESS, ret); program.getKernelInfoArray().clear(); buildLog = program.getBuildLog(device->getRootDeviceIndex()); @@ -611,9 +614,7 @@ TEST_F(ProgramDataTest, whenLinkerInputValidThenIsaIsProperlyPatched) { buildInfo.globalSurface = new MockGraphicsAllocation(globalVariablesBuffer.data(), globalVariablesBuffer.size()); buildInfo.constantSurface = new MockGraphicsAllocation(globalConstantsBuffer.data(), globalConstantsBuffer.size()); - program.pDevice = &this->pContext->getDevice(0)->getDevice(); - - auto ret = program.linkBinary(pProgram->pDevice, globalConstantsInitData.data(), globalVariablesInitData.data()); + auto ret = program.linkBinary(&pClDevice->getDevice(), globalConstantsInitData.data(), globalVariablesInitData.data()); EXPECT_EQ(CL_SUCCESS, ret); linkerInput.reset(static_cast *>(buildInfo.linkerInput.release())); @@ -661,9 +662,7 @@ TEST_F(ProgramDataTest, whenRelocationsAreNotNeededThenIsaIsPreserved) { buildInfo.globalSurface = new MockGraphicsAllocation(globalVariablesBuffer.data(), globalVariablesBuffer.size()); buildInfo.constantSurface = new MockGraphicsAllocation(globalConstantsBuffer.data(), globalConstantsBuffer.size()); - program.pDevice = &this->pContext->getDevice(0)->getDevice(); - - auto ret = program.linkBinary(pProgram->pDevice, globalConstantsInitData.data(), globalVariablesInitData.data()); + auto ret = program.linkBinary(&pClDevice->getDevice(), globalConstantsInitData.data(), globalVariablesInitData.data()); EXPECT_EQ(CL_SUCCESS, ret); EXPECT_EQ(kernelHeapData, kernelHeap); diff --git a/opencl/test/unit_test/program/program_tests.cpp b/opencl/test/unit_test/program/program_tests.cpp index b0b207881a..69d6b0a122 100644 --- a/opencl/test/unit_test/program/program_tests.cpp +++ b/opencl/test/unit_test/program/program_tests.cpp @@ -99,13 +99,13 @@ class NoCompilerInterfaceRootDeviceEnvironment : public RootDeviceEnvironment { class FailingGenBinaryProgram : public MockProgram { public: using MockProgram::MockProgram; - cl_int processGenBinary(uint32_t rootDeviceIndex) override { return CL_INVALID_BINARY; } + cl_int processGenBinary(const ClDevice &clDevice) override { return CL_INVALID_BINARY; } }; class SucceedingGenBinaryProgram : public MockProgram { public: using MockProgram::MockProgram; - cl_int processGenBinary(uint32_t rootDeviceIndex) override { return CL_SUCCESS; } + cl_int processGenBinary(const ClDevice &clDevice) override { return CL_SUCCESS; } }; TEST_P(ProgramFromBinaryTest, WhenBuildingProgramThenSuccessIsReturned) { @@ -568,7 +568,7 @@ TEST_P(ProgramFromBinaryTest, GivenGlobalVariableTotalSizeSetWhenGettingBuildGlo char constantData[1024] = {}; programInfo.globalVariables.initData = constantData; programInfo.globalVariables.size = sizeof(constantData); - p->processProgramInfo(programInfo); + p->processProgramInfo(programInfo, *pClDevice); // get build info once again retVal = pProgram->getBuildInfo( @@ -599,7 +599,7 @@ TEST_P(ProgramFromBinaryTest, givenProgramWhenItIsBeingBuildThenItContainsGraphi EXPECT_NE(kernelInfo->heapInfo.pKernelHeap, kernelIsa); EXPECT_EQ(0, memcmp(kernelIsa, kernelInfo->heapInfo.pKernelHeap, kernelInfo->heapInfo.KernelHeapSize)); auto rootDeviceIndex = graphicsAllocation->getRootDeviceIndex(); - EXPECT_EQ(GmmHelper::decanonize(graphicsAllocation->getGpuBaseAddress()), pProgram->getDevice().getMemoryManager()->getInternalHeapBaseAddress(rootDeviceIndex, graphicsAllocation->isAllocatedInLocalMemoryPool())); + EXPECT_EQ(GmmHelper::decanonize(graphicsAllocation->getGpuBaseAddress()), pDevice->getMemoryManager()->getInternalHeapBaseAddress(rootDeviceIndex, graphicsAllocation->isAllocatedInLocalMemoryPool())); } TEST_P(ProgramFromBinaryTest, whenProgramIsBeingRebuildThenOutdatedGlobalBuffersAreFreed) { @@ -608,12 +608,12 @@ TEST_P(ProgramFromBinaryTest, whenProgramIsBeingRebuildThenOutdatedGlobalBuffers EXPECT_EQ(nullptr, pProgram->buildInfos[pClDevice->getRootDeviceIndex()].globalSurface); pProgram->buildInfos[pClDevice->getRootDeviceIndex()].constantSurface = new MockGraphicsAllocation(); - pProgram->processGenBinary(rootDeviceIndex); + pProgram->processGenBinary(*pClDevice); EXPECT_EQ(nullptr, pProgram->buildInfos[pClDevice->getRootDeviceIndex()].constantSurface); EXPECT_EQ(nullptr, pProgram->buildInfos[pClDevice->getRootDeviceIndex()].globalSurface); pProgram->buildInfos[pClDevice->getRootDeviceIndex()].globalSurface = new MockGraphicsAllocation(); - pProgram->processGenBinary(rootDeviceIndex); + pProgram->processGenBinary(*pClDevice); EXPECT_EQ(nullptr, pProgram->buildInfos[pClDevice->getRootDeviceIndex()].constantSurface); EXPECT_EQ(nullptr, pProgram->buildInfos[pClDevice->getRootDeviceIndex()].globalSurface); } @@ -1503,7 +1503,7 @@ TEST(ProgramFromBinaryTests, givenBinaryWithInvalidICBEThenErrorIsReturned) { ASSERT_NE(nullptr, pProgram.get()); EXPECT_EQ(CL_SUCCESS, retVal); - retVal = pProgram->processGenBinary(mockRootDeviceIndex); + retVal = pProgram->processGenBinary(*device); EXPECT_EQ(CL_INVALID_BINARY, retVal); } } @@ -1529,7 +1529,7 @@ TEST(ProgramFromBinaryTests, givenEmptyProgramThenErrorIsReturned) { auto rootDeviceIndex = mockRootDeviceIndex; pProgram->buildInfos[rootDeviceIndex].unpackedDeviceBinary.reset(nullptr); - retVal = pProgram->processGenBinary(rootDeviceIndex); + retVal = pProgram->processGenBinary(*device); EXPECT_EQ(CL_INVALID_BINARY, retVal); } @@ -1901,7 +1901,7 @@ TEST_F(ProgramTests, givenProgramFromGenBinaryWhenSLMSizeIsBiggerThenDeviceLimit auto program = std::make_unique(nullptr, false, toClDeviceVector(*pClDevice)); program->buildInfos[rootDeviceIndex].unpackedDeviceBinary = makeCopy(patchtokensProgram.storage.data(), patchtokensProgram.storage.size()); program->buildInfos[rootDeviceIndex].unpackedDeviceBinarySize = patchtokensProgram.storage.size(); - auto retVal = program->processGenBinary(rootDeviceIndex); + auto retVal = program->processGenBinary(*pClDevice); EXPECT_EQ(CL_OUT_OF_RESOURCES, retVal); } @@ -2001,7 +2001,7 @@ TEST_F(ProgramTests, GivenZeroPrivateSizeInBlockWhenAllocateBlockProvateSurfaces program->blockKernelManager->addBlockKernelInfo(infoBlock); - program->allocateBlockPrivateSurfaces(pDevice->getRootDeviceIndex()); + program->allocateBlockPrivateSurfaces(*pClDevice); EXPECT_EQ(nullptr, program->getBlockKernelManager()->getPrivateSurface(0)); @@ -2027,7 +2027,7 @@ TEST_F(ProgramTests, GivenNonZeroPrivateSizeInBlockWhenAllocateBlockProvateSurfa program->blockKernelManager->addBlockKernelInfo(infoBlock); - program->allocateBlockPrivateSurfaces(pDevice->getRootDeviceIndex()); + program->allocateBlockPrivateSurfaces(*pClDevice); EXPECT_NE(nullptr, program->getBlockKernelManager()->getPrivateSurface(0)); @@ -2053,13 +2053,13 @@ TEST_F(ProgramTests, GivenNonZeroPrivateSizeInBlockWhenAllocateBlockProvateSurfa program->blockKernelManager->addBlockKernelInfo(infoBlock); - program->allocateBlockPrivateSurfaces(pDevice->getRootDeviceIndex()); + program->allocateBlockPrivateSurfaces(*pClDevice); GraphicsAllocation *privateSurface = program->getBlockKernelManager()->getPrivateSurface(0); EXPECT_NE(nullptr, privateSurface); - program->allocateBlockPrivateSurfaces(pDevice->getRootDeviceIndex()); + program->allocateBlockPrivateSurfaces(*pClDevice); GraphicsAllocation *privateSurface2 = program->getBlockKernelManager()->getPrivateSurface(0); @@ -2087,7 +2087,7 @@ TEST_F(ProgramTests, givenProgramWithBlockKernelsWhenfreeBlockResourcesisCalledT program->blockKernelManager->addBlockKernelInfo(infoBlock); - GraphicsAllocation *privateSurface = program->getDevice().getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize}); + GraphicsAllocation *privateSurface = pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize}); EXPECT_NE(nullptr, privateSurface); program->getBlockKernelManager()->pushPrivateSurface(privateSurface, 0); @@ -2133,7 +2133,7 @@ TEST_F(ProgramTests, givenNewProgramTheStatelessToStatefulBufferOffsetOtimizatio auto internalOptions = program.getInitInternalOptions(); HardwareCapabilities hwCaps = {0}; - HwHelper::get(program.getDevice().getHardwareInfo().platform.eRenderCoreFamily).setupHardwareCapabilities(&hwCaps, program.getDevice().getHardwareInfo()); + HwHelper::get(pDevice->getHardwareInfo().platform.eRenderCoreFamily).setupHardwareCapabilities(&hwCaps, pDevice->getHardwareInfo()); if (hwCaps.isStatelesToStatefullWithOffsetSupported) { EXPECT_TRUE(CompilerOptions::contains(internalOptions, CompilerOptions::hasBufferOffsetArg)); } else { @@ -2635,7 +2635,6 @@ TEST(CreateProgramFromBinaryTests, givenBinaryProgramWhenKernelRebulildIsNotForc auto clDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); std::unique_ptr pProgram(Program::createBuiltInFromGenBinary(nullptr, toClDeviceVector(*clDevice), programTokens.storage.data(), programTokens.storage.size(), &retVal)); - pProgram->pDevice = &clDevice->getDevice(); ASSERT_NE(nullptr, pProgram.get()); EXPECT_EQ(CL_SUCCESS, retVal); @@ -2882,7 +2881,7 @@ TEST_F(ProgramMultiRootDeviceTests, WhenPrivateSurfaceIsCreatedThenItHasCorrectR infoBlock->patchInfo.pAllocateStatelessPrivateSurface = privateSurfaceBlock.get(); program->blockKernelManager->addBlockKernelInfo(infoBlock.release()); - program->allocateBlockPrivateSurfaces(device->getRootDeviceIndex()); + program->allocateBlockPrivateSurfaces(*device); auto privateSurface = program->getBlockKernelManager()->getPrivateSurface(0); EXPECT_NE(nullptr, privateSurface); diff --git a/opencl/test/unit_test/program/program_with_kernel_debug_tests.cpp b/opencl/test/unit_test/program/program_with_kernel_debug_tests.cpp index 513b3129a9..5820212326 100644 --- a/opencl/test/unit_test/program/program_with_kernel_debug_tests.cpp +++ b/opencl/test/unit_test/program/program_with_kernel_debug_tests.cpp @@ -44,7 +44,6 @@ TEST(ProgramFromBinary, givenBinaryWithDebugDataWhenCreatingProgramFromBinaryThe auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); auto program = std::make_unique(toClDeviceVector(*device)); - program->pDevice = &device->getDevice(); program->enableKernelDebug(); size_t binarySize = 0;