diff --git a/inc/.clang-format b/inc/.clang-format index f41702bc79..e128ee2fd1 100644 --- a/inc/.clang-format +++ b/inc/.clang-format @@ -1,3 +1,4 @@ --- +BasedOnStyle: InheritParentConfig ColumnLimit: 79 ... diff --git a/inc/ext/prof_protocol.h b/inc/ext/prof_protocol.h index 1f9333abce..69a2b0b347 100644 --- a/inc/ext/prof_protocol.h +++ b/inc/ext/prof_protocol.h @@ -26,30 +26,32 @@ /* Traced API domains */ typedef enum { - ACTIVITY_DOMAIN_HSA_API = 0, /* HSA API domain */ - ACTIVITY_DOMAIN_HSA_OPS = 1, /* HSA async activity domain */ - ACTIVITY_DOMAIN_HIP_OPS = 2, /* HIP async activity domain */ - ACTIVITY_DOMAIN_HCC_OPS = ACTIVITY_DOMAIN_HIP_OPS, /* HCC async activity domain */ - ACTIVITY_DOMAIN_HIP_VDI = ACTIVITY_DOMAIN_HIP_OPS, /* HIP VDI async activity domain */ - ACTIVITY_DOMAIN_HIP_API = 3, /* HIP API domain */ - ACTIVITY_DOMAIN_KFD_API = 4, /* KFD API domain */ - ACTIVITY_DOMAIN_EXT_API = 5, /* External ID domain */ - ACTIVITY_DOMAIN_ROCTX = 6, /* ROCTX domain */ - ACTIVITY_DOMAIN_HSA_EVT = 7, /* HSA events */ + ACTIVITY_DOMAIN_HSA_API = 0, /* HSA API domain */ + ACTIVITY_DOMAIN_HSA_OPS = 1, /* HSA async activity domain */ + ACTIVITY_DOMAIN_HIP_OPS = 2, /* HIP async activity domain */ + ACTIVITY_DOMAIN_HCC_OPS = + ACTIVITY_DOMAIN_HIP_OPS, /* HCC async activity domain */ + ACTIVITY_DOMAIN_HIP_VDI = + ACTIVITY_DOMAIN_HIP_OPS, /* HIP VDI async activity domain */ + ACTIVITY_DOMAIN_HIP_API = 3, /* HIP API domain */ + ACTIVITY_DOMAIN_KFD_API = 4, /* KFD API domain */ + ACTIVITY_DOMAIN_EXT_API = 5, /* External ID domain */ + ACTIVITY_DOMAIN_ROCTX = 6, /* ROCTX domain */ + ACTIVITY_DOMAIN_HSA_EVT = 7, /* HSA events */ ACTIVITY_DOMAIN_NUMBER } activity_domain_t; -/* Extension API opcodes */ -typedef enum { ACTIVITY_EXT_OP_MARK = 0, ACTIVITY_EXT_OP_EXTERN_ID = 1 } activity_ext_op_t; - /* API callback type */ -typedef void (*activity_rtapi_callback_t)(uint32_t domain, uint32_t cid, const void* data, - void* arg); +typedef void (*activity_rtapi_callback_t)(uint32_t domain, uint32_t cid, + const void* data, void* arg); typedef uint32_t activity_kind_t; typedef uint32_t activity_op_t; /* API callback phase */ -typedef enum { ACTIVITY_API_PHASE_ENTER = 0, ACTIVITY_API_PHASE_EXIT = 1 } activity_api_phase_t; +typedef enum { + ACTIVITY_API_PHASE_ENTER = 0, + ACTIVITY_API_PHASE_EXIT = 1 +} activity_api_phase_t; /* Trace record types */ diff --git a/inc/roctracer.h b/inc/roctracer.h index 211e5c0c69..cb9b13facc 100644 --- a/inc/roctracer.h +++ b/inc/roctracer.h @@ -82,7 +82,7 @@ #include #include -#include +#include "ext/prof_protocol.h" #ifdef __cplusplus extern "C" { @@ -254,7 +254,7 @@ typedef enum { * \return Return the error string. The caller owns the returned string and * should use \p free() to deallocate it. */ -ROCTRACER_API const char *roctracer_error_string() ROCTRACER_VERSION_4_1; +ROCTRACER_API const char* roctracer_error_string() ROCTRACER_VERSION_4_1; /** @} */ @@ -284,9 +284,8 @@ typedef activity_domain_t roctracer_domain_t; * the domain or operation are invalid. The string is owned by the ROC Tracer * library. */ -ROCTRACER_API const char * -roctracer_op_string(uint32_t domain, uint32_t op, - uint32_t kind) ROCTRACER_VERSION_4_1; +ROCTRACER_API const char* roctracer_op_string( + uint32_t domain, uint32_t op, uint32_t kind) ROCTRACER_VERSION_4_1; /** * Query the operation code given a domain and the name of an operation. @@ -309,8 +308,8 @@ roctracer_op_string(uint32_t domain, uint32_t op, * not supported. */ ROCTRACER_API roctracer_status_t -roctracer_op_code(uint32_t domain, const char *str, uint32_t *op, - uint32_t *kind) ROCTRACER_VERSION_4_1; +roctracer_op_code(uint32_t domain, const char* str, uint32_t* op, + uint32_t* kind) ROCTRACER_VERSION_4_1; /** * Set the properties of a domain. @@ -325,7 +324,7 @@ roctracer_op_code(uint32_t domain, const char *str, uint32_t *op, * successfully. */ ROCTRACER_API roctracer_status_t roctracer_set_properties( - roctracer_domain_t domain, void *properties) ROCTRACER_VERSION_4_1; + roctracer_domain_t domain, void* properties) ROCTRACER_VERSION_4_1; /** @} */ @@ -368,7 +367,7 @@ typedef activity_rtapi_callback_t roctracer_rtapi_callback_t; */ 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; + void* arg) ROCTRACER_VERSION_4_1; /** * Enable runtime API callback for all operations of a domain. @@ -387,7 +386,7 @@ ROCTRACER_API roctracer_status_t roctracer_enable_op_callback( */ ROCTRACER_API roctracer_status_t roctracer_enable_domain_callback( activity_domain_t domain, activity_rtapi_callback_t callback, - void *arg) ROCTRACER_VERSION_4_1; + void* arg) ROCTRACER_VERSION_4_1; /** * Disable runtime API callback for a specific operation of a domain. @@ -454,8 +453,8 @@ typedef activity_record_t roctracer_record_t; * successfully. */ ROCTRACER_API roctracer_status_t -roctracer_next_record(const activity_record_t *record, - const activity_record_t **next) ROCTRACER_VERSION_4_1; +roctracer_next_record(const activity_record_t* record, + const activity_record_t** next) ROCTRACER_VERSION_4_1; /** * Memory pool allocator callback. @@ -476,7 +475,7 @@ roctracer_next_record(const activity_record_t *record, * \p arg Argument provided in the ::roctracer_properties_t passed to the * ::roctracer_open_pool function. */ -typedef void (*roctracer_allocator_t)(char **ptr, size_t size, void *arg); +typedef void (*roctracer_allocator_t)(char** ptr, size_t size, void* arg); /** * Memory pool buffer callback. @@ -490,8 +489,8 @@ typedef void (*roctracer_allocator_t)(char **ptr, size_t size, void *arg); * * \p arg the argument specified when the callback was defined. */ -typedef void (*roctracer_buffer_callback_t)(const char *begin, const char *end, - void *arg); +typedef void (*roctracer_buffer_callback_t)(const char* begin, const char* end, + void* arg); /** * Memory pool properties. @@ -518,7 +517,7 @@ typedef struct { /** * The argument to pass when invoking the \p alloc_fun allocator. */ - void *alloc_arg; + void* alloc_arg; /** * The function to call when a buffer becomes full or is flushed. @@ -528,7 +527,7 @@ typedef struct { /** * The argument to pass when invoking the \p buffer_callback_fun callback. */ - void *buffer_callback_arg; + void* buffer_callback_arg; } roctracer_properties_t; /** @@ -559,8 +558,8 @@ typedef void roctracer_pool_t; * for the \p pool. Unable to create the pool. */ ROCTRACER_API roctracer_status_t -roctracer_open_pool_expl(const roctracer_properties_t *properties, - roctracer_pool_t **pool) ROCTRACER_VERSION_4_1; +roctracer_open_pool_expl(const roctracer_properties_t* properties, + roctracer_pool_t** pool) ROCTRACER_VERSION_4_1; /** * Create tracer memory pool. @@ -580,7 +579,7 @@ roctracer_open_pool_expl(const roctracer_properties_t *properties, * for the \p pool. Unable to create the pool. */ ROCTRACER_API roctracer_status_t roctracer_open_pool( - const roctracer_properties_t *properties) ROCTRACER_VERSION_4_1; + const roctracer_properties_t* properties) ROCTRACER_VERSION_4_1; /** * Close tracer memory pool. @@ -596,7 +595,7 @@ ROCTRACER_API roctracer_status_t roctracer_open_pool( * successfully or pool was NULL and there is no default pool. */ ROCTRACER_API roctracer_status_t -roctracer_close_pool_expl(roctracer_pool_t *pool) ROCTRACER_VERSION_4_1; +roctracer_close_pool_expl(roctracer_pool_t* pool) ROCTRACER_VERSION_4_1; /** * Close default tracer memory pool, if defined, and set to undefined. @@ -619,15 +618,15 @@ ROCTRACER_API roctracer_status_t roctracer_close_pool() ROCTRACER_VERSION_4_1; * @return Return the current default memory pool before any change, or NULL if * none is defined. */ -ROCTRACER_API roctracer_pool_t * -roctracer_default_pool_expl(roctracer_pool_t *pool) ROCTRACER_VERSION_4_1; +ROCTRACER_API roctracer_pool_t* roctracer_default_pool_expl( + roctracer_pool_t* pool) ROCTRACER_VERSION_4_1; /** * Query the current default memory pool. * * @return Return the current default memory pool, or NULL is none is defined. */ -ROCTRACER_API roctracer_pool_t *roctracer_default_pool() ROCTRACER_VERSION_4_1; +ROCTRACER_API roctracer_pool_t* roctracer_default_pool() ROCTRACER_VERSION_4_1; /** * Enable activity record logging for a specified operation of a domain @@ -648,7 +647,7 @@ ROCTRACER_API roctracer_pool_t *roctracer_default_pool() ROCTRACER_VERSION_4_1; */ 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; + roctracer_pool_t* pool) ROCTRACER_VERSION_4_1; /** * Enable activity record logging for a specified operation of a domain using @@ -682,7 +681,7 @@ ROCTRACER_API roctracer_status_t roctracer_enable_op_activity( * defined. */ ROCTRACER_API roctracer_status_t roctracer_enable_domain_activity_expl( - activity_domain_t domain, roctracer_pool_t *pool) ROCTRACER_VERSION_4_1; + activity_domain_t domain, roctracer_pool_t* pool) ROCTRACER_VERSION_4_1; /** * Enable activity record logging for all operations of a domain using the @@ -736,7 +735,7 @@ ROCTRACER_API roctracer_status_t roctracer_disable_domain_activity( * successfully. */ ROCTRACER_API roctracer_status_t -roctracer_flush_activity_expl(roctracer_pool_t *pool) ROCTRACER_VERSION_4_1; +roctracer_flush_activity_expl(roctracer_pool_t* pool) ROCTRACER_VERSION_4_1; /** * Flush available activity records for the default memory pool. @@ -769,7 +768,7 @@ ROCTRACER_API roctracer_status_t roctracer_flush_activity() * successfully. */ ROCTRACER_API roctracer_status_t roctracer_get_timestamp( - roctracer_timestamp_t *timestamp) ROCTRACER_VERSION_4_1; + roctracer_timestamp_t* timestamp) ROCTRACER_VERSION_4_1; /** @} */ diff --git a/inc/roctracer_ext.h b/inc/roctracer_ext.h index 30c30136ea..9fc4f6a67d 100644 --- a/inc/roctracer_ext.h +++ b/inc/roctracer_ext.h @@ -30,7 +30,13 @@ #ifndef ROCTRACER_EXT_H_ #define ROCTRACER_EXT_H_ -#include +#include "roctracer.h" + +/* Extension API opcodes */ +typedef enum { + ACTIVITY_EXT_OP_MARK = 0, + ACTIVITY_EXT_OP_EXTERN_ID = 1 +} activity_ext_op_t; typedef void (*roctracer_start_cb_t)(); typedef void (*roctracer_stop_cb_t)(); @@ -58,12 +64,14 @@ void ROCTRACER_API roctracer_stop() ROCTRACER_VERSION_4_1; // Notifies that the calling thread is entering an external API region. // Push an external correlation id for the calling thread. roctracer_status_t ROCTRACER_API -roctracer_activity_push_external_correlation_id(activity_correlation_id_t id) ROCTRACER_VERSION_4_1; +roctracer_activity_push_external_correlation_id(activity_correlation_id_t id) + ROCTRACER_VERSION_4_1; // Notifies that the calling thread is leaving an external API region. // Pop an external correlation id for the calling thread. // 'lastId' returns the last external correlation if not NULL -roctracer_status_t ROCTRACER_API roctracer_activity_pop_external_correlation_id( +roctracer_status_t ROCTRACER_API +roctracer_activity_pop_external_correlation_id( activity_correlation_id_t* last_id) ROCTRACER_VERSION_4_1; #ifdef __cplusplus diff --git a/inc/roctracer_hcc.h b/inc/roctracer_hcc.h index 5da6dab0bc..969282b7fc 100644 --- a/inc/roctracer_hcc.h +++ b/inc/roctracer_hcc.h @@ -18,6 +18,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#pragma message("This file has been deprecated and marked for removal. Please use roctracer_hip.h instead.") +#pragma message( \ + "This file has been deprecated and marked for removal. Please use roctracer_hip.h instead.") -#include \ No newline at end of file +#include "roctracer_hip.h" \ No newline at end of file diff --git a/inc/roctracer_hip.h b/inc/roctracer_hip.h index 8b0434944c..5bfab84b23 100644 --- a/inc/roctracer_hip.h +++ b/inc/roctracer_hip.h @@ -18,29 +18,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef INC_ROCTRACER_HIP_H_ -#define INC_ROCTRACER_HIP_H_ +#ifndef ROCTRACER_HIP_H_ +#define ROCTRACER_HIP_H_ -#ifdef __cplusplus -#include - -inline static std::ostream& operator<<(std::ostream& out, const unsigned char& v) { - out << (unsigned int)v; - return out; -} - -inline static std::ostream& operator<<(std::ostream& out, const char& v) { - out << (unsigned char)v; - return out; -} -#endif // __cplusplus +#include "roctracer.h" #include -#include +#include "hip_ostream_ops.h" #include -#include - typedef enum { HIP_OP_ID_DISPATCH = 0, HIP_OP_ID_COPY = 1, @@ -48,15 +34,4 @@ typedef enum { HIP_OP_ID_NUMBER = 3 } hip_op_id_t; -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -// Traced calls ID enumeration -typedef enum hip_api_id_t roctracer_hip_api_cid_t; - -#ifdef __cplusplus -} // extern "C" block -#endif // __cplusplus - -#endif // INC_ROCTRACER_HIP_H_ +#endif // ROCTRACER_HIP_H_ diff --git a/inc/roctracer_hsa.h b/inc/roctracer_hsa.h index 5f86c5a21e..4af350016e 100644 --- a/inc/roctracer_hsa.h +++ b/inc/roctracer_hsa.h @@ -18,14 +18,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef INC_ROCTRACER_HSA_H_ -#define INC_ROCTRACER_HSA_H_ +#ifndef ROCTRACER_HSA_H_ +#define ROCTRACER_HSA_H_ -#include +#include "roctracer.h" #include #include -#include +#include "hsa_ostream_ops.h" +#include "hsa_prof_str.h" // HSA OP ID enumeration enum hsa_op_id_t { @@ -55,11 +56,12 @@ struct hsa_ops_properties_t { typedef struct { union { struct { - const void* ptr; // allocated area ptr - size_t size; // allocated area size, zero size means 'free' callback + const void* ptr; // allocated area ptr + size_t size; // allocated area size, zero size means 'free' callback hsa_amd_segment_t segment; // allocated area's memory segment type - hsa_amd_memory_pool_global_flag_t global_flag; // allocated area's memory global flag - int is_code; // equal to 1 if code is allocated + hsa_amd_memory_pool_global_flag_t + global_flag; // allocated area's memory global flag + int is_code; // equal to 1 if code is allocated } allocate; struct { @@ -76,11 +78,12 @@ typedef struct { } memcopy; struct { - const void* packet; // submitted to GPU packet - const char* kernel_name; // kernel name, NULL if not a kernel dispatch packet - hsa_queue_t* queue; // HSA queue the packet was submitted to - uint32_t device_type; // type of device the packet is submitted to - uint32_t device_id; // id of device the packet is submitted to + const void* packet; // submitted to GPU packet + const char* + kernel_name; // kernel name, NULL if not a kernel dispatch packet + hsa_queue_t* queue; // HSA queue the packet was submitted to + uint32_t device_type; // type of device the packet is submitted to + uint32_t device_id; // id of device the packet is submitted to } submit; struct { @@ -98,11 +101,12 @@ typedef struct { uint64_t load_base; // code object load base uint64_t load_size; // code object load size uint64_t load_delta; // code object load size - uint32_t uri_length; // URI string length (not including the terminating NUL character) - const char* uri; // URI string - int unload; // unload flag + uint32_t uri_length; // URI string length (not including the terminating + // NUL character) + const char* uri; // URI string + int unload; // unload flag } codeobj; }; } hsa_evt_data_t; -#endif // INC_ROCTRACER_HSA_H_ +#endif // ROCTRACER_HSA_H_ diff --git a/inc/roctracer_plugin.h b/inc/roctracer_plugin.h index b4a47d56b3..da8a6d725e 100644 --- a/inc/roctracer_plugin.h +++ b/inc/roctracer_plugin.h @@ -77,9 +77,8 @@ extern "C" { * * @return Returns 0 on success and -1 on error. */ -ROCTRACER_EXPORT int -roctracer_plugin_initialize(uint32_t roctracer_major_version, - uint32_t roctracer_minor_version); +ROCTRACER_EXPORT int roctracer_plugin_initialize( + uint32_t roctracer_major_version, uint32_t roctracer_minor_version); /** * Finalize plugin. @@ -109,9 +108,8 @@ ROCTRACER_EXPORT void roctracer_plugin_finalize(); * * @return Returns 0 on success and -1 on error. */ -ROCTRACER_EXPORT int -roctracer_plugin_write_callback_record(const roctracer_record_t *record, - const void *callback_data); +ROCTRACER_EXPORT int roctracer_plugin_write_callback_record( + const roctracer_record_t* record, const void* callback_data); /** * Report a range of activity trace data. @@ -127,9 +125,8 @@ roctracer_plugin_write_callback_record(const roctracer_record_t *record, * * @return Returns 0 on success and -1 on error. */ -ROCTRACER_EXPORT int -roctracer_plugin_write_activity_records(const roctracer_record_t *begin, - const roctracer_record_t *end); +ROCTRACER_EXPORT int roctracer_plugin_write_activity_records( + const roctracer_record_t* begin, const roctracer_record_t* end); /** @} */ diff --git a/inc/roctracer_roctx.h b/inc/roctracer_roctx.h index b333571364..8ff3190f63 100644 --- a/inc/roctracer_roctx.h +++ b/inc/roctracer_roctx.h @@ -21,7 +21,7 @@ #ifndef ROCTRACER_ROCTX_H_ #define ROCTRACER_ROCTX_H_ -#include +#include "roctx.h" /** * ROCTX API ID enumeration diff --git a/inc/roctx.h b/inc/roctx.h index cec83dc897..ccec5a185b 100644 --- a/inc/roctx.h +++ b/inc/roctx.h @@ -211,7 +211,8 @@ typedef uint64_t roctx_range_id_t; * * \return Returns the ID of the new range. */ -ROCTX_API roctx_range_id_t roctxRangeStartA(const char* message) ROCTX_VERSION_4_1; +ROCTX_API roctx_range_id_t roctxRangeStartA(const char* message) + ROCTX_VERSION_4_1; #define roctxRangeStart(message) roctxRangeStartA(message) /** diff --git a/script/gen_ostream_ops.py b/script/gen_ostream_ops.py index f40c9ced6f..aacbd7ce37 100755 --- a/script/gen_ostream_ops.py +++ b/script/gen_ostream_ops.py @@ -58,7 +58,15 @@ header_basic = \ ' using std::operator<<;\n' + \ ' static bool recursion = false;\n' + \ ' if (recursion == false) { recursion = true; out << v; recursion = false; }\n' + \ -' return out; }\n' +' return out;\n }\n' + \ +'\n' + \ +' inline static std::ostream &operator<<(std::ostream &out, const unsigned char &v) {\n' + \ +' out << (unsigned int)v;\n' + \ +' return out;\n }\n' + \ +'\n' + \ +' inline static std::ostream &operator<<(std::ostream &out, const char &v) {\n' + \ +' out << (unsigned char)v;\n' + \ +' return out;\n }\n' structs_analyzed = {} global_ops = '' @@ -153,11 +161,12 @@ def gen_cppheader(infilepath, outfilepath, rank): header_s = \ '#ifndef INC_' + apiname + '_OSTREAM_OPS_H_\n' + \ '#define INC_' + apiname + '_OSTREAM_OPS_H_\n' + \ + '\n' + \ + '#include "roctracer.h"\n' + \ + '\n' + \ '#ifdef __cplusplus\n' + \ '#include \n' + \ - '\n' + \ - '#include "roctracer.h"\n' - header_s += '#include \n' + '#include \n' output_filename_h.write(header_s) output_filename_h.write('\n') diff --git a/test/app/codeobj_test.cpp b/test/app/codeobj_test.cpp index 16a8a72e92..0737d49a97 100644 --- a/test/app/codeobj_test.cpp +++ b/test/app/codeobj_test.cpp @@ -22,8 +22,8 @@ #include #include -#include "inc/roctracer.h" -#include "inc/roctracer_hsa.h" +#include "roctracer.h" +#include "roctracer_hsa.h" namespace { // Check returned HSA API status @@ -66,4 +66,4 @@ ROCTRACER_EXPORT void OnUnload() { CHECK(roctracer_disable_domain_callback(ACTIVITY_DOMAIN_HSA_EVT)); } -} // extern "C" \ No newline at end of file +} // extern "C"