diff --git a/opencl/source/api/api.cpp b/opencl/source/api/api.cpp index 65b09ad0f5..77a099022d 100644 --- a/opencl/source/api/api.cpp +++ b/opencl/source/api/api.cpp @@ -1308,12 +1308,13 @@ cl_program CL_API_CALL clCreateProgramWithSource(cl_context context, "count", count, "strings", strings, "lengths", lengths); - retVal = validateObjects(context, count, strings); + Context *pContext = nullptr; + retVal = validateObjects(WithCastToInternal(context, &pContext), count, strings); cl_program program = nullptr; if (CL_SUCCESS == retVal) { program = Program::create( - context, + pContext, count, strings, lengths, diff --git a/opencl/source/built_ins/builtins_dispatch_builder.cpp b/opencl/source/built_ins/builtins_dispatch_builder.cpp index 1847a3c1bd..29b1c06b05 100644 --- a/opencl/source/built_ins/builtins_dispatch_builder.cpp +++ b/opencl/source/built_ins/builtins_dispatch_builder.cpp @@ -799,10 +799,10 @@ std::unique_ptr BuiltinDispatchInfoBuilder::createProgramFromCode(const break; case BuiltinCode::ECodeType::Source: case BuiltinCode::ECodeType::Intermediate: - ret.reset(Program::create(data, nullptr, deviceVector, true, &err)); + ret.reset(Program::createBuiltInFromSource(data, nullptr, deviceVector, &err)); break; case BuiltinCode::ECodeType::Binary: - ret.reset(Program::createFromGenBinary(*deviceVector[0]->getExecutionEnvironment(), nullptr, data, dataLen, true, nullptr, &deviceVector[0]->getDevice())); + ret.reset(Program::createBuiltInFromGenBinary(nullptr, deviceVector, data, dataLen, &err)); break; } return ret; diff --git a/opencl/source/built_ins/vme_builtin.cpp b/opencl/source/built_ins/vme_builtin.cpp index ae4c5e9234..e308f368ea 100644 --- a/opencl/source/built_ins/vme_builtin.cpp +++ b/opencl/source/built_ins/vme_builtin.cpp @@ -68,7 +68,7 @@ Program *Vme::createBuiltInProgram( } Program *pBuiltInProgram = nullptr; - pBuiltInProgram = Program::create(programSourceStr.c_str(), &context, deviceVector, true, nullptr); + pBuiltInProgram = Program::createBuiltInFromSource(programSourceStr.c_str(), &context, deviceVector, nullptr); auto &device = *deviceVector[0]; diff --git a/opencl/source/context/context.cpp b/opencl/source/context/context.cpp index 2db99a7cf4..c9d53ad369 100644 --- a/opencl/source/context/context.cpp +++ b/opencl/source/context/context.cpp @@ -385,13 +385,11 @@ SchedulerKernel &Context::getSchedulerKernel() { auto device = &getDevice(0)->getDevice(); auto src = SchedulerKernel::loadSchedulerKernel(device); - auto program = Program::createFromGenBinary(*device->getExecutionEnvironment(), - this, - src.resource.data(), - src.resource.size(), - true, - &retVal, - device); + auto program = Program::createBuiltInFromGenBinary(this, + devices, + src.resource.data(), + src.resource.size(), + &retVal); DEBUG_BREAK_IF(retVal != CL_SUCCESS); DEBUG_BREAK_IF(!program); diff --git a/opencl/source/program/create.cpp b/opencl/source/program/create.cpp index 345cbdf690..d18bddcbbb 100644 --- a/opencl/source/program/create.cpp +++ b/opencl/source/program/create.cpp @@ -16,8 +16,8 @@ CreateFromILFunc createFromIL = Program::createFromIL; } // namespace ProgramFunctions template Program *Program::create(Context *, const ClDeviceVector &, const size_t *, const unsigned char **, cl_int *, cl_int &); -template Program *Program::create(cl_context, cl_uint, const char **, const size_t *, cl_int &); -template Program *Program::create(const char *, Context *, const ClDeviceVector &, bool, cl_int *); +template Program *Program::create(Context *, cl_uint, const char **, const size_t *, cl_int &); +template Program *Program::createBuiltInFromSource(const char *, Context *, const ClDeviceVector &, cl_int *); template Program *Program::createFromIL(Context *, const void *, size_t length, cl_int &); -template Program *Program::createFromGenBinary(ExecutionEnvironment &executionEnvironment, Context *context, const void *binary, size_t size, bool isBuiltIn, cl_int *errcodeRet, Device *device); +template Program *Program::createBuiltInFromGenBinary(Context *context, const ClDeviceVector &, const void *binary, size_t size, cl_int *errcodeRet); } // namespace NEO diff --git a/opencl/source/program/create.inl b/opencl/source/program/create.inl index 3c03c4c56e..cb035b38c4 100644 --- a/opencl/source/program/create.inl +++ b/opencl/source/program/create.inl @@ -56,7 +56,7 @@ T *Program::create( template T *Program::create( - cl_context context, + Context *pContext, cl_uint count, const char **strings, const size_t *lengths, @@ -64,8 +64,6 @@ T *Program::create( std::string combinedString; size_t combinedStringSize = 0; T *program = nullptr; - auto pContext = castToObject(context); - DEBUG_BREAK_IF(!pContext); auto retVal = createCombinedString( combinedString, @@ -85,11 +83,10 @@ T *Program::create( } template -T *Program::create( +T *Program::createBuiltInFromSource( const char *nullTerminatedString, Context *context, const ClDeviceVector &deviceVector, - bool isBuiltIn, cl_int *errcodeRet) { cl_int retVal = CL_SUCCESS; T *program = nullptr; @@ -99,7 +96,7 @@ T *Program::create( } if (retVal == CL_SUCCESS) { - program = new T(context, isBuiltIn, deviceVector); + program = new T(context, true, deviceVector); program->sourceCode = nullTerminatedString; program->createdFrom = CreatedFrom::SOURCE; } @@ -112,14 +109,12 @@ T *Program::create( } template -T *Program::createFromGenBinary( - ExecutionEnvironment &executionEnvironment, +T *Program::createBuiltInFromGenBinary( Context *context, + const ClDeviceVector &deviceVector, const void *binary, size_t size, - bool isBuiltIn, - cl_int *errcodeRet, - Device *device) { + cl_int *errcodeRet) { cl_int retVal = CL_SUCCESS; T *program = nullptr; @@ -129,11 +124,12 @@ T *Program::createFromGenBinary( if (CL_SUCCESS == retVal) { - ClDeviceVector deviceVector; - deviceVector.push_back(device->getSpecializedDevice()); - program = new T(context, isBuiltIn, deviceVector); - program->numDevices = 1; - program->replaceDeviceBinary(makeCopy(binary, size), size, device->getRootDeviceIndex()); + program = new T(context, true, deviceVector); + for (const auto &device : deviceVector) { + if (program->buildInfos[device->getRootDeviceIndex()].packedDeviceBinarySize == 0) { + program->replaceDeviceBinary(makeCopy(binary, size), size, device->getRootDeviceIndex()); + } + } program->isCreatedFromBinary = true; program->programBinaryType = CL_PROGRAM_BINARY_TYPE_EXECUTABLE; program->buildStatus = CL_BUILD_SUCCESS; diff --git a/opencl/source/program/program.h b/opencl/source/program/program.h index 67007c8418..82296b0b88 100644 --- a/opencl/source/program/program.h +++ b/opencl/source/program/program.h @@ -93,29 +93,26 @@ class Program : public BaseObject<_cl_program> { // Create program from source template static T *create( - cl_context context, + Context *pContext, cl_uint count, const char **strings, const size_t *lengths, cl_int &errcodeRet); template - static T *create( + static T *createBuiltInFromSource( const char *nullTerminatedString, Context *context, const ClDeviceVector &deviceVector, - bool isBuiltIn, cl_int *errcodeRet); template - static T *createFromGenBinary( - ExecutionEnvironment &executionEnvironment, + static T *createBuiltInFromGenBinary( Context *context, + const ClDeviceVector &deviceVector, const void *binary, size_t size, - bool isBuiltIn, - cl_int *errcodeRet, - Device *device); + cl_int *errcodeRet); template static T *createFromIL(Context *context, diff --git a/opencl/test/unit_test/api/cl_get_program_info_tests.inl b/opencl/test/unit_test/api/cl_get_program_info_tests.inl index b7e3cc286b..e4fb022be1 100644 --- a/opencl/test/unit_test/api/cl_get_program_info_tests.inl +++ b/opencl/test/unit_test/api/cl_get_program_info_tests.inl @@ -407,4 +407,100 @@ TEST(clGetProgramInfoTest, GivenMultiDeviceProgramCreatedWithBuiltInKernelsWhenG retVal = clReleaseProgram(pProgram); EXPECT_EQ(CL_SUCCESS, retVal); } + +TEST(clGetProgramInfoTest, GivenMultiDeviceBuiltInProgramCreatedWithGenBinaryWhenGettingDevicesThenCorrectDevicesAreReturned) { + MockUnrestrictiveContextMultiGPU context; + + auto expectedNumDevices = context.getNumDevices(); + + auto devicesForProgram = std::make_unique(expectedNumDevices); + + for (auto i = 0u; i < expectedNumDevices; i++) { + devicesForProgram[i] = context.getDevice(i); + } + + std::unique_ptr pBinary = nullptr; + size_t binarySize = 0; + std::string testFile; + retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd16_", ".bin"); + + pBinary = loadDataFromFile( + testFile.c_str(), + binarySize); + + ASSERT_NE(0u, binarySize); + ASSERT_NE(nullptr, pBinary); + + cl_program pProgram = nullptr; + + cl_int retVal = CL_INVALID_PROGRAM; + pProgram = Program::createBuiltInFromGenBinary(&context, context.getDevices(), pBinary.get(), binarySize, &retVal); + + EXPECT_NE(nullptr, pProgram); + EXPECT_EQ(CL_SUCCESS, retVal); + + verifyDevices(pProgram, expectedNumDevices, devicesForProgram.get()); + + retVal = clReleaseProgram(pProgram); + EXPECT_EQ(CL_SUCCESS, retVal); +} + +TEST(clGetProgramInfoTest, GivenMultiDeviceBuiltInProgramCreatedWithGenBinaryWhenGettingDevicesThenCorrectBinariesAreReturned) { + MockUnrestrictiveContextMultiGPU context; + + auto expectedNumDevices = context.getNumDevices(); + + auto devicesForProgram = std::make_unique(expectedNumDevices); + + for (auto i = 0u; i < expectedNumDevices; i++) { + devicesForProgram[i] = context.getDevice(i); + } + + std::unique_ptr pBinary = nullptr; + size_t binarySize = 0; + std::string testFile; + retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd16_", ".bin"); + + pBinary = loadDataFromFile( + testFile.c_str(), + binarySize); + + ASSERT_NE(0u, binarySize); + ASSERT_NE(nullptr, pBinary); + + cl_program pProgram = nullptr; + + cl_int retVal = CL_INVALID_PROGRAM; + pProgram = Program::createBuiltInFromGenBinary(&context, context.getDevices(), pBinary.get(), binarySize, &retVal); + + EXPECT_NE(nullptr, pProgram); + EXPECT_EQ(CL_SUCCESS, retVal); + + auto programBinarySizes = std::make_unique(expectedNumDevices); + memset(programBinarySizes.get(), 0, expectedNumDevices * sizeof(size_t)); + + retVal = clGetProgramInfo(pProgram, CL_PROGRAM_BINARY_SIZES, expectedNumDevices * sizeof(size_t), programBinarySizes.get(), nullptr); + EXPECT_EQ(CL_SUCCESS, retVal); + for (auto i = 0u; i < expectedNumDevices; i++) { + EXPECT_EQ(binarySize, programBinarySizes[i]); + } + + auto programBinaries = std::make_unique(expectedNumDevices); + + auto binariesBuffer = std::make_unique(expectedNumDevices * binarySize); + memset(binariesBuffer.get(), 0, expectedNumDevices * binarySize); + + for (auto i = 0u; i < expectedNumDevices; i++) { + programBinaries[i] = ptrOffset(binariesBuffer.get(), i * binarySize); + } + + retVal = clGetProgramInfo(pProgram, CL_PROGRAM_BINARIES, expectedNumDevices * sizeof(unsigned char *), programBinaries.get(), nullptr); + EXPECT_EQ(CL_SUCCESS, retVal); + for (auto i = 0u; i < expectedNumDevices; i++) { + EXPECT_EQ(0, memcmp(programBinaries[i], pBinary.get(), binarySize)); + } + + retVal = clReleaseProgram(pProgram); + EXPECT_EQ(CL_SUCCESS, retVal); +} } // namespace ULT 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 b12264525e..58f38ea944 100644 --- a/opencl/test/unit_test/built_ins/built_in_tests.cpp +++ b/opencl/test/unit_test/built_ins/built_in_tests.cpp @@ -2007,8 +2007,7 @@ TEST_F(BuiltInTests, WhenGettingSipKernelThenReturnProgramCreatedFromIsaAcquired pDevice->getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex]->compilerInterface.reset(mockCompilerInterface); mockCompilerInterface->sipKernelBinaryOverride = mockCompilerInterface->getDummyGenBinary(); cl_int errCode = CL_BUILD_PROGRAM_FAILURE; - auto p = Program::createFromGenBinary(*pDevice->getExecutionEnvironment(), pContext, mockCompilerInterface->sipKernelBinaryOverride.data(), mockCompilerInterface->sipKernelBinaryOverride.size(), - false, &errCode, pDevice); + auto p = Program::createBuiltInFromGenBinary(pContext, pContext->getDevices(), mockCompilerInterface->sipKernelBinaryOverride.data(), mockCompilerInterface->sipKernelBinaryOverride.size(), &errCode); ASSERT_EQ(CL_SUCCESS, errCode); errCode = p->processGenBinary(rootDeviceIndex); ASSERT_EQ(CL_SUCCESS, errCode); diff --git a/opencl/test/unit_test/command_queue/enqueue_svm_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_svm_tests.cpp index 218981fb7c..8fba34bd36 100644 --- a/opencl/test/unit_test/command_queue/enqueue_svm_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_svm_tests.cpp @@ -736,7 +736,7 @@ TEST_F(EnqueueSvmTest, GivenSvmAllocationWhenEnqueingKernelThenSuccessIsReturned GraphicsAllocation *pSvmAlloc = svmData->gpuAllocations.getGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex()); EXPECT_NE(nullptr, ptrSVM); - std::unique_ptr program(Program::create("FillBufferBytes", context, context->getDevices(), true, &retVal)); + std::unique_ptr program(Program::createBuiltInFromSource("FillBufferBytes", context, context->getDevices(), &retVal)); cl_device_id device = pClDevice; program->build(1, &device, nullptr, nullptr, nullptr, false); std::unique_ptr kernel(Kernel::create(program.get(), *program->getKernelInfo("FillBufferBytes"), &retVal)); @@ -765,7 +765,7 @@ TEST_F(EnqueueSvmTest, givenEnqueueTaskBlockedOnUserEventWhenItIsEnqueuedThenSur GraphicsAllocation *pSvmAlloc = svmData->gpuAllocations.getGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex()); EXPECT_NE(nullptr, ptrSVM); - auto program = clUniquePtr(Program::create("FillBufferBytes", context, context->getDevices(), true, &retVal)); + auto program = clUniquePtr(Program::createBuiltInFromSource("FillBufferBytes", context, context->getDevices(), &retVal)); cl_device_id device = pClDevice; program->build(1, &device, nullptr, nullptr, nullptr, false); auto kernel = clUniquePtr(Kernel::create(program.get(), *program->getKernelInfo("FillBufferBytes"), &retVal)); diff --git a/opencl/test/unit_test/command_queue/get_size_required_image_tests.cpp b/opencl/test/unit_test/command_queue/get_size_required_image_tests.cpp index 015a06e835..c261a1e6a2 100644 --- a/opencl/test/unit_test/command_queue/get_size_required_image_tests.cpp +++ b/opencl/test/unit_test/command_queue/get_size_required_image_tests.cpp @@ -115,7 +115,7 @@ HWTEST_F(GetSizeRequiredImageTest, WhenCopyingReadWriteImageThenHeapsAndCommandB auto usedBeforeIOH = ioh.getUsed(); auto usedBeforeSSH = ssh.getUsed(); - std::unique_ptr program(Program::create("CopyImageToImage3d", context, context->getDevices(), true, nullptr)); + std::unique_ptr program(Program::createBuiltInFromSource("CopyImageToImage3d", context, context->getDevices(), nullptr)); cl_device_id device = pClDevice; program->build(1, &device, nullptr, nullptr, nullptr, false); std::unique_ptr kernel(Kernel::create(program.get(), *program->getKernelInfo("CopyImageToImage3d"), nullptr)); diff --git a/opencl/test/unit_test/fixtures/program_fixture.cpp b/opencl/test/unit_test/fixtures/program_fixture.cpp index 64c0758de4..c115fcdbd7 100644 --- a/opencl/test/unit_test/fixtures/program_fixture.cpp +++ b/opencl/test/unit_test/fixtures/program_fixture.cpp @@ -11,7 +11,7 @@ #include "opencl/test/unit_test/mocks/mock_program.h" namespace NEO { -void ProgramFixture::CreateProgramWithSource(cl_context context, +void ProgramFixture::CreateProgramWithSource(Context *pContext, cl_device_id *deviceList, const std::string &sourceFileName) { Cleanup(); @@ -31,7 +31,7 @@ void ProgramFixture::CreateProgramWithSource(cl_context context, const char *sources[1] = {knownSource.get()}; pProgram = Program::create( - context, + pContext, 1, sources, &knownSourceSize, diff --git a/opencl/test/unit_test/fixtures/program_fixture.h b/opencl/test/unit_test/fixtures/program_fixture.h index 374de9b240..98f4c11f64 100644 --- a/opencl/test/unit_test/fixtures/program_fixture.h +++ b/opencl/test/unit_test/fixtures/program_fixture.h @@ -29,7 +29,7 @@ class ProgramFixture { const std::string &binaryFileName, const std::string &options = ""); - void CreateProgramWithSource(cl_context pContext, + void CreateProgramWithSource(Context *pContext, cl_device_id *pDeviceList, const std::string &sourceFileName); diff --git a/opencl/test/unit_test/gtpin/gtpin_tests.cpp b/opencl/test/unit_test/gtpin/gtpin_tests.cpp index 4ba7294ecf..a2d5846118 100644 --- a/opencl/test/unit_test/gtpin/gtpin_tests.cpp +++ b/opencl/test/unit_test/gtpin/gtpin_tests.cpp @@ -1013,7 +1013,7 @@ TEST_F(GTPinTests, givenInitializedGTPinInterfaceWhenKernelWithoutSSHIsUsedThenK char binary[1024] = {1, 2, 3, 4, 5, 6, 7, 8, 9, '\0'}; size_t binSize = 10; - MockProgram *pProgram = Program::createFromGenBinary(*pDevice->getExecutionEnvironment(), pContext, &binary[0], binSize, false, &retVal, &pDevice->getDevice()); + MockProgram *pProgram = Program::createBuiltInFromGenBinary(pContext, pContext->getDevices(), &binary[0], binSize, &retVal); ASSERT_NE(nullptr, pProgram); EXPECT_EQ(CL_SUCCESS, retVal); @@ -1073,7 +1073,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, GTPinTests, givenInitializedGTPinInterfaceWhenKernel // Prepare a kernel with fake Execution Environment char binary[1024] = {1, 2, 3, 4, 5, 6, 7, 8, 9, '\0'}; size_t binSize = 10; - MockProgram *pProgram = Program::createFromGenBinary(*pDevice->getExecutionEnvironment(), pContext, &binary[0], binSize, false, &retVal, &pDevice->getDevice()); + MockProgram *pProgram = Program::createBuiltInFromGenBinary(pContext, pContext->getDevices(), &binary[0], binSize, &retVal); ASSERT_NE(nullptr, pProgram); EXPECT_EQ(CL_SUCCESS, retVal); @@ -2096,7 +2096,7 @@ TEST_F(GTPinTests, givenInitializedGTPinInterfaceWhenLowMemoryConditionOccursThe char binary[1024] = {1, 2, 3, 4, 5, 6, 7, 8, 9, '\0'}; size_t binSize = 10; - MockProgram *pProgram = Program::createFromGenBinary(*pDevice->getExecutionEnvironment(), pContext, &binary[0], binSize, false, &retVal, &pDevice->getDevice()); + MockProgram *pProgram = Program::createBuiltInFromGenBinary(pContext, pContext->getDevices(), &binary[0], binSize, &retVal); ASSERT_NE(nullptr, pProgram); EXPECT_EQ(CL_SUCCESS, retVal); diff --git a/opencl/test/unit_test/kernel/kernel_is_patched_tests.cpp b/opencl/test/unit_test/kernel/kernel_is_patched_tests.cpp index 7537805a74..7ce11d69a6 100644 --- a/opencl/test/unit_test/kernel/kernel_is_patched_tests.cpp +++ b/opencl/test/unit_test/kernel/kernel_is_patched_tests.cpp @@ -20,7 +20,7 @@ class PatchedKernelTest : public ::testing::Test { void SetUp() override { device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); context.reset(new MockContext(device.get())); - program.reset(Program::create("FillBufferBytes", context.get(), context->getDevices(), true, &retVal)); + program.reset(Program::createBuiltInFromSource("FillBufferBytes", context.get(), context->getDevices(), &retVal)); EXPECT_EQ(CL_SUCCESS, retVal); cl_device_id clDevice = device.get(); program->build(1, &clDevice, nullptr, nullptr, nullptr, false); diff --git a/opencl/test/unit_test/program/program_tests.cpp b/opencl/test/unit_test/program/program_tests.cpp index 757f51779b..dcd228db98 100644 --- a/opencl/test/unit_test/program/program_tests.cpp +++ b/opencl/test/unit_test/program/program_tests.cpp @@ -1646,7 +1646,7 @@ TEST(ProgramFromBinaryTests, givenBinaryWithInvalidICBEThenErrorIsReturned) { { // whatever method we choose CL_INVALID_BINARY is always returned auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr, mockRootDeviceIndex)); - std::unique_ptr pProgram(Program::createFromGenBinary(*device->getExecutionEnvironment(), nullptr, &binHeader, binSize, false, &retVal, &device->getDevice())); + std::unique_ptr pProgram(Program::createBuiltInFromGenBinary(nullptr, toClDeviceVector(*device), &binHeader, binSize, &retVal)); ASSERT_NE(nullptr, pProgram.get()); EXPECT_EQ(CL_SUCCESS, retVal); @@ -1670,7 +1670,7 @@ TEST(ProgramFromBinaryTests, givenEmptyProgramThenErrorIsReturned) { size_t binSize = sizeof(SProgramBinaryHeader); auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr, mockRootDeviceIndex)); - std::unique_ptr pProgram(MockProgram::createFromGenBinary(*device->getExecutionEnvironment(), nullptr, &binHeader, binSize, false, &retVal, &device->getDevice())); + std::unique_ptr pProgram(MockProgram::createBuiltInFromGenBinary(nullptr, toClDeviceVector(*device), &binHeader, binSize, &retVal)); ASSERT_NE(nullptr, pProgram.get()); EXPECT_EQ(CL_SUCCESS, retVal); @@ -1841,7 +1841,7 @@ TEST_F(ProgramTests, Given32bitSupportWhenProgramIsCreatedThenGreaterThan4gbBuff auto defaultSetting = DebugManager.flags.DisableStatelessToStatefulOptimization.get(); DebugManager.flags.DisableStatelessToStatefulOptimization.set(false); - std::unique_ptr program{Program::create("", pContext, pContext->getDevices(), true, nullptr)}; + std::unique_ptr program{Program::createBuiltInFromSource("", pContext, pContext->getDevices(), nullptr)}; if ((false == pDevice->areSharedSystemAllocationsAllowed()) && (false == is32bit)) { EXPECT_FALSE(CompilerOptions::contains(program->getInternalOptions(), NEO::CompilerOptions::greaterThan4gbBuffersRequired)) << program->getInternalOptions(); } else { @@ -1854,13 +1854,13 @@ TEST_F(ProgramTests, GivenStatelessToStatefulIsDisabledWhenProgramIsCreatedThenG auto defaultSetting = DebugManager.flags.DisableStatelessToStatefulOptimization.get(); DebugManager.flags.DisableStatelessToStatefulOptimization.set(true); - std::unique_ptr program{Program::create("", pContext, pContext->getDevices(), true, nullptr)}; + std::unique_ptr program{Program::createBuiltInFromSource("", pContext, pContext->getDevices(), nullptr)}; EXPECT_TRUE(CompilerOptions::contains(program->getInternalOptions(), NEO::CompilerOptions::greaterThan4gbBuffersRequired)) << program->getInternalOptions(); DebugManager.flags.DisableStatelessToStatefulOptimization.set(defaultSetting); } TEST_F(ProgramTests, givenProgramWhenItIsCompiledThenItAlwaysHavePreserveVec3TypeInternalOptionSet) { - std::unique_ptr program(Program::create("", pContext, pContext->getDevices(), true, nullptr)); + std::unique_ptr program(Program::createBuiltInFromSource("", pContext, pContext->getDevices(), nullptr)); EXPECT_TRUE(CompilerOptions::contains(program->getInternalOptions(), CompilerOptions::preserveVec3Type)) << program->getInternalOptions(); } @@ -1869,7 +1869,7 @@ TEST_F(ProgramTests, Force32BitAddressessWhenProgramIsCreatedThenGreaterThan4gbB DebugManager.flags.DisableStatelessToStatefulOptimization.set(false); const_cast(&pDevice->getDeviceInfo())->force32BitAddressess = true; - std::unique_ptr program{Program::create("", pContext, pContext->getDevices(), true, nullptr)}; + std::unique_ptr program{Program::createBuiltInFromSource("", pContext, pContext->getDevices(), nullptr)}; if (is32bit) { EXPECT_TRUE(CompilerOptions::contains(program->getInternalOptions(), CompilerOptions::greaterThan4gbBuffersRequired)) << program->getInternalOptions(); } else { @@ -1924,9 +1924,9 @@ TEST_F(ProgramTests, GivenContextWhenCreateProgramFromSourceThenIncrementContext auto initialApiRefCount = pContext->getReference(); auto initialInternalRefCount = pContext->getRefInternalCount(); - auto tempProgram = Program::create("", nullptr, pContext->getDevices(), false, nullptr); + auto tempProgram = new Program(nullptr, false, pContext->getDevices()); EXPECT_FALSE(tempProgram->getIsBuiltIn()); - auto program = Program::create("", pContext, pContext->getDevices(), false, nullptr); + auto program = new Program(pContext, false, pContext->getDevices()); EXPECT_FALSE(program->getIsBuiltIn()); EXPECT_EQ(pContext->getReference(), initialApiRefCount); @@ -1943,9 +1943,9 @@ TEST_F(ProgramTests, GivenContextWhenCreateBuiltInProgramFromSourceThenDontIncre auto initialApiRefCount = pContext->getReference(); auto initialInternalRefCount = pContext->getRefInternalCount(); - auto tempProgram = Program::create("", nullptr, pContext->getDevices(), true, nullptr); + auto tempProgram = new Program(nullptr, true, pContext->getDevices()); EXPECT_TRUE(tempProgram->getIsBuiltIn()); - auto program = Program::create("", pContext, pContext->getDevices(), true, nullptr); + auto program = new Program(pContext, true, pContext->getDevices()); EXPECT_TRUE(program->getIsBuiltIn()); EXPECT_EQ(pContext->getReference(), initialApiRefCount); @@ -1960,19 +1960,19 @@ TEST_F(ProgramTests, GivenContextWhenCreateBuiltInProgramFromSourceThenDontIncre TEST_F(ProgramTests, WhenBuildingProgramThenPointerToProgramIsReturned) { cl_int retVal = CL_DEVICE_NOT_FOUND; - Program *pProgram = Program::create("", pContext, pContext->getDevices(), false, &retVal); + Program *pProgram = Program::createBuiltInFromSource("", pContext, pContext->getDevices(), &retVal); EXPECT_NE(nullptr, pProgram); EXPECT_EQ(CL_SUCCESS, retVal); delete pProgram; - pProgram = Program::create("", pContext, pContext->getDevices(), false, nullptr); + pProgram = Program::createBuiltInFromSource("", pContext, pContext->getDevices(), nullptr); EXPECT_NE(nullptr, pProgram); delete pProgram; } TEST_F(ProgramTests, GivenNullBinaryWhenCreatingProgramFromGenBinaryThenInvalidValueErrorIsReturned) { cl_int retVal = CL_SUCCESS; - Program *pProgram = Program::createFromGenBinary(*pDevice->getExecutionEnvironment(), pContext, nullptr, 0, false, &retVal, pDevice); + Program *pProgram = Program::createBuiltInFromGenBinary(pContext, pContext->getDevices(), nullptr, 0, &retVal); EXPECT_EQ(nullptr, pProgram); EXPECT_NE(CL_SUCCESS, retVal); } @@ -1982,12 +1982,12 @@ TEST_F(ProgramTests, WhenCreatingProgramFromGenBinaryThenSuccessIsReturned) { char binary[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, '\0'}; size_t size = 10; - Program *pProgram = Program::createFromGenBinary(*pDevice->getExecutionEnvironment(), pContext, binary, size, false, &retVal, pDevice); + Program *pProgram = Program::createBuiltInFromGenBinary(pContext, pContext->getDevices(), binary, size, &retVal); EXPECT_NE(nullptr, pProgram); EXPECT_EQ(CL_SUCCESS, retVal); EXPECT_EQ((uint32_t)CL_PROGRAM_BINARY_TYPE_EXECUTABLE, (uint32_t)pProgram->getProgramBinaryType()); - EXPECT_FALSE(pProgram->getIsBuiltIn()); + EXPECT_TRUE(pProgram->getIsBuiltIn()); cl_device_id deviceId = pContext->getDevice(0); cl_build_status status = 0; @@ -1998,25 +1998,11 @@ TEST_F(ProgramTests, WhenCreatingProgramFromGenBinaryThenSuccessIsReturned) { delete pProgram; } -TEST_F(ProgramTests, GivenBuiltInFlagSetWhenCreatingProgramFromGenBinaryThenBuiltInIsCreated) { - cl_int retVal = CL_INVALID_BINARY; - char binary[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, '\0'}; - size_t size = 10; - - Program *pProgram = Program::createFromGenBinary(*pDevice->getExecutionEnvironment(), pContext, binary, size, true, &retVal, pDevice); - EXPECT_NE(nullptr, pProgram); - EXPECT_EQ(CL_SUCCESS, retVal); - - EXPECT_TRUE(pProgram->getIsBuiltIn()); - - delete pProgram; -} - TEST_F(ProgramTests, GivenRetValNullPointerWhenCreatingProgramFromGenBinaryThenSuccessIsReturned) { char binary[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, '\0'}; size_t size = 10; - Program *pProgram = Program::createFromGenBinary(*pDevice->getExecutionEnvironment(), pContext, binary, size, false, nullptr, pDevice); + Program *pProgram = Program::createBuiltInFromGenBinary(pContext, pContext->getDevices(), binary, size, nullptr); EXPECT_NE(nullptr, pProgram); EXPECT_EQ((uint32_t)CL_PROGRAM_BINARY_TYPE_EXECUTABLE, (uint32_t)pProgram->getProgramBinaryType()); @@ -2034,7 +2020,7 @@ TEST_F(ProgramTests, GivenNullContextWhenCreatingProgramFromGenBinaryThenSuccess char binary[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, '\0'}; size_t size = 10; - Program *pProgram = Program::createFromGenBinary(*pDevice->getExecutionEnvironment(), nullptr, binary, size, false, &retVal, pDevice); + Program *pProgram = Program::createBuiltInFromGenBinary(nullptr, toClDeviceVector(*pClDevice), binary, size, &retVal); EXPECT_NE(nullptr, pProgram); EXPECT_EQ(CL_SUCCESS, retVal); EXPECT_EQ((uint32_t)CL_PROGRAM_BINARY_TYPE_EXECUTABLE, (uint32_t)pProgram->getProgramBinaryType()); @@ -2745,7 +2731,7 @@ TEST(CreateProgramFromBinaryTests, givenBinaryProgramWhenKernelRebulildIsForcedT PatchTokensTestData::ValidEmptyProgram programTokens; auto clDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); - std::unique_ptr pProgram(Program::createFromGenBinary(*clDevice->getExecutionEnvironment(), nullptr, programTokens.storage.data(), programTokens.storage.size(), false, &retVal, &clDevice->getDevice())); + 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); @@ -2765,7 +2751,7 @@ TEST(CreateProgramFromBinaryTests, givenBinaryProgramWhenKernelRebulildIsNotForc PatchTokensTestData::ValidEmptyProgram programTokens; auto clDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); - std::unique_ptr pProgram(Program::createFromGenBinary(*clDevice->getExecutionEnvironment(), nullptr, programTokens.storage.data(), programTokens.storage.size(), false, &retVal, &clDevice->getDevice())); + 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);