Skip to content

Commit a65ef2f

Browse files
Docs for API tracing feature
Change-Id: Ibfc77ff0133b9f416b15f39c0241ae789376a285
1 parent c86fa77 commit a65ef2f

File tree

2 files changed

+96
-8
lines changed

2 files changed

+96
-8
lines changed

runtime/tracing/tracing_api.h

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,72 @@
1313
extern "C" {
1414
#endif
1515

16+
/*!
17+
Function creates a tracing handle object
18+
\param[in] device Device to create tracing handle for
19+
\param[in] callback User-defined callback that will be called along with
20+
traced API function
21+
\param[in] userData Pointer to any data user would like to pass into the
22+
callback, can be zero
23+
\param[out] handle Tracing handle object that describes current tracing
24+
session
25+
\return Status code for current operation
26+
27+
Thread Safety: yes
28+
*/
1629
cl_int CL_API_CALL clCreateTracingHandleINTEL(cl_device_id device, cl_tracing_callback callback, void *userData, cl_tracing_handle *handle);
30+
31+
/*!
32+
Function allows to specify which target API call should be traced.
33+
By default function will NOT be traced
34+
\param[in] handle Tracing handle object
35+
\param[in] fid Target function identifier
36+
\param[in] enable Flag to enable/disable tracing for target function
37+
\return Status code for current operation
38+
39+
Thread Safety: no
40+
*/
1741
cl_int CL_API_CALL clSetTracingPointINTEL(cl_tracing_handle handle, cl_function_id fid, cl_bool enable);
42+
43+
/*!
44+
Function destroys the tracing handle object and releases all the associated
45+
resources
46+
\param[in] handle Tracing handle object
47+
\return Status code for current operation
48+
49+
Thread Safety: no
50+
*/
1851
cl_int CL_API_CALL clDestroyTracingHandleINTEL(cl_tracing_handle handle);
1952

53+
/*!
54+
Function enables the tracing process for the handle. Multiple handles
55+
can be enabled at a time
56+
\param[in] handle Tracing handle object
57+
\return Status code for current operation
58+
59+
Thread Safety: yes
60+
*/
2061
cl_int CL_API_CALL clEnableTracingINTEL(cl_tracing_handle handle);
62+
63+
/*!
64+
Function disables the tracing process for the handle. It will wait until
65+
all currently running callbacks are done
66+
\param[in] handle Tracing handle object
67+
\return Status code for current operation
68+
69+
Thread Safety: yes
70+
*/
2171
cl_int CL_API_CALL clDisableTracingINTEL(cl_tracing_handle handle);
72+
73+
/*!
74+
Function requests the tracing state for the handle
75+
\param[in] handle Tracing handle object
76+
\param[out] enable Returns TRUE if tracing handle is in use and
77+
FALSE otherwise
78+
\return Status code for current operation
79+
80+
Thread Safety: yes
81+
*/
2282
cl_int CL_API_CALL clGetTracingStateINTEL(cl_tracing_handle handle, cl_bool *enable);
2383

2484
#ifdef __cplusplus

runtime/tracing/tracing_types.h

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,38 @@
1313
struct _cl_tracing_handle;
1414
typedef _cl_tracing_handle *cl_tracing_handle;
1515

16+
//! Enumeration of callback call sites
1617
typedef enum _cl_callback_site {
17-
CL_CALLBACK_SITE_ENTER = 0,
18-
CL_CALLBACK_SITE_EXIT = 1
18+
CL_CALLBACK_SITE_ENTER = 0, //!< Before the function
19+
CL_CALLBACK_SITE_EXIT = 1 //!< After the function
1920
} cl_callback_site;
2021

22+
/*!
23+
\brief Callback data structure
24+
25+
The structure contains information about the traced function.
26+
Function name allows to determine which function is currently traced.
27+
Call site is used to determine if the callback was called at the beginning
28+
or at the end of function.
29+
Correlation ID and Data fields allow to associate the callback on
30+
enter with the callback on exit and pass any piece of data between them.
31+
Function arguments and return value available both for reading and writing.
32+
Return value will be available only within on-exit callback
33+
*/
2134
typedef struct _cl_callback_data {
22-
cl_callback_site site;
23-
cl_uint correlationId;
24-
cl_ulong *correlationData;
25-
const char *functionName;
26-
const void *functionParams;
27-
void *functionReturnValue;
35+
cl_callback_site site; //!< Call site, can be ENTER or EXIT
36+
cl_uint correlationId; //!< Correlation identifier, the same for ENTER
37+
//!< and EXIT callbacks
38+
cl_ulong *correlationData; //!< Pointer to correlation data repository,
39+
//!< can be used to move data from ENTER to
40+
//!< EXIT callback
41+
const char *functionName; //!< Name of the traced function
42+
const void *functionParams; //!< Traced function arguments, should be
43+
//!< casted to appropriate params structure
44+
void *functionReturnValue; //!< Return value for the traced function
2845
} cl_callback_data;
2946

47+
//! Enumeration of supported functions for tracing
3048
typedef enum _cl_function_id {
3149
CL_FUNCTION_clBuildProgram = 0,
3250
CL_FUNCTION_clCloneKernel = 1,
@@ -149,6 +167,16 @@ typedef enum _cl_function_id {
149167
CL_FUNCTION_COUNT = 118,
150168
} cl_function_id;
151169

170+
/*!
171+
User-defined tracing callback prototype
172+
\param[in] fid Identifier of the function for which the callback is called
173+
\param[in] callbackData Data structure with information about the traced
174+
function
175+
\param[in] userData User-defined data pointer passed through
176+
clCreateTracingHandleINTEL() function
177+
178+
Thread Safety: must be guaranteed by customer
179+
*/
152180
typedef void (*cl_tracing_callback)(cl_function_id fid, cl_callback_data *callbackData, void *userData);
153181

154182
typedef struct _cl_params_clBuildProgram {

0 commit comments

Comments
 (0)