Skip to content

Commit 2b8acba

Browse files
ola2308Compute-Runtime-Automation
authored andcommitted
feature: Adding support to clCreateProgramWithIL
Related-To: NEO-15701 Signed-off-by: Aleksandra Nizio <aleksandra.nizio@intel.com>
1 parent 7aa5349 commit 2b8acba

File tree

11 files changed

+63
-22
lines changed

11 files changed

+63
-22
lines changed

opencl/source/program/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2018-2022 Intel Corporation
2+
# Copyright (C) 2018-2025 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
@@ -9,6 +9,7 @@ set(RUNTIME_SRCS_PROGRAM
99
${CMAKE_CURRENT_SOURCE_DIR}/build.cpp
1010
${CMAKE_CURRENT_SOURCE_DIR}/compile.cpp
1111
${CMAKE_CURRENT_SOURCE_DIR}/create.cpp
12+
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}create_ext.cpp
1213
${CMAKE_CURRENT_SOURCE_DIR}/create.inl
1314
${CMAKE_CURRENT_SOURCE_DIR}/get_info.cpp
1415
${CMAKE_CURRENT_SOURCE_DIR}/link.cpp

opencl/source/program/build.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ cl_int Program::build(
6969

7070
TranslationInput inputArgs = {IGC::CodeType::oclC, IGC::CodeType::oclGenBin};
7171
if (createdFrom != CreatedFrom::source) {
72-
inputArgs.srcType = isSpirV ? IGC::CodeType::spirV : IGC::CodeType::llvmBc;
72+
inputArgs.srcType = (intermediateRepresentation != IGC::CodeType::invalid)
73+
? intermediateRepresentation
74+
: (isSpirV ? IGC::CodeType::spirV : IGC::CodeType::llvmBc);
7375
inputArgs.src = ArrayRef<const char>(irBinary.get(), irBinarySize);
7476
} else {
7577
inputArgs.src = ArrayRef<const char>(sourceCode.c_str(), sourceCode.size());
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (C) 2025 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "opencl/source/program/program.h"
9+
10+
namespace NEO {
11+
cl_int Program::createFromILExt(Context *context, const void *il, size_t length) {
12+
return CL_INVALID_BINARY;
13+
}
14+
} // namespace NEO

opencl/source/program/program.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ cl_int Program::createProgramFromBinary(
176176

177177
auto rootDeviceIndex = clDevice.getRootDeviceIndex();
178178
cl_int retVal = CL_INVALID_BINARY;
179-
179+
if (pBinary == nullptr) {
180+
return retVal;
181+
}
180182
this->irBinary.reset();
181183
this->irBinarySize = 0U;
182184
this->isSpirV = false;
@@ -280,6 +282,8 @@ cl_int Program::createProgramFromBinary(
280282
break;
281283
}
282284
}
285+
} else {
286+
retVal = this->createFromILExt(context, pBinary, binarySize);
283287
}
284288

285289
return retVal;

opencl/source/program/program.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ class Program : public BaseObject<_cl_program> {
276276
Zebin::Debug::Segments getZebinSegments(uint32_t rootDeviceIndex);
277277
MOCKABLE_VIRTUAL void callPopulateZebinExtendedArgsMetadataOnce(uint32_t rootDeviceIndex);
278278
MOCKABLE_VIRTUAL void callGenerateDefaultExtendedArgsMetadataOnce(uint32_t rootDeviceIndex);
279+
MOCKABLE_VIRTUAL cl_int createFromILExt(Context *context, const void *il, size_t length);
279280

280281
protected:
281282
MOCKABLE_VIRTUAL cl_int createProgramFromBinary(const void *pBinary, size_t binarySize, ClDevice &clDevice);
@@ -388,6 +389,7 @@ class Program : public BaseObject<_cl_program> {
388389
std::string decodeErrors;
389390
std::string decodeWarnings;
390391
} decodedSingleDeviceBinary;
392+
IGC::CodeType::CodeType_t intermediateRepresentation = IGC::CodeType::invalid;
391393
};
392394

393395
static_assert(NEO::NonCopyableAndNonMovable<Program>);

opencl/test/unit_test/api/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ set(IGDRCL_SRCS_tests_api
2727
${CMAKE_CURRENT_SOURCE_DIR}/cl_create_perf_counters_command_queue_tests.inl
2828
${CMAKE_CURRENT_SOURCE_DIR}/cl_create_pipe_tests.inl
2929
${CMAKE_CURRENT_SOURCE_DIR}/cl_create_program_with_binary_tests.inl
30+
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}cl_create_program_with_binary_tests.cpp
3031
${CMAKE_CURRENT_SOURCE_DIR}/cl_create_program_with_built_in_kernels_tests.cpp
3132
${CMAKE_CURRENT_SOURCE_DIR}/cl_create_sampler_tests.inl
3233
${CMAKE_CURRENT_SOURCE_DIR}/cl_create_sampler_with_properties_tests.inl
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (C) 2025 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "opencl/test/unit_test/api/cl_api_tests.h"
9+
10+
using namespace NEO;
11+
12+
using ClCreateProgramWithILTests = ApiTests;
13+
14+
namespace ULT {
15+
TEST_F(ClCreateProgramWithILTests, GivenIncorrectIlWhenCreatingProgramWithIlThenExpectedErrorIsReturned) {
16+
const uint32_t notSpirv[16] = {0xDEADBEEF};
17+
18+
cl_int err = CL_SUCCESS;
19+
cl_program prog = clCreateProgramWithIL(pContext, notSpirv, sizeof(notSpirv), &err);
20+
EXPECT_EQ(CL_INVALID_BINARY, err);
21+
EXPECT_EQ(nullptr, prog);
22+
}
23+
24+
TEST_F(ClCreateProgramWithILTests, GivenIncorrectIlAndNoErrorPointerWhenCreatingProgramWithIlThenExpectedErrorIsReturned) {
25+
const uint32_t notSpirv[16] = {0xDEADBEEF};
26+
27+
cl_program prog = clCreateProgramWithIL(pContext, notSpirv, sizeof(notSpirv), nullptr);
28+
EXPECT_EQ(nullptr, prog);
29+
}
30+
} // namespace ULT

opencl/test/unit_test/api/cl_create_program_with_binary_tests.inl

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -163,22 +163,6 @@ TEST_F(ClCreateProgramWithILTests, GivenIncorrectIlSizeWhenCreatingProgramWithIl
163163
EXPECT_EQ(nullptr, prog);
164164
}
165165

166-
TEST_F(ClCreateProgramWithILTests, GivenIncorrectIlWhenCreatingProgramWithIlThenInvalidBinaryErrorIsReturned) {
167-
const uint32_t notSpirv[16] = {0xDEADBEEF};
168-
169-
cl_int err = CL_SUCCESS;
170-
cl_program prog = clCreateProgramWithIL(pContext, notSpirv, sizeof(notSpirv), &err);
171-
EXPECT_EQ(CL_INVALID_BINARY, err);
172-
EXPECT_EQ(nullptr, prog);
173-
}
174-
175-
TEST_F(ClCreateProgramWithILTests, GivenIncorrectIlAndNoErrorPointerWhenCreatingProgramWithIlThenInvalidBinaryErrorIsReturned) {
176-
const uint32_t notSpirv[16] = {0xDEADBEEF};
177-
178-
cl_program prog = clCreateProgramWithIL(pContext, notSpirv, sizeof(notSpirv), nullptr);
179-
EXPECT_EQ(nullptr, prog);
180-
}
181-
182166
TEST_F(ClCreateProgramWithILKHRTests, GivenCorrectParametersWhenCreatingProgramWithIlkhrThenProgramIsCreatedAndSuccessIsReturned) {
183167
const uint32_t spirv[16] = {0x03022307};
184168

opencl/test/unit_test/mocks/mock_program.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ class MockProgram : public Program {
256256
bool wasDebuggerNotified = false;
257257
bool wasPopulateZebinExtendedArgsMetadataOnceCalled = false;
258258
bool callBasePopulateZebinExtendedArgsMetadataOnce = false;
259+
auto getIntermediateRepresentation() const { return this->intermediateRepresentation; }
260+
auto getIsGeneratedByIgc() const { return this->isGeneratedByIgc; }
261+
auto &getBuildInfos() { return this->buildInfos; }
259262
};
260263

261264
} // namespace NEO

opencl/test/unit_test/program/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2018-2023 Intel Corporation
2+
# Copyright (C) 2018-2025 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
@@ -12,7 +12,7 @@ set(IGDRCL_SRCS_tests_program
1212
${CMAKE_CURRENT_SOURCE_DIR}/kernel_info_from_patchtokens_tests.cpp
1313
${CMAKE_CURRENT_SOURCE_DIR}/printf_handler_tests.cpp
1414
${CMAKE_CURRENT_SOURCE_DIR}/process_debug_data_tests.cpp
15-
${CMAKE_CURRENT_SOURCE_DIR}/process_elf_binary_tests.cpp
15+
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}process_elf_binary_tests.cpp
1616
${CMAKE_CURRENT_SOURCE_DIR}/process_spir_binary_tests.cpp
1717
${CMAKE_CURRENT_SOURCE_DIR}/program_data_tests.cpp
1818
${CMAKE_CURRENT_SOURCE_DIR}/program_from_binary.h

0 commit comments

Comments
 (0)