@@ -1005,7 +1005,10 @@ void AllocaCommandBase::emitInstrumentationData() {
1005
1005
xpti::addMetadata (TE, " sycl_device_name" ,
1006
1006
getSyclObjImpl (MQueue->get_device ())->getDeviceName ());
1007
1007
xpti::addMetadata (TE, " memory_object" , reinterpret_cast <size_t >(MAddress));
1008
- xpti::addMetadata (TE, " queue_id" , MQueue->getQueueID ());
1008
+ // Since we do NOT add queue_id value to metadata, we are stashing it to TLS
1009
+ // as this data is mutable and the metadata is supposed to be invariant
1010
+ xpti::framework::stash_tuple (XPTI_QUEUE_INSTANCE_ID_KEY,
1011
+ MQueue->getQueueID ());
1009
1012
}
1010
1013
#endif
1011
1014
}
@@ -1124,7 +1127,8 @@ void AllocaSubBufCommand::emitInstrumentationData() {
1124
1127
this ->MRequirement .MAccessRange [0 ]);
1125
1128
xpti::addMetadata (TE, " access_range_end" ,
1126
1129
this ->MRequirement .MAccessRange [1 ]);
1127
- xpti::addMetadata (TE, " queue_id" , MQueue->getQueueID ());
1130
+ xpti::framework::stash_tuple (XPTI_QUEUE_INSTANCE_ID_KEY,
1131
+ MQueue->getQueueID ());
1128
1132
makeTraceEventEpilog ();
1129
1133
}
1130
1134
#endif
@@ -1202,8 +1206,10 @@ void ReleaseCommand::emitInstrumentationData() {
1202
1206
getSyclObjImpl (MQueue->get_device ())->getDeviceName ());
1203
1207
xpti::addMetadata (TE, " allocation_type" ,
1204
1208
commandToName (MAllocaCmd->getType ()));
1205
- xpti::addMetadata (TE, " queue_id" , MQueue->getQueueID ());
1206
-
1209
+ // Since we do NOT add queue_id value to metadata, we are stashing it to TLS
1210
+ // as this data is mutable and the metadata is supposed to be invariant
1211
+ xpti::framework::stash_tuple (XPTI_QUEUE_INSTANCE_ID_KEY,
1212
+ MQueue->getQueueID ());
1207
1213
makeTraceEventEpilog ();
1208
1214
}
1209
1215
#endif
@@ -1323,8 +1329,10 @@ void MapMemObject::emitInstrumentationData() {
1323
1329
xpti::addMetadata (TE, " sycl_device_name" ,
1324
1330
getSyclObjImpl (MQueue->get_device ())->getDeviceName ());
1325
1331
xpti::addMetadata (TE, " memory_object" , reinterpret_cast <size_t >(MAddress));
1326
- xpti::addMetadata (TE, " queue_id" , MQueue->getQueueID ());
1327
-
1332
+ // Since we do NOT add queue_id value to metadata, we are stashing it to TLS
1333
+ // as this data is mutable and the metadata is supposed to be invariant
1334
+ xpti::framework::stash_tuple (XPTI_QUEUE_INSTANCE_ID_KEY,
1335
+ MQueue->getQueueID ());
1328
1336
makeTraceEventEpilog ();
1329
1337
}
1330
1338
#endif
@@ -1386,8 +1394,10 @@ void UnMapMemObject::emitInstrumentationData() {
1386
1394
xpti::addMetadata (TE, " sycl_device_name" ,
1387
1395
getSyclObjImpl (MQueue->get_device ())->getDeviceName ());
1388
1396
xpti::addMetadata (TE, " memory_object" , reinterpret_cast <size_t >(MAddress));
1389
- xpti::addMetadata (TE, " queue_id" , MQueue->getQueueID ());
1390
-
1397
+ // Since we do NOT add queue_id value to metadata, we are stashing it to TLS
1398
+ // as this data is mutable and the metadata is supposed to be invariant
1399
+ xpti::framework::stash_tuple (XPTI_QUEUE_INSTANCE_ID_KEY,
1400
+ MQueue->getQueueID ());
1391
1401
makeTraceEventEpilog ();
1392
1402
}
1393
1403
#endif
@@ -1489,8 +1499,10 @@ void MemCpyCommand::emitInstrumentationData() {
1489
1499
xpti::addMetadata (
1490
1500
CmdTraceEvent, " copy_to" ,
1491
1501
reinterpret_cast <size_t >(getSyclObjImpl (MQueue->get_device ()).get ()));
1492
- xpti::addMetadata (CmdTraceEvent, " queue_id" , MQueue->getQueueID ());
1493
-
1502
+ // Since we do NOT add queue_id value to metadata, we are stashing it to TLS
1503
+ // as this data is mutable and the metadata is supposed to be invariant
1504
+ xpti::framework::stash_tuple (XPTI_QUEUE_INSTANCE_ID_KEY,
1505
+ MQueue->getQueueID ());
1494
1506
makeTraceEventEpilog ();
1495
1507
}
1496
1508
#endif
@@ -1665,8 +1677,10 @@ void MemCpyCommandHost::emitInstrumentationData() {
1665
1677
xpti::addMetadata (
1666
1678
CmdTraceEvent, " copy_to" ,
1667
1679
reinterpret_cast <size_t >(getSyclObjImpl (MQueue->get_device ()).get ()));
1668
- xpti::addMetadata (CmdTraceEvent, " queue_id" , MQueue->getQueueID ());
1669
-
1680
+ // Since we do NOT add queue_id value to metadata, we are stashing it to TLS
1681
+ // as this data is mutable and the metadata is supposed to be invariant
1682
+ xpti::framework::stash_tuple (XPTI_QUEUE_INSTANCE_ID_KEY,
1683
+ MQueue->getQueueID ());
1670
1684
makeTraceEventEpilog ();
1671
1685
}
1672
1686
#endif
@@ -1756,8 +1770,10 @@ void EmptyCommand::emitInstrumentationData() {
1756
1770
getSyclObjImpl (MQueue->get_device ())->getDeviceName ());
1757
1771
xpti::addMetadata (CmdTraceEvent, " memory_object" ,
1758
1772
reinterpret_cast <size_t >(MAddress));
1759
- xpti::addMetadata (CmdTraceEvent, " queue_id" , MQueue->getQueueID ());
1760
-
1773
+ // Since we do NOT add queue_id value to metadata, we are stashing it to TLS
1774
+ // as this data is mutable and the metadata is supposed to be invariant
1775
+ xpti::framework::stash_tuple (XPTI_QUEUE_INSTANCE_ID_KEY,
1776
+ MQueue->getQueueID ());
1761
1777
makeTraceEventEpilog ();
1762
1778
}
1763
1779
#endif
@@ -1828,8 +1844,10 @@ void UpdateHostRequirementCommand::emitInstrumentationData() {
1828
1844
getSyclObjImpl (MQueue->get_device ())->getDeviceName ());
1829
1845
xpti::addMetadata (CmdTraceEvent, " memory_object" ,
1830
1846
reinterpret_cast <size_t >(MAddress));
1831
- xpti::addMetadata (CmdTraceEvent, " queue_id" , MQueue->getQueueID ());
1832
-
1847
+ // Since we do NOT add queue_id value to metadata, we are stashing it to TLS
1848
+ // as this data is mutable and the metadata is supposed to be invariant
1849
+ xpti::framework::stash_tuple (XPTI_QUEUE_INSTANCE_ID_KEY,
1850
+ MQueue->getQueueID ());
1833
1851
makeTraceEventEpilog ();
1834
1852
}
1835
1853
#endif
@@ -2063,7 +2081,9 @@ void instrumentationFillCommonData(const std::string &KernelName,
2063
2081
xpti::addMetadata (CmdTraceEvent, " sym_column_no" ,
2064
2082
static_cast <int >(Column));
2065
2083
}
2066
- xpti::addMetadata (CmdTraceEvent, " queue_id" , Queue->getQueueID ());
2084
+ // We no longer set the 'queue_id' in the metadata structure as it is a
2085
+ // mutable value and multiple threads using the same queue created at the
2086
+ // same location will overwrite the metadata values creating inconsistencies
2067
2087
}
2068
2088
}
2069
2089
#endif
@@ -2096,6 +2116,10 @@ std::pair<xpti_td *, uint64_t> emitKernelInstrumentationData(
2096
2116
FromSource, InstanceID, CmdTraceEvent);
2097
2117
2098
2118
if (CmdTraceEvent) {
2119
+ // Stash the queue_id mutable metadata in TLS
2120
+ xpti::framework::stash_tuple (XPTI_QUEUE_INSTANCE_ID_KEY,
2121
+ Queue->getQueueID ());
2122
+
2099
2123
instrumentationAddExtraKernelMetadata (CmdTraceEvent, NDRDesc,
2100
2124
KernelBundleImplPtr, SyclKernelName,
2101
2125
SyclKernel, Queue, CGArgs);
@@ -2139,6 +2163,8 @@ void ExecCGCommand::emitInstrumentationData() {
2139
2163
CmdTraceEvent);
2140
2164
2141
2165
if (CmdTraceEvent) {
2166
+ xpti::framework::stash_tuple (XPTI_QUEUE_INSTANCE_ID_KEY,
2167
+ MQueue->getQueueID ());
2142
2168
MTraceEvent = static_cast <void *>(CmdTraceEvent);
2143
2169
if (MCommandGroup->getType () == detail::CG::Kernel) {
2144
2170
auto KernelCG =
@@ -3351,10 +3377,12 @@ void KernelFusionCommand::emitInstrumentationData() {
3351
3377
deviceToString (MQueue->get_device ()));
3352
3378
xpti::addMetadata (CmdTraceEvent, " sycl_device_name" ,
3353
3379
getSyclObjImpl (MQueue->get_device ())->getDeviceName ());
3354
- xpti::addMetadata (CmdTraceEvent, " queue_id" , MQueue->getQueueID ());
3355
3380
}
3356
-
3357
3381
if (MFirstInstance) {
3382
+ // Since we do NOT add queue_id value to metadata, we are stashing it to TLS
3383
+ // as this data is mutable and the metadata is supposed to be invariant
3384
+ xpti::framework::stash_tuple (XPTI_QUEUE_INSTANCE_ID_KEY,
3385
+ MQueue->getQueueID ());
3358
3386
xptiNotifySubscribers (MStreamID, NotificationTraceType,
3359
3387
detail::GSYCLGraphEvent,
3360
3388
static_cast <xpti_td *>(MTraceEvent), MInstanceID,
0 commit comments