[SDK][rocprofv3] Buffer tracing records with args (HIP) (#285)

* [SDK][rocprofv3] HIP API buffer records with args (ext)

- New buffer tracing domain(s) for HIP APIs which include the arguments and the return value in the buffer records
- Update HIP stream support for extended HIP buffer tracing
- Update rocprofv3 tool library and output library to use extended HIP buffer tracing recods

* Update stream.cpp

- handle hipStream_t address being reused for a new stream

* Update doxygen docs for rocprofiler_iterate_buffer_tracing_record_args

* Update rocprofv3 tool.cpp

- configure buffer tracing services with HIP_*_API_EXT variants
- tweak logging level for hip_stream_display_callback

* Fix validation tests

- add HIP_RUNTIME_API_EXT and HIP_COMPILER_API_EXT to valid domain names

* Serialization support for buffer tracing args

* Disable stream service for __hipPopCallConfiguration

- this is interpreted as a stream create but it doesn't create a stream

* Fix execute_buffer_record_emplace for HIP extended contexts

* Add uint64_t_retval to rocprofiler_hip_api_retval_t union

- reading in hipError_t_retval during serialization of pointer return value causes undefined behavior

* Fix compilation warning about unused but set parameter

- in hip/stream.cpp

* Add synchronization for async_copy_data

* Fix compilation error

* Fix compilation error

---------

Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
This commit is contained in:
Madsen, Jonathan
2025-03-22 19:57:32 -05:00
committed by GitHub
parent 2d072f9217
commit e33dff7ad0
30 changed files with 548 additions and 118 deletions
@@ -39,6 +39,7 @@
#include "lib/rocprofiler-sdk/rocjpeg/rocjpeg.hpp"
#include "lib/rocprofiler-sdk/runtime_initialization.hpp"
#include <rocprofiler-sdk/buffer_tracing.h>
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/hip/table_id.h>
#include <rocprofiler-sdk/hsa/table_id.h>
@@ -99,6 +100,8 @@ ROCPROFILER_BUFFER_TRACING_KIND_STRING(RUNTIME_INITIALIZATION)
ROCPROFILER_BUFFER_TRACING_KIND_STRING(ROCDECODE_API)
ROCPROFILER_BUFFER_TRACING_KIND_STRING(ROCJPEG_API)
ROCPROFILER_BUFFER_TRACING_KIND_STRING(HIP_STREAM_API)
ROCPROFILER_BUFFER_TRACING_KIND_STRING(HIP_RUNTIME_API_EXT)
ROCPROFILER_BUFFER_TRACING_KIND_STRING(HIP_COMPILER_API_EXT)
template <size_t Idx, size_t... Tail>
std::pair<const char*, size_t>
@@ -263,11 +266,13 @@ rocprofiler_query_buffer_tracing_kind_operation_name(rocprofiler_buffer_tracing_
break;
}
case ROCPROFILER_BUFFER_TRACING_HIP_RUNTIME_API:
case ROCPROFILER_BUFFER_TRACING_HIP_RUNTIME_API_EXT:
{
val = rocprofiler::hip::name_by_id<ROCPROFILER_HIP_TABLE_ID_Runtime>(operation);
break;
}
case ROCPROFILER_BUFFER_TRACING_HIP_COMPILER_API:
case ROCPROFILER_BUFFER_TRACING_HIP_COMPILER_API_EXT:
{
val = rocprofiler::hip::name_by_id<ROCPROFILER_HIP_TABLE_ID_Compiler>(operation);
break;
@@ -410,11 +415,13 @@ rocprofiler_iterate_buffer_tracing_kind_operations(
break;
}
case ROCPROFILER_BUFFER_TRACING_HIP_RUNTIME_API:
case ROCPROFILER_BUFFER_TRACING_HIP_RUNTIME_API_EXT:
{
ops = rocprofiler::hip::get_ids<ROCPROFILER_HIP_TABLE_ID_Runtime>();
break;
}
case ROCPROFILER_BUFFER_TRACING_HIP_COMPILER_API:
case ROCPROFILER_BUFFER_TRACING_HIP_COMPILER_API_EXT:
{
ops = rocprofiler::hip::get_ids<ROCPROFILER_HIP_TABLE_ID_Compiler>();
break;
@@ -467,6 +474,54 @@ rocprofiler_iterate_buffer_tracing_kind_operations(
}
return ROCPROFILER_STATUS_SUCCESS;
}
rocprofiler_status_t
rocprofiler_iterate_buffer_tracing_record_args(
rocprofiler_record_header_t record,
rocprofiler_buffer_tracing_operation_args_cb_t callback,
void* user_data)
{
switch(record.kind)
{
case ROCPROFILER_BUFFER_TRACING_NONE:
case ROCPROFILER_BUFFER_TRACING_LAST:
{
return ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENT;
}
case ROCPROFILER_BUFFER_TRACING_HSA_CORE_API:
case ROCPROFILER_BUFFER_TRACING_HSA_AMD_EXT_API:
case ROCPROFILER_BUFFER_TRACING_HSA_IMAGE_EXT_API:
case ROCPROFILER_BUFFER_TRACING_HSA_FINALIZE_EXT_API:
case ROCPROFILER_BUFFER_TRACING_MARKER_CORE_API:
case ROCPROFILER_BUFFER_TRACING_MARKER_CONTROL_API:
case ROCPROFILER_BUFFER_TRACING_MARKER_NAME_API:
case ROCPROFILER_BUFFER_TRACING_SCRATCH_MEMORY:
case ROCPROFILER_BUFFER_TRACING_KERNEL_DISPATCH:
case ROCPROFILER_BUFFER_TRACING_MEMORY_COPY:
case ROCPROFILER_BUFFER_TRACING_RCCL_API:
{
return ROCPROFILER_STATUS_ERROR_NOT_IMPLEMENTED;
}
case ROCPROFILER_BUFFER_TRACING_HIP_COMPILER_API_EXT:
{
auto* _payload =
static_cast<rocprofiler_buffer_tracing_hip_api_ext_record_t*>(record.payload);
rocprofiler::hip::iterate_args<ROCPROFILER_HIP_TABLE_ID_Compiler>(
_payload->operation, _payload->args, callback, user_data);
return ROCPROFILER_STATUS_SUCCESS;
}
case ROCPROFILER_BUFFER_TRACING_HIP_RUNTIME_API_EXT:
{
auto* _payload =
static_cast<rocprofiler_buffer_tracing_hip_api_ext_record_t*>(record.payload);
rocprofiler::hip::iterate_args<ROCPROFILER_HIP_TABLE_ID_Runtime>(
_payload->operation, _payload->args, callback, user_data);
return ROCPROFILER_STATUS_SUCCESS;
}
}
return ROCPROFILER_STATUS_ERROR_NOT_IMPLEMENTED;
}
}
#undef RETURN_STATUS_ON_FAIL