Skip to content

Commit 47e60f8

Browse files
committed
revert template specialization
1 parent 6c03dba commit 47e60f8

File tree

5 files changed

+33
-24
lines changed

5 files changed

+33
-24
lines changed

sycl/source/detail/config.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,12 @@ unsigned int parseLevel(const char *ValStr) {
204204

205205
} // namespace
206206

207-
void SYCLConfigTrace::reset() { Level = parseLevel(BaseT::getRawValue()); }
207+
void SYCLConfig<SYCL_CACHE_TRACE>::reset() {
208+
Level = parseLevel(BaseT::getRawValue());
209+
}
208210

209-
unsigned int SYCLConfigTrace::Level =
210-
parseLevel(SYCLConfigTrace::BaseT::getRawValue());
211+
unsigned int SYCLConfig<SYCL_CACHE_TRACE>::Level =
212+
parseLevel(BaseT::getRawValue());
211213

212214
} // namespace detail
213215
} // namespace _V1

sycl/source/detail/config.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ template <> class SYCLConfig<SYCL_JIT_AMDGCN_PTX_TARGET_FEATURES> {
709709
// tracing of the corresponding caches. If the input value is not null and
710710
// not a valid number, the disk cache tracing will be enabled (depreciated
711711
// behavior). The default value is 0 and no tracing is enabled.
712-
class SYCLConfigTrace {
712+
template <> class SYCLConfig<SYCL_CACHE_TRACE> {
713713
using BaseT = SYCLConfigBase<SYCL_CACHE_TRACE>;
714714
enum TraceBitmask { DiskCache = 1, InMemCache = 2, KernelCompiler = 4 };
715715

sycl/source/detail/kernel_program_cache.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ class KernelProgramCache {
331331
template <typename MsgType>
332332
static inline void traceProgram(const MsgType &Msg,
333333
const ProgramCacheKeyT &CacheKey) {
334-
if (!SYCLConfigTrace::isTraceInMemCache())
334+
if (!SYCLConfig<SYCL_CACHE_TRACE>::isTraceInMemCache())
335335
return;
336336

337337
int ImageId = CacheKey.first.second;
@@ -368,7 +368,8 @@ class KernelProgramCache {
368368
// set.
369369
static void traceKernel(const char *Msg, KernelNameStrRefT KernelName,
370370
bool isFastKernelCache = false) {
371-
if (__builtin_expect(SYCLConfigTrace::isTraceInMemCache(), false))
371+
if (__builtin_expect(SYCLConfig<SYCL_CACHE_TRACE>::isTraceInMemCache(),
372+
false))
372373
traceKernelImpl(Msg, KernelName, isFastKernelCache);
373374
}
374375

@@ -507,7 +508,8 @@ class KernelProgramCache {
507508
auto LockedCacheKP = acquireKernelsPerProgramCache();
508509
// List kernels that are to be removed from the cache, if tracing is
509510
// enabled.
510-
if (__builtin_expect(SYCLConfigTrace::isTraceInMemCache(), false)) {
511+
if (__builtin_expect(SYCLConfig<SYCL_CACHE_TRACE>::isTraceInMemCache(),
512+
false)) {
511513
for (const auto &Kernel : LockedCacheKP.get()[NativePrg])
512514
traceKernel("Kernel evicted.", Kernel.first);
513515
}

sycl/source/detail/persistent_device_code_cache.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,17 @@ class PersistentDeviceCodeCache {
222222

223223
/* Sends message to std:cerr stream when SYCL_CACHE_TRACE environemnt is set*/
224224
static void trace(const std::string &msg, const std::string &path = "") {
225-
if (__builtin_expect(SYCLConfigTrace::isTraceDiskCache(), false)) {
225+
if (__builtin_expect(SYCLConfig<SYCL_CACHE_TRACE>::isTraceDiskCache(),
226+
false)) {
226227
auto outputPath = path;
227228
std::replace(outputPath.begin(), outputPath.end(), '\\', '/');
228229
std::cerr << "[Persistent Cache]: " << msg << outputPath << std::endl;
229230
}
230231
}
231232
static void trace_KernelCompiler(const std::string &msg,
232233
const std::string &path = "") {
233-
if (__builtin_expect(SYCLConfigTrace::isTraceKernelCompiler(), false)) {
234+
if (__builtin_expect(SYCLConfig<SYCL_CACHE_TRACE>::isTraceKernelCompiler(),
235+
false)) {
234236
auto outputPath = path;
235237
std::replace(outputPath.begin(), outputPath.end(), '\\', '/');
236238
std::cerr << "[kernel_compiler Persistent Cache]: " << msg << outputPath

sycl/unittests/config/ConfigTests.cpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -249,17 +249,20 @@ TEST(ConfigTests, CheckSyclCacheTraceTest) {
249249
// Lambda to test parsing of SYCL_CACHE_TRACE
250250
auto TestConfig = [](int expectedValue, int expectedDiskCache,
251251
int expectedInMemCache, int expectedKernelCompiler) {
252-
EXPECT_EQ(static_cast<unsigned int>(expectedValue), SYCLConfigTrace::get());
252+
EXPECT_EQ(static_cast<unsigned int>(expectedValue),
253+
SYCLConfig<SYCL_CACHE_TRACE>::get());
253254

254255
EXPECT_EQ(
255256
expectedDiskCache,
256-
static_cast<int>(sycl::detail::SYCLConfigTrace::isTraceDiskCache()));
257+
static_cast<int>(
258+
sycl::detail::SYCLConfig<SYCL_CACHE_TRACE>::isTraceDiskCache()));
257259
EXPECT_EQ(
258260
expectedInMemCache,
259-
static_cast<int>(sycl::detail::SYCLConfigTrace::isTraceInMemCache()));
261+
static_cast<int>(
262+
sycl::detail::SYCLConfig<SYCL_CACHE_TRACE>::isTraceInMemCache()));
260263
EXPECT_EQ(expectedKernelCompiler,
261-
static_cast<int>(
262-
sycl::detail::SYCLConfigTrace::isTraceKernelCompiler()));
264+
static_cast<int>(sycl::detail::SYCLConfig<
265+
SYCL_CACHE_TRACE>::isTraceKernelCompiler()));
263266
};
264267

265268
// Lambda to set SYCL_CACHE_TRACE
@@ -276,40 +279,40 @@ TEST(ConfigTests, CheckSyclCacheTraceTest) {
276279
TestConfig(0, 0, 0, 0);
277280

278281
SetSyclCacheTraceEnv("1");
279-
sycl::detail::SYCLConfigTrace::reset();
282+
sycl::detail::SYCLConfig<SYCL_CACHE_TRACE>::reset();
280283
TestConfig(1, 1, 0, 0);
281284

282285
SetSyclCacheTraceEnv("2");
283-
sycl::detail::SYCLConfigTrace::reset();
286+
sycl::detail::SYCLConfig<SYCL_CACHE_TRACE>::reset();
284287
TestConfig(2, 0, 1, 0);
285288

286289
SetSyclCacheTraceEnv("3");
287-
sycl::detail::SYCLConfigTrace::reset();
290+
sycl::detail::SYCLConfig<SYCL_CACHE_TRACE>::reset();
288291
TestConfig(3, 1, 1, 0);
289292

290293
SetSyclCacheTraceEnv("4");
291-
sycl::detail::SYCLConfigTrace::reset();
294+
sycl::detail::SYCLConfig<SYCL_CACHE_TRACE>::reset();
292295
TestConfig(4, 0, 0, 1);
293296

294297
SetSyclCacheTraceEnv("5");
295-
sycl::detail::SYCLConfigTrace::reset();
298+
sycl::detail::SYCLConfig<SYCL_CACHE_TRACE>::reset();
296299
TestConfig(5, 1, 0, 1);
297300

298301
SetSyclCacheTraceEnv("6");
299-
sycl::detail::SYCLConfigTrace::reset();
302+
sycl::detail::SYCLConfig<SYCL_CACHE_TRACE>::reset();
300303
TestConfig(6, 0, 1, 1);
301304

302305
SetSyclCacheTraceEnv("7");
303-
sycl::detail::SYCLConfigTrace::reset();
306+
sycl::detail::SYCLConfig<SYCL_CACHE_TRACE>::reset();
304307
TestConfig(7, 1, 1, 1);
305308

306309
SetSyclCacheTraceEnv("8");
307-
sycl::detail::SYCLConfigTrace::reset();
310+
sycl::detail::SYCLConfig<SYCL_CACHE_TRACE>::reset();
308311
TestConfig(1, 1, 0, 0);
309312

310313
// Set random non-null value. It should default to 1.
311314
SetSyclCacheTraceEnv("random");
312-
sycl::detail::SYCLConfigTrace::reset();
315+
sycl::detail::SYCLConfig<SYCL_CACHE_TRACE>::reset();
313316
TestConfig(1, 1, 0, 0);
314317

315318
// When SYCL_CACHE_TRACE is not set, it should default to 0.
@@ -318,7 +321,7 @@ TEST(ConfigTests, CheckSyclCacheTraceTest) {
318321
#else
319322
unsetenv("SYCL_CACHE_TRACE");
320323
#endif
321-
sycl::detail::SYCLConfigTrace::reset();
324+
sycl::detail::SYCLConfig<SYCL_CACHE_TRACE>::reset();
322325
TestConfig(0, 0, 0, 0);
323326
}
324327

0 commit comments

Comments
 (0)