/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-roctracer-docs/checkouts/docs-6.3.3/inc/roctracer.h Source File

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-roctracer-docs/checkouts/docs-6.3.3/inc/roctracer.h Source File#

ROCTracer API: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-roctracer-docs/checkouts/docs-6.3.3/inc/roctracer.h Source File
roctracer.h
Go to the documentation of this file.
1 /* Copyright (c) 2018-2022 Advanced Micro Devices, Inc.
2 
3  Permission is hereby granted, free of charge, to any person obtaining a copy
4  of this software and associated documentation files (the "Software"), to deal
5  in the Software without restriction, including without limitation the rights
6  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7  copies of the Software, and to permit persons to whom the Software is
8  furnished to do so, subject to the following conditions:
9 
10  The above copyright notice and this permission notice shall be included in
11  all copies or substantial portions of the Software.
12 
13  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19  THE SOFTWARE. */
20 
39 #ifndef ROCTRACER_H_
40 #define ROCTRACER_H_
41 
42 /* Placeholder for calling convention and import/export macros */
43 #if !defined(ROCTRACER_CALL)
44 #define ROCTRACER_CALL
45 #endif /* !defined (ROCTRACER_CALL) */
46 
47 #if !defined(ROCTRACER_EXPORT_DECORATOR)
48 #if defined(__GNUC__)
49 #define ROCTRACER_EXPORT_DECORATOR __attribute__((visibility("default")))
50 #elif defined(_MSC_VER)
51 #define ROCTRACER_EXPORT_DECORATOR __declspec(dllexport)
52 #endif /* defined (_MSC_VER) */
53 #endif /* !defined (ROCTRACER_EXPORT_DECORATOR) */
54 
55 #if !defined(ROCTRACER_IMPORT_DECORATOR)
56 #if defined(__GNUC__)
57 #define ROCTRACER_IMPORT_DECORATOR
58 #elif defined(_MSC_VER)
59 #define ROCTRACER_IMPORT_DECORATOR __declspec(dllimport)
60 #endif /* defined (_MSC_VER) */
61 #endif /* !defined (ROCTRACER_IMPORT_DECORATOR) */
62 
63 #define ROCTRACER_EXPORT ROCTRACER_EXPORT_DECORATOR ROCTRACER_CALL
64 #define ROCTRACER_IMPORT ROCTRACER_IMPORT_DECORATOR ROCTRACER_CALL
65 
66 #if !defined(ROCTRACER)
67 #if defined(ROCTRACER_EXPORTS)
68 #define ROCTRACER_API ROCTRACER_EXPORT
69 #else /* !defined (ROCTRACER_EXPORTS) */
70 #define ROCTRACER_API ROCTRACER_IMPORT
71 #endif /* !defined (ROCTRACER_EXPORTS) */
72 #endif /* !defined (ROCTRACER) */
73 
74 #include <stddef.h>
75 #include <stdint.h>
76 
77 #include "ext/prof_protocol.h"
78 
79 #ifdef __cplusplus
80 extern "C" {
81 #endif /* __cplusplus */
82 
102 #define ROCTRACER_VERSION_4_1
103 
123 #define ROCTRACER_VERSION_MAJOR 4
124 
129 #define ROCTRACER_VERSION_MINOR 1
130 
139 
148 
161 typedef enum {
237 
250 
264 typedef activity_domain_t roctracer_domain_t;
265 
280  uint32_t domain, uint32_t op, uint32_t kind) ROCTRACER_VERSION_4_1;
281 
303 roctracer_op_code(uint32_t domain, const char* str, uint32_t* op,
304  uint32_t* kind) ROCTRACER_VERSION_4_1;
305 
319  roctracer_domain_t domain, void* properties) ROCTRACER_VERSION_4_1;
320 
338 typedef activity_rtapi_callback_t roctracer_rtapi_callback_t;
339 
361  activity_domain_t domain, uint32_t op, activity_rtapi_callback_t callback,
362  void* arg) ROCTRACER_VERSION_4_1;
363 
380  activity_domain_t domain, activity_rtapi_callback_t callback,
381  void* arg) ROCTRACER_VERSION_4_1;
382 
399  activity_domain_t domain, uint32_t op) ROCTRACER_VERSION_4_1;
400 
412  activity_domain_t domain) ROCTRACER_VERSION_4_1;
413 
431 typedef activity_record_t roctracer_record_t;
432 
448 roctracer_next_record(const activity_record_t* record,
449  const activity_record_t** next) ROCTRACER_VERSION_4_1;
450 
470 typedef void (*roctracer_allocator_t)(char** ptr, size_t size, void* arg);
471 
484 typedef void (*roctracer_buffer_callback_t)(const char* begin, const char* end,
485  void* arg);
486 
492 typedef struct {
496  uint32_t mode;
497 
501  size_t buffer_size;
502 
508 
512  void* alloc_arg;
513 
518 
524 
528 typedef void roctracer_pool_t;
529 
555 
575 
591 
603 
615 
622 
641  activity_domain_t domain, uint32_t op,
643 
658  activity_domain_t domain, uint32_t op) ROCTRACER_VERSION_4_1;
659 
676  activity_domain_t domain, roctracer_pool_t* pool) ROCTRACER_VERSION_4_1;
677 
690  activity_domain_t domain) ROCTRACER_VERSION_4_1;
691 
703  activity_domain_t domain, uint32_t op) ROCTRACER_VERSION_4_1;
704 
714  activity_domain_t domain) ROCTRACER_VERSION_4_1;
715 
731 
744 
763  roctracer_timestamp_t* timestamp) ROCTRACER_VERSION_4_1;
764 
767 #ifdef __cplusplus
768 } /* extern "C" block */
769 #endif /* __cplusplus */
770 
771 #endif /* ROCTRACER_H_ */
ROCTRACER_API roctracer_status_t roctracer_disable_op_activity(activity_domain_t domain, uint32_t op) ROCTRACER_VERSION_4_1
Disable activity record logging for a specified operation of a domain.
void roctracer_pool_t
Tracer memory pool type.
Definition: roctracer.h:528
void(* roctracer_buffer_callback_t)(const char *begin, const char *end, void *arg)
Memory pool buffer callback.
Definition: roctracer.h:484
ROCTRACER_API roctracer_pool_t * roctracer_default_pool_expl(roctracer_pool_t *pool) ROCTRACER_VERSION_4_1
Query and set the default memory pool.
ROCTRACER_API roctracer_status_t roctracer_next_record(const activity_record_t *record, const activity_record_t **next) ROCTRACER_VERSION_4_1
Get a pointer to the next activity record.
ROCTRACER_API roctracer_pool_t * roctracer_default_pool() ROCTRACER_VERSION_4_1
Query the current default memory pool.
ROCTRACER_API roctracer_status_t roctracer_flush_activity_expl(roctracer_pool_t *pool) ROCTRACER_VERSION_4_1
Flush available activity records for a memory pool.
ROCTRACER_API roctracer_status_t roctracer_flush_activity() ROCTRACER_VERSION_4_1
Flush available activity records for the default memory pool.
ROCTRACER_API roctracer_status_t roctracer_open_pool_expl(const roctracer_properties_t *properties, roctracer_pool_t **pool) ROCTRACER_VERSION_4_1
Create tracer memory pool.
activity_record_t roctracer_record_t
Activity record.
Definition: roctracer.h:431
ROCTRACER_API roctracer_status_t roctracer_enable_op_activity_expl(activity_domain_t domain, uint32_t op, roctracer_pool_t *pool) ROCTRACER_VERSION_4_1
Enable activity record logging for a specified operation of a domain providing a memory pool.
ROCTRACER_API roctracer_status_t roctracer_close_pool_expl(roctracer_pool_t *pool) ROCTRACER_VERSION_4_1
Close tracer memory pool.
ROCTRACER_API roctracer_status_t roctracer_enable_domain_activity(activity_domain_t domain) ROCTRACER_VERSION_4_1
Enable activity record logging for all operations of a domain using the default memory pool.
ROCTRACER_API roctracer_status_t roctracer_close_pool() ROCTRACER_VERSION_4_1
Close default tracer memory pool, if defined, and set to undefined.
void(* roctracer_allocator_t)(char **ptr, size_t size, void *arg)
Memory pool allocator callback.
Definition: roctracer.h:470
ROCTRACER_API roctracer_status_t roctracer_open_pool(const roctracer_properties_t *properties) ROCTRACER_VERSION_4_1
Create tracer memory pool.
ROCTRACER_API roctracer_status_t roctracer_disable_domain_activity(activity_domain_t domain) ROCTRACER_VERSION_4_1
Disable activity record logging for all operations of a domain.
ROCTRACER_API roctracer_status_t roctracer_enable_domain_activity_expl(activity_domain_t domain, roctracer_pool_t *pool) ROCTRACER_VERSION_4_1
Enable activity record logging for all operations of a domain providing a memory pool.
ROCTRACER_API roctracer_status_t roctracer_enable_op_activity(activity_domain_t domain, uint32_t op) ROCTRACER_VERSION_4_1
Enable activity record logging for a specified operation of a domain using the default memory pool.
ROCTRACER_API roctracer_status_t roctracer_enable_domain_callback(activity_domain_t domain, activity_rtapi_callback_t callback, void *arg) ROCTRACER_VERSION_4_1
Enable runtime API callback for all operations of a domain.
ROCTRACER_API roctracer_status_t roctracer_enable_op_callback(activity_domain_t domain, uint32_t op, activity_rtapi_callback_t callback, void *arg) ROCTRACER_VERSION_4_1
Enable runtime API callback for a specific operation of a domain.
activity_rtapi_callback_t roctracer_rtapi_callback_t
Runtime API callback type.
Definition: roctracer.h:338
ROCTRACER_API roctracer_status_t roctracer_disable_domain_callback(activity_domain_t domain) ROCTRACER_VERSION_4_1
Disable runtime API callback for all operations of a domain.
ROCTRACER_API roctracer_status_t roctracer_disable_op_callback(activity_domain_t domain, uint32_t op) ROCTRACER_VERSION_4_1
Disable runtime API callback for a specific operation of a domain.
ROCTRACER_API roctracer_status_t roctracer_set_properties(roctracer_domain_t domain, void *properties) ROCTRACER_VERSION_4_1
Set the properties of a domain.
ROCTRACER_API roctracer_status_t roctracer_op_code(uint32_t domain, const char *str, uint32_t *op, uint32_t *kind) ROCTRACER_VERSION_4_1
Query the operation code given a domain and the name of an operation.
ROCTRACER_API const char * roctracer_op_string(uint32_t domain, uint32_t op, uint32_t kind) ROCTRACER_VERSION_4_1
Query textual name of an operation of a domain.
activity_domain_t roctracer_domain_t
Enumeration of domains that can be traced.
Definition: roctracer.h:264
roctracer_status_t
ROC Tracer API status codes.
Definition: roctracer.h:161
ROCTRACER_API const char * roctracer_error_string() ROCTRACER_VERSION_4_1
Query the textual description of the last error for the current thread.
@ ROCTRACER_STATUS_HIP_API_ERR
Deprecated error code.
Definition: roctracer.h:219
@ ROCTRACER_STATUS_ERROR_DEFAULT_POOL_UNDEFINED
No default pool is defined.
Definition: roctracer.h:181
@ ROCTRACER_STATUS_HSA_ERR
Deprecated error code.
Definition: roctracer.h:231
@ ROCTRACER_STATUS_ERROR_DEFAULT_POOL_ALREADY_DEFINED
The default pool is already defined.
Definition: roctracer.h:185
@ ROCTRACER_STATUS_HIP_OPS_ERR
Deprecated error code.
Definition: roctracer.h:223
@ ROCTRACER_STATUS_HCC_OPS_ERR
Deprecated error code.
Definition: roctracer.h:227
@ ROCTRACER_STATUS_ERROR_INVALID_DOMAIN_ID
The domain ID is invalid.
Definition: roctracer.h:173
@ ROCTRACER_STATUS_ERROR_INVALID_ARGUMENT
An invalid argument was given to the function.
Definition: roctracer.h:177
@ ROCTRACER_STATUS_ERROR_NOT_IMPLEMENTED
The operation is not currently implemented.
Definition: roctracer.h:199
@ ROCTRACER_STATUS_ERROR_MISMATCHED_EXTERNAL_CORRELATION_ID
External correlation ID pop mismatch.
Definition: roctracer.h:193
@ ROCTRACER_STATUS_UNINIT
Deprecated error code.
Definition: roctracer.h:203
@ ROCTRACER_STATUS_ERROR_MEMORY_ALLOCATION
Memory allocation error.
Definition: roctracer.h:189
@ ROCTRACER_STATUS_ERROR
A generic error has occurred.
Definition: roctracer.h:169
@ ROCTRACER_STATUS_BAD_PARAMETER
Deprecated error code.
Definition: roctracer.h:215
@ ROCTRACER_STATUS_ROCTX_ERR
Deprecated error code.
Definition: roctracer.h:235
@ ROCTRACER_STATUS_SUCCESS
The function has executed successfully.
Definition: roctracer.h:165
@ ROCTRACER_STATUS_BREAK
Deprecated error code.
Definition: roctracer.h:207
@ ROCTRACER_STATUS_BAD_DOMAIN
Deprecated error code.
Definition: roctracer.h:211
#define ROCTRACER_VERSION_4_1
The function was introduced in version 4.1 of the interface and has the symbol version string of "ROC...
Definition: roctracer.h:102
ROCTRACER_API roctracer_status_t roctracer_get_timestamp(roctracer_timestamp_t *timestamp) ROCTRACER_VERSION_4_1
Get the system clock timestamp.
ROCTRACER_API uint32_t roctracer_version_major() ROCTRACER_VERSION_4_1
Query the major version of the installed library.
ROCTRACER_API uint32_t roctracer_version_minor() ROCTRACER_VERSION_4_1
Query the minor version of the installed library.
#define ROCTRACER_API
Definition: roctracer.h:70
Memory pool properties.
Definition: roctracer.h:492
size_t buffer_size
Size of buffer in bytes.
Definition: roctracer.h:501
uint32_t mode
ROC Tracer mode.
Definition: roctracer.h:496
roctracer_allocator_t alloc_fun
The allocator function to use to allocate and deallocate the buffer.
Definition: roctracer.h:507
roctracer_buffer_callback_t buffer_callback_fun
The function to call when a buffer becomes full or is flushed.
Definition: roctracer.h:517
void * alloc_arg
The argument to pass when invoking the alloc_fun allocator.
Definition: roctracer.h:512
void * buffer_callback_arg
The argument to pass when invoking the buffer_callback_fun callback.
Definition: roctracer.h:522