NVTX C API Reference v3
NVIDIA Tools Extension Library
Loading...
Searching...
No Matches
nvToolsExtCounters.h
1/*
2 * SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * Licensed under the Apache License v2.0 with LLVM Exceptions.
18 * See https://nvidia.github.io/NVTX/LICENSE.txt for license information.
19 */
20
21#if defined(NVTX_AS_SYSTEM_HEADER)
22#if defined(__clang__)
23#pragma clang system_header
24#elif defined(__GNUC__) || defined(__NVCOMPILER)
25#pragma GCC system_header
26#elif defined(_MSC_VER)
27#pragma system_header
28#endif
29#endif
30
31#include "nvToolsExtPayload.h"
32
36#ifndef NVTX_EXT_COUNTERS_COMPATID
37#define NVTX_EXT_COUNTERS_COMPATID 0x0102
38#endif
39
44#ifndef NVTX_EXT_COUNTERS_MODULEID
45#define NVTX_EXT_COUNTERS_MODULEID 4
46#endif
47
48#ifndef NVTX_COUNTER_IDS_V1
49#define NVTX_COUNTER_IDS_V1
50
52#define NVTX_COUNTER_ID_NONE 0
53
55#define NVTX_COUNTER_ID_STATIC_START (1 << 24)
56
58#define NVTX_COUNTER_ID_DYNAMIC_START (NVTX_STATIC_CAST(uint64_t, 1) << 32)
59
60#endif /* NVTX_COUNTER_IDS_V1 */
61
63#ifndef NVTX_COUNTER_SAMPLES_V1
64#define NVTX_COUNTER_SAMPLES_V1
65
66#define NVTX_COUNTER_SAMPLE_ZERO 0
67#define NVTX_COUNTER_SAMPLE_UNCHANGED 1
68#define NVTX_COUNTER_SAMPLE_UNAVAILABLE 2 /* Failed to get a counter sample. */
69
70#endif /* NVTX_COUNTER_SAMPLES_V1 */
71
77#ifndef NVTX_COUNTER_BATCH_FLAGS_V1
78#define NVTX_COUNTER_BATCH_FLAGS_V1
79
80#define NVTX_COUNTER_BATCH_FLAG_BEGINTIME_INTERVAL_PAIR (1 << 32)
81#define NVTX_COUNTER_BATCH_FLAG_ENDTIME_INTERVAL_PAIR (2 << 32)
82
83#endif /* NVTX_COUNTER_BATCH_FLAGS_V1 */
84
85#ifdef __cplusplus
86extern "C" {
87#endif /* __cplusplus */
88
89#ifndef NVTX_COUNTER_TYPEDEFS_V1
90#define NVTX_COUNTER_TYPEDEFS_V1
91
95typedef struct nvtxCounterAttr_v1
96{
97 size_t structSize;
98
103 uint64_t schemaId;
104
106 const char* name;
107
112 const char* description;
113
120 uint64_t scopeId;
121
130
136 uint64_t counterId;
138
147typedef struct nvtxCounterBatch_v1
148{
153 uint64_t counterId;
154
156 const void* counters;
157
160
165 uint64_t flags;
166
175 const int64_t* timestamps;
176
180
181#endif /* NVTX_COUNTER_TYPEDEFS_V1 */
182
183#ifndef NVTX_COUNTER_API_FUNCTIONS_V1
184#define NVTX_COUNTER_API_FUNCTIONS_V1
185
195NVTX_DECLSPEC uint64_t NVTX_API nvtxCounterRegister(
196 nvtxDomainHandle_t hDomain,
197 const nvtxCounterAttr_t* attr);
198
207NVTX_DECLSPEC void NVTX_API nvtxCounterSampleInt64(
208 nvtxDomainHandle_t hDomain,
209 uint64_t counterId,
210 int64_t value);
211
220NVTX_DECLSPEC void NVTX_API nvtxCounterSampleFloat64(
221 nvtxDomainHandle_t hDomain,
222 uint64_t counterId,
223 double value);
224
234NVTX_DECLSPEC void NVTX_API nvtxCounterSample(
235 nvtxDomainHandle_t hDomain,
236 uint64_t counterId,
237 const void* value,
238 size_t size);
239
247NVTX_DECLSPEC void NVTX_API nvtxCounterSampleNoValue(
248 nvtxDomainHandle_t hDomain,
249 uint64_t counterId,
250 uint8_t reason);
251
262NVTX_DECLSPEC void NVTX_API nvtxCounterBatchSubmit(
263 nvtxDomainHandle_t hDomain,
264 const nvtxCounterBatch_t* counterData);
265
266#endif /* NVTX_COUNTER_API_FUNCTIONS_V1 */
267
268#ifndef NVTX_COUNTER_CALLBACK_ID_V1
269#define NVTX_COUNTER_CALLBACK_ID_V1
270
271#define NVTX3EXT_CBID_nvtxCounterRegister 0
272#define NVTX3EXT_CBID_nvtxCounterSampleInt64 1
273#define NVTX3EXT_CBID_nvtxCounterSampleFloat64 2
274#define NVTX3EXT_CBID_nvtxCounterSample 3
275#define NVTX3EXT_CBID_nvtxCounterSampleNoValue 4
276#define NVTX3EXT_CBID_nvtxCounterBatchSubmit 5
277
278#endif /* NVTX_COUNTER_CALLBACK_ID_V1 */
279
280/* Macros to create versioned symbols. */
281#ifndef NVTX_EXT_COUNTERS_VERSIONED_IDENTIFIERS_V1
282#define NVTX_EXT_COUNTERS_VERSIONED_IDENTIFIERS_V1
283#define NVTX_EXT_COUNTERS_VERSIONED_IDENTIFIER_L3(NAME, VERSION, COMPATID) \
284 NAME##_v##VERSION##_cnt##COMPATID
285#define NVTX_EXT_COUNTERS_VERSIONED_IDENTIFIER_L2(NAME, VERSION, COMPATID) \
286 NVTX_EXT_COUNTERS_VERSIONED_IDENTIFIER_L3(NAME, VERSION, COMPATID)
287#define NVTX_EXT_COUNTERS_VERSIONED_ID(NAME) \
288 NVTX_EXT_COUNTERS_VERSIONED_IDENTIFIER_L2(NAME, NVTX_VERSION, NVTX_EXT_COUNTERS_COMPATID)
289#endif /* NVTX_EXT_COUNTERS_VERSIONED_IDENTIFIERS_V1 */
290
291#ifdef __GNUC__
292#pragma GCC visibility push(internal)
293#endif
294
295#define NVTX_EXT_TYPES_GUARD /* Ensure other headers cannot be included directly. */
296#include "nvtxDetail/nvtxExtTypes.h"
297#undef NVTX_EXT_TYPES_GUARD
298
299#ifndef NVTX_NO_IMPL
300#define NVTX_EXT_IMPL_COUNTERS_GUARD /* Ensure other headers cannot be included directly. */
301#include "nvtxDetail/nvtxExtImplCounters_v1.h"
302#undef NVTX_EXT_IMPL_COUNTERS_GUARD
303#endif /*NVTX_NO_IMPL*/
304
305#ifdef __GNUC__
306#pragma GCC visibility pop
307#endif
308
309#ifdef __cplusplus
310}
311#endif /* __cplusplus */
Attributes of a counter or counter group.
const nvtxSemanticsHeader_t * semantics
Helper struct to submit a batch of counters.
const int64_t * timestamps
Header of the payload entry's semantic field.