Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
uditagarwal97 committed Oct 23, 2024
1 parent 76919e2 commit ba15609
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 37 deletions.
22 changes: 9 additions & 13 deletions sycl/doc/EnvironmentVariables.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ variables in production code.</span>
| `SYCL_USE_KERNEL_SPV` | Path to the SPIR-V binary | Load device image from the specified file. If runtime is unable to read the file, `sycl::runtime_error` exception is thrown. The image is assumed to have been created using the `-fno-sycl-dead-args-optimization` option. |
| `SYCL_DUMP_IMAGES` | Any(\*) | Dump device image binaries to file. Control has no effect if `SYCL_USE_KERNEL_SPV` is set. |
| `SYCL_HOST_UNIFIED_MEMORY` | Integer | Enforce host unified memory support or lack of it for the execution graph builder. If set to 0, it is enforced as not supported by all devices. If set to 1, it is enforced as supported by all devices. |
| `SYCL_CACHE_TRACE` | Described [below](#sycl_cache_trace-options) | Enable tracing for different SYCL caches and kernel_compiler. |
| `SYCL_CACHE_TRACE` | Described [below](#sycl_cache_trace-options) | Enable tracing for different SYCL and `kernel_compiler` caches. |
| `SYCL_PARALLEL_FOR_RANGE_ROUNDING_TRACE` | Any(\*) | Enables tracing of `parallel_for` invocations with rounded-up ranges. |
| `SYCL_PI_SUPPRESS_ERROR_MESSAGE` | Any(\*) | Suppress printing of error message, only used for CI in order not to interrupt errors generated by underlying toolchains; note that the variable only modifies the printing of the error message (error value, name, description and location), the handling of error return code and aborting/throwing behaviour remains unchanged. |
| `SYCL_JIT_COMPILER_DEBUG` | Any(\*) | Passes can specify their own debug types, `sycl-spec-const-materializer` enables debug output generation in specialization constants materialization pass. |
Expand Down Expand Up @@ -247,19 +247,15 @@ Supported tracing levels are in the table below

### `SYCL_CACHE_TRACE` Options

`SYCL_CACHE_TRACE` enables tracing of different SYCL caches and kernel_compiler. It accepts one of the values from the table below:

| Option | Description |
`SYCL_CACHE_TRACE` accepts a bit-mask to control the tracing of different SYCL caches. The input value is parsed as an integer and the following bit-masks are used to determine the tracing behavior:
| Bit-mask | Corresponding cache tracing |
| ------ | ----------- |
| 0 | Disable tracing |
| 1 | Enable tracing of persistent cache |
| 2 | Enable tracing of in-memory cache |
| 3 | Enable tracing of persistent and in-memory cache |
| 4 | Enable tracing of kernel_compiler |
| 5 | Enable tracing of persistent cache and kernel_compiler |
| 6 | Enable tracing of in-memory cache and kernel_compiler |
| 7 | Enable tracing of persistent, in-memory cache, and kernel_compiler |
| Other non-null values | Enable tracing of persistent cache (Depreciated) |
| 0x01 | Enable tracing of persistent cache |
| 0x02 | Enable tracing of in-memory cache |
| 0x04 | Enable tracing of `kernel_compiler` cache |

Any valid combination of the above bit-masks can be used to enable/disable tracing of the corresponding caches. If the input value is not null and not a valid number, the disk cache tracing will be enabled (depreciated behavior).
The default value is 0 and no tracing is enabled.

## Debugging variables for Level Zero Plugin

Expand Down
33 changes: 20 additions & 13 deletions sycl/source/detail/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,25 +698,32 @@ template <> class SYCLConfig<SYCL_JIT_AMDGCN_PTX_TARGET_FEATURES> {
}
};

// SYCL_CACHE_TRACE accepts the following values:
// 0 - no tracing
// 1 - trace disk cache
// 2 - trace in-memory cache
// 3 - trace disk and in-memory cache
// 4 - trace kernel_compiler
// 5 - trace disk and kernel_compiler
// 6 - trace in-memory and kernel_compiler
// 7 - trace disk, in-memory and kernel_compiler
// <Any other non-null value> - trace disk cache (Legacy behavior)
// SYCL_CACHE_TRACE accepts a bit-mask to control the tracing of
// different SYCL caches. The input value is parsed as an integer and
// the following bit-masks is used to determine the tracing behavior:
// 0x01 - trace disk cache
// 0x02 - trace in-memory cache
// 0x04 - trace kernel_compiler cache
// Any valid combination of the above bit-masks can be used to enable/disable
// tracing of the corresponding caches. If the input value is not null and
// not a valid number, the disk cache tracing will be enabled (depreciated
// behavior). The default value is 0 and no tracing is enabled.
template <> class SYCLConfig<SYCL_CACHE_TRACE> {
using BaseT = SYCLConfigBase<SYCL_CACHE_TRACE>;
enum TraceBitmask { DiskCache = 1, InMemCache = 2, KernelCompiler = 4 };

public:
static unsigned int get() { return getCachedValue(); }
static void reset() { (void)getCachedValue(true); }
static bool isTraceDiskCache() { return getCachedValue() & 1; }
static bool isTraceInMemCache() { return getCachedValue() & 2; }
static bool isTraceKernelCompiler() { return getCachedValue() & 4; }
static bool isTraceDiskCache() {
return getCachedValue() & TraceBitmask::DiskCache;
}
static bool isTraceInMemCache() {
return getCachedValue() & TraceBitmask::InMemCache;
}
static bool isTraceKernelCompiler() {
return getCachedValue() & TraceBitmask::KernelCompiler;
}

private:
static unsigned int getCachedValue(bool ResetCache = false) {
Expand Down
21 changes: 10 additions & 11 deletions sycl/unittests/config/ConfigTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,16 @@ TEST(ConfigTests, CheckConfigProcessing) {
sycl::detail::SYCL_PRINT_EXECUTION_GRAPH>::get());
}

// Unit test for SYCL_CACHE_TRACE environment variable.
// SYCL_CACHE_TRACE accepts the following values:
// 0 - no tracing
// 1 - trace disk cache
// 2 - trace in-memory cache
// 3 - trace disk and in-memory cache
// 4 - trace kernel_compiler
// 5 - trace disk and kernel_compiler
// 6 - trace in-memory and kernel_compiler
// 7 - trace disk, in-memory and kernel_compiler
// <Any other non-null value> - trace disk cache (Legacy behavior)
// SYCL_CACHE_TRACE accepts a bit-mask to control the tracing of
// different SYCL caches. The input value is parsed as an integer and
// the following bit-masks is used to determine the tracing behavior:
// 0x01 - trace disk cache
// 0x02 - trace in-memory cache
// 0x04 - trace kernel_compiler cache
// Any valid combination of the above bit-masks can be used to enable/disable
// tracing of the corresponding caches. If the input value is not null and
// not a valid number, the disk cache tracing will be enabled (depreciated
// behavior). The default value is 0 and no tracing is enabled.
using namespace sycl::detail;
TEST(ConfigTests, CheckSyclCacheTraceTest) {

Expand Down

0 comments on commit ba15609

Please sign in to comment.