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 <CL/cl.h>
0034 
0035 #ifndef NVTOOLSEXT_OPENCL_V3
0036 #define NVTOOLSEXT_OPENCL_V3
0037 
0038 #ifdef __cplusplus
0039 extern "C" {
0040 #endif /* __cplusplus */
0041 
0042 /* ========================================================================= */
0043 /** \name Functions for OpenCL Resource Naming
0044  */
0045 /** \addtogroup RESOURCE_NAMING
0046  * \section RESOURCE_NAMING_OPENCL OpenCL Resource Naming
0047  *
0048  * This section covers the API functions that allow to annotate OpenCL resources
0049  * with user-provided names.
0050  *
0051  * @{
0052  */
0053 
0054 /*  ------------------------------------------------------------------------- */
0055 /* \cond SHOW_HIDDEN
0056 * \brief Used to build a non-colliding value for resource types separated class
0057 * \version NVTX_VERSION_2
0058 */
0059 #define NVTX_RESOURCE_CLASS_OPENCL 6
0060 /** \endcond */
0061 
0062 /*  ------------------------------------------------------------------------- */
0063 /** \brief Resource types for OpenCL
0064 */
0065 typedef enum nvtxResourceOpenCLType_t
0066 {
0067     NVTX_RESOURCE_TYPE_OPENCL_DEVICE = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 1),
0068     NVTX_RESOURCE_TYPE_OPENCL_CONTEXT = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 2),
0069     NVTX_RESOURCE_TYPE_OPENCL_COMMANDQUEUE = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 3),
0070     NVTX_RESOURCE_TYPE_OPENCL_MEMOBJECT = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 4),
0071     NVTX_RESOURCE_TYPE_OPENCL_SAMPLER = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 5),
0072     NVTX_RESOURCE_TYPE_OPENCL_PROGRAM = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 6),
0073     NVTX_RESOURCE_TYPE_OPENCL_EVENT = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 7)
0074 } nvtxResourceOpenCLType_t;
0075 
0076 
0077 /* ------------------------------------------------------------------------- */
0078 /** \brief Annotates an OpenCL device.
0079  *
0080  * Allows to associate an OpenCL device with a user-provided name.
0081  *
0082  * \param device - The handle of the OpenCL device to name.
0083  * \param name   - The name of the OpenCL device.
0084  *
0085  * \version NVTX_VERSION_1
0086  * @{ */
0087 NVTX_DECLSPEC void NVTX_API nvtxNameClDeviceA(cl_device_id device, const char* name);
0088 NVTX_DECLSPEC void NVTX_API nvtxNameClDeviceW(cl_device_id device, const wchar_t* name);
0089 /** @} */
0090 
0091 /* ------------------------------------------------------------------------- */
0092 /** \brief Annotates an OpenCL context.
0093  *
0094  * Allows to associate an OpenCL context with a user-provided name.
0095  *
0096  * \param context - The handle of the OpenCL context to name.
0097  * \param name    - The name of the OpenCL context.
0098  *
0099  * \version NVTX_VERSION_1
0100  * @{ */
0101 NVTX_DECLSPEC void NVTX_API nvtxNameClContextA(cl_context context, const char* name);
0102 NVTX_DECLSPEC void NVTX_API nvtxNameClContextW(cl_context context, const wchar_t* name);
0103 /** @} */
0104 
0105 /* ------------------------------------------------------------------------- */
0106 /** \brief Annotates an OpenCL command queue.
0107  *
0108  * Allows to associate an OpenCL command queue with a user-provided name.
0109  *
0110  * \param command_queue - The handle of the OpenCL command queue to name.
0111  * \param name          - The name of the OpenCL command queue.
0112  *
0113  * \version NVTX_VERSION_1
0114  * @{ */
0115 NVTX_DECLSPEC void NVTX_API nvtxNameClCommandQueueA(cl_command_queue command_queue, const char* name);
0116 NVTX_DECLSPEC void NVTX_API nvtxNameClCommandQueueW(cl_command_queue command_queue, const wchar_t* name);
0117 /** @} */
0118 
0119 /* ------------------------------------------------------------------------- */
0120 /** \brief Annotates an OpenCL memory object.
0121  *
0122  * Allows to associate an OpenCL memory object with a user-provided name.
0123  *
0124  * \param memobj - The handle of the OpenCL memory object to name.
0125  * \param name   - The name of the OpenCL memory object.
0126  *
0127  * \version NVTX_VERSION_1
0128  * @{ */
0129 NVTX_DECLSPEC void NVTX_API nvtxNameClMemObjectA(cl_mem memobj, const char* name);
0130 NVTX_DECLSPEC void NVTX_API nvtxNameClMemObjectW(cl_mem memobj, const wchar_t* name);
0131 /** @} */
0132 
0133 /* ------------------------------------------------------------------------- */
0134 /** \brief Annotates an OpenCL sampler.
0135  *
0136  * Allows to associate an OpenCL sampler with a user-provided name.
0137  *
0138  * \param sampler - The handle of the OpenCL sampler to name.
0139  * \param name    - The name of the OpenCL sampler.
0140  *
0141  * \version NVTX_VERSION_1
0142  * @{ */
0143 NVTX_DECLSPEC void NVTX_API nvtxNameClSamplerA(cl_sampler sampler, const char* name);
0144 NVTX_DECLSPEC void NVTX_API nvtxNameClSamplerW(cl_sampler sampler, const wchar_t* name);
0145 /** @} */
0146 
0147 /* ------------------------------------------------------------------------- */
0148 /** \brief Annotates an OpenCL program.
0149  *
0150  * Allows to associate an OpenCL program with a user-provided name.
0151  *
0152  * \param program - The handle of the OpenCL program to name.
0153  * \param name    - The name of the OpenCL program.
0154  *
0155  * \code
0156  * cpProgram = clCreateProgramWithSource(cxGPUContext, 1,
0157  *     (const char **) &cSourceCL, &program_length, &ciErrNum);
0158  * shrCheckErrorEX(ciErrNum, CL_SUCCESS, pCleanup);
0159  * nvtxNameClProgram(cpProgram, L"PROGRAM_NAME");
0160  * \endcode
0161  *
0162  * \version NVTX_VERSION_1
0163  * @{ */
0164 NVTX_DECLSPEC void NVTX_API nvtxNameClProgramA(cl_program program, const char* name);
0165 NVTX_DECLSPEC void NVTX_API nvtxNameClProgramW(cl_program program, const wchar_t* name);
0166 /** @} */
0167 
0168 /* ------------------------------------------------------------------------- */
0169 /** \brief Annotates an OpenCL event.
0170  *
0171  * Allows to associate an OpenCL event with a user-provided name.
0172  *
0173  * \param evnt - The handle of the OpenCL event to name.
0174  * \param name - The name of the OpenCL event.
0175  *
0176  * \version NVTX_VERSION_1
0177  * @{ */
0178 NVTX_DECLSPEC void NVTX_API nvtxNameClEventA(cl_event evnt, const char* name);
0179 NVTX_DECLSPEC void NVTX_API nvtxNameClEventW(cl_event evnt, const wchar_t* name);
0180 /** @} */
0181 
0182 /** @} */ /* END RESOURCE_NAMING */
0183 
0184 /* ========================================================================= */
0185 #ifdef UNICODE
0186   #define nvtxNameClDevice        nvtxNameClDeviceW
0187   #define nvtxNameClContext       nvtxNameClContextW
0188   #define nvtxNameClCommandQueue  nvtxNameClCommandQueueW
0189   #define nvtxNameClMemObject     nvtxNameClMemObjectW
0190   #define nvtxNameClSampler       nvtxNameClSamplerW
0191   #define nvtxNameClProgram       nvtxNameClProgramW
0192   #define nvtxNameClEvent         nvtxNameClEventW
0193 #else
0194   #define nvtxNameClDevice        nvtxNameClDeviceA
0195   #define nvtxNameClContext       nvtxNameClContextA
0196   #define nvtxNameClCommandQueue  nvtxNameClCommandQueueA
0197   #define nvtxNameClMemObject     nvtxNameClMemObjectA
0198   #define nvtxNameClSampler       nvtxNameClSamplerA
0199   #define nvtxNameClProgram       nvtxNameClProgramA
0200   #define nvtxNameClEvent         nvtxNameClEventA
0201 #endif
0202 
0203 #ifdef __cplusplus
0204 }
0205 #endif /* __cplusplus */
0206 
0207 #ifndef NVTX_NO_IMPL
0208 #define NVTX_IMPL_GUARD_OPENCL /* Ensure other headers cannot be included directly */
0209 #include "nvtxDetail/nvtxImplOpenCL_v3.h"
0210 #undef NVTX_IMPL_GUARD_OPENCL
0211 #endif /*NVTX_NO_IMPL*/
0212 
0213 #endif /* NVTOOLSEXT_OPENCL_V3 */