This sample is a simple LD_PRELOAD based tool that allows to collect such GPU hardware metrics as execution unit (EU) active, stall and idle ratios attributed to Level Zero kernels. The sample is based on continuous mode for metrics collection.
As a result, table like the following will be printed. For each kernel its call count, total time and metric values will be shown.
=== Device Metrics: ===
Total Execution Time (ns): 516360532
Total Kernel Time (ns): 174056667
Kernel, Calls, Time (ns), Time (%), Average (ns), EU Active (%), EU Stall (%), EU Idle (%)
GEMM, 4, 174056667, 100.00, 43514166, 73.24, 26.67, 0.09
To set target device and sub-device to collect metrics from one can specify PTI_DEVICE_ID
and PTI_SUB_DEVICE_ID
environment variables.
- Linux
- Windows (under development)
- CMake (version 3.12 and above)
- Git (version 1.8 and above)
- Python (version 2.7 and above)
- oneAPI Level Zero loader
- Intel(R) Graphics Compute Runtime for oneAPI Level Zero and OpenCL(TM) Driver
- Intel(R) Metrics Discovery Application Programming Interface
- Metrics Library for Metrics Discovery API (Metrics Library for MD API)
- libdrm
Run the following commands to build the sample:
cd <pti>/samples/ze_metric_streamer
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
Use this command line to run the tool:
./ze_metric_streamer <target_application>
One may use ze_gemm as target application:
./ze_metric_streamer ../../ze_gemm/build/ze_gemm
Since Intel(R) Metrics Discovery Application Programming Interface library is loaded at runtime, one may need to set its path explicitly, e.g.:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib ./ze_metric_streamer ../../ze_gemm/build/ze_gemm
On Linux one may need to enable collection for non-root users:
sudo echo 0 > /proc/sys/dev/i915/perf_stream_paranoid
Use Microsoft* Visual Studio x64 command prompt to run the following commands and build the sample:
cd <pti>\samples\ze_metric_streamer
mkdir build
cd build
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_LIBRARY_PATH=<level_zero_loader>\lib -DCMAKE_INCLUDE_PATH=<level_zero_loader>\include ..
nmake
Use this command line to run the tool:
ze_metric_streamer.exe <target_application>
One may use ze_gemm as target application:
ze_metric_streamer.exe ..\..\ze_gemm\build\ze_gemm.exe
Since Intel(R) Metrics Discovery Application Programming Interface and Metrics Library for Metrics Discovery API (Metrics Library for MD API) are loaded at runtime, one may need to set its path explicitly (see the output of cmake), e.g.:
set PATH=%PATH%;C:\Windows\system32\DriverStore\FileRepository\igdlh64.inf_amd64_d59561bc9241aaf5
ze_metric_streamer.exe ..\..\ze_gemm\build\ze_gemm.exe