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
This commit is contained in:
Jonathan R. Madsen
2024-03-01 01:46:07 -06:00
committed by GitHub
parent a1267e1fd2
commit 1bb94add11
27 changed files with 419 additions and 200 deletions
@@ -37,6 +37,7 @@
#include <glog/logging.h>
#include <atomic>
#include <cstdint>
#include <vector>
#define RETURN_STATUS_ON_FAIL(...) \
@@ -325,8 +326,20 @@ rocprofiler_status_t
rocprofiler_iterate_callback_tracing_kind_operation_args(
rocprofiler_callback_tracing_record_t record,
rocprofiler_callback_tracing_operation_args_cb_t callback,
int32_t max_deref,
void* user_data)
{
if(max_deref > 1 && record.phase == ROCPROFILER_CALLBACK_PHASE_ENTER)
{
const char* name = "(unknown)";
rocprofiler_query_callback_tracing_kind_operation_name(
record.kind, record.operation, &name, nullptr);
LOG(WARNING) << __FUNCTION__
<< " invoked with a max dereference count > 1 when the record.phase == "
<< "ROCPROFILER_CALLBACK_PHASE_ENTER for '" << name
<< "' record. This may result in a segmentation fault";
}
switch(record.kind)
{
case ROCPROFILER_CALLBACK_TRACING_NONE:
@@ -340,6 +353,7 @@ rocprofiler_iterate_callback_tracing_kind_operation_args(
record.operation,
*static_cast<rocprofiler_callback_tracing_hsa_api_data_t*>(record.payload),
callback,
max_deref,
user_data);
return ROCPROFILER_STATUS_SUCCESS;
}
@@ -349,6 +363,7 @@ rocprofiler_iterate_callback_tracing_kind_operation_args(
record.operation,
*static_cast<rocprofiler_callback_tracing_hsa_api_data_t*>(record.payload),
callback,
max_deref,
user_data);
return ROCPROFILER_STATUS_SUCCESS;
}
@@ -358,6 +373,7 @@ rocprofiler_iterate_callback_tracing_kind_operation_args(
record.operation,
*static_cast<rocprofiler_callback_tracing_hsa_api_data_t*>(record.payload),
callback,
max_deref,
user_data);
return ROCPROFILER_STATUS_SUCCESS;
}
@@ -367,6 +383,7 @@ rocprofiler_iterate_callback_tracing_kind_operation_args(
record.operation,
*static_cast<rocprofiler_callback_tracing_hsa_api_data_t*>(record.payload),
callback,
max_deref,
user_data);
return ROCPROFILER_STATUS_SUCCESS;
}
@@ -376,6 +393,7 @@ rocprofiler_iterate_callback_tracing_kind_operation_args(
record.operation,
*static_cast<rocprofiler_callback_tracing_marker_api_data_t*>(record.payload),
callback,
max_deref,
user_data);
return ROCPROFILER_STATUS_SUCCESS;
}
@@ -385,6 +403,7 @@ rocprofiler_iterate_callback_tracing_kind_operation_args(
record.operation,
*static_cast<rocprofiler_callback_tracing_marker_api_data_t*>(record.payload),
callback,
max_deref,
user_data);
return ROCPROFILER_STATUS_SUCCESS;
}
@@ -394,16 +413,27 @@ rocprofiler_iterate_callback_tracing_kind_operation_args(
record.operation,
*static_cast<rocprofiler_callback_tracing_marker_api_data_t*>(record.payload),
callback,
max_deref,
user_data);
return ROCPROFILER_STATUS_SUCCESS;
}
case ROCPROFILER_CALLBACK_TRACING_HIP_COMPILER_API:
{
rocprofiler::hip::iterate_args<ROCPROFILER_HIP_TABLE_ID_Compiler>(
record.operation,
*static_cast<rocprofiler_callback_tracing_hip_api_data_t*>(record.payload),
callback,
max_deref,
user_data);
return ROCPROFILER_STATUS_SUCCESS;
}
case ROCPROFILER_CALLBACK_TRACING_HIP_RUNTIME_API:
{
rocprofiler::hip::iterate_args<ROCPROFILER_HIP_TABLE_ID_Runtime>(
record.operation,
*static_cast<rocprofiler_callback_tracing_hip_api_data_t*>(record.payload),
callback,
max_deref,
user_data);
return ROCPROFILER_STATUS_SUCCESS;
}