|
|
|||
File indexing completed on 2026-05-10 08:45:13
0001 /* 0002 * SPDX-FileCopyrightText: Copyright (c) 2021-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 0003 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0004 * 0005 * Licensed under the Apache License, Version 2.0 (the "License"); 0006 * you may not use this file except in compliance with the License. 0007 * You may obtain a copy of the License at 0008 * 0009 * http://www.apache.org/licenses/LICENSE-2.0 0010 * 0011 * Unless required by applicable law or agreed to in writing, software 0012 * distributed under the License is distributed on an "AS IS" BASIS, 0013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0014 * See the License for the specific language governing permissions and 0015 * limitations under the License. 0016 * 0017 * Licensed under the Apache License v2.0 with LLVM Exceptions. 0018 * See https://nvidia.github.io/NVTX/LICENSE.txt for license information. 0019 */ 0020 0021 #if defined(NVTX_AS_SYSTEM_HEADER) 0022 #if defined(__clang__) 0023 #pragma clang system_header 0024 #elif defined(__GNUC__) || defined(__NVCOMPILER) 0025 #pragma GCC system_header 0026 #elif defined(_MSC_VER) 0027 #pragma system_header 0028 #endif 0029 #endif 0030 0031 #include "nvToolsExt.h" 0032 0033 /* Optionally include helper macros. */ 0034 /* #include "nvToolsExtPayloadHelper.h" */ 0035 0036 /** 0037 * If needed, semantic extension headers can be included after this header. 0038 */ 0039 0040 /** 0041 * \brief The compatibility ID is used for versioning of this extension. 0042 */ 0043 #ifndef NVTX_EXT_PAYLOAD_COMPATID 0044 #define NVTX_EXT_PAYLOAD_COMPATID 0x0104 0045 #endif 0046 0047 /** 0048 * \brief The module ID identifies the payload extension. It has to be unique 0049 * among the extension modules. 0050 */ 0051 #ifndef NVTX_EXT_PAYLOAD_MODULEID 0052 #define NVTX_EXT_PAYLOAD_MODULEID 2 0053 #endif 0054 0055 /** 0056 * \brief Additional value for the enum @ref nvtxPayloadType_t 0057 */ 0058 #ifndef NVTX_PAYLOAD_TYPE_EXT 0059 #define NVTX_PAYLOAD_TYPE_EXT (NVTX_STATIC_CAST(int32_t, 0xDFBD0009)) 0060 #endif 0061 0062 /** --------------------------------------------------------------------------- 0063 * Payload schema entry flags. Used for @ref nvtxPayloadSchemaEntry_t::flags. 0064 * ------------------------------------------------------------------------- */ 0065 #ifndef NVTX_PAYLOAD_ENTRY_FLAGS_V1 0066 #define NVTX_PAYLOAD_ENTRY_FLAGS_V1 0067 0068 #define NVTX_PAYLOAD_ENTRY_FLAG_UNUSED 0 0069 0070 /** 0071 * Absolute pointer into a payload (entry) of the same event. 0072 */ 0073 #define NVTX_PAYLOAD_ENTRY_FLAG_POINTER (1 << 1) 0074 0075 /** 0076 * Offset from base address of the payload. 0077 */ 0078 #define NVTX_PAYLOAD_ENTRY_FLAG_OFFSET_FROM_BASE (1 << 2) 0079 0080 /** 0081 * Offset from the end of this payload entry. 0082 */ 0083 #define NVTX_PAYLOAD_ENTRY_FLAG_OFFSET_FROM_HERE (1 << 3) 0084 0085 /** 0086 * The value is an array with fixed length, set with the field `arrayLength`. 0087 */ 0088 #define NVTX_PAYLOAD_ENTRY_FLAG_ARRAY_FIXED_SIZE (1 << 4) 0089 0090 /** 0091 * The value is a zero-/null-terminated array. 0092 */ 0093 #define NVTX_PAYLOAD_ENTRY_FLAG_ARRAY_ZERO_TERMINATED (2 << 4) 0094 0095 /** 0096 * \brief A single or multi-dimensional array of variable length. 0097 * 0098 * The field `arrayOrUnionDetail` contains the index of the schema entry that 0099 * holds the length(s). If the length entry is a scalar, then this entry is a 1D 0100 * array. If the length entry is a fixed-size array, then the number of 0101 * dimensions is defined with the registration of the schema. If the length 0102 * entry is a zero-terminated array, then the array of the dimensions can be 0103 * determined at runtime. 0104 * For multidimensional arrays, values are stored in row-major order, with rows 0105 * being stored consecutively in contiguous memory. The size of the entry (in 0106 * bytes) is the product of the dimensions multiplied with size of the array 0107 * element. 0108 */ 0109 #define NVTX_PAYLOAD_ENTRY_FLAG_ARRAY_LENGTH_INDEX (3 << 4) 0110 0111 /** 0112 * \brief A single or multi-dimensional array of variable length, where the 0113 * dimensions are stored in a different payload (index) of the same event. 0114 * 0115 * This enables an existing address to an array to be directly passed, while the 0116 * dimensions are defined in a separate payload (with only one payload entry). 0117 */ 0118 #define NVTX_PAYLOAD_ENTRY_FLAG_ARRAY_LENGTH_PAYLOAD_INDEX (4 << 4) 0119 0120 /** 0121 * \brief The value or data that is pointed to by this payload entry value shall 0122 * be copied by the NVTX handler. 0123 * 0124 * A tool may not support deep copy and just ignore this flag. 0125 * See @ref NVTX_PAYLOAD_SCHEMA_FLAG_DEEP_COPY for more details. 0126 */ 0127 #define NVTX_PAYLOAD_ENTRY_FLAG_DEEP_COPY (1 << 8) 0128 0129 /** 0130 * Notifies the NVTX handler to hide this entry in case of visualization. 0131 */ 0132 #define NVTX_PAYLOAD_ENTRY_FLAG_HIDE (1 << 9) 0133 0134 /** 0135 * The entry specifies the event message. Any string type can be used. 0136 */ 0137 #define NVTX_PAYLOAD_ENTRY_FLAG_EVENT_MESSAGE (1 << 10) 0138 0139 /** 0140 * \brief The entry contains a timestamp. 0141 * 0142 * The time source might be provided via the entry semantics field. In most 0143 * cases, the timestamp (entry) type is @ref NVTX_PAYLOAD_ENTRY_TYPE_INT64. 0144 */ 0145 #define NVTX_PAYLOAD_ENTRY_FLAG_TIMESTAMP (2 << 10) 0146 0147 /** 0148 * These flags specify the NVTX event type to which an entry refers. 0149 */ 0150 #define NVTX_PAYLOAD_ENTRY_FLAG_RANGE_BEGIN (1 << 12) 0151 #define NVTX_PAYLOAD_ENTRY_FLAG_RANGE_END (2 << 12) 0152 #define NVTX_PAYLOAD_ENTRY_FLAG_MARK (3 << 12) 0153 #define NVTX_PAYLOAD_ENTRY_FLAG_COUNTER (4 << 12) 0154 0155 #endif /* NVTX_PAYLOAD_ENTRY_FLAGS_V1 */ 0156 /** --------------------------------------------------------------------------- 0157 * END: Payload schema entry flags. 0158 * ------------------------------------------------------------------------- */ 0159 0160 /** 0161 * @note The 'array' flags assume that the array is embedded. Otherwise, 0162 * @ref NVTX_PAYLOAD_ENTRY_FLAG_POINTER has to be additionally specified. Some 0163 * combinations may be invalid based on the `NVTX_PAYLOAD_SCHEMA_TYPE_*` this 0164 * entry is enclosed. For instance, variable length embedded arrays are valid 0165 * within @ref NVTX_PAYLOAD_SCHEMA_TYPE_DYNAMIC but invalid with 0166 * @ref NVTX_PAYLOAD_SCHEMA_TYPE_STATIC. See `NVTX_PAYLOAD_SCHEMA_TYPE_*` for 0167 * additional details. 0168 */ 0169 0170 /* Helper macro to check if an entry represents an array. */ 0171 #define NVTX_PAYLOAD_ENTRY_FLAG_IS_ARRAY (\ 0172 NVTX_PAYLOAD_ENTRY_FLAG_ARRAY_FIXED_SIZE | \ 0173 NVTX_PAYLOAD_ENTRY_FLAG_ARRAY_ZERO_TERMINATED | \ 0174 NVTX_PAYLOAD_ENTRY_FLAG_ARRAY_LENGTH_INDEX) 0175 0176 #define NVTX_PAYLOAD_ENTRY_FLAG_ARRAY_TYPE(F) \ 0177 ((F) & NVTX_PAYLOAD_ENTRY_FLAG_IS_ARRAY) 0178 0179 0180 /** --------------------------------------------------------------------------- 0181 * Types of entries in a payload schema. 0182 * 0183 * @note Several of the predefined types contain the size (in bits) in their 0184 * names. For some data types the size (in bytes) is not fixed and may differ 0185 * for different platforms/operating systems/compilers. To provide portability, 0186 * an array of sizes (in bytes) for type 1 to 28 ( @ref 0187 * NVTX_PAYLOAD_ENTRY_TYPE_CHAR to @ref NVTX_PAYLOAD_ENTRY_TYPE_INFO_ARRAY_SIZE) 0188 * is passed to the NVTX extension initialization function 0189 * @ref InitializeInjectionNvtxExtension via the `extInfo` field of 0190 * @ref nvtxExtModuleInfo_t. 0191 * ------------------------------------------------------------------------- */ 0192 #ifndef NVTX_PAYLOAD_ENTRY_TYPES_V1 0193 #define NVTX_PAYLOAD_ENTRY_TYPES_V1 0194 0195 #define NVTX_PAYLOAD_ENTRY_TYPE_INVALID 0 0196 0197 /** 0198 * Basic integer types. 0199 */ 0200 #define NVTX_PAYLOAD_ENTRY_TYPE_CHAR 1 0201 #define NVTX_PAYLOAD_ENTRY_TYPE_UCHAR 2 0202 #define NVTX_PAYLOAD_ENTRY_TYPE_SHORT 3 0203 #define NVTX_PAYLOAD_ENTRY_TYPE_USHORT 4 0204 #define NVTX_PAYLOAD_ENTRY_TYPE_INT 5 0205 #define NVTX_PAYLOAD_ENTRY_TYPE_UINT 6 0206 #define NVTX_PAYLOAD_ENTRY_TYPE_LONG 7 0207 #define NVTX_PAYLOAD_ENTRY_TYPE_ULONG 8 0208 #define NVTX_PAYLOAD_ENTRY_TYPE_LONGLONG 9 0209 #define NVTX_PAYLOAD_ENTRY_TYPE_ULONGLONG 10 0210 0211 /** 0212 * Integer types with explicit size. 0213 */ 0214 #define NVTX_PAYLOAD_ENTRY_TYPE_INT8 11 0215 #define NVTX_PAYLOAD_ENTRY_TYPE_UINT8 12 0216 #define NVTX_PAYLOAD_ENTRY_TYPE_INT16 13 0217 #define NVTX_PAYLOAD_ENTRY_TYPE_UINT16 14 0218 #define NVTX_PAYLOAD_ENTRY_TYPE_INT32 15 0219 #define NVTX_PAYLOAD_ENTRY_TYPE_UINT32 16 0220 #define NVTX_PAYLOAD_ENTRY_TYPE_INT64 17 0221 #define NVTX_PAYLOAD_ENTRY_TYPE_UINT64 18 0222 0223 /** 0224 * Floating point types 0225 */ 0226 #define NVTX_PAYLOAD_ENTRY_TYPE_FLOAT 19 0227 #define NVTX_PAYLOAD_ENTRY_TYPE_DOUBLE 20 0228 #define NVTX_PAYLOAD_ENTRY_TYPE_LONGDOUBLE 21 0229 0230 /** 0231 * Size type (`size_t` in C). 0232 */ 0233 #define NVTX_PAYLOAD_ENTRY_TYPE_SIZE 22 0234 0235 /** 0236 * Any address, e.g. `void*`. If the pointer type matters, use the flag @ref 0237 * NVTX_PAYLOAD_ENTRY_FLAG_POINTER and the respective type instead. 0238 */ 0239 #define NVTX_PAYLOAD_ENTRY_TYPE_ADDRESS 23 0240 0241 /** 0242 * Special character types. 0243 */ 0244 #define NVTX_PAYLOAD_ENTRY_TYPE_WCHAR 24 /* wide character (since C90) */ 0245 #define NVTX_PAYLOAD_ENTRY_TYPE_CHAR8 25 /* since C2x and C++20 */ 0246 #define NVTX_PAYLOAD_ENTRY_TYPE_CHAR16 26 0247 #define NVTX_PAYLOAD_ENTRY_TYPE_CHAR32 27 0248 0249 /** 0250 * There is type size and alignment information for all previous types. 0251 */ 0252 #define NVTX_PAYLOAD_ENTRY_TYPE_INFO_ARRAY_SIZE (NVTX_PAYLOAD_ENTRY_TYPE_CHAR32 + 1) 0253 0254 /** 0255 * Store raw 8-bit binary data. As with `char`, 1-byte alignment is assumed. 0256 * Typically, a tool will display this as hex or binary. 0257 */ 0258 #define NVTX_PAYLOAD_ENTRY_TYPE_BYTE 32 0259 0260 /** 0261 * These types do not have standardized equivalents. It is assumed that the 0262 * number at the end corresponds to the bits used to store the value and that 0263 * the alignment corresponds to standardized types of the same size. 0264 * A tool may not support these types. 0265 */ 0266 #define NVTX_PAYLOAD_ENTRY_TYPE_INT128 33 0267 #define NVTX_PAYLOAD_ENTRY_TYPE_UINT128 34 0268 0269 #define NVTX_PAYLOAD_ENTRY_TYPE_FLOAT16 42 0270 #define NVTX_PAYLOAD_ENTRY_TYPE_FLOAT32 43 0271 #define NVTX_PAYLOAD_ENTRY_TYPE_FLOAT64 44 0272 #define NVTX_PAYLOAD_ENTRY_TYPE_FLOAT128 45 0273 0274 #define NVTX_PAYLOAD_ENTRY_TYPE_BF16 50 0275 #define NVTX_PAYLOAD_ENTRY_TYPE_TF32 52 0276 0277 /** 0278 * Data types are as defined by NVTXv3 core. 0279 */ 0280 #define NVTX_PAYLOAD_ENTRY_TYPE_CATEGORY 68 /* uint32_t */ 0281 #define NVTX_PAYLOAD_ENTRY_TYPE_COLOR_ARGB 69 /* uint32_t */ 0282 0283 /** 0284 * The scope of events or counters (see `nvtxScopeRegister`). 0285 */ 0286 #define NVTX_PAYLOAD_ENTRY_TYPE_SCOPE_ID 70 /* uint64_t */ 0287 0288 /** 0289 * Process ID as scope. 0290 */ 0291 #define NVTX_PAYLOAD_ENTRY_TYPE_PID_UINT32 71 0292 #define NVTX_PAYLOAD_ENTRY_TYPE_PID_UINT64 72 0293 0294 /** 0295 * Thread ID as scope. 0296 */ 0297 #define NVTX_PAYLOAD_ENTRY_TYPE_TID_UINT32 73 0298 #define NVTX_PAYLOAD_ENTRY_TYPE_TID_UINT64 74 0299 0300 /** 0301 * \brief String types. 0302 * 0303 * If no flags are set for the entry and `arrayOrUnionDetail > 0`, the entry is 0304 * assumed to be a fixed-size string with the given length, embedded in the payload. 0305 * `NVTX_PAYLOAD_ENTRY_FLAG_ARRAY_FIXED_SIZE` is redundant for fixed-size strings. 0306 * 0307 * Setting the flag `NVTX_PAYLOAD_ENTRY_FLAG_ARRAY_ZERO_TERMINATED` specifies a 0308 * zero-terminated string. If `arrayOrUnionDetail > 0`, the entry is handled as 0309 * a zero-terminated array of fixed-size strings. 0310 * 0311 * Setting the flag `NVTX_PAYLOAD_ENTRY_FLAG_ARRAY_LENGTH_INDEX` specifies a 0312 * variable-length string with the length given in the entry specified by the 0313 * field `arrayOrUnionDetail`. 0314 */ 0315 #define NVTX_PAYLOAD_ENTRY_TYPE_CSTRING 75 /* `char*`, system LOCALE */ 0316 #define NVTX_PAYLOAD_ENTRY_TYPE_CSTRING_UTF8 76 0317 #define NVTX_PAYLOAD_ENTRY_TYPE_CSTRING_UTF16 77 0318 #define NVTX_PAYLOAD_ENTRY_TYPE_CSTRING_UTF32 78 0319 0320 /** 0321 * The entry value is of type @ref nvtxStringHandle_t returned by 0322 * @ref nvtxDomainRegisterString. 0323 */ 0324 #define NVTX_PAYLOAD_ENTRY_TYPE_NVTX_REGISTERED_STRING_HANDLE 80 0325 0326 /** 0327 * This type marks the union selector member (entry index) in schemas used by 0328 * a union with internal selector. 0329 * See @ref NVTX_PAYLOAD_SCHEMA_TYPE_UNION_WITH_INTERNAL_SELECTOR. 0330 */ 0331 #define NVTX_PAYLOAD_ENTRY_TYPE_UNION_SELECTOR 100 0332 0333 /** 0334 * \brief Predefined schema ID for payload data that is referenced in another payload. 0335 * 0336 * This schema ID can be used in @ref nvtxPayloadData_t::schema_id to indicate that the 0337 * payload is a blob of memory which other payload entries may point into. 0338 * A tool will not expose this payload directly. 0339 * 0340 * This schema ID cannot be used as schema entry type! 0341 */ 0342 #define NVTX_TYPE_PAYLOAD_SCHEMA_REFERENCED 1022 0343 0344 /** 0345 * \brief Predefined schema ID for raw payload data. 0346 * 0347 * This schema ID can be used in @ref nvtxPayloadData_t::schema_id to indicate 0348 * that the payload is a blob, which can be shown with an arbitrary data viewer. 0349 * This schema ID cannot be used as schema entry type! 0350 */ 0351 #define NVTX_TYPE_PAYLOAD_SCHEMA_RAW 1023 0352 0353 /* Custom (static) schema IDs. */ 0354 #define NVTX_PAYLOAD_SCHEMA_ID_STATIC_START (1 << 24) 0355 0356 /* Dynamic schema IDs (generated by the tool) start here. */ 0357 #define NVTX_PAYLOAD_SCHEMA_ID_DYNAMIC_START (NVTX_STATIC_CAST(uint64_t, 1) << 32) 0358 0359 #endif /* NVTX_PAYLOAD_ENTRY_TYPES_V1 */ 0360 /** --------------------------------------------------------------------------- 0361 * END: Payload schema entry types. 0362 * ------------------------------------------------------------------------- */ 0363 0364 0365 #ifndef NVTX_PAYLOAD_SCHEMA_TYPES_V1 0366 #define NVTX_PAYLOAD_SCHEMA_TYPES_V1 0367 0368 /** 0369 * \brief The payload schema type. 0370 * 0371 * A schema can be either of the following types. It is set with 0372 * @ref nvtxPayloadSchemaAttr_t::type. 0373 */ 0374 #define NVTX_PAYLOAD_SCHEMA_TYPE_INVALID 0 0375 #define NVTX_PAYLOAD_SCHEMA_TYPE_STATIC 1 0376 #define NVTX_PAYLOAD_SCHEMA_TYPE_DYNAMIC 2 0377 #define NVTX_PAYLOAD_SCHEMA_TYPE_UNION 3 0378 #define NVTX_PAYLOAD_SCHEMA_TYPE_UNION_WITH_INTERNAL_SELECTOR 4 0379 0380 #endif /* NVTX_PAYLOAD_SCHEMA_TYPES_V1 */ 0381 0382 0383 #ifndef NVTX_PAYLOAD_SCHEMA_FLAGS_V1 0384 #define NVTX_PAYLOAD_SCHEMA_FLAGS_V1 0385 0386 /** 0387 * \brief Flags for static and dynamic schemas. 0388 * 0389 * The schema flags are used with @ref nvtxPayloadSchemaAttr_t::flags. 0390 */ 0391 #define NVTX_PAYLOAD_SCHEMA_FLAG_NONE 0 0392 0393 /** 0394 * This flag indicates that a schema and the corresponding payloads can 0395 * contain fields which require a deep copy. 0396 */ 0397 #define NVTX_PAYLOAD_SCHEMA_FLAG_DEEP_COPY (1 << 1) 0398 0399 /** 0400 * This flag indicates that a schema and the corresponding payload can be 0401 * referenced by another payload of the same event. If the schema is not 0402 * intended to be visualized directly, it is possible use 0403 * @ref NVTX_TYPE_PAYLOAD_SCHEMA_REFERENCED instead. 0404 */ 0405 #define NVTX_PAYLOAD_SCHEMA_FLAG_REFERENCED (1 << 2) 0406 0407 /** 0408 * The schema defines a counter group. An NVTX handler can expect that the schema 0409 * contains entries with counter semantics. 0410 */ 0411 #define NVTX_PAYLOAD_SCHEMA_FLAG_COUNTER_GROUP (1 << 3) 0412 0413 /** 0414 * The schema defines a range or marker. An NVTX handler can expect that the 0415 * schema contains a message and timestamp(s). 0416 */ 0417 #define NVTX_PAYLOAD_SCHEMA_FLAG_RANGE_PUSHPOP (2 << 3) 0418 #define NVTX_PAYLOAD_SCHEMA_FLAG_RANGE_STARTEND (3 << 3) 0419 #define NVTX_PAYLOAD_SCHEMA_FLAG_MARK (4 << 3) 0420 0421 #endif /* NVTX_PAYLOAD_SCHEMA_FLAGS_V1 */ 0422 0423 0424 #ifndef NVTX_PAYLOAD_SCHEMA_ATTR_FIELDS_V1 0425 #define NVTX_PAYLOAD_SCHEMA_ATTR_FIELDS_V1 0426 0427 /** 0428 * The values allow the valid fields in @ref nvtxPayloadSchemaAttr_t to be 0429 * specified via setting the field `fieldMask`. 0430 */ 0431 #define NVTX_PAYLOAD_SCHEMA_ATTR_FIELD_NAME (1 << 1) 0432 #define NVTX_PAYLOAD_SCHEMA_ATTR_FIELD_TYPE (1 << 2) 0433 #define NVTX_PAYLOAD_SCHEMA_ATTR_FIELD_FLAGS (1 << 3) 0434 #define NVTX_PAYLOAD_SCHEMA_ATTR_FIELD_ENTRIES (1 << 4) 0435 #define NVTX_PAYLOAD_SCHEMA_ATTR_FIELD_NUM_ENTRIES (1 << 5) 0436 #define NVTX_PAYLOAD_SCHEMA_ATTR_FIELD_STATIC_SIZE (1 << 6) 0437 #define NVTX_PAYLOAD_SCHEMA_ATTR_FIELD_ALIGNMENT (1 << 7) 0438 #define NVTX_PAYLOAD_SCHEMA_ATTR_FIELD_SCHEMA_ID (1 << 8) 0439 #define NVTX_PAYLOAD_SCHEMA_ATTR_FIELD_EXTENSION (1 << 9) 0440 0441 #endif /* NVTX_PAYLOAD_SCHEMA_ATTR_FIELDS_V1 */ 0442 0443 0444 #ifndef NVTX_PAYLOAD_ENUM_ATTR_FIELDS_V1 0445 #define NVTX_PAYLOAD_ENUM_ATTR_FIELDS_V1 0446 0447 /** 0448 * The values are used to set the field `fieldMask` and specify which fields in 0449 * @ref nvtxPayloadEnumAttr_t are set. 0450 */ 0451 #define NVTX_PAYLOAD_ENUM_ATTR_FIELD_NAME (1 << 1) 0452 #define NVTX_PAYLOAD_ENUM_ATTR_FIELD_ENTRIES (1 << 2) 0453 #define NVTX_PAYLOAD_ENUM_ATTR_FIELD_NUM_ENTRIES (1 << 3) 0454 #define NVTX_PAYLOAD_ENUM_ATTR_FIELD_SIZE (1 << 4) 0455 #define NVTX_PAYLOAD_ENUM_ATTR_FIELD_SCHEMA_ID (1 << 5) 0456 #define NVTX_PAYLOAD_ENUM_ATTR_FIELD_EXTENSION (1 << 6) 0457 0458 #endif /* NVTX_PAYLOAD_ENUM_ATTR_FIELDS_V1 */ 0459 0460 /** 0461 * An NVTX scope specifies the execution scope or source of events or counters. 0462 * A tool determines the value for a predefined scope when the sample is taken. 0463 */ 0464 #ifndef NVTX_SCOPES_V1 0465 #define NVTX_SCOPES_V1 0466 0467 #define NVTX_SCOPE_NONE 0 /* No scope specified. */ 0468 #define NVTX_SCOPE_ROOT 1 /* The root in a hierarchy. */ 0469 0470 /* Hardware events */ 0471 #define NVTX_SCOPE_CURRENT_HW_MACHINE 2 /* Node/machine name */ 0472 #define NVTX_SCOPE_CURRENT_HW_SOCKET 3 0473 #define NVTX_SCOPE_CURRENT_HW_CPU_PHYSICAL 4 /* Physical CPU core */ 0474 #define NVTX_SCOPE_CURRENT_HW_CPU_LOGICAL 5 /* Logical CPU core */ 0475 /* Innermost HW execution context */ 0476 #define NVTX_SCOPE_CURRENT_HW_INNERMOST 15 0477 0478 /* Virtualized hardware, virtual machines */ 0479 #define NVTX_SCOPE_CURRENT_HYPERVISOR 16 0480 #define NVTX_SCOPE_CURRENT_VM 17 0481 #define NVTX_SCOPE_CURRENT_KERNEL 18 0482 #define NVTX_SCOPE_CURRENT_CONTAINER 19 0483 #define NVTX_SCOPE_CURRENT_OS 20 0484 0485 /* Software scopes */ 0486 #define NVTX_SCOPE_CURRENT_SW_PROCESS 21 /* Process scope */ 0487 #define NVTX_SCOPE_CURRENT_SW_THREAD 22 /* Thread scope */ 0488 /* Innermost SW execution context */ 0489 #define NVTX_SCOPE_CURRENT_SW_INNERMOST 31 0490 0491 /** Static (user-provided) scope IDs (feed forward) */ 0492 #define NVTX_SCOPE_ID_STATIC_START (1 << 24) 0493 0494 /* Dynamically (tool) generated scope IDs */ 0495 #define NVTX_SCOPE_ID_DYNAMIC_START (NVTX_STATIC_CAST(uint64_t, 1) << 32) 0496 0497 #endif /* NVTX_SCOPES_V1 */ 0498 0499 #ifndef NVTX_TIME_V1 0500 #define NVTX_TIME_V1 0501 0502 /** 0503 * Timestamp source is not known, e.g. NIC or switch. The NVTX handler can 0504 * assume that at least two synchronization points are created with NVTX 0505 * instrumentation. 0506 */ 0507 #define NVTX_TIMESTAMP_TYPE_NONE 0 0508 0509 /** The timestamp was provided by the NVTX handler via `nvtxTimestampGet()`. */ 0510 #define NVTX_TIMESTAMP_TYPE_TOOL_PROVIDED 1 0511 0512 /** CPU timestamp sources */ 0513 #define NVTX_TIMESTAMP_TYPE_CPU_TSC /* RDTSC on x86, CNTVCT on ARM */ 10 0514 #define NVTX_TIMESTAMP_TYPE_CPU_TSC_NONVIRTUALIZED /* CNTPCT on ARM */ 11 0515 #define NVTX_TIMESTAMP_TYPE_CPU_CLOCK_GETTIME_REALTIME 12 0516 #define NVTX_TIMESTAMP_TYPE_CPU_CLOCK_GETTIME_REALTIME_COARSE 13 0517 #define NVTX_TIMESTAMP_TYPE_CPU_CLOCK_GETTIME_MONOTONIC 14 0518 #define NVTX_TIMESTAMP_TYPE_CPU_CLOCK_GETTIME_MONOTONIC_RAW 15 0519 #define NVTX_TIMESTAMP_TYPE_CPU_CLOCK_GETTIME_MONOTONIC_COARSE 16 0520 #define NVTX_TIMESTAMP_TYPE_CPU_CLOCK_GETTIME_BOOTTIME 17 0521 #define NVTX_TIMESTAMP_TYPE_CPU_CLOCK_GETTIME_PROCESS_CPUTIME_ID 18 0522 #define NVTX_TIMESTAMP_TYPE_CPU_CLOCK_GETTIME_THREAD_CPUTIME_ID 19 0523 0524 #define NVTX_TIMESTAMP_TYPE_WIN_QPC 30 0525 #define NVTX_TIMESTAMP_TYPE_WIN_GSTAFT 31 0526 #define NVTX_TIMESTAMP_TYPE_WIN_GSTAFTP 32 0527 0528 #define NVTX_TIMESTAMP_TYPE_C_TIME 40 0529 #define NVTX_TIMESTAMP_TYPE_C_CLOCK 41 0530 #define NVTX_TIMESTAMP_TYPE_C_TIMESPEC_GET 42 0531 0532 #define NVTX_TIMESTAMP_TYPE_CPP_STEADY_CLOCK 50 0533 #define NVTX_TIMESTAMP_TYPE_CPP_HIGH_RESOLUTION_CLOCK 51 0534 #define NVTX_TIMESTAMP_TYPE_CPP_SYSTEM_CLOCK 52 0535 #define NVTX_TIMESTAMP_TYPE_CPP_UTC_CLOCK 53 0536 #define NVTX_TIMESTAMP_TYPE_CPP_TAI_CLOCK 54 0537 #define NVTX_TIMESTAMP_TYPE_CPP_GPS_CLOCK 55 0538 #define NVTX_TIMESTAMP_TYPE_CPP_FILE_CLOCK 56 0539 0540 /** GPU timestamp sources */ 0541 #define NVTX_TIMESTAMP_TYPE_GPU_GLOBALTIMER 80 /* e.g. PTIMER */ 0542 0543 /** Returned by `nvtxTimeDomainRegister` if time domain registration failed. */ 0544 #define NVTX_TIME_DOMAIN_ID_NONE 0 0545 0546 /** Static (user-provided) time domain IDs (feed forward) */ 0547 #define NVTX_TIME_DOMAIN_ID_STATIC_START (1 << 24) 0548 0549 /* Dynamically (tool) generated time domain IDs */ 0550 #define NVTX_TIME_DOMAIN_ID_DYNAMIC_START (NVTX_STATIC_CAST(uint64_t, 1) << 32) 0551 0552 /** Timer properties */ 0553 #define NVTX_TIMER_FLAG_NONE 0 0554 #define NVTX_TIMER_FLAG_CLOCK_MONOTONIC (1 << 1) 0555 #define NVTX_TIMER_FLAG_CLOCK_STEADY (1 << 2) 0556 0557 /** Point in time when the timer starts (its value is 0). */ 0558 #define NVTX_TIMER_START_UNKNOWN 0 0559 #define NVTX_TIMER_START_SYSTEM_BOOT 1 0560 #define NVTX_TIMER_START_VM_BOOT 2 0561 #define NVTX_TIMER_START_UNIX_EPOCH 3 /* 1 January 1970 */ 0562 #define NVTX_TIMER_START_WIN_FILETIME 4 /* 1 January 1601 */ 0563 0564 /** 0565 * Flags specifying whether it is safe or unsafe to call the timestamp 0566 * provider after process teardown. 0567 */ 0568 #define NVTX_TIMER_SOURCE_SAFE_CALL_AFTER_PROCESS_TEARDOWN 0 0569 #define NVTX_TIMER_SOURCE_UNSAFE_CALL_AFTER_PROCESS_TEARDOWN 1 0570 0571 #endif /* NVTX_TIME_V1 */ 0572 0573 #ifndef NVTX_BATCH_FLAGS_V1 0574 #define NVTX_BATCH_FLAGS_V1 0575 0576 /** 0577 * Timestamp ordering flags for a batch of deferred events or counters. 0578 * By default, chronological order by the first timestamp of the event or 0579 * counter is assumed. 0580 */ 0581 #define NVTX_BATCH_FLAG_TIME_SORTED 0 0582 #define NVTX_BATCH_FLAG_TIME_SORTED_PARTIALLY (1 << 1) 0583 #define NVTX_BATCH_FLAG_TIME_SORTED_PER_SCOPE (2 << 1) 0584 #define NVTX_BATCH_FLAG_UNSORTED (3 << 1) 0585 0586 #endif /* NVTX_BATCH_FLAGS_V1 */ 0587 0588 #ifdef __cplusplus 0589 extern "C" { 0590 #endif /* __cplusplus */ 0591 0592 #ifndef NVTX_PAYLOAD_TYPEDEFS_V1 0593 #define NVTX_PAYLOAD_TYPEDEFS_V1 0594 0595 /** 0596 * \brief Size and alignment information for predefined payload entry types. 0597 * 0598 * The struct contains the size and the alignment size in bytes. A respective 0599 * array for the predefined types is passed via nvtxExtModuleInfo_t to the NVTX 0600 * client/handler. The type (ID) is used as index into this array. 0601 */ 0602 typedef struct nvtxPayloadEntryTypeInfo_v1 0603 { 0604 uint16_t size; 0605 uint16_t align; 0606 } nvtxPayloadEntryTypeInfo_t; 0607 0608 /** 0609 * \brief Binary payload data, size and decoding information. 0610 * 0611 * An array of type `nvtxPayloadData_t` is passed to the NVTX event attached to 0612 * an NVTX event via the `payload.ullvalue` field of NVTX event attributes. 0613 * 0614 * The `schemaId` be a predefined schema entry type (`NVTX_PAYLOAD_ENTRY_TYPE*`), 0615 * a schema ID (statically specified or dynamically created) or one of 0616 * `NVTX_PAYLOAD_TYPE_REFERENCED` or `NVTX_PAYLOAD_TYPE_RAW`. 0617 * 0618 * Setting the size of a payload to `MAX_SIZE` can be useful to reduce the 0619 * overhead of NVTX instrumentation, when no NVTX handler is attached. However, 0620 * a tool might not be able to detect the size of a payload and thus skip it. 0621 * A reasonable use case is a payload that represents a null-terminated 0622 * C string, where the NVTX handler can call `strlen()`. 0623 */ 0624 typedef struct nvtxPayloadData_v1 0625 { 0626 /** 0627 * The schema ID, which defines the layout of the binary data. 0628 */ 0629 uint64_t schemaId; 0630 0631 /** 0632 * Size of the payload (blob) in bytes. `SIZE_MAX` (`-1`) indicates the tool 0633 * that it should figure out the size, which might not be possible. 0634 */ 0635 size_t size; 0636 0637 /** 0638 * Pointer to the binary payload data. 0639 */ 0640 const void* payload; 0641 } nvtxPayloadData_t; 0642 0643 0644 /** 0645 * \brief Header of the payload entry's semantic field. 0646 * 0647 * If the semantic field of the payload schema entry is set, the first four 0648 * fields (header) are defined with this type. A tool can iterate through the 0649 * extensions and check, if it supports (can handle) it. 0650 */ 0651 typedef struct nvtxSemanticsHeader_v1 0652 { 0653 uint32_t structSize; /** Size of semantic extension struct. */ 0654 uint16_t semanticId; 0655 uint16_t version; 0656 const struct nvtxSemanticsHeader_v1* next; /** linked list */ 0657 /* Additional fields are defined by the specific semantic extension. */ 0658 } nvtxSemanticsHeader_t; 0659 0660 /** 0661 * \brief Entry in a schema. 0662 * 0663 * A payload schema consists of an array of payload schema entries. It is 0664 * registered with @ref nvtxPayloadSchemaRegister. `flag` can be set to `0` for 0665 * simple values, 'type' is the only "required" field. If not set explicitly, 0666 * all other fields are zero-initialized, which means that the entry has no name 0667 * and the offset is determined based on self-alignment rules. 0668 * 0669 * Example schema: 0670 * nvtxPayloadSchemaEntry_t schema[] = { 0671 * {0, NVTX_EXT_PAYLOAD_TYPE_UINT8, "one byte"}, 0672 * {0, NVTX_EXT_PAYLOAD_TYPE_INT32, "four bytes"} 0673 * }; 0674 */ 0675 typedef struct nvtxPayloadSchemaEntry_v1 0676 { 0677 /** 0678 * \brief Flags to augment the basic type. 0679 * 0680 * This field allows additional properties of the payload entry to be 0681 * specified. Valid values are `NVTX_PAYLOAD_ENTRY_FLAG_*`. 0682 */ 0683 uint64_t flags; 0684 0685 /** 0686 * \brief Predefined payload schema entry type or custom schema ID. 0687 * 0688 * Predefined types are `NVTX_PAYLOAD_ENTRY_TYPE_*`. Passing a schema ID 0689 * enables nesting of schemas. 0690 */ 0691 uint64_t type; 0692 0693 /** 0694 * \brief Name or label of the payload entry. (Optional) 0695 * 0696 * A meaningful name or label can help organizing and interpreting the data. 0697 */ 0698 const char* name; 0699 0700 /** 0701 * \brief Description of the payload entry. (Optional) 0702 * 0703 * A more detail description of the data that is stored with this entry. 0704 */ 0705 const char* description; 0706 0707 /** 0708 * \brief String length, array length or member selector for union types. 0709 * 0710 * If @ref type is a C string type, this field specifies the string length. 0711 * 0712 * If @ref flags specify that the entry is an array, this field specifies 0713 * the array length. See `NVTX_PAYLOAD_ENTRY_FLAG_ARRAY_*` for more details. 0714 * 0715 * If @ref type is a union with schema type @ref NVTX_PAYLOAD_SCHEMA_TYPE_UNION 0716 * (external selection of the union member), this field contains the index 0717 * (starting with 0) to an entry of integral type in the same schema. The 0718 * associated field value specifies the selected union member. 0719 * 0720 * @note An array of schema type @ref NVTX_PAYLOAD_SCHEMA_TYPE_UNION is not 0721 * supported. @ref NVTX_PAYLOAD_SCHEMA_TYPE_UNION_WITH_INTERNAL_SELECTOR can 0722 * be used instead. 0723 */ 0724 uint64_t arrayOrUnionDetail; 0725 0726 /** 0727 * \brief Offset in the binary payload data (in bytes). 0728 * 0729 * This field specifies the byte offset from the base address of the actual 0730 * binary data (blob) to the start address of the data of this entry. 0731 * 0732 * It is recommended (but not required) to provide the offset it. Otherwise, 0733 * the NVTX handler will determine the offset from natural alignment rules. 0734 * In some cases, e.g. dynamic schema layouts, the offset cannot be set and 0735 * has to be determined based on the data of prior entries. 0736 * 0737 * Setting the offset can also be used to skip entries during payload parsing. 0738 */ 0739 uint64_t offset; 0740 0741 /** 0742 * \brief Additional semantics of the payload entry. 0743 * 0744 * The field points to the first element in a linked list, which enables 0745 * multiple semantic extensions. 0746 */ 0747 const nvtxSemanticsHeader_t* semantics; 0748 0749 /** 0750 * \brief Reserved for future use. Do not use it! 0751 */ 0752 const void* reserved; 0753 } nvtxPayloadSchemaEntry_t; 0754 0755 /** 0756 * \brief NVTX payload schema attributes. 0757 */ 0758 typedef struct nvtxPayloadSchemaAttr_v1 0759 { 0760 /** 0761 * \brief Mask of valid fields in this struct. 0762 * 0763 * Use the `NVTX_PAYLOAD_SCHEMA_ATTR_FIELD_*` defines. 0764 */ 0765 uint64_t fieldMask; 0766 0767 /** 0768 * \brief Name of the payload schema. (Optional) 0769 */ 0770 const char* name; 0771 0772 /** 0773 * \brief Payload schema type. (Mandatory) \anchor PAYLOAD_TYPE_FIELD 0774 * 0775 * Use the `NVTX_PAYLOAD_SCHEMA_TYPE_*` defines. 0776 */ 0777 uint64_t type; 0778 0779 /** 0780 * \brief Payload schema flags. (Optional) 0781 * 0782 * Flags defined by `NVTX_PAYLOAD_SCHEMA_FLAG_*` can be used to set 0783 * additional properties of the schema. 0784 */ 0785 uint64_t flags; 0786 0787 /** 0788 * \brief Entries of a payload schema. (Mandatory) \anchor ENTRIES_FIELD 0789 * 0790 * This field is a pointer to an array of schema entries, each describing a 0791 * field in a data structure, e.g. in a C struct or union. 0792 */ 0793 const nvtxPayloadSchemaEntry_t* entries; 0794 0795 /** 0796 * \brief Number of entries in the payload schema. (Mandatory) 0797 * 0798 * Number of entries in the array of payload entries \ref ENTRIES_FIELD. 0799 */ 0800 size_t numEntries; 0801 0802 /** 0803 * \brief The binary payload size in bytes for static payload schemas. 0804 * 0805 * If \ref PAYLOAD_TYPE_FIELD is @ref NVTX_PAYLOAD_SCHEMA_TYPE_DYNAMIC this 0806 * value is ignored. If this field is not specified for a schema of type 0807 * @ref NVTX_PAYLOAD_SCHEMA_TYPE_STATIC, the size can be automatically 0808 * determined by a tool. 0809 */ 0810 size_t payloadStaticSize; 0811 0812 /** 0813 * \brief The byte alignment for packed structures. 0814 * 0815 * If not specified, this field defaults to `0`, which means that the fields 0816 * in the data structure are not packed and natural alignment rules can be 0817 * applied. 0818 */ 0819 size_t packAlign; 0820 0821 /** 0822 * A static payload schema ID must be unique within the domain, 0823 * >= NVTX_PAYLOAD_SCHEMA_ID_STATIC_START and 0824 * < NVTX_PAYLOAD_SCHEMA_ID_DYNAMIC_START 0825 */ 0826 uint64_t schemaId; 0827 0828 /** 0829 * Flexible extension for schema attributes. 0830 * (Do not use. Reserved for future use.) 0831 */ 0832 void* extension; 0833 } nvtxPayloadSchemaAttr_t; 0834 0835 /** 0836 * \brief This type is used to describe an enumeration. 0837 * 0838 * Since the value of an enum entry might not be meaningful for the analysis 0839 * and/or visualization, a tool can show the name of enum entry instead. 0840 * 0841 * An array of this struct is passed to @ref nvtxPayloadEnumAttr_t::entries to be 0842 * finally registered via @ref nvtxPayloadEnumRegister with the NVTX handler. 0843 * 0844 * @note EXPERIMENTAL 0845 */ 0846 typedef struct nvtxPayloadEnum_v1 0847 { 0848 /** 0849 * Name of the enum value. 0850 */ 0851 const char* name; 0852 0853 /** 0854 * Value of the enum entry. 0855 */ 0856 uint64_t value; 0857 0858 /** 0859 * Indicates that this entry sets a specific set of bits, which can be used 0860 * to define bitsets. 0861 */ 0862 int8_t isFlag; 0863 } nvtxPayloadEnum_t; 0864 0865 /** 0866 * \brief NVTX payload enumeration type attributes. 0867 * 0868 * A pointer to this struct is passed to @ref nvtxPayloadEnumRegister. 0869 */ 0870 typedef struct nvtxPayloadEnumAttr_v1 0871 { 0872 /** 0873 * Mask of valid fields in this struct. See `NVTX_PAYLOAD_ENUM_ATTR_FIELD_*`. 0874 */ 0875 uint64_t fieldMask; 0876 0877 /** 0878 * Name of the enum. (Optional) 0879 */ 0880 const char* name; 0881 0882 /** 0883 * Entries of the enum. (Mandatory) 0884 */ 0885 const nvtxPayloadEnum_t* entries; 0886 0887 /** 0888 * Number of entries in the enum. (Mandatory) 0889 */ 0890 size_t numEntries; 0891 0892 /** 0893 * Size of enumeration type in bytes 0894 */ 0895 size_t sizeOfEnum; 0896 0897 /** 0898 * A static payload schema ID must be unique within the domain, 0899 * >= NVTX_PAYLOAD_SCHEMA_ID_STATIC_START and 0900 * < NVTX_PAYLOAD_SCHEMA_ID_DYNAMIC_START 0901 */ 0902 uint64_t schemaId; 0903 0904 /** 0905 * Flexible extension for enumeration attributes. 0906 * (Do not use. Reserved for future use.) 0907 */ 0908 void* extension; 0909 } nvtxPayloadEnumAttr_t; 0910 0911 typedef struct nvtxScopeAttr_v1 0912 { 0913 size_t structSize; 0914 0915 /** 0916 * Path delimited by '/' characters, relative to @ref parentScope. Leading 0917 * slashes are ignored. Nodes in the path may use name[key] syntax to 0918 * indicate an array of sibling nodes, which may be combined with other 0919 * non-array nodes or different arrays at the same scope. Node names should 0920 * be UTF8 printable characters. '\' has to be used to escape '/', '[', and 0921 * ']' characters in node names. An empty C string "" and `NULL` are valid 0922 * inputs and treated equivalently. 0923 * 0924 * A GPU can be specified using its: 0925 * - Unique identifier (UUID) with "GPU[UUID:#]", 0926 * - CUDA device ID (sensitive to CUDA_VISIBLE_DEVICES) with "GPU[CUDAID:#]", 0927 * - NVML (nvidia-smi) device ID with "GPU[NVSMI:#]" 0928 * 0929 * (replace `#` with the actual device ID). 0930 * For display purposes, a tool is recommended to show a pretty name. 0931 * To clearly identify a GPU, the @ref parentScope should also match 0932 * the GPU's execution context. 0933 */ 0934 const char* path; 0935 0936 /** Identifier of the parent scope, to which `path` is appended. */ 0937 uint64_t parentScope; 0938 0939 /** 0940 * Static scope ID. Must be unique within the domain, 0941 * >= NVTX_SCOPE_ID_STATIC_START, and < NVTX_SCOPE_ID_DYNAMIC_START. 0942 * Use NVTX_SCOPE_NONE to let the tool create a (dynamic) scope ID. 0943 */ 0944 uint64_t scopeId; 0945 } nvtxScopeAttr_t; 0946 0947 #endif /* NVTX_PAYLOAD_TYPEDEFS_V1 */ 0948 0949 #ifndef NVTX_PAYLOAD_TYPEDEFS_DEFERRED_V1 0950 #define NVTX_PAYLOAD_TYPEDEFS_DEFERRED_V1 0951 0952 /** Attributes of an NVTX time domain. */ 0953 typedef struct nvtxTimeDomainAttr_v1 0954 { 0955 /** Identifyer of the NVTX scope the time domain is associated with. */ 0956 uint64_t scopeId; 0957 0958 /** Predefined `NVTX_TIMESTAMP_TYPE_*`. */ 0959 uint64_t timestampTypeId; 0960 0961 /** 0962 * Static (feed-forward) time domain ID. `0` makes the tool generate the ID. 0963 * The static schema ID must be >= NVTX_TIME_DOMAIN_ID_STATIC_START and 0964 * < NVTX_TIME_DOMAIN_ID_DYNAMIC_START 0965 */ 0966 uint64_t timeDomainId; 0967 0968 /** Properties of the timer (use NVTX_TIMER_FLAG_*). */ 0969 uint64_t timerFlags; 0970 0971 /** Ticks per second (0 means unknown). */ 0972 int64_t timerResolution; 0973 0974 /** Point in time when the timer starts (use NVTX_TIMER_START_*). */ 0975 uint64_t timerStart; 0976 } nvtxTimeDomainAttr_t; 0977 0978 /** Synchronization point between two time domains. */ 0979 typedef struct nvtxSyncPoint_v1 0980 { 0981 int64_t src; 0982 int64_t dst; 0983 } nvtxSyncPoint_t; 0984 0985 /** 0986 * \brief Helper struct to submit a batch of events (marks or ranges). 0987 * 0988 * By default, events are assumed to be chronologically sorted by the first 0989 * timestamp in the event (start time in a range). If the events are not sorted, 0990 * the `flags` field must be set accordingly (see `NVTX_BATCH_FLAG_*`). 0991 */ 0992 typedef struct nvtxEventBatch_v1 0993 { 0994 /** 0995 * Identifier of the data layout of a deferred event in the array of events. 0996 * Only layouts with static payload size are allowed. The size of an event 0997 * in the array is specified by the static payload size during the schema 0998 * registration. The time domain of event timestamps is provided via time 0999 * semantics in the schema registration. 1000 */ 1001 uint64_t eventSchemaId; 1002 1003 /** Size of the array of deferred events (in bytes). */ 1004 size_t size; 1005 1006 /** Pointer to the array of deferred events. */ 1007 const void* events; 1008 1009 /** Scope of all events or counters in the batch. */ 1010 uint64_t scope; 1011 1012 /** Timestamp ordering (sorted, partially sorted, unsorted), etc. */ 1013 uint64_t flags; 1014 1015 /** Flexible data which can be referenced by events in the batch. */ 1016 const void* flexData; 1017 1018 /** Size of the flexible data memory blob. */ 1019 size_t flexDataSize; 1020 1021 /** 1022 * Offset from the `flexData` pointer to the begin of the flexible data 1023 * in bytes. 1024 */ 1025 size_t flexDataOffset; 1026 } nvtxEventBatch_t; 1027 1028 #endif /* NVTX_PAYLOAD_TYPEDEFS_DEFERRED_V1 */ 1029 1030 #ifndef NVTX_PAYLOAD_API_FUNCTIONS_V1 1031 #define NVTX_PAYLOAD_API_FUNCTIONS_V1 1032 1033 /** 1034 * \brief Register a payload schema. 1035 * 1036 * @param domain NVTX domain handle. 1037 * @param attr NVTX payload schema attributes. 1038 */ 1039 NVTX_DECLSPEC uint64_t NVTX_API nvtxPayloadSchemaRegister( 1040 nvtxDomainHandle_t domain, 1041 const nvtxPayloadSchemaAttr_t* attr); 1042 1043 /** 1044 * \brief Register an enumeration type with the payload extension. 1045 * 1046 * @param domain NVTX domain handle 1047 * @param attr NVTX payload enumeration type attributes. 1048 */ 1049 NVTX_DECLSPEC uint64_t NVTX_API nvtxPayloadEnumRegister( 1050 nvtxDomainHandle_t domain, 1051 const nvtxPayloadEnumAttr_t* attr); 1052 1053 /** 1054 * \brief Register a scope. 1055 * 1056 * @param domain NVTX domain handle 1057 * @param attr Scope attributes. 1058 * 1059 * @return an identifier for the scope. If the operation was not successful, 1060 * `NVTX_SCOPE_NONE` is returned. 1061 */ 1062 NVTX_DECLSPEC uint64_t NVTX_API nvtxScopeRegister( 1063 nvtxDomainHandle_t domain, 1064 const nvtxScopeAttr_t* attr); 1065 1066 /** 1067 * \brief Marks an instantaneous event in the application with the attributes 1068 * being passed via the extended payload. 1069 * 1070 * An NVTX handler can assume that the payload contains the event message. 1071 * Otherwise, it might ignore the event. 1072 * 1073 * @param domain NVTX domain handle 1074 * @param payloadData pointer to an array of structured payloads. 1075 * @param count number of payload BLOBs. 1076 */ 1077 NVTX_DECLSPEC void NVTX_API nvtxMarkPayload( 1078 nvtxDomainHandle_t domain, 1079 const nvtxPayloadData_t* payloadData, 1080 size_t count); 1081 1082 /** 1083 * \brief Begin a nested thread range with the attributes being passed via the 1084 * payload. 1085 * 1086 * @param domain NVTX domain handle 1087 * @param payloadData Pointer to an array of extended payloads. 1088 * @param count Number of payloads. 1089 * 1090 * @return The level of the range being ended. If an error occurs a negative 1091 * value is returned on the current thread. 1092 */ 1093 NVTX_DECLSPEC int NVTX_API nvtxRangePushPayload( 1094 nvtxDomainHandle_t domain, 1095 const nvtxPayloadData_t* payloadData, 1096 size_t count); 1097 1098 /** 1099 * \brief End a nested thread range with an additional custom payload. 1100 * 1101 * NVTX event attributes passed to this function (via the payloads) overwrite 1102 * event attributes (message and color) that have been set in the push event. 1103 * Other payload entries extend the data of the range. 1104 * 1105 * @param domain NVTX domain handle 1106 * @param payloadData pointer to an array of structured payloads. 1107 * @param count number of payload BLOBs. 1108 * 1109 * @return The level of the range being ended. If an error occurs a negative 1110 * value is returned on the current thread. 1111 */ 1112 NVTX_DECLSPEC int NVTX_API nvtxRangePopPayload( 1113 nvtxDomainHandle_t domain, 1114 const nvtxPayloadData_t* payloadData, 1115 size_t count); 1116 1117 /** 1118 * \brief Start a thread range with attributes passed via the extended payload. 1119 * 1120 * @param domain NVTX domain handle 1121 * @param payloadData pointer to an array of structured payloads. 1122 * @param count number of payload BLOBs. 1123 * 1124 * @return The level of the range being ended. If an error occurs a negative 1125 * value is returned on the current thread. 1126 */ 1127 NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxRangeStartPayload( 1128 nvtxDomainHandle_t domain, 1129 const nvtxPayloadData_t* payloadData, 1130 size_t count); 1131 1132 /** 1133 * \brief End a thread range and pass a custom payload. 1134 * 1135 * NVTX event attributes passed to this function (via the payloads) overwrite 1136 * event attributes (message and color) that have been set in the start event. 1137 * Other payload entries extend the data of the range. 1138 * 1139 * @param domain NVTX domain handle 1140 * @param id The correlation ID returned from a NVTX range start call. 1141 * @param payloadData pointer to an array of structured payloads. 1142 * @param count number of payload BLOBs. 1143 */ 1144 NVTX_DECLSPEC void NVTX_API nvtxRangeEndPayload( 1145 nvtxDomainHandle_t domain, 1146 nvtxRangeId_t id, 1147 const nvtxPayloadData_t* payloadData, 1148 size_t count); 1149 1150 /** 1151 * \brief Checks if the given NVTX domain is enabled. 1152 * 1153 * This function can be used to guard expensive code instrumentation. 1154 * In general, it is recommended to avoid different execution branches based on 1155 * NVTX instrumenation. 1156 * 1157 * If no tool is attached, this function will always return `0`. 1158 * If a tool is attached, but does not handle this function, `1` is returned. 1159 * If a tool is attached and handles this function, the return value is 1160 * determined by the tool. Positive (>0) return values indicate that the domain 1161 * is enabled, `0` indicates that the domain is disabled. 1162 * 1163 * @param domain NVTX domain handle 1164 * @return 0 if the domain is disabled. Values > 0 indicate an enabled domain. 1165 */ 1166 NVTX_DECLSPEC uint8_t NVTX_API nvtxDomainIsEnabled( 1167 nvtxDomainHandle_t domain); 1168 1169 #endif /* NVTX_PAYLOAD_API_FUNCTIONS_V1 */ 1170 1171 #ifndef NVTX_PAYLOAD_API_FUNCTIONS_DEFERRED_V1 1172 #define NVTX_PAYLOAD_API_FUNCTIONS_DEFERRED_V1 1173 1174 /** 1175 * Get a timestamp from the NVTX handler or tool. If no tool is attached, the 1176 * CPU TSC might be returned. No guarantees are made. 1177 * The returned timestamp is just meant to be used in deferred events/counters. 1178 */ 1179 NVTX_DECLSPEC int64_t NVTX_API nvtxTimestampGet(void); 1180 1181 /** 1182 * Register a time domain. Associates an NVTX scope with the time domain. 1183 * Timestamps of NVTX events or counters in the scope are interpreted according 1184 * to the time domain definitions. 1185 * 1186 * @param domain NVTX domain handle. 1187 * @param timeAttr Time domain attributes (timestamp type, scope, flags, etc.). 1188 * @return time domain ID. 1189 */ 1190 NVTX_DECLSPEC uint64_t NVTX_API nvtxTimeDomainRegister( 1191 nvtxDomainHandle_t domain, 1192 const nvtxTimeDomainAttr_t* timeAttr); 1193 1194 /** 1195 * Provide the pointer to a function that returns a timestamp. 1196 * This enables the tool to create time synchronization points. 1197 * 1198 * @param domain NVTX domain handle. 1199 * @param timeDomainId time domain identifier or timestamp type ID, if it is 1200 * unambiguous. 1201 * @param flags indicates if it is safe to call the timestamp provider after 1202 * process teardown. 1203 * @param timestampProviderFn Pointer to a function that returns a timestamp. 1204 */ 1205 NVTX_DECLSPEC void NVTX_API nvtxTimerSource( 1206 nvtxDomainHandle_t domain, 1207 uint64_t timeDomainId, 1208 uint64_t flags, 1209 int64_t (*timestampProviderFn)(void)); 1210 1211 /** 1212 * Same as `nvtxTimerSource`, but with an additional data pointer argument. 1213 * 1214 * @param domain NVTX domain handle. 1215 * @param timeDomainId time domain identifier or timestamp type ID, if it is 1216 * unambiguous. 1217 * @param flags indicates if it is safe to call the timestamp provider after 1218 * process teardown. 1219 * @param timestampProviderFn Pointer to a function that returns a timestamp. 1220 * @param data Pointer to data that is passed to the timestamp provider function. 1221 */ 1222 NVTX_DECLSPEC void NVTX_API nvtxTimerSourceWithData( 1223 nvtxDomainHandle_t domain, 1224 uint64_t timeDomainId, 1225 uint64_t flags, 1226 int64_t (*timestampProviderFn)(void* data), 1227 void* data); 1228 1229 /** 1230 * Provides a synchronization point between two time domains. 1231 * Two synchronization points are required to enable a timestamp conversion. 1232 * The tool must know one of the time domains or it least must be able to chain 1233 * conversions to enable the conversion between the given timestamps. 1234 * 1235 * @param domain NVTX domain handle. 1236 * @param timeDomainId1 time domain 1 ID or timestamp type ID, if it is 1237 * unambiguous. 1238 * @param timeDomainId2 time domain 2 ID or timestamp type ID, if it is 1239 * unambiguous. 1240 * @param timestamp1 Timestamp in the first time domain. 1241 * @param timestamp2 Timestamp in the second time domain. 1242 */ 1243 NVTX_DECLSPEC void NVTX_API nvtxTimeSyncPoint( 1244 nvtxDomainHandle_t domain, 1245 uint64_t timeDomainId1, 1246 uint64_t timeDomainId2, 1247 int64_t timestamp1, 1248 int64_t timestamp2); 1249 1250 /** 1251 * The same as `nvtxTimeSyncPoint` but with multiple synchronization points. 1252 * 1253 * @param domain NVTX domain handle. 1254 * @param timeDomainIdSrc source time domain ID or timestamp type ID, if it is 1255 * unambiguous. 1256 * @param timeDomainIdDst destination time domain ID or timestamp type ID, if it 1257 * is unambiguous. 1258 * @param syncPoints Pointer to an array of synchronization points. 1259 * @param count Number of synchronization points. 1260 */ 1261 NVTX_DECLSPEC void NVTX_API nvtxTimeSyncPointTable( 1262 nvtxDomainHandle_t domain, 1263 uint64_t timeDomainIdSrc, 1264 uint64_t timeDomainIdDst, 1265 const nvtxSyncPoint_t* syncPoints, 1266 size_t count); 1267 1268 /** 1269 * @brief Pass a conversion factor between two time domains to the NVTX handler. 1270 * 1271 * @param domain NVTX domain handle. 1272 * @param timeDomainIdSrc source time domain ID or timestamp type ID, if it is 1273 * unambiguous. 1274 * @param timeDomainIdDst destination time domain ID or timestamp type ID, if it 1275 * is unambiguous. 1276 * @param slope Conversion factor between the two time domains. 1277 * @param timestampSrc Timestamp in the source time domain. 1278 * @param timestampDst Timestamp in the destination time domain. 1279 */ 1280 NVTX_DECLSPEC void NVTX_API nvtxTimestampConversionFactor( 1281 nvtxDomainHandle_t domain, 1282 uint64_t timeDomainIdSrc, 1283 uint64_t timeDomainIdDst, 1284 double slope, 1285 int64_t timestampSrc, 1286 int64_t timestampDst); 1287 1288 /** 1289 * @brief Submit one deferred event. 1290 * 1291 * @param domain NVTX domain handle. 1292 * @param payloadData Pointer to an array of structured payloads. 1293 * @param numPayloads Number of payloads of the event. 1294 */ 1295 NVTX_DECLSPEC void NVTX_API nvtxEventSubmit( 1296 nvtxDomainHandle_t domain, 1297 const nvtxPayloadData_t* payloadData, 1298 size_t numPayloads); 1299 1300 /** 1301 * \brief Submit a batch of deferred events in the given domain. 1302 * 1303 * @param domain NVTX domain handle. 1304 * @param eventBatch Pointer to deferred events batch details. 1305 */ 1306 NVTX_DECLSPEC void NVTX_API nvtxEventBatchSubmit( 1307 nvtxDomainHandle_t domain, 1308 const nvtxEventBatch_t* eventBatch); 1309 1310 #endif /* NVTX_PAYLOAD_API_FUNCTIONS_DEFERRED_V1 */ 1311 1312 /** 1313 * \brief Callback IDs of API functions in the payload extension. 1314 * 1315 * The NVTX handler can use these values to register a handler function. When 1316 * `InitializeInjectionNvtxExtension(nvtxExtModuleInfo_t* moduleInfo)` is 1317 * executed, a handler routine can be registered as follows: 1318 * \code{.c} 1319 * moduleInfo->segments->slots[NVTX3EXT_CBID_nvtxPayloadSchemaRegister] = 1320 * (intptr_t)PayloadSchemaRegisterHandlerFn; 1321 * \endcode 1322 */ 1323 #ifndef NVTX_PAYLOAD_CALLBACK_ID_V1 1324 #define NVTX_PAYLOAD_CALLBACK_ID_V1 1325 1326 #define NVTX3EXT_CBID_nvtxPayloadSchemaRegister 0 1327 #define NVTX3EXT_CBID_nvtxPayloadEnumRegister 1 1328 #define NVTX3EXT_CBID_nvtxMarkPayload 2 1329 #define NVTX3EXT_CBID_nvtxRangePushPayload 3 1330 #define NVTX3EXT_CBID_nvtxRangePopPayload 4 1331 #define NVTX3EXT_CBID_nvtxRangeStartPayload 5 1332 #define NVTX3EXT_CBID_nvtxRangeEndPayload 6 1333 #define NVTX3EXT_CBID_nvtxDomainIsEnabled 7 1334 #define NVTX3EXT_CBID_nvtxScopeRegister 12 1335 1336 #endif /* NVTX_PAYLOAD_CALLBACK_ID_V1 */ 1337 1338 #ifndef NVTX_PAYLOAD_CALLBACK_ID_DEFERRED_V1 1339 #define NVTX_PAYLOAD_CALLBACK_ID_DEFERRED_V1 1340 1341 #define NVTX3EXT_CBID_nvtxTimestampGet 8 1342 #define NVTX3EXT_CBID_nvtxTimeDomainRegister 9 1343 #define NVTX3EXT_CBID_nvtxTimerSource 10 1344 #define NVTX3EXT_CBID_nvtxTimerSourceWithData 11 1345 #define NVTX3EXT_CBID_nvtxTimeSyncPoint 13 1346 #define NVTX3EXT_CBID_nvtxTimeSyncPointTable 14 1347 #define NVTX3EXT_CBID_nvtxTimestampConversionFactor 15 1348 #define NVTX3EXT_CBID_nvtxEventSubmit 16 1349 #define NVTX3EXT_CBID_nvtxEventBatchSubmit 17 1350 1351 #endif /* NVTX_PAYLOAD_CALLBACK_ID_DEFERRED_V1 */ 1352 1353 /*** Helper utilities ***/ 1354 1355 /** \brief Helper macro for safe double-cast of pointer to uint64_t value. */ 1356 #ifndef NVTX_POINTER_AS_PAYLOAD_ULLVALUE 1357 # ifdef __cplusplus 1358 # define NVTX_POINTER_AS_PAYLOAD_ULLVALUE(p) \ 1359 static_cast<uint64_t>(reinterpret_cast<uintptr_t>(p)) 1360 # else 1361 #define NVTX_POINTER_AS_PAYLOAD_ULLVALUE(p) (NVTX_STATIC_CAST(uint64_t, NVTX_STATIC_CAST(uintptr_t, p)) 1362 # endif 1363 #endif 1364 1365 #ifndef NVTX_PAYLOAD_EVTATTR_SET_DATA 1366 /** 1367 * \brief Helper macro to attach a single payload to an NVTX event attribute. 1368 * 1369 * @param evtAttr NVTX event attribute (variable name) 1370 * @param pldata_addr Address of `nvtxPayloadData_t` variable. 1371 * @param schema_id NVTX binary payload schema ID. 1372 * @param pl_addr Address of the (actual) payload. 1373 * @param sz size of the (actual) payload. 1374 */ 1375 #define NVTX_PAYLOAD_EVTATTR_SET_DATA(evtAttr, pldata_addr, schema_id, pl_addr, sz) \ 1376 (pldata_addr)->schemaId = schema_id; \ 1377 (pldata_addr)->size = sz; \ 1378 (pldata_addr)->payload = pl_addr; \ 1379 (evtAttr).payload.ullValue = NVTX_POINTER_AS_PAYLOAD_ULLVALUE(pldata_addr); \ 1380 (evtAttr).payloadType = NVTX_PAYLOAD_TYPE_EXT; \ 1381 (evtAttr).reserved0 = 1; 1382 #endif /* NVTX_PAYLOAD_EVTATTR_SET_DATA */ 1383 1384 #ifndef NVTX_PAYLOAD_EVTATTR_SET_MULTIPLE 1385 /** 1386 * \brief Helper macro to attach multiple payloads to an NVTX event attribute. 1387 * 1388 * @param evtAttr NVTX event attribute (variable name) 1389 * @param pldata Payload data array (of type `nvtxPayloadData_t`) 1390 */ 1391 #define NVTX_PAYLOAD_EVTATTR_SET_MULTIPLE(evtAttr, pldata) \ 1392 (evtAttr).payloadType = NVTX_PAYLOAD_TYPE_EXT; \ 1393 (evtAttr).reserved0 = sizeof(pldata)/sizeof(nvtxPayloadData_t); \ 1394 (evtAttr).payload.ullValue = NVTX_POINTER_AS_PAYLOAD_ULLVALUE(pldata); 1395 #endif /* NVTX_PAYLOAD_EVTATTR_SET_MULTIPLE */ 1396 1397 #ifndef NVTX_PAYLOAD_EVTATTR_SET 1398 /* 1399 * Do not use this macro directly! It is a helper to attach a single payload to 1400 * an NVTX event attribute. 1401 * @warning The NVTX push, start or mark operation must not be in an outer scope. 1402 */ 1403 #define NVTX_PAYLOAD_EVTATTR_SET(evtAttr, schema_id, pl_addr, sz) \ 1404 nvtxPayloadData_t _NVTX_PAYLOAD_DATA_VAR[] = \ 1405 {{schema_id, sz, pl_addr}}; \ 1406 (evtAttr)->payload.ullValue = \ 1407 NVTX_POINTER_AS_PAYLOAD_ULLVALUE(_NVTX_PAYLOAD_DATA_VAR); \ 1408 (evtAttr)->payloadType = NVTX_PAYLOAD_TYPE_EXT; \ 1409 (evtAttr)->reserved0 = 1; 1410 #endif /* NVTX_PAYLOAD_EVTATTR_SET */ 1411 1412 #ifndef nvtxPayloadRangePush 1413 /** 1414 * \brief Helper macro to push a range with extended payload. 1415 * 1416 * @param domain NVTX domain handle 1417 * @param evtAttr pointer to NVTX event attribute. 1418 * @param schemaId NVTX payload schema ID 1419 * @param plAddr Pointer to the binary data (actual payload) 1420 * @param size Size of the binary payload data in bytes. 1421 */ 1422 #define nvtxPayloadRangePush(domain, evtAttr, schemaId, plAddr, size) \ 1423 do { \ 1424 NVTX_PAYLOAD_EVTATTR_SET(evtAttr, schemaId, plAddr, size) \ 1425 nvtxDomainRangePushEx(domain, evtAttr); \ 1426 } while (0) 1427 #endif /* nvtxPayloadRangePush */ 1428 1429 #ifndef nvtxPayloadMark 1430 /** 1431 * \brief Helper macro to set a marker with extended payload. 1432 * 1433 * @param domain NVTX domain handle 1434 * @param evtAttr pointer to NVTX event attribute. 1435 * @param schemaId NVTX payload schema ID 1436 * @param plAddr Pointer to the binary data (actual payload) 1437 * @param size Size of the binary payload data in bytes. 1438 */ 1439 #define nvtxPayloadMark(domain, evtAttr, schemaId, plAddr, size) \ 1440 do { \ 1441 NVTX_PAYLOAD_EVTATTR_SET(evtAttr, schemaId, plAddr, size) \ 1442 nvtxDomainMarkEx(domain, evtAttr); \ 1443 } while (0) 1444 #endif /* nvtxPayloadMark */ 1445 1446 /* Macros to create versioned symbols. */ 1447 #ifndef NVTX_EXT_PAYLOAD_VERSIONED_IDENTIFIERS_V1 1448 #define NVTX_EXT_PAYLOAD_VERSIONED_IDENTIFIERS_V1 1449 #define NVTX_EXT_PAYLOAD_VERSIONED_IDENTIFIER_L3(NAME, VERSION, COMPATID) \ 1450 NAME##_v##VERSION##_bpl##COMPATID 1451 #define NVTX_EXT_PAYLOAD_VERSIONED_IDENTIFIER_L2(NAME, VERSION, COMPATID) \ 1452 NVTX_EXT_PAYLOAD_VERSIONED_IDENTIFIER_L3(NAME, VERSION, COMPATID) 1453 #define NVTX_EXT_PAYLOAD_VERSIONED_ID(NAME) \ 1454 NVTX_EXT_PAYLOAD_VERSIONED_IDENTIFIER_L2(NAME, NVTX_VERSION, NVTX_EXT_PAYLOAD_COMPATID) 1455 #endif /* NVTX_EXT_PAYLOAD_VERSIONED_IDENTIFIERS_V1 */ 1456 1457 #ifdef __GNUC__ 1458 #pragma GCC visibility push(internal) 1459 #endif 1460 1461 /* Extension types are required for the implementation and the NVTX handler. */ 1462 #define NVTX_EXT_TYPES_GUARD 1463 #include "nvtxDetail/nvtxExtTypes.h" 1464 #undef NVTX_EXT_TYPES_GUARD 1465 1466 #ifndef NVTX_NO_IMPL 1467 #define NVTX_EXT_IMPL_PAYLOAD_GUARD 1468 #include "nvtxDetail/nvtxExtImplPayload_v1.h" 1469 #undef NVTX_EXT_IMPL_PAYLOAD_GUARD 1470 #endif /* NVTX_NO_IMPL */ 1471 1472 #ifdef __GNUC__ 1473 #pragma GCC visibility pop 1474 #endif 1475 1476 #ifdef __cplusplus 1477 } 1478 #endif /* __cplusplus */
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|