1
- // ==----- PersistenDeviceCodeCache .cpp --- Persistent cache tests - ---------==//
1
+ // ==----- PersistentDeviceCodeCache .cpp --- Persistent cache tests ---------==//
2
2
//
3
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
4
// See https://llvm.org/LICENSE.txt for license information.
@@ -78,7 +78,8 @@ static pi_result redefinedProgramGetInfo(pi_program program,
78
78
return PI_SUCCESS;
79
79
}
80
80
81
- class PersistenDeviceCodeCache : public ::testing::Test {
81
+ class PersistentDeviceCodeCache
82
+ : public ::testing::TestWithParam<pi_device_binary_type> {
82
83
public:
83
84
#ifdef _WIN32
84
85
int setenv (const char *name, const char *value, int overwrite) {
@@ -123,6 +124,8 @@ class PersistenDeviceCodeCache : public ::testing::Test {
123
124
EXPECT_NE (getenv (" SYCL_CACHE_DIR" ), nullptr )
124
125
<< " Please set SYCL_CACHE_DIR environment variable pointing to cache "
125
126
" location." ;
127
+ // Set binary format from parameter.
128
+ BinStruct.Format = GetParam ();
126
129
}
127
130
128
131
virtual void TearDown () {
@@ -133,7 +136,7 @@ class PersistenDeviceCodeCache : public ::testing::Test {
133
136
: nullptr );
134
137
}
135
138
136
- PersistenDeviceCodeCache () : Plt{default_selector ()} {
139
+ PersistentDeviceCodeCache () : Plt{default_selector ()} {
137
140
138
141
if (Plt.is_host () || Plt.get_backend () != backend::opencl) {
139
142
std::clog << " This test is only supported on OpenCL devices\n " ;
@@ -199,9 +202,10 @@ class PersistenDeviceCodeCache : public ::testing::Test {
199
202
detail::OSModuleHandle ModuleHandle = detail::OSUtil::ExeModuleHandle;
200
203
platform Plt;
201
204
device Dev;
205
+ // NOTE: Format is a parameter of the test so use none and set in SetUp.
202
206
pi_device_binary_struct BinStruct{/* Version*/ 1 ,
203
207
/* Kind*/ 4 ,
204
- /* Format*/ PI_DEVICE_BINARY_TYPE_SPIRV ,
208
+ /* Format*/ PI_DEVICE_BINARY_TYPE_NONE ,
205
209
/* DeviceTargetSpec*/ nullptr ,
206
210
/* CompileOptions*/ nullptr ,
207
211
/* LinkOptions*/ nullptr ,
@@ -221,7 +225,7 @@ class PersistenDeviceCodeCache : public ::testing::Test {
221
225
222
226
/* Checks that key values with \0 symbols are processed correctly
223
227
*/
224
- TEST_F (PersistenDeviceCodeCache , KeysWithNullTermSymbol) {
228
+ TEST_P (PersistentDeviceCodeCache , KeysWithNullTermSymbol) {
225
229
if (Plt.is_host () || Plt.get_backend () != backend::opencl) {
226
230
return ;
227
231
}
@@ -254,21 +258,21 @@ TEST_F(PersistenDeviceCodeCache, KeysWithNullTermSymbol) {
254
258
/* Do read/write for the same cache item to/from 300 threads for small device
255
259
* code size. Make sure that there is no data corruption or crashes.
256
260
*/
257
- TEST_F (PersistenDeviceCodeCache , ConcurentReadWriteSmallItem) {
261
+ TEST_P (PersistentDeviceCodeCache , ConcurentReadWriteSmallItem) {
258
262
ConcurentReadWriteCache (0 , 300 );
259
263
}
260
264
261
265
/* Do read/write for the same cache item to/from 100 threads for medium device
262
266
* code size. Make sure that there is no data corruption or crashes.
263
267
*/
264
- TEST_F (PersistenDeviceCodeCache , ConcurentReadWriteCacheMediumItem) {
268
+ TEST_P (PersistentDeviceCodeCache , ConcurentReadWriteCacheMediumItem) {
265
269
ConcurentReadWriteCache (1 , 100 );
266
270
}
267
271
268
272
/* Do read/write for the same cache item to/from 20 threads from big device
269
273
* code size. Make sure that there is no data corruption or crashes.
270
274
*/
271
- TEST_F (PersistenDeviceCodeCache , ConcurentReadWriteCacheBigItem) {
275
+ TEST_P (PersistentDeviceCodeCache , ConcurentReadWriteCacheBigItem) {
272
276
ConcurentReadWriteCache (2 , 20 );
273
277
}
274
278
@@ -279,7 +283,7 @@ TEST_F(PersistenDeviceCodeCache, ConcurentReadWriteCacheBigItem) {
279
283
* - source file is corrupted;
280
284
* - binary file is corrupted.
281
285
*/
282
- TEST_F (PersistenDeviceCodeCache , CorruptedCacheFiles) {
286
+ TEST_P (PersistentDeviceCodeCache , CorruptedCacheFiles) {
283
287
if (Plt.is_host () || Plt.get_backend () != backend::opencl) {
284
288
return ;
285
289
}
@@ -349,7 +353,7 @@ TEST_F(PersistenDeviceCodeCache, CorruptedCacheFiles) {
349
353
* - new cache item is created if existing one is locked on write operation;
350
354
* - cache miss happens on read operation.
351
355
*/
352
- TEST_F (PersistenDeviceCodeCache , LockFile) {
356
+ TEST_P (PersistentDeviceCodeCache , LockFile) {
353
357
if (Plt.is_host () || Plt.get_backend () != backend::opencl) {
354
358
return ;
355
359
}
@@ -405,7 +409,7 @@ TEST_F(PersistenDeviceCodeCache, LockFile) {
405
409
// llvm::sys::fs::setPermissions does not make effect on Windows
406
410
/* Checks cache behavior when filesystem read/write operations fail
407
411
*/
408
- TEST_F (PersistenDeviceCodeCache , AccessDeniedForCacheDir) {
412
+ TEST_P (PersistentDeviceCodeCache , AccessDeniedForCacheDir) {
409
413
if (Plt.is_host () || Plt.get_backend () != backend::opencl) {
410
414
return ;
411
415
}
@@ -452,4 +456,9 @@ TEST_F(PersistenDeviceCodeCache, AccessDeniedForCacheDir) {
452
456
ASSERT_NO_ERROR (llvm::sys::fs::remove_directories (ItemDir));
453
457
}
454
458
#endif // _WIN32
459
+
460
+ INSTANTIATE_TEST_SUITE_P (PersistentDeviceCodeCacheImpl,
461
+ PersistentDeviceCodeCache,
462
+ ::testing::Values (PI_DEVICE_BINARY_TYPE_SPIRV,
463
+ PI_DEVICE_BINARY_TYPE_NATIVE));
455
464
} // namespace
0 commit comments