Skip to content

Commit ea95271

Browse files
gzadica1gzadicariosergey-semenovGuy Zadickario
authored
[SYCL][XPTI] Improvements to allow framework/app software level layers to provide code locations for sycl generated XPTI events. (#15190)
It is useful for framework software layers which uses sycl in their implementation (like IPEX) to provide framework level code location information for XPTI events generated by sycl. This allows a framework specific instrumentation tool to capture sycl XPTI events with code location information coming from the framework level. This allows the specific instrumentation tool, for example, to capture sycl stream task_begin and task_end events and correlate the specific execution with the upper layer graph node (or application level name of work) that this task represents by querying the payload attached to the events. The change does not require any new APIs or ABI change, to capture a code location the framework software layer should instantiate the existing sycl::detail::tls_code_loc_t object before calling a sycl entry point (usually queue.submit or graph.add). There are 3 commits in this PR: 1) Change all sycl entry points that tries to set code location in TLS to use the code location that is already set in TLS, if one is set. Instead of passing on the entry point code location at any case. 2) Payload for kernel execution commands uses the kernel name in place of the function name from code location. This changes this behavior in case that the upper layer software has captured code location in TLS before calling sycl. 3) Fixes XPTI events in graph mode, some events were missing when bypassing scheduler. --------- Signed-off-by: Guy Zadicario <[email protected]> Co-authored-by: Guy Zadicario <[email protected]> Co-authored-by: Sergey Semenov <[email protected]> Co-authored-by: Guy Zadickario <[email protected]>
1 parent a4f74a9 commit ea95271

19 files changed

+388
-109
lines changed

sycl/include/sycl/detail/common.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ class __SYCL_EXPORT tls_code_loc_t {
140140
/// @return The code location information saved in the TLS slot. If not TLS
141141
/// entry has been set up, a default coe location is returned.
142142
const detail::code_location &query();
143+
/// @brief Returns true if the TLS slot was cleared when this object was
144+
/// constructed.
145+
bool isToplevel() const { return !MLocalScope; }
143146

144147
private:
145148
// The flag that is used to determine if the object is in a local scope or in

sycl/include/sycl/ext/oneapi/bindless_images.hpp

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ inline event queue::ext_oneapi_copy(
13691369
detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc);
13701370
return submit(
13711371
[&](handler &CGH) { CGH.ext_oneapi_copy(Src, Dest, DestImgDesc); },
1372-
CodeLoc);
1372+
TlsCodeLocCapture.query());
13731373
}
13741374

13751375
inline event queue::ext_oneapi_copy(
@@ -1383,7 +1383,7 @@ inline event queue::ext_oneapi_copy(
13831383
CGH.ext_oneapi_copy(Src, SrcOffset, SrcExtent, Dest, DestOffset,
13841384
DestImgDesc, CopyExtent);
13851385
},
1386-
CodeLoc);
1386+
TlsCodeLocCapture.query());
13871387
}
13881388

13891389
inline event queue::ext_oneapi_copy(
@@ -1396,7 +1396,7 @@ inline event queue::ext_oneapi_copy(
13961396
CGH.depends_on(DepEvent);
13971397
CGH.ext_oneapi_copy(Src, Dest, DestImgDesc);
13981398
},
1399-
CodeLoc);
1399+
TlsCodeLocCapture.query());
14001400
}
14011401

14021402
inline event queue::ext_oneapi_copy(
@@ -1412,7 +1412,7 @@ inline event queue::ext_oneapi_copy(
14121412
CGH.ext_oneapi_copy(Src, SrcOffset, SrcExtent, Dest, DestOffset,
14131413
DestImgDesc, CopyExtent);
14141414
},
1415-
CodeLoc);
1415+
TlsCodeLocCapture.query());
14161416
}
14171417

14181418
inline event queue::ext_oneapi_copy(
@@ -1425,7 +1425,7 @@ inline event queue::ext_oneapi_copy(
14251425
CGH.depends_on(DepEvents);
14261426
CGH.ext_oneapi_copy(Src, Dest, DestImgDesc);
14271427
},
1428-
CodeLoc);
1428+
TlsCodeLocCapture.query());
14291429
}
14301430

14311431
inline event queue::ext_oneapi_copy(
@@ -1441,7 +1441,7 @@ inline event queue::ext_oneapi_copy(
14411441
CGH.ext_oneapi_copy(Src, SrcOffset, SrcExtent, Dest, DestOffset,
14421442
DestImgDesc, CopyExtent);
14431443
},
1444-
CodeLoc);
1444+
TlsCodeLocCapture.query());
14451445
}
14461446

14471447
inline event queue::ext_oneapi_copy(
@@ -1451,7 +1451,7 @@ inline event queue::ext_oneapi_copy(
14511451
detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc);
14521452
return submit(
14531453
[&](handler &CGH) { CGH.ext_oneapi_copy(Src, Dest, SrcImgDesc); },
1454-
CodeLoc);
1454+
TlsCodeLocCapture.query());
14551455
}
14561456

14571457
inline event queue::ext_oneapi_copy(
@@ -1466,7 +1466,7 @@ inline event queue::ext_oneapi_copy(
14661466
CGH.ext_oneapi_copy(Src, SrcOffset, SrcImgDesc, Dest, DestOffset,
14671467
DestExtent, CopyExtent);
14681468
},
1469-
CodeLoc);
1469+
TlsCodeLocCapture.query());
14701470
}
14711471

14721472
inline event queue::ext_oneapi_copy(
@@ -1479,7 +1479,7 @@ inline event queue::ext_oneapi_copy(
14791479
CGH.depends_on(DepEvent);
14801480
CGH.ext_oneapi_copy(Src, Dest, SrcImgDesc);
14811481
},
1482-
CodeLoc);
1482+
TlsCodeLocCapture.query());
14831483
}
14841484

14851485
inline event queue::ext_oneapi_copy(
@@ -1496,7 +1496,7 @@ inline event queue::ext_oneapi_copy(
14961496
CGH.ext_oneapi_copy(Src, SrcOffset, SrcImgDesc, Dest, DestOffset,
14971497
DestExtent, CopyExtent);
14981498
},
1499-
CodeLoc);
1499+
TlsCodeLocCapture.query());
15001500
}
15011501

15021502
inline event queue::ext_oneapi_copy(
@@ -1509,7 +1509,7 @@ inline event queue::ext_oneapi_copy(
15091509
CGH.depends_on(DepEvents);
15101510
CGH.ext_oneapi_copy(Src, Dest, SrcImgDesc);
15111511
},
1512-
CodeLoc);
1512+
TlsCodeLocCapture.query());
15131513
}
15141514

15151515
inline event queue::ext_oneapi_copy(
@@ -1526,7 +1526,7 @@ inline event queue::ext_oneapi_copy(
15261526
CGH.ext_oneapi_copy(Src, SrcOffset, SrcImgDesc, Dest, DestOffset,
15271527
DestExtent, CopyExtent);
15281528
},
1529-
CodeLoc);
1529+
TlsCodeLocCapture.query());
15301530
}
15311531

15321532
inline event queue::ext_oneapi_copy(
@@ -1538,7 +1538,7 @@ inline event queue::ext_oneapi_copy(
15381538
[&](handler &CGH) {
15391539
CGH.ext_oneapi_copy(Src, Dest, DeviceImgDesc, DeviceRowPitch);
15401540
},
1541-
CodeLoc);
1541+
TlsCodeLocCapture.query());
15421542
}
15431543

15441544
inline event queue::ext_oneapi_copy(
@@ -1553,7 +1553,7 @@ inline event queue::ext_oneapi_copy(
15531553
CGH.ext_oneapi_copy(Src, SrcOffset, Dest, DestOffset, DeviceImgDesc,
15541554
DeviceRowPitch, HostExtent, CopyExtent);
15551555
},
1556-
CodeLoc);
1556+
TlsCodeLocCapture.query());
15571557
}
15581558

15591559
inline event queue::ext_oneapi_copy(
@@ -1567,7 +1567,7 @@ inline event queue::ext_oneapi_copy(
15671567
CGH.depends_on(DepEvent);
15681568
CGH.ext_oneapi_copy(Src, Dest, DeviceImgDesc, DeviceRowPitch);
15691569
},
1570-
CodeLoc);
1570+
TlsCodeLocCapture.query());
15711571
}
15721572

15731573
inline event queue::ext_oneapi_copy(
@@ -1581,7 +1581,7 @@ inline event queue::ext_oneapi_copy(
15811581
CGH.depends_on(DepEvent);
15821582
CGH.ext_oneapi_copy(Src, Dest, ImageDesc);
15831583
},
1584-
CodeLoc);
1584+
TlsCodeLocCapture.query());
15851585
}
15861586

15871587
inline event queue::ext_oneapi_copy(
@@ -1595,7 +1595,7 @@ inline event queue::ext_oneapi_copy(
15951595
CGH.depends_on(DepEvents);
15961596
CGH.ext_oneapi_copy(Src, Dest, ImageDesc);
15971597
},
1598-
CodeLoc);
1598+
TlsCodeLocCapture.query());
15991599
}
16001600

16011601
inline event queue::ext_oneapi_copy(
@@ -1606,7 +1606,7 @@ inline event queue::ext_oneapi_copy(
16061606
detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc);
16071607
return submit(
16081608
[&](handler &CGH) { CGH.ext_oneapi_copy(Src, Dest, ImageDesc); },
1609-
CodeLoc);
1609+
TlsCodeLocCapture.query());
16101610
}
16111611

16121612
inline event queue::ext_oneapi_copy(
@@ -1622,7 +1622,7 @@ inline event queue::ext_oneapi_copy(
16221622
CGH.ext_oneapi_copy(Src, SrcOffset, Dest, DestOffset, DeviceImgDesc,
16231623
DeviceRowPitch, HostExtent, CopyExtent);
16241624
},
1625-
CodeLoc);
1625+
TlsCodeLocCapture.query());
16261626
}
16271627

16281628
inline event queue::ext_oneapi_copy(
@@ -1636,7 +1636,7 @@ inline event queue::ext_oneapi_copy(
16361636
CGH.depends_on(DepEvents);
16371637
CGH.ext_oneapi_copy(Src, Dest, DeviceImgDesc, DeviceRowPitch);
16381638
},
1639-
CodeLoc);
1639+
TlsCodeLocCapture.query());
16401640
}
16411641

16421642
inline event queue::ext_oneapi_copy(
@@ -1652,7 +1652,7 @@ inline event queue::ext_oneapi_copy(
16521652
CGH.ext_oneapi_copy(Src, SrcOffset, Dest, DestOffset, DeviceImgDesc,
16531653
DeviceRowPitch, HostExtent, CopyExtent);
16541654
},
1655-
CodeLoc);
1655+
TlsCodeLocCapture.query());
16561656
}
16571657

16581658
inline event queue::ext_oneapi_wait_external_semaphore(
@@ -1664,7 +1664,7 @@ inline event queue::ext_oneapi_wait_external_semaphore(
16641664
CGH.depends_on(DepEvent);
16651665
CGH.ext_oneapi_wait_external_semaphore(SemaphoreHandle);
16661666
},
1667-
CodeLoc);
1667+
TlsCodeLocCapture.query());
16681668
}
16691669

16701670
inline event queue::ext_oneapi_wait_external_semaphore(
@@ -1676,7 +1676,7 @@ inline event queue::ext_oneapi_wait_external_semaphore(
16761676
CGH.depends_on(DepEvents);
16771677
CGH.ext_oneapi_wait_external_semaphore(SemaphoreHandle);
16781678
},
1679-
CodeLoc);
1679+
TlsCodeLocCapture.query());
16801680
}
16811681

16821682
inline event queue::ext_oneapi_wait_external_semaphore(
@@ -1687,7 +1687,7 @@ inline event queue::ext_oneapi_wait_external_semaphore(
16871687
[&](handler &CGH) {
16881688
CGH.ext_oneapi_wait_external_semaphore(SemaphoreHandle, WaitValue);
16891689
},
1690-
CodeLoc);
1690+
TlsCodeLocCapture.query());
16911691
}
16921692

16931693
inline event queue::ext_oneapi_wait_external_semaphore(
@@ -1699,7 +1699,7 @@ inline event queue::ext_oneapi_wait_external_semaphore(
16991699
CGH.depends_on(DepEvent);
17001700
CGH.ext_oneapi_wait_external_semaphore(SemaphoreHandle, WaitValue);
17011701
},
1702-
CodeLoc);
1702+
TlsCodeLocCapture.query());
17031703
}
17041704

17051705
inline event queue::ext_oneapi_wait_external_semaphore(
@@ -1712,7 +1712,7 @@ inline event queue::ext_oneapi_wait_external_semaphore(
17121712
CGH.depends_on(DepEvents);
17131713
CGH.ext_oneapi_wait_external_semaphore(SemaphoreHandle, WaitValue);
17141714
},
1715-
CodeLoc);
1715+
TlsCodeLocCapture.query());
17161716
}
17171717

17181718
inline event queue::ext_oneapi_signal_external_semaphore(
@@ -1723,7 +1723,7 @@ inline event queue::ext_oneapi_signal_external_semaphore(
17231723
[&](handler &CGH) {
17241724
CGH.ext_oneapi_signal_external_semaphore(SemaphoreHandle);
17251725
},
1726-
CodeLoc);
1726+
TlsCodeLocCapture.query());
17271727
}
17281728

17291729
inline event queue::ext_oneapi_signal_external_semaphore(
@@ -1735,7 +1735,7 @@ inline event queue::ext_oneapi_signal_external_semaphore(
17351735
CGH.depends_on(DepEvent);
17361736
CGH.ext_oneapi_signal_external_semaphore(SemaphoreHandle);
17371737
},
1738-
CodeLoc);
1738+
TlsCodeLocCapture.query());
17391739
}
17401740

17411741
inline event queue::ext_oneapi_signal_external_semaphore(
@@ -1747,7 +1747,7 @@ inline event queue::ext_oneapi_signal_external_semaphore(
17471747
CGH.depends_on(DepEvents);
17481748
CGH.ext_oneapi_signal_external_semaphore(SemaphoreHandle);
17491749
},
1750-
CodeLoc);
1750+
TlsCodeLocCapture.query());
17511751
}
17521752

17531753
inline event queue::ext_oneapi_signal_external_semaphore(
@@ -1758,7 +1758,7 @@ inline event queue::ext_oneapi_signal_external_semaphore(
17581758
[&](handler &CGH) {
17591759
CGH.ext_oneapi_signal_external_semaphore(SemaphoreHandle, SignalValue);
17601760
},
1761-
CodeLoc);
1761+
TlsCodeLocCapture.query());
17621762
}
17631763

17641764
inline event queue::ext_oneapi_signal_external_semaphore(
@@ -1771,7 +1771,7 @@ inline event queue::ext_oneapi_signal_external_semaphore(
17711771
CGH.depends_on(DepEvent);
17721772
CGH.ext_oneapi_signal_external_semaphore(SemaphoreHandle, SignalValue);
17731773
},
1774-
CodeLoc);
1774+
TlsCodeLocCapture.query());
17751775
}
17761776

17771777
inline event queue::ext_oneapi_signal_external_semaphore(
@@ -1784,7 +1784,7 @@ inline event queue::ext_oneapi_signal_external_semaphore(
17841784
CGH.depends_on(DepEvents);
17851785
CGH.ext_oneapi_signal_external_semaphore(SemaphoreHandle, SignalValue);
17861786
},
1787-
CodeLoc);
1787+
TlsCodeLocCapture.query());
17881788
}
17891789

17901790
} // namespace _V1

sycl/include/sycl/handler.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,11 @@ class __SYCL_EXPORT handler {
591591

592592
/// Saves the location of user's code passed in \p CodeLoc for future usage in
593593
/// finalize() method.
594-
void saveCodeLoc(detail::code_location CodeLoc) { MCodeLoc = CodeLoc; }
594+
/// TODO: remove the first version of this func (the one without the IsTopCodeLoc arg)
595+
/// at the next ABI breaking window since removing it breaks ABI on windows.
596+
void saveCodeLoc(detail::code_location CodeLoc);
597+
void saveCodeLoc(detail::code_location CodeLoc, bool IsTopCodeLoc);
598+
void copyCodeLoc(const handler &other);
595599

596600
/// Constructs CG object of specific type, passes it to Scheduler and
597601
/// returns sycl::event object representing the command group.

0 commit comments

Comments
 (0)