Skip to content

Commit 6369d8d

Browse files
authored
fix: log successful apis in the validation layer only if verbose is set (#428)
Signed-off-by: Neil R. Spruit <neil.r.spruit@intel.com>
1 parent 230d371 commit 6369d8d

File tree

11 files changed

+1780
-3
lines changed

11 files changed

+1780
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Level zero loader changelog
2+
## v1.28.2
3+
* fix logging of apis in validation layer to only print successful apis given ZEL_LOADER_LOGGING_ENABLE_SUCCESS_PRINT
24
## v1.28.1
35
* feature: Improve API Call Tracing and add ults
46
* add performance validation layer checker

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if(MSVC AND (MSVC_VERSION LESS 1900))
1313
endif()
1414

1515
# This project follows semantic versioning (https://semver.org/)
16-
project(level-zero VERSION 1.28.1)
16+
project(level-zero VERSION 1.28.2)
1717
include(GNUInstallDirs)
1818

1919
find_package(Git)

PRODUCT_GUID.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1.28.1
2-
3622767c-2b40-4af8-961d-06eda1231409
1+
1.28.2
2+
115378b3-db3b-44cf-8c29-eb1184210c18

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ validation layer is enabled. Following variables need to be set to enable API lo
9090

9191
`ZE_ENABLE_VALIDATION_LAYER=1`
9292

93+
To print successful API call results, set
94+
`ZEL_LOADER_LOGGING_ENABLE_SUCCESS_PRINT=1`
95+
Otherwise, only error results will be printed in the API trace output.
96+
NOTE: This will become the default behavior in future releases. for now, please set the env var to enable this logging feature.
97+
9398
By default logs will be written to the log file, as described above. To print the logs
9499
to stderr instead, `ZEL_LOADER_LOG_CONSOLE=1` needs to be set.
95100

scripts/templates/validation/valddi.cpp.mako

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ namespace validation_layer
6565
%endfor
6666
%endif
6767
) {
68+
// Only log success results if verbose logging is enabled
69+
if (result == ${X}_RESULT_SUCCESS && !context.verboseLogging) {
70+
return result;
71+
}
6872
std::string status = (result == ${X}_RESULT_SUCCESS) ? "SUCCESS" : "ERROR";
6973
%if is_void_params:
7074
context.logger->log_trace(status + " (" + loader::to_string(result) + ") in ${func_name}()");
@@ -117,6 +121,10 @@ namespace validation_layer
117121
const void* desc,
118122
ze_event_handle_t* phEvent
119123
) {
124+
// Only log success results if verbose logging is enabled
125+
if (result == ${X}_RESULT_SUCCESS && !context.verboseLogging) {
126+
return result;
127+
}
120128
std::string status = (result == ${X}_RESULT_SUCCESS) ? "SUCCESS" : "ERROR";
121129
std::ostringstream oss;
122130
oss << status << " (" << loader::to_string(result) << ") in zexCounterBasedEventCreate2("

source/layers/validation/ze_valddi.cpp

Lines changed: 868 additions & 0 deletions
Large diffs are not rendered by default.

source/layers/validation/ze_validation_layer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ namespace validation_layer
2323
handleLifetime = std::make_unique<HandleLifetimeValidation>();
2424
}
2525
enableThreadingValidation = getenv_tobool( "ZE_ENABLE_THREADING_VALIDATION" );
26+
verboseLogging = getenv_tobool( "ZEL_LOADER_LOGGING_ENABLE_SUCCESS_PRINT" );
2627

2728
logger = loader::createLogger();
2829
}

source/layers/validation/ze_validation_layer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ namespace validation_layer
4747

4848
bool enableHandleLifetime = false;
4949
bool enableThreadingValidation = false;
50+
bool verboseLogging = false;
5051

5152
ze_dditable_t zeDdiTable = {};
5253
zet_dditable_t zetDdiTable = {};

source/layers/validation/zer_valddi.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ namespace validation_layer
3131
const char** ppString ///< [in,out] pointer to a null-terminated array of characters describing
3232
///< cause of error.
3333
) {
34+
// Only log success results if verbose logging is enabled
35+
if (result == ZE_RESULT_SUCCESS && !context.verboseLogging) {
36+
return result;
37+
}
3438
std::string status = (result == ZE_RESULT_SUCCESS) ? "SUCCESS" : "ERROR";
3539
std::ostringstream oss;
3640
oss << status << " (" << loader::to_string(result) << ") in zerGetLastErrorDescription(";
@@ -46,6 +50,10 @@ namespace validation_layer
4650
ze_result_t result,
4751
ze_device_handle_t hDevice ///< [in] handle of the device
4852
) {
53+
// Only log success results if verbose logging is enabled
54+
if (result == ZE_RESULT_SUCCESS && !context.verboseLogging) {
55+
return result;
56+
}
4957
std::string status = (result == ZE_RESULT_SUCCESS) ? "SUCCESS" : "ERROR";
5058
std::ostringstream oss;
5159
oss << status << " (" << loader::to_string(result) << ") in zerTranslateDeviceHandleToIdentifier(";
@@ -61,6 +69,10 @@ namespace validation_layer
6169
ze_result_t result,
6270
uint32_t identifier ///< [in] integer identifier of the device
6371
) {
72+
// Only log success results if verbose logging is enabled
73+
if (result == ZE_RESULT_SUCCESS && !context.verboseLogging) {
74+
return result;
75+
}
6476
std::string status = (result == ZE_RESULT_SUCCESS) ? "SUCCESS" : "ERROR";
6577
std::ostringstream oss;
6678
oss << status << " (" << loader::to_string(result) << ") in zerTranslateIdentifierToDeviceHandle(";
@@ -74,6 +86,10 @@ namespace validation_layer
7486
}
7587
VALIDATION_MAYBE_UNUSED static ze_result_t logAndPropagateResult_zerGetDefaultContext(
7688
ze_result_t result) {
89+
// Only log success results if verbose logging is enabled
90+
if (result == ZE_RESULT_SUCCESS && !context.verboseLogging) {
91+
return result;
92+
}
7793
std::string status = (result == ZE_RESULT_SUCCESS) ? "SUCCESS" : "ERROR";
7894
context.logger->log_trace(status + " (" + loader::to_string(result) + ") in zerGetDefaultContext()");
7995
return result;

0 commit comments

Comments
 (0)