codekingpro/portable-devtools
114k
1/*
2* Copyright 2009-2016 NVIDIA Corporation. All rights reserved.
3*
4* NOTICE TO USER:
5*
6* This source code is subject to NVIDIA ownership rights under U.S. and
7* international Copyright laws.
8*
9* This software and the information contained herein is PROPRIETARY and
10* CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions
11* of a form of NVIDIA software license agreement.
12*
13* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
14* CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
15* IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
16* REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
17* MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
18* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
19* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
20* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
21* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
22* OR PERFORMANCE OF THIS SOURCE CODE.
23*
24* U.S. Government End Users. This source code is a "commercial item" as
25* that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
26* "commercial computer software" and "commercial computer software
27* documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
28* and is provided to the U.S. Government only as a commercial end item.
29* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
30* 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
31* source code with only those rights set forth herein.
32*
33* Any use of this source code in individual and commercial software must
34* include, in the user documentation and internal comments to the code,
35* the above Disclaimer and U.S. Government End Users Notice.
36*/
37
38#include "nvToolsExt.h"
39
40#include <CL/cl.h>
41
42#ifndef NVTOOLSEXT_OPENCL_V3
43#define NVTOOLSEXT_OPENCL_V3
44
45#ifdef __cplusplus
46extern "C" {
47#endif /* __cplusplus */
48
49/* ========================================================================= */
50/** \name Functions for OpenCL Resource Naming
51 */
52/** \addtogroup RESOURCE_NAMING
53 * \section RESOURCE_NAMING_OPENCL OpenCL Resource Naming
54 *
55 * This section covers the API functions that allow to annotate OpenCL resources
56 * with user-provided names.
57 *
58 * @{
59 */
60
61/* ------------------------------------------------------------------------- */
62/* \cond SHOW_HIDDEN
63* \brief Used to build a non-colliding value for resource types separated class
64* \version \NVTX_VERSION_2
65*/
66#define NVTX_RESOURCE_CLASS_OPENCL 6
67/** \endcond */
68
69/* ------------------------------------------------------------------------- */
70/** \brief Resource types for OpenCL
71*/
72typedef enum nvtxResourceOpenCLType_t
73{
74 NVTX_RESOURCE_TYPE_OPENCL_DEVICE = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 1),
75 NVTX_RESOURCE_TYPE_OPENCL_CONTEXT = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 2),
76 NVTX_RESOURCE_TYPE_OPENCL_COMMANDQUEUE = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 3),
77 NVTX_RESOURCE_TYPE_OPENCL_MEMOBJECT = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 4),
78 NVTX_RESOURCE_TYPE_OPENCL_SAMPLER = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 5),
79 NVTX_RESOURCE_TYPE_OPENCL_PROGRAM = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 6),
80 NVTX_RESOURCE_TYPE_OPENCL_EVENT = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 7),
81} nvtxResourceOpenCLType_t;
82
83
84/* ------------------------------------------------------------------------- */
85/** \brief Annotates an OpenCL device.
86 *
87 * Allows to associate an OpenCL device with a user-provided name.
88 *
89 * \param device - The handle of the OpenCL device to name.
90 * \param name - The name of the OpenCL device.
91 *
92 * \version \NVTX_VERSION_1
93 * @{ */
94NVTX_DECLSPEC void NVTX_API nvtxNameClDeviceA(cl_device_id device, const char* name);
95NVTX_DECLSPEC void NVTX_API nvtxNameClDeviceW(cl_device_id device, const wchar_t* name);
96/** @} */
97
98/* ------------------------------------------------------------------------- */
99/** \brief Annotates an OpenCL context.
100 *
101 * Allows to associate an OpenCL context with a user-provided name.
102 *
103 * \param context - The handle of the OpenCL context to name.
104 * \param name - The name of the OpenCL context.
105 *
106 * \version \NVTX_VERSION_1
107 * @{ */
108NVTX_DECLSPEC void NVTX_API nvtxNameClContextA(cl_context context, const char* name);
109NVTX_DECLSPEC void NVTX_API nvtxNameClContextW(cl_context context, const wchar_t* name);
110/** @} */
111
112/* ------------------------------------------------------------------------- */
113/** \brief Annotates an OpenCL command queue.
114 *
115 * Allows to associate an OpenCL command queue with a user-provided name.
116 *
117 * \param command_queue - The handle of the OpenCL command queue to name.
118 * \param name - The name of the OpenCL command queue.
119 *
120 * \version \NVTX_VERSION_1
121 * @{ */
122NVTX_DECLSPEC void NVTX_API nvtxNameClCommandQueueA(cl_command_queue command_queue, const char* name);
123NVTX_DECLSPEC void NVTX_API nvtxNameClCommandQueueW(cl_command_queue command_queue, const wchar_t* name);
124/** @} */
125
126/* ------------------------------------------------------------------------- */
127/** \brief Annotates an OpenCL memory object.
128 *
129 * Allows to associate an OpenCL memory object with a user-provided name.
130 *
131 * \param memobj - The handle of the OpenCL memory object to name.
132 * \param name - The name of the OpenCL memory object.
133 *
134 * \version \NVTX_VERSION_1
135 * @{ */
136NVTX_DECLSPEC void NVTX_API nvtxNameClMemObjectA(cl_mem memobj, const char* name);
137NVTX_DECLSPEC void NVTX_API nvtxNameClMemObjectW(cl_mem memobj, const wchar_t* name);
138/** @} */
139
140/* ------------------------------------------------------------------------- */
141/** \brief Annotates an OpenCL sampler.
142 *
143 * Allows to associate an OpenCL sampler with a user-provided name.
144 *
145 * \param sampler - The handle of the OpenCL sampler to name.
146 * \param name - The name of the OpenCL sampler.
147 *
148 * \version \NVTX_VERSION_1
149 * @{ */
150NVTX_DECLSPEC void NVTX_API nvtxNameClSamplerA(cl_sampler sampler, const char* name);
151NVTX_DECLSPEC void NVTX_API nvtxNameClSamplerW(cl_sampler sampler, const wchar_t* name);
152/** @} */
153
154/* ------------------------------------------------------------------------- */
155/** \brief Annotates an OpenCL program.
156 *
157 * Allows to associate an OpenCL program with a user-provided name.
158 *
159 * \param program - The handle of the OpenCL program to name.
160 * \param name - The name of the OpenCL program.
161 *
162 * \code
163 * cpProgram = clCreateProgramWithSource(cxGPUContext, 1,
164 * (const char **) &cSourceCL, &program_length, &ciErrNum);
165 * shrCheckErrorEX(ciErrNum, CL_SUCCESS, pCleanup);
166 * nvtxNameClProgram(cpProgram, L"PROGRAM_NAME");
167 * \endcode
168 *
169 * \version \NVTX_VERSION_1
170 * @{ */
171NVTX_DECLSPEC void NVTX_API nvtxNameClProgramA(cl_program program, const char* name);
172NVTX_DECLSPEC void NVTX_API nvtxNameClProgramW(cl_program program, const wchar_t* name);
173/** @} */
174
175/* ------------------------------------------------------------------------- */
176/** \brief Annotates an OpenCL event.
177 *
178 * Allows to associate an OpenCL event with a user-provided name.
179 *
180 * \param evnt - The handle of the OpenCL event to name.
181 * \param name - The name of the OpenCL event.
182 *
183 * \version \NVTX_VERSION_1
184 * @{ */
185NVTX_DECLSPEC void NVTX_API nvtxNameClEventA(cl_event evnt, const char* name);
186NVTX_DECLSPEC void NVTX_API nvtxNameClEventW(cl_event evnt, const wchar_t* name);
187/** @} */
188
189/** @} */ /* END RESOURCE_NAMING */
190
191/* ========================================================================= */
192#ifdef UNICODE
193 #define nvtxNameClDevice nvtxNameClDeviceW
194 #define nvtxNameClContext nvtxNameClContextW
195 #define nvtxNameClCommandQueue nvtxNameClCommandQueueW
196 #define nvtxNameClMemObject nvtxNameClMemObjectW
197 #define nvtxNameClSampler nvtxNameClSamplerW
198 #define nvtxNameClProgram nvtxNameClProgramW
199 #define nvtxNameClEvent nvtxNameClEventW
200#else
201 #define nvtxNameClDevice nvtxNameClDeviceA
202 #define nvtxNameClContext nvtxNameClContextA
203 #define nvtxNameClCommandQueue nvtxNameClCommandQueueA
204 #define nvtxNameClMemObject nvtxNameClMemObjectA
205 #define nvtxNameClSampler nvtxNameClSamplerA
206 #define nvtxNameClProgram nvtxNameClProgramA
207 #define nvtxNameClEvent nvtxNameClEventA
208#endif
209
210#ifdef __cplusplus
211}
212#endif /* __cplusplus */
213
214#ifndef NVTX_NO_IMPL
215#define NVTX_IMPL_GUARD_OPENCL /* Ensure other headers cannot included directly */
216#include "nvtxDetail/nvtxImplOpenCL_v3.h"
217#undef NVTX_IMPL_GUARD_OPENCL
218#endif /*NVTX_NO_IMPL*/
219
220#endif /* NVTOOLSEXT_OPENCL_V3 */
221 