NVTX C API Reference v3
NVIDIA Tools Extension Library
Loading...
Searching...
No Matches
nvToolsExt.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: Copyright (c) 2009-2022 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 LICENSE.txt for license information.
19 */
20
24/* ========================================================================= */
161#if defined(NVTX_VERSION) && NVTX_VERSION < 3
162#error "Trying to #include NVTX version 3 in a source file where an older NVTX version has already been included. If you are not directly using NVTX (the NVIDIA Tools Extension library), you are getting this error because libraries you are using have included different versions of NVTX. Suggested solutions are: (1) reorder #includes so the newest NVTX version is included first, (2) avoid using the conflicting libraries in the same .c/.cpp file, or (3) update the library using the older NVTX version to use the newer version instead."
163#endif
164
165/* Header guard */
166#if !defined(NVTX_VERSION)
167#define NVTX_VERSION 3
168
169#if defined(_MSC_VER)
170#define NVTX_API __stdcall
171#define NVTX_INLINE_STATIC __inline static
172#else /*defined(__GNUC__)*/
173#define NVTX_API
174#if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
175#define NVTX_INLINE_STATIC inline static
176#else
177#define NVTX_INLINE_STATIC __inline__ static
178#endif
179#endif /* Platform */
180
181#if defined(NVTX_NO_IMPL)
182/* When omitting implementation, avoid declaring functions inline */
183/* without definitions, since this causes compiler warnings. */
184#define NVTX_DECLSPEC
185#elif defined(NVTX_EXPORT_API)
186/* Allow overriding definition of NVTX_DECLSPEC when exporting API. */
187/* Default is empty, meaning non-inline with external linkage. */
188#if !defined(NVTX_DECLSPEC)
189#define NVTX_DECLSPEC
190#endif
191#else
192/* Normal NVTX usage defines the NVTX API inline with static */
193/* (internal) linkage. */
194#define NVTX_DECLSPEC NVTX_INLINE_STATIC
195#endif
196
197#include "nvtxDetail/nvtxLinkOnce.h"
198
199#define NVTX_VERSIONED_IDENTIFIER_L3(NAME, VERSION) NAME##_v##VERSION
200#define NVTX_VERSIONED_IDENTIFIER_L2(NAME, VERSION) NVTX_VERSIONED_IDENTIFIER_L3(NAME, VERSION)
201#define NVTX_VERSIONED_IDENTIFIER(NAME) NVTX_VERSIONED_IDENTIFIER_L2(NAME, NVTX_VERSION)
202
221#ifndef NVTX_STDINT_TYPES_ALREADY_DEFINED
222#include <stdint.h>
223#endif
224
225#include <stddef.h>
226
227#ifdef __cplusplus
228extern "C" {
229#endif /* __cplusplus */
230
235#define NVTX_SUCCESS 0
236#define NVTX_FAIL 1
237#define NVTX_ERR_INIT_LOAD_PROPERTY 2
238#define NVTX_ERR_INIT_ACCESS_LIBRARY 3
239#define NVTX_ERR_INIT_LOAD_LIBRARY 4
240#define NVTX_ERR_INIT_MISSING_LIBRARY_ENTRY_POINT 5
241#define NVTX_ERR_INIT_FAILED_LIBRARY_ENTRY_POINT 6
242#define NVTX_ERR_NO_INJECTION_LIBRARY_AVAILABLE 7
243
247#define NVTX_EVENT_ATTRIB_STRUCT_SIZE ( (uint16_t)( sizeof(nvtxEventAttributes_t) ) )
248
249#define NVTX_NO_PUSH_POP_TRACKING ((int)-2)
250
251typedef uint64_t nvtxRangeId_t;
252
253/* Forward declaration of opaque domain registration structure */
254struct nvtxDomainRegistration_st;
255typedef struct nvtxDomainRegistration_st nvtxDomainRegistration;
256
257/* \brief Domain Handle Structure.
258* \anchor DOMAIN_HANDLE_STRUCTURE
259*
260* This structure is opaque to the user and is used as a handle to reference
261* a domain. This type is returned from tools when using the NVTX API to
262* create a domain.
263*
264*/
265typedef nvtxDomainRegistration* nvtxDomainHandle_t;
266
267/* Forward declaration of opaque string registration structure */
268struct nvtxStringRegistration_st;
269typedef struct nvtxStringRegistration_st nvtxStringRegistration;
270
271/* \brief Registered String Handle Structure.
272* \anchor REGISTERED_STRING_HANDLE_STRUCTURE
273*
274* This structure is opaque to the user and is used as a handle to reference
275* a registered string. This type is returned from tools when using the NVTX
276* API to create a registered string.
277*
278*/
279typedef nvtxStringRegistration* nvtxStringHandle_t;
280
281/* ========================================================================= */
294
308
310{
311 const char* ascii;
312 const wchar_t* unicode;
313 /* NVTX_VERSION_2 */
314 nvtxStringHandle_t registered;
316
317
/*END defgroup*/
319/* ------------------------------------------------------------------------- */
341NVTX_DECLSPEC void NVTX_API nvtxInitialize(const void* reserved);
/*END defgroup*/
346
347/* ========================================================================= */
366
445{
453 uint16_t version;
454
461 uint16_t size;
462
474 uint32_t category;
475
483 int32_t colorType; /* nvtxColorType_t */
484
489 uint32_t color;
490
499 int32_t payloadType; /* nvtxPayloadType_t */
500
501 int32_t reserved0;
502
510 {
511 uint64_t ullValue;
512 int64_t llValue;
513 double dValue;
514 /* NVTX_VERSION_2 */
515 uint32_t uiValue;
516 int32_t iValue;
517 float fValue;
518 } payload;
519
527 int32_t messageType; /* nvtxMessageType_t */
528
534
536
537typedef struct nvtxEventAttributes_v2 nvtxEventAttributes_t;
538
/*END defgroup*/
540/* ========================================================================= */
550/* ------------------------------------------------------------------------- */
570NVTX_DECLSPEC void NVTX_API nvtxDomainMarkEx(nvtxDomainHandle_t domain, const nvtxEventAttributes_t* eventAttrib);
573/* ------------------------------------------------------------------------- */
606NVTX_DECLSPEC void NVTX_API nvtxMarkEx(const nvtxEventAttributes_t* eventAttrib);
609/* ------------------------------------------------------------------------- */
629NVTX_DECLSPEC void NVTX_API nvtxMarkA(const char* message);
630NVTX_DECLSPEC void NVTX_API nvtxMarkW(const wchar_t* message);
636/* ------------------------------------------------------------------------- */
665NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxDomainRangeStartEx(nvtxDomainHandle_t domain, const nvtxEventAttributes_t* eventAttrib);
668/* ------------------------------------------------------------------------- */
699NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxRangeStartEx(const nvtxEventAttributes_t* eventAttrib);
702/* ------------------------------------------------------------------------- */
726NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxRangeStartA(const char* message);
727NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxRangeStartW(const wchar_t* message);
730/* ------------------------------------------------------------------------- */
757NVTX_DECLSPEC void NVTX_API nvtxDomainRangeEnd(nvtxDomainHandle_t domain, nvtxRangeId_t id);
760/* ------------------------------------------------------------------------- */
773NVTX_DECLSPEC void NVTX_API nvtxRangeEnd(nvtxRangeId_t id);
778/* ------------------------------------------------------------------------- */
814NVTX_DECLSPEC int NVTX_API nvtxDomainRangePushEx(nvtxDomainHandle_t domain, const nvtxEventAttributes_t* eventAttrib);
817/* ------------------------------------------------------------------------- */
852NVTX_DECLSPEC int NVTX_API nvtxRangePushEx(const nvtxEventAttributes_t* eventAttrib);
855/* ------------------------------------------------------------------------- */
877NVTX_DECLSPEC int NVTX_API nvtxRangePushA(const char* message);
878NVTX_DECLSPEC int NVTX_API nvtxRangePushW(const wchar_t* message);
882/* ------------------------------------------------------------------------- */
904NVTX_DECLSPEC int NVTX_API nvtxDomainRangePop(nvtxDomainHandle_t domain);
907/* ------------------------------------------------------------------------- */
928NVTX_DECLSPEC int NVTX_API nvtxRangePop(void);
/*END defgroup*/
933/* ========================================================================= */
942/* ------------------------------------------------------------------------- */
944/* ------------------------------------------------------------------------- */
945
946/* ------------------------------------------------------------------------- */
953#define NVTX_RESOURCE_MAKE_TYPE(CLASS, INDEX) ((((uint32_t)(NVTX_RESOURCE_CLASS_ ## CLASS))<<16)|((uint32_t)(INDEX)))
954#define NVTX_RESOURCE_CLASS_GENERIC 1
957/* ------------------------------------------------------------------------- */
966{
967 NVTX_RESOURCE_TYPE_UNKNOWN = 0,
968 NVTX_RESOURCE_TYPE_GENERIC_POINTER = NVTX_RESOURCE_MAKE_TYPE(GENERIC, 1),
969 NVTX_RESOURCE_TYPE_GENERIC_HANDLE = NVTX_RESOURCE_MAKE_TYPE(GENERIC, 2),
970 NVTX_RESOURCE_TYPE_GENERIC_THREAD_NATIVE = NVTX_RESOURCE_MAKE_TYPE(GENERIC, 3),
971 NVTX_RESOURCE_TYPE_GENERIC_THREAD_POSIX = NVTX_RESOURCE_MAKE_TYPE(GENERIC, 4)
973
974
975
1052{
1060 uint16_t version;
1061
1068 uint16_t size;
1069
1078 int32_t identifierType; /* values from enums following the pattern nvtxResource[name]Type_t */
1079
1088 {
1089 const void* pValue;
1090 uint64_t ullValue;
1091 } identifier;
1092
1100 int32_t messageType; /* nvtxMessageType_t */
1101
1107
1109
1110typedef struct nvtxResourceAttributes_v0 nvtxResourceAttributes_t;
1111
1112/* \cond SHOW_HIDDEN
1113* \version \NVTX_VERSION_2
1114*/
1115#define NVTX_RESOURCE_ATTRIB_STRUCT_SIZE ( (uint16_t)( sizeof(nvtxResourceAttributes_v0) ) )
1116typedef struct nvtxResourceHandle* nvtxResourceHandle_t;
1121/* ------------------------------------------------------------------------- */
1151NVTX_DECLSPEC nvtxResourceHandle_t NVTX_API nvtxDomainResourceCreate(nvtxDomainHandle_t domain, nvtxResourceAttributes_t* attribs);
1154/* ------------------------------------------------------------------------- */
1181NVTX_DECLSPEC void NVTX_API nvtxDomainResourceDestroy(nvtxResourceHandle_t resource);
1187/* ------------------------------------------------------------------------- */
1215NVTX_DECLSPEC void NVTX_API nvtxDomainNameCategoryA(nvtxDomainHandle_t domain, uint32_t category, const char* name);
1216NVTX_DECLSPEC void NVTX_API nvtxDomainNameCategoryW(nvtxDomainHandle_t domain, uint32_t category, const wchar_t* name);
1240NVTX_DECLSPEC void NVTX_API nvtxNameCategoryA(uint32_t category, const char* name);
1241NVTX_DECLSPEC void NVTX_API nvtxNameCategoryW(uint32_t category, const wchar_t* name);
1246/* ------------------------------------------------------------------------- */
1307NVTX_DECLSPEC void NVTX_API nvtxNameOsThreadA(uint32_t threadId, const char* name);
1308NVTX_DECLSPEC void NVTX_API nvtxNameOsThreadW(uint32_t threadId, const wchar_t* name);
/*END defgroup*/
1313/* ========================================================================= */
1325/* ------------------------------------------------------------------------- */
1356NVTX_DECLSPEC nvtxStringHandle_t NVTX_API nvtxDomainRegisterStringA(nvtxDomainHandle_t domain, const char* string);
1357NVTX_DECLSPEC nvtxStringHandle_t NVTX_API nvtxDomainRegisterStringW(nvtxDomainHandle_t domain, const wchar_t* string);
/*END defgroup*/
1361/* ========================================================================= */
1380/* ------------------------------------------------------------------------- */
1419NVTX_DECLSPEC nvtxDomainHandle_t NVTX_API nvtxDomainCreateA(const char* name);
1420NVTX_DECLSPEC nvtxDomainHandle_t NVTX_API nvtxDomainCreateW(const wchar_t* name);
1423/* ------------------------------------------------------------------------- */
1443NVTX_DECLSPEC void NVTX_API nvtxDomainDestroy(nvtxDomainHandle_t domain);
/*END defgroup*/
1448/* ========================================================================= */
1451#ifdef UNICODE
1452 #define nvtxMark nvtxMarkW
1453 #define nvtxRangeStart nvtxRangeStartW
1454 #define nvtxRangePush nvtxRangePushW
1455 #define nvtxNameCategory nvtxNameCategoryW
1456 #define nvtxNameOsThread nvtxNameOsThreadW
1457 /* NVTX_VERSION_2 */
1458 #define nvtxDomainCreate nvtxDomainCreateW
1459 #define nvtxDomainRegisterString nvtxDomainRegisterStringW
1460 #define nvtxDomainNameCategory nvtxDomainNameCategoryW
1461#else
1462 #define nvtxMark nvtxMarkA
1463 #define nvtxRangeStart nvtxRangeStartA
1464 #define nvtxRangePush nvtxRangePushA
1465 #define nvtxNameCategory nvtxNameCategoryA
1466 #define nvtxNameOsThread nvtxNameOsThreadA
1467 /* NVTX_VERSION_2 */
1468 #define nvtxDomainCreate nvtxDomainCreateA
1469 #define nvtxDomainRegisterString nvtxDomainRegisterStringA
1470 #define nvtxDomainNameCategory nvtxDomainNameCategoryA
1471#endif
1472
1475#ifdef __cplusplus
1476} /* extern "C" */
1477#endif /* __cplusplus */
1478
1479#define NVTX_IMPL_GUARD /* Ensure other headers cannot be included directly */
1480
1481#include "nvtxDetail/nvtxTypes.h"
1482
1483#ifndef NVTX_NO_IMPL
1484#include "nvtxDetail/nvtxImpl.h"
1485#endif /*NVTX_NO_IMPL*/
1486
1487#undef NVTX_IMPL_GUARD
1488
1489#endif /* !defined(NVTX_VERSION) */
NVTX_DECLSPEC nvtxDomainHandle_t NVTX_API nvtxDomainCreateA(const char *name)
Register a NVTX domain.
NVTX_DECLSPEC void NVTX_API nvtxDomainDestroy(nvtxDomainHandle_t domain)
Unregister a NVTX domain.
nvtxPayloadType_t
Definition nvToolsExt.h:356
@ NVTX_PAYLOAD_TYPE_INT32
Definition nvToolsExt.h:363
@ NVTX_PAYLOAD_TYPE_DOUBLE
Definition nvToolsExt.h:360
@ NVTX_PAYLOAD_UNKNOWN
Definition nvToolsExt.h:357
@ NVTX_PAYLOAD_TYPE_UNSIGNED_INT32
Definition nvToolsExt.h:362
@ NVTX_PAYLOAD_TYPE_FLOAT
Definition nvToolsExt.h:364
@ NVTX_PAYLOAD_TYPE_INT64
Definition nvToolsExt.h:359
@ NVTX_PAYLOAD_TYPE_UNSIGNED_INT64
Definition nvToolsExt.h:358
nvtxColorType_t
Definition nvToolsExt.h:290
nvtxMessageType_t
Definition nvToolsExt.h:299
@ NVTX_COLOR_ARGB
Definition nvToolsExt.h:292
@ NVTX_COLOR_UNKNOWN
Definition nvToolsExt.h:291
@ NVTX_MESSAGE_TYPE_REGISTERED
Definition nvToolsExt.h:304
@ NVTX_MESSAGE_TYPE_UNICODE
Definition nvToolsExt.h:302
@ NVTX_MESSAGE_TYPE_ASCII
Definition nvToolsExt.h:301
@ NVTX_MESSAGE_UNKNOWN
Definition nvToolsExt.h:300
NVTX_DECLSPEC int NVTX_API nvtxDomainRangePop(nvtxDomainHandle_t domain)
Ends a nested thread range.
NVTX_DECLSPEC void NVTX_API nvtxDomainRangeEnd(nvtxDomainHandle_t domain, nvtxRangeId_t id)
Ends a process range.
NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxRangeStartA(const char *message)
Starts a process range.
NVTX_DECLSPEC int NVTX_API nvtxRangePop(void)
Ends a nested thread range.
NVTX_DECLSPEC int NVTX_API nvtxDomainRangePushEx(nvtxDomainHandle_t domain, const nvtxEventAttributes_t *eventAttrib)
Starts a nested thread range.
NVTX_DECLSPEC void NVTX_API nvtxRangeEnd(nvtxRangeId_t id)
Ends a process range.
NVTX_DECLSPEC int NVTX_API nvtxRangePushA(const char *message)
Starts a nested thread range.
NVTX_DECLSPEC void NVTX_API nvtxDomainMarkEx(nvtxDomainHandle_t domain, const nvtxEventAttributes_t *eventAttrib)
Marks an instantaneous event in the application.
NVTX_DECLSPEC void NVTX_API nvtxMarkEx(const nvtxEventAttributes_t *eventAttrib)
Marks an instantaneous event in the application.
NVTX_DECLSPEC void NVTX_API nvtxMarkA(const char *message)
Marks an instantaneous event in the application.
NVTX_DECLSPEC int NVTX_API nvtxRangePushEx(const nvtxEventAttributes_t *eventAttrib)
Starts a nested thread range.
NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxRangeStartEx(const nvtxEventAttributes_t *eventAttrib)
Starts a process range.
NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxDomainRangeStartEx(nvtxDomainHandle_t domain, const nvtxEventAttributes_t *eventAttrib)
Starts a process range in a domain.
NVTX_DECLSPEC nvtxResourceHandle_t NVTX_API nvtxDomainResourceCreate(nvtxDomainHandle_t domain, nvtxResourceAttributes_t *attribs)
Create a resource object to track and associate data with OS and middleware objects.
NVTX_DECLSPEC void NVTX_API nvtxNameCategoryA(uint32_t category, const char *name)
Annotate an NVTX category.
NVTX_DECLSPEC void NVTX_API nvtxDomainResourceDestroy(nvtxResourceHandle_t resource)
Destroy a resource object to track and associate data with OS and middleware objects.
nvtxResourceGenericType_t
Generic resource type for when a resource class is not available.
Definition nvToolsExt.h:966
NVTX_DECLSPEC void NVTX_API nvtxNameOsThreadA(uint32_t threadId, const char *name)
Annotate an OS thread.
NVTX_DECLSPEC void NVTX_API nvtxDomainNameCategoryA(nvtxDomainHandle_t domain, uint32_t category, const char *name)
Annotate an NVTX category used within a domain.
@ NVTX_RESOURCE_TYPE_GENERIC_THREAD_POSIX
Definition nvToolsExt.h:971
@ NVTX_RESOURCE_TYPE_GENERIC_HANDLE
Definition nvToolsExt.h:969
@ NVTX_RESOURCE_TYPE_GENERIC_POINTER
Definition nvToolsExt.h:968
@ NVTX_RESOURCE_TYPE_GENERIC_THREAD_NATIVE
Definition nvToolsExt.h:970
NVTX_DECLSPEC nvtxStringHandle_t NVTX_API nvtxDomainRegisterStringA(nvtxDomainHandle_t domain, const char *string)
Register a string.
NVTX_DECLSPEC void NVTX_API nvtxInitialize(const void *reserved)
Force initialization (optional)
Event Attribute Structure. .
Definition nvToolsExt.h:445
uint16_t version
Version flag of the structure.
Definition nvToolsExt.h:453
int32_t colorType
Color type specified in this attribute structure.
Definition nvToolsExt.h:483
uint16_t size
Size of the structure.
Definition nvToolsExt.h:461
int32_t payloadType
Payload type specified in this attribute structure.
Definition nvToolsExt.h:499
nvtxMessageValue_t message
Message assigned to this attribute structure..
Definition nvToolsExt.h:533
int32_t messageType
Message type specified in this attribute structure.
Definition nvToolsExt.h:527
uint32_t color
Color assigned to this event..
Definition nvToolsExt.h:489
uint32_t category
ID of the category the event is assigned to.
Definition nvToolsExt.h:474
Resource Attribute Structure. .
int32_t messageType
Message type specified in this attribute structure.
uint16_t size
Size of the structure.
uint16_t version
Version flag of the structure.
nvtxMessageValue_t message
Message assigned to this attribute structure..
int32_t identifierType
Identifier type specifies how to interpret the identifier field.
Payload assigned to this event..
Definition nvToolsExt.h:510
Identifier for the resource. .