Fix rocprofiler_iterate_callback_tracing_kind_operation_args for HIP compiler callbacks (#532)
* Fix HIP compiler iterate args
- `include/rocprofiler-sdk/hip/api_args.h`
- replace struct fields named "f" with "func"
- replace hip stream fields named "hStream" with "stream"
- `lib/rocprofiler-sdk/callback_tracing.cpp`
- iterate_args for HIP compiler table
- `lib/rocprofiler-sdk/registration.cpp`
- fix warning about roctx num_tables
- `lib/rocprofiler-sdk/hip/hip.def.cpp`
- replace struct fields named "f" with "func"
- replace hip stream fields named "hStream" with "stream"
- `lib/rocprofiler-sdk/{hip,hsa,marker}/utils.hpp`
- improve `stringize_impl`
- `lib/rocprofiler-sdk/hsa/code_object.cpp`
- remove stale commented out code
- `lib/rocprofiler-sdk/hsa/queue_controller.*`
- destory_queue -> destroy_queue
- `tests/tools/json-tool.cpp`
- improve parallelism in tool_tracing_callback
- serialize the marker api args
- only invoke rocprofiler_iterate_callback_tracing_kind_operation_args in exit phase
- `samples/counter_collection/CMakeLists.txt`
- reduce timeout on tests to 120 seconds
* Update lib/rocprofiler-sdk/hsa/utils.hpp
- disable dereference of double pointer in stringize_impl
* Update lib/common
- indirection_level in mpl.hpp
- stringize_arg.hpp
* Rework rocprofiler_iterate_callback_tracing_kind_operation_args
- provide more information in rocprofiler_callback_tracing_operation_args_cb_t
- support specifying the dereference level to account for output paramters
[ROCm/rocprofiler-sdk commit: 1bb94add11]
Tento commit je obsažen v:
1 rodič
15302ff11d
revize
cb6b79c323
27 files changed
+419
-200
No files matched your search
@@ -193,18 +193,26 @@ typedef int (*rocprofiler_callback_tracing_kind_operation_cb_t)(
|
||||
* @param [in] kind domain
|
||||
* @param [in] operation associated domain operation
|
||||
* @param [in] arg_number the argument number, starting at zero
|
||||
* @param [in] arg_value_addr the address of the argument stored by rocprofiler.
|
||||
* @param [in] arg_indirection_count the total number of indirection levels for the argument, e.g.
|
||||
* int == 0, int* == 1, int** == 2
|
||||
* @param [in] arg_type the typeid name of the argument
|
||||
* @param [in] arg_name the name of the argument in the prototype (or rocprofiler union)
|
||||
* @param [in] arg_value_str conversion of the argument to a string, e.g. operator<< overload
|
||||
* @param [in] arg_value_addr the address of the argument stored by rocprofiler.
|
||||
* @param [in] arg_dereference_count the number of times the argument was dereferenced when it was
|
||||
* converted to a string
|
||||
* @param [in] data user data
|
||||
*/
|
||||
typedef int (*rocprofiler_callback_tracing_operation_args_cb_t)(
|
||||
rocprofiler_callback_tracing_kind_t kind,
|
||||
uint32_t operation,
|
||||
uint32_t arg_number,
|
||||
const void* const arg_value_addr,
|
||||
int32_t arg_indirection_count,
|
||||
const char* arg_type,
|
||||
const char* arg_name,
|
||||
const char* arg_value_str,
|
||||
const void* const arg_value_addr,
|
||||
int32_t arg_dereference_count,
|
||||
void* data);
|
||||
|
||||
/**
|
||||
@@ -322,14 +330,63 @@ rocprofiler_iterate_callback_tracing_kind_operations(
|
||||
* particularly useful when tools want to annotate traces with the function arguments. See
|
||||
* @example samples/api_callback_tracing/client.cpp for a usage example.
|
||||
*
|
||||
* It is recommended to use this function when the record phase is ::ROCPROFILER_CALLBACK_PHASE_EXIT
|
||||
* or ::ROCPROFILER_CALLBACK_PHASE_NONE. When the phase is ::ROCPROFILER_CALLBACK_PHASE_ENTER, the
|
||||
* function may have output parameters which have not set. In the case of an output parameter with
|
||||
* one level of indirection, e.g. `int* output_len`, this is considered safe since the output
|
||||
* parameter is either null or, in the worst case scenario, pointing to an uninitialized value which
|
||||
* will result in garbage values to be stringified. However, if the output parameter has more than
|
||||
* one level of indirection, e.g. `const char** output_name`, this can result in a segmentation
|
||||
* fault because the dereferenced output parameter may be uninitialized and point to an invalid
|
||||
address. E.g.:
|
||||
*
|
||||
* @code{.cpp}
|
||||
* struct dim3
|
||||
* {
|
||||
* int x;
|
||||
* int y;
|
||||
* int z;
|
||||
* };
|
||||
*
|
||||
* static dim3 default_dims = {.x = 1, .y = 1, .z = 1};
|
||||
*
|
||||
* void set_dim_x(int val, dim3* output_dims) { output_dims->x = val; }
|
||||
*
|
||||
* void get_default_dims(dim3** output_dims) { *output_dims = default_dims; }
|
||||
*
|
||||
* int main()
|
||||
* {
|
||||
* dim3 my_dims; // uninitialized value. x, y, and z may be set to random values
|
||||
* dim3* current_dims; // uninitialized pointer. May be set to invalid address
|
||||
*
|
||||
* set_dim_x(3, &my_dims); // if rocprofiler-sdk wrapped this function and tried to stringify
|
||||
* // in the enter phase, dereferencing my_dims is not problematic
|
||||
* // since there is an actual dim3 allocation
|
||||
*
|
||||
* get_default_dims(¤t_dims); // if rocprofiler-sdk wrapped this function,
|
||||
* // and tried to stringify in the enter phase,
|
||||
* // current_dims may point to an address outside
|
||||
* // of the address space of this process and
|
||||
* // cause a segfault
|
||||
* }
|
||||
* @endcode
|
||||
*
|
||||
*
|
||||
* @param[in] record Record provided by service callback
|
||||
* @param[in] callback The callback function which will be invoked for each argument
|
||||
* @param[in] max_dereference_count In the callback enter phase, certain arguments may be output
|
||||
* parameters which have not been set. When the output parameter has multiple levels of indirection,
|
||||
* it may be invalid to dereference the output parameter more than once and doing so may result in a
|
||||
* segmentation fault. Thus, it is recommended to set this parameter to a maximum value of 1 when
|
||||
* the phase is ::ROCPROFILER_CALLBACK_PHASE_ENTER to ensure that output parameters which point to
|
||||
* uninitialized pointers do not cause segmentation faults.
|
||||
* @param[in] user_data Data to be passed to each invocation of the callback
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_iterate_callback_tracing_kind_operation_args(
|
||||
rocprofiler_callback_tracing_record_t record,
|
||||
rocprofiler_callback_tracing_operation_args_cb_t callback,
|
||||
int32_t max_dereference_count,
|
||||
void* user_data) ROCPROFILER_NONNULL(2);
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -1298,7 +1298,7 @@ typedef union rocprofiler_hip_api_args_u
|
||||
} hipIpcOpenMemHandle;
|
||||
struct
|
||||
{
|
||||
hipFunction_t f;
|
||||
hipFunction_t func;
|
||||
} hipKernelNameRef;
|
||||
struct
|
||||
{
|
||||
@@ -1311,7 +1311,7 @@ typedef union rocprofiler_hip_api_args_u
|
||||
} hipLaunchByPtr;
|
||||
struct
|
||||
{
|
||||
const void* f;
|
||||
const void* func;
|
||||
dim3 gridDim;
|
||||
dim3 blockDimX;
|
||||
void** kernelParams;
|
||||
@@ -1960,7 +1960,7 @@ typedef union rocprofiler_hip_api_args_u
|
||||
} hipModuleGetTexRef;
|
||||
struct
|
||||
{
|
||||
hipFunction_t f;
|
||||
hipFunction_t func;
|
||||
unsigned int gridDimX;
|
||||
unsigned int gridDimY;
|
||||
unsigned int gridDimZ;
|
||||
@@ -1979,7 +1979,7 @@ typedef union rocprofiler_hip_api_args_u
|
||||
} hipModuleLaunchCooperativeKernelMultiDevice;
|
||||
struct
|
||||
{
|
||||
hipFunction_t f;
|
||||
hipFunction_t func;
|
||||
unsigned int gridDimX;
|
||||
unsigned int gridDimY;
|
||||
unsigned int gridDimZ;
|
||||
@@ -2012,14 +2012,14 @@ typedef union rocprofiler_hip_api_args_u
|
||||
struct
|
||||
{
|
||||
int* numBlocks;
|
||||
hipFunction_t f;
|
||||
hipFunction_t func;
|
||||
int blockSize;
|
||||
size_t dynSharedMemPerBlk;
|
||||
} hipModuleOccupancyMaxActiveBlocksPerMultiprocessor;
|
||||
struct
|
||||
{
|
||||
int* numBlocks;
|
||||
hipFunction_t f;
|
||||
hipFunction_t func;
|
||||
int blockSize;
|
||||
size_t dynSharedMemPerBlk;
|
||||
unsigned int flags;
|
||||
@@ -2028,7 +2028,7 @@ typedef union rocprofiler_hip_api_args_u
|
||||
{
|
||||
int* gridSize;
|
||||
int* blockSize;
|
||||
hipFunction_t f;
|
||||
hipFunction_t func;
|
||||
size_t dynSharedMemPerBlk;
|
||||
int blockSizeLimit;
|
||||
} hipModuleOccupancyMaxPotentialBlockSize;
|
||||
@@ -2036,7 +2036,7 @@ typedef union rocprofiler_hip_api_args_u
|
||||
{
|
||||
int* gridSize;
|
||||
int* blockSize;
|
||||
hipFunction_t f;
|
||||
hipFunction_t func;
|
||||
size_t dynSharedMemPerBlk;
|
||||
int blockSizeLimit;
|
||||
unsigned int flags;
|
||||
@@ -2048,14 +2048,14 @@ typedef union rocprofiler_hip_api_args_u
|
||||
struct
|
||||
{
|
||||
int* numBlocks;
|
||||
const void* f;
|
||||
const void* func;
|
||||
int blockSize;
|
||||
size_t dynSharedMemPerBlk;
|
||||
} hipOccupancyMaxActiveBlocksPerMultiprocessor;
|
||||
struct
|
||||
{
|
||||
int* numBlocks;
|
||||
const void* f;
|
||||
const void* func;
|
||||
int blockSize;
|
||||
size_t dynSharedMemPerBlk;
|
||||
unsigned int flags;
|
||||
@@ -2064,7 +2064,7 @@ typedef union rocprofiler_hip_api_args_u
|
||||
{
|
||||
int* gridSize;
|
||||
int* blockSize;
|
||||
const void* f;
|
||||
const void* func;
|
||||
size_t dynSharedMemPerBlk;
|
||||
int blockSizeLimit;
|
||||
} hipOccupancyMaxPotentialBlockSize;
|
||||
@@ -2453,7 +2453,7 @@ typedef union rocprofiler_hip_api_args_u
|
||||
} hipCreateChannelDesc;
|
||||
struct
|
||||
{
|
||||
hipFunction_t f;
|
||||
hipFunction_t func;
|
||||
uint32_t globalWorkSizeX;
|
||||
uint32_t globalWorkSizeY;
|
||||
uint32_t globalWorkSizeZ;
|
||||
@@ -2461,7 +2461,7 @@ typedef union rocprofiler_hip_api_args_u
|
||||
uint32_t localWorkSizeY;
|
||||
uint32_t localWorkSizeZ;
|
||||
size_t sharedMemBytes;
|
||||
hipStream_t hStream;
|
||||
hipStream_t stream;
|
||||
void** kernelParams;
|
||||
void** extra;
|
||||
hipEvent_t startEvent;
|
||||
@@ -2470,7 +2470,7 @@ typedef union rocprofiler_hip_api_args_u
|
||||
} hipExtModuleLaunchKernel;
|
||||
struct
|
||||
{
|
||||
hipFunction_t f;
|
||||
hipFunction_t func;
|
||||
uint32_t globalWorkSizeX;
|
||||
uint32_t globalWorkSizeY;
|
||||
uint32_t globalWorkSizeZ;
|
||||
@@ -2478,7 +2478,7 @@ typedef union rocprofiler_hip_api_args_u
|
||||
uint32_t localWorkSizeY;
|
||||
uint32_t localWorkSizeZ;
|
||||
size_t sharedMemBytes;
|
||||
hipStream_t hStream;
|
||||
hipStream_t stream;
|
||||
void** kernelParams;
|
||||
void** extra;
|
||||
hipEvent_t startEvent;
|
||||
@@ -2699,12 +2699,12 @@ typedef union rocprofiler_hip_api_args_u
|
||||
} hipEventRecord_spt;
|
||||
struct
|
||||
{
|
||||
const void* f;
|
||||
const void* func;
|
||||
dim3 gridDim;
|
||||
dim3 blockDim;
|
||||
void** kernelParams;
|
||||
uint32_t sharedMemBytes;
|
||||
hipStream_t hStream;
|
||||
hipStream_t stream;
|
||||
} hipLaunchCooperativeKernel_spt;
|
||||
struct
|
||||
{
|
||||
|
||||
Reference in new issue
Zablokovat Uživatele