Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:45:13

0001 /*
0002  * SPDX-FileCopyrightText: Copyright (c) 2009-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 #include "cuda.h"
0034 #include "driver_types.h"
0035 
0036 #ifndef NVTOOLSEXT_CUDART_V3
0037 #define NVTOOLSEXT_CUDART_V3
0038 
0039 #ifdef __cplusplus
0040 extern "C" {
0041 #endif /* __cplusplus */
0042 
0043 /* ========================================================================= */
0044 /** \name Functions for CUDA Resource Naming
0045 */
0046 /** \addtogroup RESOURCE_NAMING
0047  * \section RESOURCE_NAMING_CUDART CUDA Runtime Resource Naming
0048  *
0049  * This section covers the API functions that allow to annotate CUDA resources
0050  * with user-provided names.
0051  *
0052  * @{
0053  */
0054 
0055 /*  ------------------------------------------------------------------------- */
0056 /* \cond SHOW_HIDDEN
0057 * \brief Used to build a non-colliding value for resource types separated class
0058 * \version NVTX_VERSION_2
0059 */
0060 #define NVTX_RESOURCE_CLASS_CUDART 5
0061 /** \endcond */
0062 
0063 /*  ------------------------------------------------------------------------- */
0064 /** \brief Resource types for CUDART
0065 */
0066 typedef enum nvtxResourceCUDARTType_t
0067 {
0068     NVTX_RESOURCE_TYPE_CUDART_DEVICE = NVTX_RESOURCE_MAKE_TYPE(CUDART, 0), /* int device */
0069     NVTX_RESOURCE_TYPE_CUDART_STREAM = NVTX_RESOURCE_MAKE_TYPE(CUDART, 1), /* cudaStream_t */
0070     NVTX_RESOURCE_TYPE_CUDART_EVENT = NVTX_RESOURCE_MAKE_TYPE(CUDART, 2) /* cudaEvent_t */
0071 } nvtxResourceCUDARTType_t;
0072 
0073 
0074 /* ------------------------------------------------------------------------- */
0075 /** \brief Annotates a CUDA device.
0076  *
0077  * Allows the user to associate a CUDA device with a user-provided name.
0078  *
0079  * \param device - The id of the CUDA device to name.
0080  * \param name   - The name of the CUDA device.
0081  *
0082  * \version NVTX_VERSION_1
0083  * @{ */
0084 NVTX_DECLSPEC void NVTX_API nvtxNameCudaDeviceA(int device, const char* name);
0085 NVTX_DECLSPEC void NVTX_API nvtxNameCudaDeviceW(int device, const wchar_t* name);
0086 /** @} */
0087 
0088 /* ------------------------------------------------------------------------- */
0089 /** \brief Annotates a CUDA stream.
0090  *
0091  * Allows the user to associate a CUDA stream with a user-provided name.
0092  *
0093  * \param stream - The handle of the CUDA stream to name.
0094  * \param name   - The name of the CUDA stream.
0095  *
0096  * \version NVTX_VERSION_1
0097  * @{ */
0098 NVTX_DECLSPEC void NVTX_API nvtxNameCudaStreamA(cudaStream_t stream, const char* name);
0099 NVTX_DECLSPEC void NVTX_API nvtxNameCudaStreamW(cudaStream_t stream, const wchar_t* name);
0100 /** @} */
0101 
0102 /* ------------------------------------------------------------------------- */
0103 /** \brief Annotates a CUDA event.
0104  *
0105  * Allows the user to associate a CUDA event with a user-provided name.
0106  *
0107  * \param event - The handle of the CUDA event to name.
0108  * \param name  - The name of the CUDA event.
0109  *
0110  * \version NVTX_VERSION_1
0111  * @{ */
0112 NVTX_DECLSPEC void NVTX_API nvtxNameCudaEventA(cudaEvent_t event, const char* name);
0113 NVTX_DECLSPEC void NVTX_API nvtxNameCudaEventW(cudaEvent_t event, const wchar_t* name);
0114 /** @} */
0115 
0116 /** @} */ /* END RESOURCE_NAMING */
0117 
0118 /* ========================================================================= */
0119 #ifdef UNICODE
0120   #define nvtxNameCudaDevice nvtxNameCudaDeviceW
0121   #define nvtxNameCudaStream nvtxNameCudaStreamW
0122   #define nvtxNameCudaEvent  nvtxNameCudaEventW
0123 #else
0124   #define nvtxNameCudaDevice nvtxNameCudaDeviceA
0125   #define nvtxNameCudaStream nvtxNameCudaStreamA
0126   #define nvtxNameCudaEvent  nvtxNameCudaEventA
0127 #endif
0128 
0129 #ifdef __cplusplus
0130 }
0131 #endif /* __cplusplus */
0132 
0133 #ifndef NVTX_NO_IMPL
0134 #define NVTX_IMPL_GUARD_CUDART /* Ensure other headers cannot be included directly */
0135 #include "nvtxDetail/nvtxImplCudaRt_v3.h"
0136 #undef NVTX_IMPL_GUARD_CUDART
0137 #endif /*NVTX_NO_IMPL*/
0138 
0139 #endif /* NVTOOLSEXT_CUDART_V3 */