Skip to content

Commit

Permalink
Cleanup the include files
Browse files Browse the repository at this point in the history
Use #include "header" instead of #include <header> so that the header
files are found when the application #includes <roctracer/roctracer.h>
with -I /opt/rocm/include.

Change-Id: I24feac9a5030d3600aee98084340e246c3990db5
  • Loading branch information
lmoriche committed Sep 13, 2022
1 parent 4856d33 commit 05ee3ff
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 114 deletions.
1 change: 1 addition & 0 deletions inc/.clang-format
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
BasedOnStyle: InheritParentConfig
ColumnLimit: 79
...
34 changes: 18 additions & 16 deletions inc/ext/prof_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
55 changes: 27 additions & 28 deletions inc/roctracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
#include <stddef.h>
#include <stdint.h>

#include <ext/prof_protocol.h>
#include "ext/prof_protocol.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -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;

/** @} */

Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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;

/** @} */

Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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;

/**
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;

/** @} */

Expand Down
14 changes: 11 additions & 3 deletions inc/roctracer_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@
#ifndef ROCTRACER_EXT_H_
#define ROCTRACER_EXT_H_

#include <roctracer.h>
#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)();
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions inc/roctracer_hcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <roctracer_hip.h>
#include "roctracer_hip.h"
35 changes: 5 additions & 30 deletions inc/roctracer_hip.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,20 @@
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 <iostream>

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 <hip/hip_runtime.h>
#include <hip_ostream_ops.h>
#include "hip_ostream_ops.h"
#include <hip/amd_detail/hip_prof_str.h>

#include <roctracer.h>

typedef enum {
HIP_OP_ID_DISPATCH = 0,
HIP_OP_ID_COPY = 1,
HIP_OP_ID_BARRIER = 2,
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_
Loading

0 comments on commit 05ee3ff

Please sign in to comment.