Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions source/layers/validation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,22 @@ Validates:
When this mode is enabled, the certification checker validates API usage against the version supported by the driver or an explicitly specified version.
If an API is used that was introduced in a version higher than the supported version, the checker will return `ZE_RESULT_ERROR_UNSUPPORTED_VERSION`.

### `ZEL_ENABLE_PERFORMANCE_CHECKER`

When this mode is enabled, the performance checker validates API usage against known performance best practices. It can be used to identify potential performance issues in an application and provide recommendations for improvement.
To enable use following environment variable:
```bash
export ZEL_ENABLE_PERFORMANCE_CHECKER=1
export ZEL_ENABLE_LOADER_LOGGING=1
export ZE_ENABLE_VALIDATION_LAYER=1
export ZEL_LOADER_LOG_CONSOLE=1 # Optional: enable console logging for immediate feedback
```

Currently checked things:
- check whether created immediate command lists are not synchrnous
- check whether created immediate command lists are using in order queues
- check whether in order command lists are using copy offload

### `ZEL_ENABLE_SYSTEM_RESOURCE_TRACKER_CHECKER` (Linux Only)

The System Resource Tracker monitors both Level Zero API resources and system resources in real-time. It tracks:
Expand Down
1 change: 1 addition & 0 deletions source/layers/validation/checkers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
add_subdirectory(basic_leak)
add_subdirectory(certification)
add_subdirectory(events_checker)
add_subdirectory(performance)
add_subdirectory(parameter_validation)
add_subdirectory(template)

Expand Down
5 changes: 5 additions & 0 deletions source/layers/validation/checkers/performance/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
target_sources(${TARGET_NAME}
PRIVATE
${CMAKE_CURRENT_LIST_DIR}/zel_performance_checker.h
${CMAKE_CURRENT_LIST_DIR}/zel_performance_checker.cpp
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (C) 2026 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
* @file zel_performance_checker.cpp
*
*/
#include "zel_performance_checker.h"

namespace validation_layer
{
class performanceChecker performance_checker;

performanceChecker::performanceChecker() {
enableperformance = getenv_tobool( "ZEL_ENABLE_PERFORMANCE_CHECKER" );
if(enableperformance) {
performanceChecker::ZEperformanceChecker *zeChecker = new performanceChecker::ZEperformanceChecker;
performanceChecker::ZESperformanceChecker *zesChecker = new performanceChecker::ZESperformanceChecker;
performanceChecker::ZETperformanceChecker *zetChecker = new performanceChecker::ZETperformanceChecker;
performance_checker.zeValidation = zeChecker;
performance_checker.zetValidation = zetChecker;
performance_checker.zesValidation = zesChecker;
validation_layer::context.validationHandlers.push_back(&performance_checker);
}
}

performanceChecker::~performanceChecker() {
if(enableperformance) {
delete performance_checker.zeValidation;
delete performance_checker.zetValidation;
delete performance_checker.zesValidation;
}
}
ze_result_t performanceChecker::ZEperformanceChecker::zeCommandListCreateImmediateEpilogue(ze_context_handle_t, ze_device_handle_t, const ze_command_queue_desc_t* descriptor, ze_command_list_handle_t*, ze_result_t result)
{
if (result == ZE_RESULT_SUCCESS) {
if (descriptor->mode & ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS) {
context.logger->log_performance("Synchronous command queue may cause performance degradation. Consider using asynchronous mode.");
}
if (descriptor->flags & ZE_COMMAND_QUEUE_FLAG_IN_ORDER) {
if (!(descriptor->flags & ZE_COMMAND_QUEUE_FLAG_COPY_OFFLOAD_HINT)) {
context.logger->log_performance("In-order command list created without copy offload hint. Consider using copy offload hint for better performance of copy operations.");
}
}
else {
context.logger->log_performance("Out-of-order command list created. Consider using in-order command lists for better performance.");
}
}
return result;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
*
* Copyright (C) 2026 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
* @file zel_performance_checker.h
*
*/

#pragma once

#include <string>
#include "ze_api.h"
#include "ze_validation_layer.h"

namespace validation_layer
{
class __zedlllocal performanceChecker : public validationChecker{
public:
performanceChecker();
~performanceChecker();

class ZEperformanceChecker : public ZEValidationEntryPoints {
ze_result_t zeCommandListCreateImmediateEpilogue(ze_context_handle_t, ze_device_handle_t, const ze_command_queue_desc_t*, ze_command_list_handle_t*, ze_result_t result) override;
};
class ZESperformanceChecker : public ZESValidationEntryPoints {};
class ZETperformanceChecker : public ZETValidationEntryPoints {};


bool enableperformance = false;
};
extern class performanceChecker performance_checker;
}
8 changes: 7 additions & 1 deletion source/utils/logging.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2024 Intel Corporation
* Copyright (C) 2024-2026 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -137,6 +137,12 @@ class Logger {
_logger->critical(msg);
}

void log_performance(std::string msg) {
if (!logging_enabled)
return;
_logger->warn("[performance] " + msg);
}

std::shared_ptr<spdlog::logger> get_base_logger(){
return _logger;
}
Expand Down
Loading