1- From 3881cc54a21ba2638ba84127ac3b973dda3201cc Mon Sep 17 00:00:00 2001
2- From: "Shahneous Bari, Md Abdullah" <md.abdullah.shahneous.bari @intel.com>
3- Date: Tue, 21 Oct 2025 01:05:24 +0000
4- Subject: [PATCH] Add profile support in upstream LevelZeroRuntimeWrapper.
1+ From a4c92dc66a3de2561ae1b9d4055b5498aa05d7aa Mon Sep 17 00:00:00 2001
2+ From: Garra1980 <igor.zamyatin @intel.com>
3+ Date: Wed, 4 Mar 2026 01:02:08 +0100
4+ Subject: [PATCH] Add profile support in upstream LevelZeroRuntimeWrappers.cpp
55
66---
77 .../LevelZeroRuntimeWrappers.cpp | 334 +++++++++++++++++-
88 1 file changed, 316 insertions(+), 18 deletions(-)
99
1010diff --git a/mlir/lib/ExecutionEngine/LevelZeroRuntimeWrappers.cpp b/mlir/lib/ExecutionEngine/LevelZeroRuntimeWrappers.cpp
11- index d0728274b94c..c728e3576f11 100644
11+ index 7859fb3feaab..6a1cd7ba3b4d 100644
1212--- a/mlir/lib/ExecutionEngine/LevelZeroRuntimeWrappers.cpp
1313+++ b/mlir/lib/ExecutionEngine/LevelZeroRuntimeWrappers.cpp
14- @@ -13 ,12 +13 ,16 @@
15- #include "llvm/ADT/Twine.h"
14+ @@ -11 ,12 +11 ,16 @@
15+ //===----------------------------------------------------------------------===//
1616
1717 #include "level_zero/ze_api.h"
1818+ #include <algorithm>
@@ -25,10 +25,10 @@ index d0728274b94c..c728e3576f11 100644
2525 #include <iostream>
2626 #include <limits>
2727+ #include <numeric>
28+ #include <memory>
29+ #include <stdexcept>
2830 #include <unordered_set>
29- #include <vector>
30-
31- @@ -328,6 +332,92 @@ struct DynamicEventPool {
31+ @@ -327,6 +331,92 @@ struct DynamicEventPool {
3232 }
3333 };
3434
@@ -121,7 +121,7 @@ index d0728274b94c..c728e3576f11 100644
121121 static L0RTContextWrapper &getRtContext() {
122122 thread_local static L0RTContextWrapper rtContext(0);
123123 return rtContext;
124- @@ -338 ,6 +428 ,75 @@ static DynamicEventPool &getDynamicEventPool() {
124+ @@ -337 ,6 +427 ,75 @@ static DynamicEventPool &getDynamicEventPool() {
125125 return dynEventPool;
126126 }
127127
@@ -197,7 +197,7 @@ index d0728274b94c..c728e3576f11 100644
197197 struct StreamWrapper {
198198 // avoid event pointer invalidations
199199 std::deque<ze_event_handle_t> implicitEventStack;
200- @@ -407 ,6 +566 ,98 @@ static ze_module_handle_t loadModule(const void *data, size_t dataSize) {
200+ @@ -406 ,6 +565 ,98 @@ static ze_module_handle_t loadModule(const void *data, size_t dataSize) {
201201 return zeModule;
202202 }
203203
@@ -296,7 +296,7 @@ index d0728274b94c..c728e3576f11 100644
296296 //===----------------------------------------------------------------------===//
297297 // L0 Wrappers definition
298298 //===----------------------------------------------------------------------===//
299- @@ -454 ,24 +705 ,8 @@ extern "C" void mgpuEventRecord(ze_event_handle_t event,
299+ @@ -453 ,24 +704 ,8 @@ extern "C" void mgpuEventRecord(ze_event_handle_t event,
300300 extern "C" void *mgpuMemAlloc(uint64_t size, StreamWrapper *stream,
301301 bool isShared) {
302302 return catchAll([&]() {
@@ -322,15 +322,15 @@ index d0728274b94c..c728e3576f11 100644
322322 });
323323 }
324324
325- @@ -537 ,7 +772 ,6 @@ extern "C" void mgpuLaunchKernel(ze_kernel_handle_t kernel, size_t gridX,
325+ @@ -536 ,7 +771 ,6 @@ extern "C" void mgpuLaunchKernel(ze_kernel_handle_t kernel, size_t gridX,
326326 size_t sharedMemBytes, StreamWrapper *stream,
327327 void **params, void ** /*extra*/,
328328 size_t paramsCount) {
329329-
330330 if (sharedMemBytes > 0) {
331331 paramsCount = paramsCount - 1; // Last param is shared memory size
332332 L0_SAFE_CALL(
333- @@ -551 ,6 +785 ,70 @@ extern "C" void mgpuLaunchKernel(ze_kernel_handle_t kernel, size_t gridX,
333+ @@ -550 ,6 +784 ,70 @@ extern "C" void mgpuLaunchKernel(ze_kernel_handle_t kernel, size_t gridX,
334334 dispatch.groupCountX = static_cast<uint32_t>(gridX);
335335 dispatch.groupCountY = static_cast<uint32_t>(gridY);
336336 dispatch.groupCountZ = static_cast<uint32_t>(gridZ);
@@ -402,4 +402,4 @@ index d0728274b94c..c728e3576f11 100644
402402 ze_event_handle_t *waitEvents) {
403403 L0_SAFE_CALL(zeCommandListAppendLaunchKernel(
404404- -
405- 2.43.0
405+ 2.34.1
0 commit comments