9
9
#include " shared/test/common/helpers/kernel_binary_helper.h"
10
10
#include " shared/test/common/helpers/test_files.h"
11
11
#include " shared/test/common/mocks/mock_compilers.h"
12
+ #include " shared/test/common/mocks/mock_modules_zebin.h"
12
13
13
14
#include " opencl/source/context/context.h"
14
15
#include " opencl/source/program/program.h"
@@ -75,19 +76,17 @@ TEST_F(clBuildProgramTests, GivenSourceAsInputWhenCreatingProgramWithSourceThenP
75
76
TEST_F (clBuildProgramTests, GivenBinaryAsInputWhenCreatingProgramWithSourceThenProgramBuildSucceeds) {
76
77
cl_program pProgram = nullptr ;
77
78
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" );
82
79
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 ;
86
83
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 ();
89
89
90
- const unsigned char *binaries[1 ] = {reinterpret_cast <const unsigned char *>(pBinary.get ())};
91
90
pProgram = clCreateProgramWithBinary (
92
91
pContext,
93
92
1 ,
@@ -97,8 +96,6 @@ TEST_F(clBuildProgramTests, GivenBinaryAsInputWhenCreatingProgramWithSourceThenP
97
96
&binaryStatus,
98
97
&retVal);
99
98
100
- pBinary.reset ();
101
-
102
99
EXPECT_NE (nullptr , pProgram);
103
100
ASSERT_EQ (CL_SUCCESS, retVal);
104
101
@@ -120,21 +117,18 @@ TEST_F(clBuildProgramTests, GivenBinaryAsInputWhenCreatingProgramWithBinaryForMu
120
117
MockUnrestrictiveContextMultiGPU context;
121
118
cl_program pProgram = nullptr ;
122
119
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" );
127
120
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 ;
131
124
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 ();
134
128
135
129
const size_t numBinaries = 6 ;
136
130
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 ()));
138
132
cl_device_id devicesForProgram[] = {context.pRootDevice0 , context.pSubDevice00 , context.pSubDevice01 , context.pRootDevice1 , context.pSubDevice10 , context.pSubDevice11 };
139
133
size_t sizeBinaries[numBinaries];
140
134
std::fill (sizeBinaries, sizeBinaries + numBinaries, binarySize);
@@ -148,8 +142,6 @@ TEST_F(clBuildProgramTests, GivenBinaryAsInputWhenCreatingProgramWithBinaryForMu
148
142
&binaryStatus,
149
143
&retVal);
150
144
151
- pBinary.reset ();
152
-
153
145
EXPECT_NE (nullptr , pProgram);
154
146
ASSERT_EQ (CL_SUCCESS, retVal);
155
147
@@ -170,17 +162,16 @@ TEST_F(clBuildProgramTests, GivenBinaryAsInputWhenCreatingProgramWithBinaryForMu
170
162
TEST_F (clBuildProgramTests, GivenProgramCreatedFromBinaryWhenBuildProgramWithOptionsIsCalledThenStoredOptionsAreUsed) {
171
163
cl_program pProgram = nullptr ;
172
164
cl_int binaryStatus = CL_SUCCESS;
173
- size_t binarySize = 0 ;
174
- std::string testFile;
175
- retrieveBinaryKernelFilename (testFile, " CopyBuffer_simd16_" , " .bin" );
176
165
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 ;
180
169
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 ())};
184
175
pProgram = clCreateProgramWithBinary (
185
176
pContext,
186
177
1 ,
@@ -192,7 +183,6 @@ TEST_F(clBuildProgramTests, GivenProgramCreatedFromBinaryWhenBuildProgramWithOpt
192
183
193
184
auto pInternalProgram = castToObject<Program>(pProgram);
194
185
195
- pBinary.reset ();
196
186
auto storedOptionsSize = pInternalProgram->getOptions ().size ();
197
187
198
188
EXPECT_NE (nullptr , pProgram);
@@ -316,17 +306,16 @@ TEST_F(clBuildProgramTests, GivenInvalidCallbackInputWhenBuildProgramThenInvalid
316
306
TEST_F (clBuildProgramTests, GivenValidCallbackInputWhenBuildProgramThenCallbackIsInvoked) {
317
307
cl_program pProgram = nullptr ;
318
308
cl_int binaryStatus = CL_SUCCESS;
319
- size_t binarySize = 0 ;
320
- std::string testFile;
321
- retrieveBinaryKernelFilename (testFile, " CopyBuffer_simd16_" , " .bin" );
322
309
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 ;
326
313
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 ())};
330
319
pProgram = clCreateProgramWithBinary (
331
320
pContext,
332
321
1 ,
0 commit comments