1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
/*
* SPDX-FileCopyrightText: Copyright (c) 2021-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Licensed under the Apache License v2.0 with LLVM Exceptions.
* See https://nvidia.github.io/NVTX/LICENSE.txt for license information.
*/
/** \file nvToolsExtPayload.h
* \brief NVTX payload extension API: schema types, entry flags, and registration.
*
* Extended payloads allow arbitrary structured data to be attached to NVTX mark
* and range events. A registered schema describes how tools decode payload bytes.
*
* Workflow:
* - Define payload layout and register the schema with
* @ref nvtxPayloadSchemaRegister.
* - Build one or more @ref nvtxPayloadData_t entries for event data.
* - Attach payload data to NVTX events via event attributes (for example
* using the helper macro @ref nvtxPayloadRangePush) or dedicated APIs such
* as @ref nvtxMarkPayload and @ref nvtxRangePushPayload.
*
* For detailed concepts, full workflow, and example usage, see
* \ref NVTX_EXTENDED_PAYLOADS.
*/
/* Optionally include helper macros. */
/* #include "nvToolsExtPayloadHelper.h" */
/**
* If needed, semantic extension headers can be included after this header.
*/
/**
* \brief The compatibility ID is used for versioning of this extension.
*/
/**
* \brief Unique module ID identifying the payload extension.
*/
/**
* \brief Additional value for the enum @ref nvtxPayloadType_t.
*/
/**
* Payload schema entry flags. Used for @ref nvtxPayloadSchemaEntry_t::flags.
*/
/**
* Absolute pointer into a payload (entry) of the same event.
*/
/**
* Offset from base address of the payload.
*/
/**
* Offset from the end of this payload entry.
*/
/**
* The value is an array with fixed length set by `arrayOrUnionDetail`.
*/
/**
* A zero-terminated array. The terminator is an element whose bytes are all zero.
*/
/**
* \brief A single or multi-dimensional array of variable length.
*
* The field `arrayOrUnionDetail` contains the index of the schema entry that
* holds the length(s). If the length entry is a scalar, then this entry is a 1D
* array. If the length entry is a fixed-size array, then the number of
* dimensions is defined with the registration of the schema. If the length
* entry is a zero-terminated array, then the array of the dimensions can be
* determined at runtime.
* For multidimensional arrays, values are stored in row-major order, with rows
* being stored consecutively in contiguous memory. The size of the entry (in
* bytes) is the product of the dimensions multiplied by the size of the array
* element.
*
* The referenced length entry must appear **before** this entry in the schema's
* entries array and must be of an integer type. For signed integer length
* entries, negative values are treated as zero (resulting in a zero-length array).
*/
/**
* \brief A single or multi-dimensional array of variable length, where the
* dimensions are stored in a different payload (index) of the same event.
*
* `arrayOrUnionDetail` contains the zero-based **payload index** (into the
* `nvtxPayloadData_t` array of the event) of a separate payload whose single
* entry holds the array length(s). The referenced payload is decoded as an
* integer (1D) or integer array (multi-dimensional, row-major).
*
* This enables an existing array to be passed as payload data, while the array
* dimensions are defined in a separate payload with only one payload entry.
*/
/**
* \brief The value or data that is pointed to by this payload entry value shall
* be copied by the NVTX handler.
*
* A tool that does not support deep copy may retain only the address value; in
* that case, the referenced data is unavailable for interpretation.
* See @ref NVTX_PAYLOAD_SCHEMA_FLAG_DEEP_COPY for more details.
*/
/**
* Notifies the NVTX handler to hide this entry in case of visualization.
*/
/**
* The entry specifies the event message. Any string type can be used.
*
* If multiple messages are specified for a logical event, the effective message
* is selected according to @ref NVTX_PAYLOAD_EVENT_ATTRIBUTE_PRECEDENCE.
*/
/**
* \brief The entry contains a timestamp.
*
* The time source might be provided via the entry semantics field. In most
* cases, the timestamp (entry) type is @ref NVTX_PAYLOAD_ENTRY_TYPE_INT64.
*/
/**
* \brief Flags that assign an event-type role to an entry.
*
* These flags let a tool identify which entries carry special event semantics
* (e.g. timestamps for range begin/end, counter values). They work in
* conjunction with the schema-level flags `NVTX_PAYLOAD_SCHEMA_FLAG_*`:
*
* - `NVTX_PAYLOAD_SCHEMA_FLAG_RANGE_PUSHPOP` or `_RANGE_STARTEND`: the schema
* represents a range. Use the entry flags `RANGE_BEGIN` and `RANGE_END` on
* timestamp entries to mark start and end time.
* - `NVTX_PAYLOAD_SCHEMA_FLAG_MARK`: the schema represents an instantaneous
* marker. Use `NVTX_PAYLOAD_ENTRY_FLAG_MARK` on a timestamp entry.
* - `NVTX_PAYLOAD_SCHEMA_FLAG_COUNTER_GROUP`: the schema represents a group
* of counters. Use `NVTX_PAYLOAD_ENTRY_FLAG_COUNTER` on each value entry
* that is a counter. Counter semantics (normalization, limits, interpolation)
* can be further described via the entry's
* @ref nvtxPayloadSchemaEntry_t::semantics field. For counter registration
* and sampling, use `nvtx3/nvToolsExtCounters.h`.
*
* For ranges and marks, use `NVTX_PAYLOAD_ENTRY_FLAG_EVENT_MESSAGE` on a
* string entry to provide the event's display name.
*/
/** \brief Marks a timestamp entry as the end of a range. */
/** \brief Marks a timestamp entry as an instantaneous marker. */
/** \brief Marks a payload entry as a counter value. */
/**
* @note The 'array' flags assume that the array is embedded. Otherwise,
* @ref NVTX_PAYLOAD_ENTRY_FLAG_POINTER must also be specified. Some
* combinations may be invalid based on the `NVTX_PAYLOAD_SCHEMA_TYPE_*` this
* entry is enclosed. For instance, variable length embedded arrays are valid
* within @ref NVTX_PAYLOAD_SCHEMA_TYPE_DYNAMIC but invalid with
* @ref NVTX_PAYLOAD_SCHEMA_TYPE_STATIC. See `NVTX_PAYLOAD_SCHEMA_TYPE_*` for
* additional details.
*/
/* Helper macro to check if an entry represents an array. */
/* NVTX_PAYLOAD_ENTRY_FLAGS_V1 */
/** ---------------------------------------------------------------------------
* END: Payload schema entry flags.
* ------------------------------------------------------------------------- */
/**
* \anchor NVTX_PAYLOAD_EVENT_ATTRIBUTE_PRECEDENCE
* \par Event attribute precedence
*
* If the same event attribute is specified more than once for a logical event,
* the latest-specified value is the effective value. Tools may preserve
* superseded values, but applications should not rely on them being available.
*
* Ordering is: regular @ref nvtxEventAttributes_v2 "nvtxEventAttributes_t"
* attributes first, then @ref nvtxPayloadData_t entries in array order, then
* schema entries in order.
*
* For ranges, end/pop attributes are ordered later than start/push attributes.
* Tools that act before range completion can only use attributes known at that
* time. Runtime filtering on extended-payload attributes is optional for tools;
* tools may skip it to avoid decoding overhead.
*
* \anchor NVTX_PAYLOAD_EVENT_MESSAGE_REQUIREMENT
* Payload APIs that emit a mark, begin a range, or submit a deferred event
* supply the event message with @ref NVTX_PAYLOAD_ENTRY_FLAG_EVENT_MESSAGE. If
* the message is missing, a tool may ignore the event. Range pop/end payloads
* may omit a message unless they intentionally override the range message.
* Keep range messages stable for filtering; use color or payload fields for
* state changes.
*/
/**
* \brief Types of entries in a payload schema.
*
* @note Some predefined types have platform-dependent sizes. See
* @ref nvtxPayloadEntryTypeInfo_t for the portability mechanism.
*/
/**
* Basic integer types.
*/
/**
* Integer types with explicit size.
*/
/** \brief 64-bit signed integer payload entry type. */
/**
* Floating point types
*/
/**
* Size type (`size_t` in C).
*/
/**
* Any address, e.g. `void*`. If the pointee type matters, use
* @ref NVTX_PAYLOAD_ENTRY_FLAG_POINTER with the pointee type instead.
*/
/**
* Special character types.
*/
/**
* There is type size and alignment information for all previous types.
*/
/**
* Store raw 8-bit binary data. As with `char`, 1-byte alignment is assumed.
* Typically, a tool will display this as hex or binary.
*/
/**
* These types do not have standardized equivalents. It is assumed that the
* number at the end corresponds to the bits used to store the value and that
* the alignment corresponds to standardized types of the same size.
* A tool may not support these types.
*/
/**
* IEEE 754 floating-point types with explicit size. The number at the end
* corresponds to the storage width in bits. The alignment is assumed to match
* standardized types of the same size.
*/
/**
* Data types are as defined by NVTXv3 core.
*
* Entries of these types are interpreted as event attributes.
*/
/**
* The scope of events or counters (see `nvtxScopeRegister`).
*/
/**
* Process ID as scope.
*/
/**
* Thread ID as scope.
*/
/**
* \brief String types.
*
* String entries hold inline character data or a pointer. With no array flags,
* `arrayOrUnionDetail` is a fixed length in string code units; setting
* @ref NVTX_PAYLOAD_ENTRY_FLAG_ARRAY_FIXED_SIZE is redundant (still a single
* fixed-length string, not an array of strings). With
* @ref NVTX_PAYLOAD_ENTRY_FLAG_ARRAY_LENGTH_INDEX, `arrayOrUnionDetail` is the
* index of a length-source entry whose value is the length in string code units,
* where 0 denotes an empty string. Zero-terminated strings use
* @ref NVTX_PAYLOAD_ENTRY_FLAG_ARRAY_ZERO_TERMINATED. A string code unit is 1 byte
* for `CSTRING`/`CSTRING_UTF8`, 2 bytes for `CSTRING_UTF16`, and 4 bytes for
* `CSTRING_UTF32`. Despite the `CSTRING` name, strings with an explicit length
* need not be null-terminated.
*
* A fixed-length string always occupies (for inline data) or is read (for
* pointer and deep-copy forms) as exactly the declared number of code units.
* Its value is the code units up to, but not including, the first null
* terminator; if no null terminator occurs within the declared length, the
* value is all of the declared code units. Code units after the first null
* terminator are ignored.
*
* Pointer strings normally reference data in another payload of the same event.
* With @ref NVTX_PAYLOAD_ENTRY_FLAG_DEEP_COPY, they may reference arbitrary
* memory that the tool should copy.
*/
/**
* The entry value is of type
* @ref REGISTERED_STRING_HANDLE_STRUCTURE "nvtxStringHandle_t" returned by
* @ref nvtxDomainRegisterStringA or @ref nvtxDomainRegisterStringW.
*/
/**
* This type marks the union selector member (entry index) in schemas used by
* a union with internal selector.
* See @ref NVTX_PAYLOAD_SCHEMA_TYPE_UNION_WITH_INTERNAL_SELECTOR.
*/
/**
* \brief Predefined value for payload data that is referenced in another payload.
*
* This value can be used in @ref nvtxPayloadData_t::schemaId to indicate that the
* payload is a blob of memory which other payload entries may point into.
* A tool will not expose this payload directly.
*
* This value cannot be used as a schema entry type.
*/
/**
* \brief Predefined value for raw payload data.
*
* This value can be used in @ref nvtxPayloadData_t::schemaId to indicate
* that the payload is a blob, which can be shown with an arbitrary data viewer.
* This value cannot be used as a schema entry type.
*/
/* Custom (static) schema IDs. */
/** \brief First valid user-defined static schema ID. */
/* Dynamic schema IDs (generated by the tool) start here. */
/* NVTX_PAYLOAD_ENTRY_TYPES_V1 */
/** ---------------------------------------------------------------------------
* END: Payload schema entry types.
* ------------------------------------------------------------------------- */
/**
* \brief The payload schema type.
*
* A schema can be either of the following types. It is set with
* @ref nvtxPayloadSchemaAttr_t::type.
*
* **Static schemas** (`NVTX_PAYLOAD_SCHEMA_TYPE_STATIC`) describe C-like
* structs with a fixed binary size. All entry offsets and sizes must be
* deterministic at compile time. Variable-length fields are not allowed.
*
* **Dynamic schemas** (`NVTX_PAYLOAD_SCHEMA_TYPE_DYNAMIC`) allow
* variable-length fields. A tool parses fields sequentially, advancing a
* running cursor with proper alignment after each field. Entries with an
* explicit non-zero @ref nvtxPayloadSchemaEntry_t::offset are placed at that
* offset; otherwise the offset is computed from the cursor. Entries that rely
* on implicit offsets must be declared in memory order. Arrays of nested
* dynamic schemas are not supported (each nested dynamic-schema entry must be
* a scalar). `payloadStaticSize` may be omitted for dynamic schemas.
*
* **Union schemas** (`NVTX_PAYLOAD_SCHEMA_TYPE_UNION` and
* `NVTX_PAYLOAD_SCHEMA_TYPE_UNION_WITH_INTERNAL_SELECTOR`) describe C-like
* unions. The selected member is determined by an external or internal
* selector entry of integral type.
*/
/** \brief Fixed-size C-like struct schema type. */
/** \brief Variable-length payload schema type. */
/** \brief C-like union schema with an external selector entry. */
/** \brief C-like union schema with an internal selector entry. */
/* NVTX_PAYLOAD_SCHEMA_TYPES_V1 */
/**
* \brief Flags for static and dynamic schemas.
*
* The schema flags are used with @ref nvtxPayloadSchemaAttr_t::flags.
*/
/**
* This flag indicates that a schema and the corresponding payloads can
* contain fields which require a deep copy.
*/
/**
* This flag indicates that a schema and the corresponding payload can be
* referenced by another payload of the same event. If the schema is not
* intended to be visualized directly, use
* @ref NVTX_TYPE_PAYLOAD_SCHEMA_REFERENCED instead.
*/
/**
* The schema defines a counter group. An NVTX handler can expect that the schema
* contains entries with counter semantics. For counter registration and sampling,
* use `nvtx3/nvToolsExtCounters.h`.
*/
/**
* The schema defines a range or marker. An NVTX handler can expect timestamp
* entries and an optional message entry with event semantics.
*/
/** \brief Schema represents a start/end range event. */
/** \brief Schema represents an instantaneous marker event. */
/* NVTX_PAYLOAD_SCHEMA_FLAGS_V1 */
/**
* \brief Bitmask values for @ref nvtxPayloadSchemaAttr_t::fieldMask.
*
* Each bit indicates that the corresponding field in @ref nvtxPayloadSchemaAttr_t
* has been set by the caller. A tool must not read fields whose bit is not set.
* `TYPE`, `ENTRIES`, and `NUM_ENTRIES` must be set for successful registration.
*/
/* NVTX_PAYLOAD_SCHEMA_ATTR_FIELDS_V1 */
/**
* \brief Bitmask values for @ref nvtxPayloadEnumAttr_t::fieldMask.
*
* Each bit indicates that the corresponding field in @ref nvtxPayloadEnumAttr_t
* has been set by the caller.
* `ENTRIES`, `NUM_ENTRIES`, and `SIZE` must be set for successful registration.
*/
/* NVTX_PAYLOAD_ENUM_ATTR_FIELDS_V1 */
/**
* \anchor NVTX_SCOPE_SPECIFICATION_AND_PRECEDENCE
* \par Scope specification and precedence
*
* An NVTX scope describes where an event or counter originated, or the
* execution context it belongs to. Predefined scopes identify common execution
* contexts; custom scopes can be registered with \ref nvtxScopeRegister.
*
* The `NVTX_SCOPE_CURRENT_*` values are runtime-resolved scope references: a
* tool resolves them against the live execution context of the instrumented
* code when an event or counter sample is taken.
*
* Scopes can be specified by payload entries, scope semantics
* (\ref nvtxSemanticsScope_t), deferred-event batch attributes, or counter
* registration attributes. If more than one scope applies to the same event
* role, counter role, or timestamp purpose, tools should select the effective
* scope in this order:
*
* <ol>
* <li>Purpose-specific \ref NVTX_PAYLOAD_ENTRY_TYPE_SCOPE_ID entry with a
* role or timestamp flag (for example
* \ref NVTX_PAYLOAD_ENTRY_FLAG_RANGE_BEGIN,
* \ref NVTX_PAYLOAD_ENTRY_FLAG_RANGE_END,
* \ref NVTX_PAYLOAD_ENTRY_FLAG_MARK,
* \ref NVTX_PAYLOAD_ENTRY_FLAG_COUNTER, or
* \ref NVTX_PAYLOAD_ENTRY_FLAG_TIMESTAMP).
* <li>Purpose-specific scope semantics attached to a payload entry with a
* role or timestamp flag.
* <li>General \ref NVTX_PAYLOAD_ENTRY_TYPE_SCOPE_ID entry without a role or
* timestamp flag.
* <li>\ref nvtxEventBatch_t::scope.
* <li>General scope semantics attached to an arbitrary payload entry.
* <li>Counter registration scope (for example
* \c nvtxCounterAttr_t::scopeId; see \ref nvToolsExtCounters.h "nvtxCounterRegister").
* </ol>
*
* \ref NVTX_SCOPE_NONE means no scope is specified. Scopes for different
* purposes are independent and may be different.
*/
/** \brief No scope is specified. */
/* Hardware events */
/* Innermost HW execution context */
/* Virtualized hardware, virtual machines */
/* Software scopes */
/* Innermost SW execution context */
/** Static (user-provided) scope IDs. */
/* Dynamically (tool) generated scope IDs */
/* NVTX_SCOPES_V1 */
/**
* Predefined `NVTX_TIMESTAMP_TYPE_*` values identify well-known timestamp
* sources. Where an API accepts a time domain ID, a predefined timestamp type
* may be used directly as the time domain ID if the source is unambiguous.
*/
/**
* Timestamp source is not known, e.g. NIC or switch. The NVTX handler can
* assume that at least two synchronization points are created with NVTX
* instrumentation.
*/
/** The timestamp was provided by the NVTX handler via `nvtxTimestampGet()`. */
/** CPU timestamp sources */
/* RDTSC on x86, CNTVCT on ARM */
/* CNTPCT on ARM */
/* Nanoseconds since epoch (relative to UTC), clock_gettime(CLOCK_REALTIME) */
/* Same as above but less overhead and precision (1-10 ms) */
/* POSIX, Time since system boot, adjusted by NTP */
/* Linux only, Time since system boot, no NTP or frequency corrections */
/* Same as `CLOCK_MONOTONIC`, but less overhead and precision (1-10ms) */
/* Same as `CLOCK_MONOTONIC`, but including suspended time. */
/* The total CPU time consumed by the calling process. */
/* The total CPU time consumed by the calling thread. */
/** Windows timestamp sources */
/** C timestamp sources */
/* Seconds since epoch (represented in C as `time_t`) */
/* CPU clock value (represented in C as `clock_t`) as returned by `clock()` */
/* High-resolution time into struct timespec (C11) */
/** C++ timestamp sources */
/* std::chrono::steady_clock (monotonic clock), similar to `CLOCK_MONOTONIC` */
/* std::chrono::high_resolution_clock, similar to `CLOCK_MONOTONIC` or `CLOCK_MONOTONIC_RAW` */
/* std::chrono::system_clock, similar to `CLOCK_REALTIME` */
/* (since C++20) std::chrono::utc_clock, similar to `CPP_SYSTEM_CLOCK` */
/* (since C++20) std::chrono::tai_clock */
/* (since C++20) std::chrono::gps_clock */
/* (since C++20) std::chrono::file_clock */
/** GPU timestamp sources */
/** Returned by `nvtxTimeDomainRegister` if time domain registration failed. */
/** Static (user-provided) time domain IDs. */
/* Dynamically (tool) generated time domain IDs */
/** Timer properties */
/** Point in time when the timer starts (its value is 0). */
/**
* Flags specifying whether it is safe or unsafe to call the timestamp
* provider after process teardown.
*/
/* NVTX_TIME_V1 */
/**
* Timestamp ordering flags for a batch of deferred events or counters.
* By default, chronological order by the first timestamp of the event or
* counter is assumed.
*/
/* NVTX_BATCH_FLAGS_V1 */
extern "C" NVTX_PAYLOAD_TYPEDEFS_V1
/**
* \brief Size and alignment information for predefined payload entry types.
*
* The struct contains the size and alignment in bytes. An array for the
* predefined types is passed via nvtxExtModuleInfo_t to the NVTX client/handler.
* The entry type value is used as the index into this array.
*
* Providing this array is important for cross-platform portability. Types such
* as `NVTX_PAYLOAD_ENTRY_TYPE_INT`, `_LONG`, `_SIZE`, `_ADDRESS`, and
* `_LONGDOUBLE` have platform-dependent sizes. Without this information, a
* tool falls back to using its own platform's `sizeof()`, which may differ
* from the producer's platform (e.g. 32-bit vs 64-bit, or different
* compilers with varying `long` / `long double` sizes). The array must have
* at least @ref NVTX_PAYLOAD_ENTRY_TYPE_INFO_ARRAY_SIZE entries.
*/
typedef struct nvtxPayloadEntryTypeInfo_v1
nvtxPayloadEntryTypeInfo_t;
/**
* \brief Binary payload data, size and decoding information.
*
* An array of `nvtxPayloadData_t` can be passed directly to the payload event
* APIs (`nvtxMarkPayload`, `nvtxRangePushPayload`, `nvtxRangePopPayload`,
* `nvtxRangeStartPayload`, `nvtxRangeEndPayload`, `nvtxEventSubmit`), or
* attached to @ref nvtxEventAttributes_v2 "nvtxEventAttributes_t" via its `payload.ullValue`
* field. The helper macros @ref nvtxPayloadMark, @ref nvtxPayloadRangePush,
* and @ref NVTX_PAYLOAD_EVTATTR_SET_MULTIPLE simplify the latter approach.
*
* Payload array order and schema-entry order define the ordering of event
* attributes supplied by extended payloads; see
* @ref NVTX_PAYLOAD_EVENT_ATTRIBUTE_PRECEDENCE.
*/
typedef struct nvtxPayloadData_v1
nvtxPayloadData_t;
/**
* \brief Header of the payload entry's semantic field.
*
* Semantic extension structs begin with this header and are linked through
* @ref next.
*/
typedef struct nvtxSemanticsHeader_v1
nvtxSemanticsHeader_t;
/**
* \brief Entry in a schema.
*
* Payload schemas are arrays of entries registered with
* @ref nvtxPayloadSchemaRegister. For simple values, set `flags` to `0`;
* `type` is the only required field. Zero-initialized optional fields mean no
* name and implicit offset calculation.
*
* Example schema:
* nvtxPayloadSchemaEntry_t schema[] = {
* {0, NVTX_PAYLOAD_ENTRY_TYPE_UINT8, "one byte"},
* {0, NVTX_PAYLOAD_ENTRY_TYPE_INT32, "four bytes"}
* };
*/
typedef struct nvtxPayloadSchemaEntry_v1
nvtxPayloadSchemaEntry_t;
/**
* \brief NVTX payload schema attributes.
*/
typedef struct nvtxPayloadSchemaAttr_v1
nvtxPayloadSchemaAttr_t;
/**
* \brief Description of one enumeration value.
*
* Each entry maps a numeric value to a name and optionally marks it as a bit
* flag.
* Arrays of these entries are registered with @ref nvtxPayloadEnumRegister.
*/
typedef struct nvtxPayloadEnum_v1
nvtxPayloadEnum_t;
/**
* \brief NVTX payload enumeration type attributes.
*
* A pointer to this struct is passed to @ref nvtxPayloadEnumRegister.
*/
typedef struct nvtxPayloadEnumAttr_v1
nvtxPayloadEnumAttr_t;
typedef struct nvtxScopeAttr_v1
nvtxScopeAttr_t;
/* NVTX_PAYLOAD_TYPEDEFS_V1 */
/** Attributes of an NVTX time domain. */
typedef struct nvtxTimeDomainAttr_v1
nvtxTimeDomainAttr_t;
/**
* \brief A pair of timestamps taken at the same instant in two different time
* domains. Used with @ref nvtxTimeSyncPointTable.
*/
typedef struct nvtxSyncPoint_v1
nvtxSyncPoint_t;
/**
* \brief Helper struct to submit a batch of events (marks or ranges).
*
* By default, events are assumed to be chronologically sorted by the first
* timestamp in the event (start time in a range). If the events are not sorted,
* the `flags` field must be set accordingly (see `NVTX_BATCH_FLAG_*`).
*/
typedef struct nvtxEventBatch_v1
nvtxEventBatch_t;
/* NVTX_PAYLOAD_TYPEDEFS_DEFERRED_V1 */
/**
* \brief Register a payload schema.
*
* The `attr` pointer only needs to be valid during the call.
*
* @param domain NVTX domain handle.
* @param attr Pointer to the payload schema attributes.
*
* @return The schema ID on success, or `0` on failure (e.g. invalid layout, or
* duplicate ID).
*/
NVTX_DECLSPEC uint64_t NVTX_API
;
/**
* \brief Register an enumeration type with the payload extension.
*
* The `attr` pointer only needs to be valid during the call.
*
* @param domain NVTX domain handle
* @param attr Pointer to the payload enumeration type attributes.
*
* @return The enum ID on success, or `0` on failure.
*/
NVTX_DECLSPEC uint64_t NVTX_API
;
/**
* \brief Register a scope.
*
* The `attr` pointer only needs to be valid during the call.
*
* @param domain NVTX domain handle
* @param attr Pointer to the scope attributes.
*
* @return An identifier for the scope. If the operation was not successful,
* `NVTX_SCOPE_NONE` is returned.
*/
NVTX_DECLSPEC uint64_t NVTX_API
;
/**
* \brief Marks an instantaneous event in the application with the attributes
* being passed via the extended payload.
*
* See @ref NVTX_PAYLOAD_EVENT_MESSAGE_REQUIREMENT.
*
* @param domain NVTX domain handle
* @param payloadData pointer to an array of structured payloads.
* @param count number of payload BLOBs.
*/
NVTX_DECLSPEC void NVTX_API
;
/**
* \brief Begin a nested thread range with the attributes being passed via the
* payload.
*
* See @ref NVTX_PAYLOAD_EVENT_MESSAGE_REQUIREMENT.
*
* @param domain NVTX domain handle
* @param payloadData Pointer to an array of extended payloads.
* @param count Number of payloads.
*
* @return The new range nesting level. If an error occurs, a negative value is
* returned on the current thread.
*/
NVTX_DECLSPEC int NVTX_API
;
/**
* \brief End a nested thread range with an additional custom payload.
*
* NVTX event attributes passed to this function (via the payloads) are later
* specifications of the same range's attributes; see
* @ref NVTX_PAYLOAD_EVENT_ATTRIBUTE_PRECEDENCE. Other payload entries extend
* the data of the range.
*
* See @ref NVTX_PAYLOAD_EVENT_MESSAGE_REQUIREMENT.
*
* @param domain NVTX domain handle
* @param payloadData pointer to an array of structured payloads.
* @param count number of payload BLOBs.
*
* @return The ended range nesting level. If an error occurs, a negative value
* is returned on the current thread.
*/
NVTX_DECLSPEC int NVTX_API
;
/**
* \brief Start a thread range with attributes passed via the extended payload.
*
* See @ref NVTX_PAYLOAD_EVENT_MESSAGE_REQUIREMENT.
*
* @param domain NVTX domain handle
* @param payloadData pointer to an array of structured payloads.
* @param count number of payload BLOBs.
*
* @return A non-zero unique ID used to correlate a pair of Start and End
* events. A return value of 0 is a null range ID and does not represent a
* started range. Applications may initialize nvtxRangeId_t variables to 0 and
* compare them with 0 to determine whether they reference a started range.
*/
NVTX_DECLSPEC nvtxRangeId_t NVTX_API ;
/**
* \brief End a thread range and pass a custom payload.
*
* Same attribute precedence as @ref nvtxRangePopPayload.
*
* @param domain NVTX domain handle
* @param id The correlation ID returned from a NVTX range start call.
* @param payloadData pointer to an array of structured payloads.
* @param count number of payload BLOBs.
*/
NVTX_DECLSPEC void NVTX_API ;
/**
* \brief Checks if the given NVTX domain is enabled.
*
* This function can be used to guard expensive code instrumentation.
* Applications should generally avoid making execution depend on NVTX API
* results, such as by branching on whether instrumentation is enabled.
*
* If no tool is attached, this function will always return `0`.
* If a tool is attached, but does not handle this function, `1` is returned.
* If a tool is attached and handles this function, the return value is
* determined by the tool. Positive (>0) return values indicate that the domain
* is enabled, `0` indicates that the domain is disabled.
*
* @param domain NVTX domain handle
* @return 0 if the domain is disabled. Values > 0 indicate an enabled domain.
*/
NVTX_DECLSPEC uint8_t NVTX_API ;
/* NVTX_PAYLOAD_API_FUNCTIONS_V1 */
/**
* Get a timestamp from the NVTX handler or tool. If no tool is attached, the
* CPU TSC might be returned. No guarantees are made.
* The returned timestamp is just meant to be used in deferred events/counters.
*/
NVTX_DECLSPEC int64_t NVTX_API ;
/**
* Register a time domain. Associates an NVTX scope with the time domain.
* Timestamps of NVTX events or counters in the scope are interpreted according
* to the time domain definitions.
*
* @param domain NVTX domain handle.
* @param timeAttr Time domain attributes (timestamp type, scope, flags, etc.).
* @return time domain ID.
*/
NVTX_DECLSPEC uint64_t NVTX_API
;
/**
* Provide the pointer to a function that returns a timestamp.
* This enables the tool to create time synchronization points.
*
* @param domain NVTX domain handle.
* @param timeDomainId time domain identifier or timestamp type ID, if it is
* unambiguous.
* @param flags indicates if it is safe to call the timestamp provider after
* process teardown.
* @param timestampProviderFn Pointer to a function that returns a timestamp.
*/
NVTX_DECLSPEC void NVTX_API ;
/**
* Same as `nvtxTimerSource`, but with an additional data pointer argument.
*
* @param domain NVTX domain handle.
* @param timeDomainId time domain identifier or timestamp type ID, if it is
* unambiguous.
* @param flags indicates if it is safe to call the timestamp provider after
* process teardown.
* @param timestampProviderFn Pointer to a function that returns a timestamp.
* @param data Pointer to data that is passed to the timestamp provider function.
*/
NVTX_DECLSPEC void NVTX_API ;
/**
* Provides a synchronization point between two time domains.
* Two synchronization points are required to enable a timestamp conversion.
* The tool must know one of the time domains, or at least be able to chain
* conversions to enable the conversion between the given timestamps.
*
* @param domain NVTX domain handle.
* @param timeDomainId1 time domain 1 ID or timestamp type ID, if it is
* unambiguous.
* @param timeDomainId2 time domain 2 ID or timestamp type ID, if it is
* unambiguous.
* @param timestamp1 Timestamp in the first time domain.
* @param timestamp2 Timestamp in the second time domain.
*/
NVTX_DECLSPEC void NVTX_API ;
/**
* The same as `nvtxTimeSyncPoint` but with multiple synchronization points.
*
* @param domain NVTX domain handle.
* @param timeDomainIdSrc source time domain ID or timestamp type ID, if it is
* unambiguous.
* @param timeDomainIdDst destination time domain ID or timestamp type ID, if it
* is unambiguous.
* @param syncPoints Pointer to an array of synchronization points.
* @param count Number of synchronization points.
*/
NVTX_DECLSPEC void NVTX_API ;
/**
* @brief Pass a conversion factor between two time domains to the NVTX handler.
*
* @param domain NVTX domain handle.
* @param timeDomainIdSrc source time domain ID or timestamp type ID, if it is
* unambiguous.
* @param timeDomainIdDst destination time domain ID or timestamp type ID, if it
* is unambiguous.
* @param slope Conversion factor between the two time domains.
* @param timestampSrc Timestamp in the source time domain.
* @param timestampDst Timestamp in the destination time domain.
*/
NVTX_DECLSPEC void NVTX_API ;
/**
* @brief Submit one deferred event.
*
* See @ref NVTX_PAYLOAD_EVENT_MESSAGE_REQUIREMENT.
*
* @param domain NVTX domain handle.
* @param payloadData Pointer to an array of structured payloads.
* @param numPayloads Number of payloads of the event.
*/
NVTX_DECLSPEC void NVTX_API ;
/**
* \brief Submit a batch of deferred events in the given domain.
*
* @param domain NVTX domain handle.
* @param eventBatch Pointer to deferred events batch details.
*/
NVTX_DECLSPEC void NVTX_API
;
/* NVTX_PAYLOAD_API_FUNCTIONS_DEFERRED_V1 */
/**
* \brief Callback IDs of API functions in the payload extension.
*
* The NVTX handler can use these values to register a handler function. When
* `InitializeInjectionNvtxExtension(nvtxExtModuleInfo_t* moduleInfo)` is
* executed, a handler routine can be registered as follows:
* \code{.c}
* moduleInfo->segments->slots[NVTX3EXT_CBID_nvtxPayloadSchemaRegister] =
* (intptr_t)PayloadSchemaRegisterHandlerFn;
* \endcode
*/
/* NVTX_PAYLOAD_CALLBACK_ID_V1 */
/* NVTX_PAYLOAD_CALLBACK_ID_DEFERRED_V1 */
/*** Helper utilities ***/
/** \brief Helper macro for safe double-cast of a pointer to a uint64_t value. */
/**
* \brief Helper macro to attach a single payload to an NVTX event attribute.
*
* @param evtAttr NVTX event attributes (variable name).
* @param pldata_addr Address of an `nvtxPayloadData_t` variable.
* @param schema_id NVTX binary payload schema ID.
* @param pl_addr Address of the payload.
* @param sz Size of the payload.
*/
/* NVTX_PAYLOAD_EVTATTR_SET_DATA */
/**
* \brief Helper macro to attach multiple payloads to an NVTX event attribute.
*
* @param evtAttr NVTX event attributes (variable name).
* @param pldata Payload data array of type `nvtxPayloadData_t`.
*/
/* NVTX_PAYLOAD_EVTATTR_SET_MULTIPLE */
/**
* \brief Helper macro to attach multiple payloads to an NVTX event attribute
* with an explicit count of payload data objects.
*
* @param evtAttr NVTX event attribute (variable name)
* @param pldata Payload data array (of type `nvtxPayloadData_t`)
* @param count Number of entries in payload data array
*/
/* NVTX_PAYLOAD_EVTATTR_SET_MULTIPLE_N */
/*
* Do not use this macro directly! It is a helper to attach a single payload to
* an NVTX event attribute.
* @warning The NVTX push, start, or mark call must be in the same scope.
*/
/* NVTX_PAYLOAD_EVTATTR_SET */
/**
* \brief Helper macro to push a range with extended payload.
*
* @param domain NVTX domain handle
* @param evtAttr Pointer to NVTX event attributes.
* @param schemaId NVTX payload schema ID
* @param plAddr Pointer to the binary payload data.
* @param size Size of the binary payload data in bytes.
*/
/* nvtxPayloadRangePush */
/**
* \brief Helper macro to set a marker with extended payload.
*
* @param domain NVTX domain handle
* @param evtAttr Pointer to NVTX event attributes.
* @param schemaId NVTX payload schema ID
* @param plAddr Pointer to the binary payload data.
* @param size Size of the binary payload data in bytes.
*/
/* nvtxPayloadMark */
/* Macros to create versioned symbols. */
/* NVTX_EXT_PAYLOAD_VERSIONED_IDENTIFIERS_V1 */
/* Extension types are required for the implementation and the NVTX handler. */
/* NVTX_NO_IMPL */
}
/* __cplusplus */