99#include " shared/test/common/helpers/kernel_binary_helper.h"
1010#include " shared/test/common/helpers/test_files.h"
1111#include " shared/test/common/mocks/mock_compilers.h"
12+ #include " shared/test/common/mocks/mock_modules_zebin.h"
1213
1314#include " opencl/source/context/context.h"
1415#include " opencl/source/program/program.h"
@@ -75,19 +76,17 @@ TEST_F(clBuildProgramTests, GivenSourceAsInputWhenCreatingProgramWithSourceThenP
7576TEST_F (clBuildProgramTests, GivenBinaryAsInputWhenCreatingProgramWithSourceThenProgramBuildSucceeds) {
7677 cl_program pProgram = nullptr ;
7778 cl_int binaryStatus = CL_SUCCESS;
78- std::unique_ptr<char []> pBinary = nullptr ;
79- size_t binarySize = 0 ;
80- std::string testFile;
81- retrieveBinaryKernelFilename (testFile, " CopyBuffer_simd16_" , " .bin" );
8279
83- pBinary = loadDataFromFile (
84- testFile. c_str (),
85- binarySize) ;
80+ constexpr auto numBits = is32bit ? Elf::EI_CLASS_32 : Elf::EI_CLASS_64;
81+ auto zebinData = std::make_unique<ZebinTestData::ZebinCopyBufferSimdModule<numBits>>(pDevice-> getHardwareInfo (), 16 );
82+ const auto &src = zebinData-> storage ;
8683
87- ASSERT_NE (0u , binarySize);
88- ASSERT_NE (nullptr , pBinary);
84+ ASSERT_NE (nullptr , src.data ());
85+ ASSERT_NE (0u , src.size ());
86+
87+ const unsigned char *binaries[1 ] = {reinterpret_cast <const unsigned char *>(src.data ())};
88+ const size_t binarySize = src.size ();
8989
90- const unsigned char *binaries[1 ] = {reinterpret_cast <const unsigned char *>(pBinary.get ())};
9190 pProgram = clCreateProgramWithBinary (
9291 pContext,
9392 1 ,
@@ -97,8 +96,6 @@ TEST_F(clBuildProgramTests, GivenBinaryAsInputWhenCreatingProgramWithSourceThenP
9796 &binaryStatus,
9897 &retVal);
9998
100- pBinary.reset ();
101-
10299 EXPECT_NE (nullptr , pProgram);
103100 ASSERT_EQ (CL_SUCCESS, retVal);
104101
@@ -120,21 +117,18 @@ TEST_F(clBuildProgramTests, GivenBinaryAsInputWhenCreatingProgramWithBinaryForMu
120117 MockUnrestrictiveContextMultiGPU context;
121118 cl_program pProgram = nullptr ;
122119 cl_int binaryStatus = CL_SUCCESS;
123- std::unique_ptr<char []> pBinary = nullptr ;
124- size_t binarySize = 0 ;
125- std::string testFile;
126- retrieveBinaryKernelFilename (testFile, " CopyBuffer_simd16_" , " .bin" );
127120
128- pBinary = loadDataFromFile (
129- testFile. c_str (),
130- binarySize) ;
121+ constexpr auto numBits = is32bit ? Elf::EI_CLASS_32 : Elf::EI_CLASS_64;
122+ auto zebinData = std::make_unique<ZebinTestData::ZebinCopyBufferSimdModule<numBits>>(pDevice-> getHardwareInfo (), 16 );
123+ const auto &src = zebinData-> storage ;
131124
132- ASSERT_NE (0u , binarySize);
133- ASSERT_NE (nullptr , pBinary);
125+ ASSERT_NE (nullptr , src.data ());
126+ ASSERT_NE (0u , src.size ());
127+ const size_t binarySize = src.size ();
134128
135129 const size_t numBinaries = 6 ;
136130 const unsigned char *binaries[numBinaries];
137- std::fill (binaries, binaries + numBinaries, reinterpret_cast <const unsigned char *>(pBinary. get ()));
131+ std::fill (binaries, binaries + numBinaries, reinterpret_cast <const unsigned char *>(src. data ()));
138132 cl_device_id devicesForProgram[] = {context.pRootDevice0 , context.pSubDevice00 , context.pSubDevice01 , context.pRootDevice1 , context.pSubDevice10 , context.pSubDevice11 };
139133 size_t sizeBinaries[numBinaries];
140134 std::fill (sizeBinaries, sizeBinaries + numBinaries, binarySize);
@@ -148,8 +142,6 @@ TEST_F(clBuildProgramTests, GivenBinaryAsInputWhenCreatingProgramWithBinaryForMu
148142 &binaryStatus,
149143 &retVal);
150144
151- pBinary.reset ();
152-
153145 EXPECT_NE (nullptr , pProgram);
154146 ASSERT_EQ (CL_SUCCESS, retVal);
155147
@@ -170,17 +162,16 @@ TEST_F(clBuildProgramTests, GivenBinaryAsInputWhenCreatingProgramWithBinaryForMu
170162TEST_F (clBuildProgramTests, GivenProgramCreatedFromBinaryWhenBuildProgramWithOptionsIsCalledThenStoredOptionsAreUsed) {
171163 cl_program pProgram = nullptr ;
172164 cl_int binaryStatus = CL_SUCCESS;
173- size_t binarySize = 0 ;
174- std::string testFile;
175- retrieveBinaryKernelFilename (testFile, " CopyBuffer_simd16_" , " .bin" );
176165
177- auto pBinary = loadDataFromFile (
178- testFile. c_str (),
179- binarySize) ;
166+ constexpr auto numBits = is32bit ? Elf::EI_CLASS_32 : Elf::EI_CLASS_64;
167+ auto zebinData = std::make_unique<ZebinTestData::ZebinCopyBufferSimdModule<numBits>>(pDevice-> getHardwareInfo (), 16 );
168+ const auto &src = zebinData-> storage ;
180169
181- ASSERT_NE (0u , binarySize);
182- ASSERT_NE (nullptr , pBinary);
183- const unsigned char *binaries[1 ] = {reinterpret_cast <const unsigned char *>(pBinary.get ())};
170+ ASSERT_NE (nullptr , src.data ());
171+ ASSERT_NE (0u , src.size ());
172+ const size_t binarySize = src.size ();
173+
174+ const unsigned char *binaries[1 ] = {reinterpret_cast <const unsigned char *>(src.data ())};
184175 pProgram = clCreateProgramWithBinary (
185176 pContext,
186177 1 ,
@@ -192,7 +183,6 @@ TEST_F(clBuildProgramTests, GivenProgramCreatedFromBinaryWhenBuildProgramWithOpt
192183
193184 auto pInternalProgram = castToObject<Program>(pProgram);
194185
195- pBinary.reset ();
196186 auto storedOptionsSize = pInternalProgram->getOptions ().size ();
197187
198188 EXPECT_NE (nullptr , pProgram);
@@ -316,17 +306,16 @@ TEST_F(clBuildProgramTests, GivenInvalidCallbackInputWhenBuildProgramThenInvalid
316306TEST_F (clBuildProgramTests, GivenValidCallbackInputWhenBuildProgramThenCallbackIsInvoked) {
317307 cl_program pProgram = nullptr ;
318308 cl_int binaryStatus = CL_SUCCESS;
319- size_t binarySize = 0 ;
320- std::string testFile;
321- retrieveBinaryKernelFilename (testFile, " CopyBuffer_simd16_" , " .bin" );
322309
323- auto pBinary = loadDataFromFile (
324- testFile. c_str (),
325- binarySize) ;
310+ constexpr auto numBits = is32bit ? Elf::EI_CLASS_32 : Elf::EI_CLASS_64;
311+ auto zebinData = std::make_unique<ZebinTestData::ZebinCopyBufferSimdModule<numBits>>(pDevice-> getHardwareInfo (), 16 );
312+ const auto &src = zebinData-> storage ;
326313
327- ASSERT_NE (0u , binarySize);
328- ASSERT_NE (nullptr , pBinary);
329- const unsigned char *binaries[1 ] = {reinterpret_cast <const unsigned char *>(pBinary.get ())};
314+ ASSERT_NE (nullptr , src.data ());
315+ ASSERT_NE (0u , src.size ());
316+ const size_t binarySize = src.size ();
317+
318+ const unsigned char *binaries[1 ] = {reinterpret_cast <const unsigned char *>(src.data ())};
330319 pProgram = clCreateProgramWithBinary (
331320 pContext,
332321 1 ,
0 commit comments