From 1bb94add113c3b42c14ab369a83b8d389034a0e5 Mon Sep 17 00:00:00 2001 From: "Jonathan R. Madsen" Date: Fri, 1 Mar 2024 01:46:07 -0600 Subject: [PATCH] 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 --- samples/api_callback_tracing/client.cpp | 13 +- .../rocprofiler-sdk/callback_tracing.h | 61 ++++++++- source/include/rocprofiler-sdk/hip/api_args.h | 34 ++--- source/lib/common/CMakeLists.txt | 1 + source/lib/common/mpl.hpp | 21 +++ source/lib/common/stringize_arg.hpp | 123 ++++++++++++++++++ .../lib/rocprofiler-sdk/callback_tracing.cpp | 30 +++++ source/lib/rocprofiler-sdk/hip/defines.hpp | 5 +- source/lib/rocprofiler-sdk/hip/hip.cpp | 26 ++-- source/lib/rocprofiler-sdk/hip/hip.def.cpp | 28 ++-- source/lib/rocprofiler-sdk/hip/hip.hpp | 1 + source/lib/rocprofiler-sdk/hip/utils.hpp | 35 +---- .../lib/rocprofiler-sdk/hsa/code_object.cpp | 14 -- source/lib/rocprofiler-sdk/hsa/defines.hpp | 9 +- source/lib/rocprofiler-sdk/hsa/hsa.cpp | 25 ++-- source/lib/rocprofiler-sdk/hsa/hsa.hpp | 1 + .../rocprofiler-sdk/hsa/queue_controller.cpp | 8 +- .../rocprofiler-sdk/hsa/queue_controller.hpp | 2 +- source/lib/rocprofiler-sdk/hsa/utils.hpp | 41 ++---- source/lib/rocprofiler-sdk/marker/defines.hpp | 5 +- source/lib/rocprofiler-sdk/marker/marker.cpp | 25 ++-- source/lib/rocprofiler-sdk/marker/marker.hpp | 1 + source/lib/rocprofiler-sdk/marker/utils.hpp | 39 ++---- source/lib/rocprofiler-sdk/registration.cpp | 6 +- .../rocprofiler-sdk/tests/registration.cpp | 10 +- source/lib/rocprofiler-sdk/tests/roctx.cpp | 10 +- tests/tools/json-tool.cpp | 45 +++++-- 27 files changed, 419 insertions(+), 200 deletions(-) create mode 100644 source/lib/common/stringize_arg.hpp diff --git a/samples/api_callback_tracing/client.cpp b/samples/api_callback_tracing/client.cpp index 9051c9d729..6b22ab4d1f 100644 --- a/samples/api_callback_tracing/client.cpp +++ b/samples/api_callback_tracing/client.cpp @@ -123,20 +123,27 @@ tool_tracing_callback(rocprofiler_callback_tracing_record_t record, auto info_data_cb = [](rocprofiler_callback_tracing_kind_t, uint32_t, uint32_t arg_num, + const void* const arg_value_addr, + int32_t indirection_count, + const char* arg_type, const char* arg_name, const char* arg_value_str, - const void* const arg_value_addr, + int32_t dereference_count, void* cb_data) -> int { auto& dss = *static_cast(cb_data); dss << ((arg_num == 0) ? "(" : ", "); dss << arg_num << ": " << arg_name << "=" << arg_value_str; (void) arg_value_addr; + (void) arg_type; + (void) indirection_count; + (void) dereference_count; return 0; }; - auto info_data = std::stringstream{}; + int32_t max_deref = (record.phase == ROCPROFILER_CALLBACK_PHASE_ENTER) ? 1 : 2; + auto info_data = std::stringstream{}; ROCPROFILER_CALL(rocprofiler_iterate_callback_tracing_kind_operation_args( - record, info_data_cb, static_cast(&info_data)), + record, info_data_cb, max_deref, static_cast(&info_data)), "Failure iterating trace operation args"); auto info_data_str = info_data.str(); diff --git a/source/include/rocprofiler-sdk/callback_tracing.h b/source/include/rocprofiler-sdk/callback_tracing.h index 99e1d08029..eb20ab0a9b 100644 --- a/source/include/rocprofiler-sdk/callback_tracing.h +++ b/source/include/rocprofiler-sdk/callback_tracing.h @@ -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); /** @} */ diff --git a/source/include/rocprofiler-sdk/hip/api_args.h b/source/include/rocprofiler-sdk/hip/api_args.h index 1db9ee906a..54a04d41f9 100644 --- a/source/include/rocprofiler-sdk/hip/api_args.h +++ b/source/include/rocprofiler-sdk/hip/api_args.h @@ -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 { diff --git a/source/lib/common/CMakeLists.txt b/source/lib/common/CMakeLists.txt index 49f0c73fe8..d9803be307 100644 --- a/source/lib/common/CMakeLists.txt +++ b/source/lib/common/CMakeLists.txt @@ -13,6 +13,7 @@ set(common_headers mpl.hpp scope_destructor.hpp static_object.hpp + stringize_arg.hpp synchronized.hpp utility.hpp xml.hpp) diff --git a/source/lib/common/mpl.hpp b/source/lib/common/mpl.hpp index 50dc8b879c..3187688e33 100644 --- a/source/lib/common/mpl.hpp +++ b/source/lib/common/mpl.hpp @@ -126,6 +126,27 @@ constexpr bool is_type_complete_v = false; // NOLINT(misc-definitions-in-header template // NOLINTNEXTLINE(misc-definitions-in-headers) constexpr bool is_type_complete_v> = true; + +template +struct indirection_level_impl_n +{ + using value_type = std::conditional_t::value, Tp, std::decay_t>; + static_assert(!std::is_pointer::value, "missing overload"); + static constexpr size_t value = N; +}; + +template +struct indirection_level_impl_n : indirection_level_impl_n +{}; + +template +struct indirection_level_impl_n : indirection_level_impl_n +{}; + +template +struct indirection_level +: indirection_level_impl_n>>, 0> +{}; } // namespace mpl } // namespace common } // namespace rocprofiler diff --git a/source/lib/common/stringize_arg.hpp b/source/lib/common/stringize_arg.hpp new file mode 100644 index 0000000000..f252bf9832 --- /dev/null +++ b/source/lib/common/stringize_arg.hpp @@ -0,0 +1,123 @@ +// MIT License +// +// Copyright (c) 2023 Advanced Micro Devices, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#pragma once + +#include "lib/common/mpl.hpp" + +#include +#include + +#include +#include +#include + +namespace rocprofiler +{ +namespace common +{ +struct stringified_argument +{ + int32_t indirection_level = 0; + int32_t dereference_count = 0; + const char* type = nullptr; + std::string name = {}; + std::string value = {}; +}; + +template +auto +stringize_arg_impl(const Tp& _v, const int32_t max_deref, int32_t& deref_cnt, FuncT&& impl) +{ + using value_type = std::decay_t; + using nonpointer_type = std::remove_pointer_t; + + if constexpr(common::mpl::is_string_type::value && + !std::is_pointer::value) + { + if constexpr(std::is_pointer::value) + { + if(!_v) return std::string{"(null)"}; + } + + return std::string{_v}; + } + else if constexpr(fmt::is_formattable::value && !std::is_pointer::value) + { + return fmt::format("{}", _v); + } + else if constexpr(std::is_pointer::value && + !std::is_pointer::value && + common::mpl::is_type_complete_v && + !std::is_void::value) + { + if(_v && deref_cnt < max_deref) + return stringize_arg_impl(*_v, max_deref, ++deref_cnt, std::forward(impl)); + else if(_v) + return std::forward(impl)(_v); + else + return std::string{"(null)"}; + } + else if constexpr(std::is_pointer::value && std::is_pointer::value) + { + using next_nonpointer_type = std::remove_pointer_t; + + if(_v) + { + if constexpr(!std::is_void::value) + { + if(deref_cnt < max_deref) + return stringize_arg_impl( + *_v, max_deref, ++deref_cnt, std::forward(impl)); + else + return std::forward(impl)(_v); + } + else + { + return std::forward(impl)(_v); + } + } + else + { + return std::string{"(null)"}; + } + } + else + { + return std::forward(impl)(_v); + } +} + +template +common::stringified_argument +stringize_arg(int32_t max_deref, const std::pair& arg, FuncT&& impl) +{ + auto _arg = common::stringified_argument{}; + _arg.indirection_level = mpl::indirection_level::value; + _arg.type = typeid(Tp).name(); + _arg.name = std::string{arg.first}; + _arg.value = stringize_arg_impl( + arg.second, max_deref, _arg.dereference_count, std::forward(impl)); + return _arg; +} +} // namespace common +} // namespace rocprofiler diff --git a/source/lib/rocprofiler-sdk/callback_tracing.cpp b/source/lib/rocprofiler-sdk/callback_tracing.cpp index 293609e568..6759cb1def 100644 --- a/source/lib/rocprofiler-sdk/callback_tracing.cpp +++ b/source/lib/rocprofiler-sdk/callback_tracing.cpp @@ -37,6 +37,7 @@ #include #include +#include #include #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(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(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(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(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(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(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(record.payload), callback, + max_deref, user_data); return ROCPROFILER_STATUS_SUCCESS; } case ROCPROFILER_CALLBACK_TRACING_HIP_COMPILER_API: + { + rocprofiler::hip::iterate_args( + record.operation, + *static_cast(record.payload), + callback, + max_deref, + user_data); + return ROCPROFILER_STATUS_SUCCESS; + } case ROCPROFILER_CALLBACK_TRACING_HIP_RUNTIME_API: { rocprofiler::hip::iterate_args( record.operation, *static_cast(record.payload), callback, + max_deref, user_data); return ROCPROFILER_STATUS_SUCCESS; } diff --git a/source/lib/rocprofiler-sdk/hip/defines.hpp b/source/lib/rocprofiler-sdk/hip/defines.hpp index 47927449cb..9ce3bd41b4 100644 --- a/source/lib/rocprofiler-sdk/hip/defines.hpp +++ b/source/lib/rocprofiler-sdk/hip/defines.hpp @@ -98,7 +98,7 @@ \ static std::vector as_arg_addr(callback_data_type) { return std::vector{}; } \ \ - static std::vector> as_arg_list(callback_data_type) \ + static std::vector as_arg_list(callback_data_type, int32_t) \ { \ return {}; \ } \ @@ -185,9 +185,10 @@ GET_ADDR_MEMBER_FIELDS(get_api_data_args(trace_data.args), __VA_ARGS__)}; \ } \ \ - static auto as_arg_list(callback_data_type trace_data) \ + static auto as_arg_list(callback_data_type trace_data, int32_t max_deref) \ { \ return utils::stringize( \ + max_deref, \ GET_NAMED_MEMBER_FIELDS(get_api_data_args(trace_data.args), __VA_ARGS__)); \ } \ }; \ diff --git a/source/lib/rocprofiler-sdk/hip/hip.cpp b/source/lib/rocprofiler-sdk/hip/hip.cpp index 941a46c113..4cd08d15a8 100644 --- a/source/lib/rocprofiler-sdk/hip/hip.cpp +++ b/source/lib/rocprofiler-sdk/hip/hip.cpp @@ -438,29 +438,34 @@ void iterate_args(const uint32_t id, const DataT& data, rocprofiler_callback_tracing_operation_args_cb_t func, + int32_t max_deref, void* user_data, std::index_sequence) { if(OpIdx == id) { using info_type = hip_api_info; - auto&& arg_list = info_type::as_arg_list(data); + auto&& arg_list = info_type::as_arg_list(data, max_deref); auto&& arg_addr = info_type::as_arg_addr(data); for(size_t i = 0; i < std::min(arg_list.size(), arg_addr.size()); ++i) { - auto ret = func(info_type::callback_domain_idx, // kind - id, // operation - i, // arg_number - arg_list.at(i).first.c_str(), // arg_name - arg_list.at(i).second.c_str(), // arg_value_str - arg_addr.at(i), // arg_value_addr + auto ret = func(info_type::callback_domain_idx, // kind + id, // operation + i, // arg_number + arg_addr.at(i), // arg_value_addr + arg_list.at(i).indirection_level, // indirection + arg_list.at(i).type, // arg_type + arg_list.at(i).name.c_str(), // arg_name + arg_list.at(i).value.c_str(), // arg_value_str + arg_list.at(i).dereference_count, // num deref in str user_data); if(ret != 0) break; } return; } if constexpr(sizeof...(OpIdxTail) > 0) - iterate_args(id, data, func, user_data, std::index_sequence{}); + iterate_args( + id, data, func, max_deref, user_data, std::index_sequence{}); } bool @@ -617,12 +622,14 @@ void iterate_args(uint32_t id, const rocprofiler_callback_tracing_hip_api_data_t& data, rocprofiler_callback_tracing_operation_args_cb_t callback, + int32_t max_deref, void* user_data) { if(callback) iterate_args(id, data, callback, + max_deref, user_data, std::make_index_sequence::last>{}); } @@ -656,7 +663,8 @@ using hip_op_args_cb_t = rocprofiler_callback_tracing_operation_args_cb_t; template uint32_t id_by_name(const char*); \ template std::vector get_ids(); \ template std::vector get_names(); \ - template void iterate_args(uint32_t, const hip_api_data_t&, hip_op_args_cb_t, void*); + template void iterate_args( \ + uint32_t, const hip_api_data_t&, hip_op_args_cb_t, int32_t, void*); INSTANTIATE_HIP_TABLE_FUNC(hip_runtime_api_table_t, ROCPROFILER_HIP_TABLE_ID_Runtime) INSTANTIATE_HIP_TABLE_FUNC(hip_compiler_api_table_t, ROCPROFILER_HIP_TABLE_ID_Compiler) diff --git a/source/lib/rocprofiler-sdk/hip/hip.def.cpp b/source/lib/rocprofiler-sdk/hip/hip.def.cpp index 050d8ead14..2232ca110b 100644 --- a/source/lib/rocprofiler-sdk/hip/hip.def.cpp +++ b/source/lib/rocprofiler-sdk/hip/hip.def.cpp @@ -284,10 +284,10 @@ HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNT HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipIpcGetMemHandle, hipIpcGetMemHandle, hipIpcGetMemHandle_fn, handle, devPtr) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipIpcOpenEventHandle, hipIpcOpenEventHandle, hipIpcOpenEventHandle_fn, event, handle) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipIpcOpenMemHandle, hipIpcOpenMemHandle, hipIpcOpenMemHandle_fn, devPtr, handle, flags) -HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipKernelNameRef, hipKernelNameRef, hipKernelNameRef_fn, f) +HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipKernelNameRef, hipKernelNameRef, hipKernelNameRef_fn, func) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipKernelNameRefByPtr, hipKernelNameRefByPtr, hipKernelNameRefByPtr_fn, hostFunction, stream) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipLaunchByPtr, hipLaunchByPtr, hipLaunchByPtr_fn, func) -HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipLaunchCooperativeKernel, hipLaunchCooperativeKernel, hipLaunchCooperativeKernel_fn, f, gridDim, blockDimX, kernelParams, sharedMemBytes, stream) +HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipLaunchCooperativeKernel, hipLaunchCooperativeKernel, hipLaunchCooperativeKernel_fn, func, gridDim, blockDimX, kernelParams, sharedMemBytes, stream) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipLaunchCooperativeKernelMultiDevice, hipLaunchCooperativeKernelMultiDevice, hipLaunchCooperativeKernelMultiDevice_fn, launchParamsList, numDevices, flags) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipLaunchHostFunc, hipLaunchHostFunc, hipLaunchHostFunc_fn, stream, fn, userData) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipLaunchKernel, hipLaunchKernel, hipLaunchKernel_fn, function_address, numBlocks, dimBlocks, args, sharedMemBytes, stream) @@ -382,20 +382,20 @@ HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNT HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleGetFunction, hipModuleGetFunction, hipModuleGetFunction_fn, function, module, kname) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleGetGlobal, hipModuleGetGlobal, hipModuleGetGlobal_fn, dptr, bytes, hmod, name) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleGetTexRef, hipModuleGetTexRef, hipModuleGetTexRef_fn, texRef, hmod, name) -HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleLaunchCooperativeKernel, hipModuleLaunchCooperativeKernel, hipModuleLaunchCooperativeKernel_fn, f, gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ, sharedMemBytes, stream, kernelParams) +HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleLaunchCooperativeKernel, hipModuleLaunchCooperativeKernel, hipModuleLaunchCooperativeKernel_fn, func, gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ, sharedMemBytes, stream, kernelParams) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleLaunchCooperativeKernelMultiDevice, hipModuleLaunchCooperativeKernelMultiDevice, hipModuleLaunchCooperativeKernelMultiDevice_fn, launchParamsList, numDevices, flags) -HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleLaunchKernel, hipModuleLaunchKernel, hipModuleLaunchKernel_fn, f, gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ, sharedMemBytes, stream, kernelParams, extra) +HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleLaunchKernel, hipModuleLaunchKernel, hipModuleLaunchKernel_fn, func, gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ, sharedMemBytes, stream, kernelParams, extra) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleLoad, hipModuleLoad, hipModuleLoad_fn, module, fname) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleLoadData, hipModuleLoadData, hipModuleLoadData_fn, module, image) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleLoadDataEx, hipModuleLoadDataEx, hipModuleLoadDataEx_fn, module, image, numOptions, options, optionValues) -HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleOccupancyMaxActiveBlocksPerMultiprocessor, hipModuleOccupancyMaxActiveBlocksPerMultiprocessor, hipModuleOccupancyMaxActiveBlocksPerMultiprocessor_fn, numBlocks, f, blockSize, dynSharedMemPerBlk) -HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags, hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags, hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags_fn, numBlocks, f, blockSize, dynSharedMemPerBlk, flags) -HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleOccupancyMaxPotentialBlockSize, hipModuleOccupancyMaxPotentialBlockSize, hipModuleOccupancyMaxPotentialBlockSize_fn, gridSize, blockSize, f, dynSharedMemPerBlk, blockSizeLimit) -HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleOccupancyMaxPotentialBlockSizeWithFlags, hipModuleOccupancyMaxPotentialBlockSizeWithFlags, hipModuleOccupancyMaxPotentialBlockSizeWithFlags_fn, gridSize, blockSize, f, dynSharedMemPerBlk, blockSizeLimit, flags) +HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleOccupancyMaxActiveBlocksPerMultiprocessor, hipModuleOccupancyMaxActiveBlocksPerMultiprocessor, hipModuleOccupancyMaxActiveBlocksPerMultiprocessor_fn, numBlocks, func, blockSize, dynSharedMemPerBlk) +HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags, hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags, hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags_fn, numBlocks, func, blockSize, dynSharedMemPerBlk, flags) +HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleOccupancyMaxPotentialBlockSize, hipModuleOccupancyMaxPotentialBlockSize, hipModuleOccupancyMaxPotentialBlockSize_fn, gridSize, blockSize, func, dynSharedMemPerBlk, blockSizeLimit) +HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleOccupancyMaxPotentialBlockSizeWithFlags, hipModuleOccupancyMaxPotentialBlockSizeWithFlags, hipModuleOccupancyMaxPotentialBlockSizeWithFlags_fn, gridSize, blockSize, func, dynSharedMemPerBlk, blockSizeLimit, flags) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipModuleUnload, hipModuleUnload, hipModuleUnload_fn, module) -HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipOccupancyMaxActiveBlocksPerMultiprocessor, hipOccupancyMaxActiveBlocksPerMultiprocessor, hipOccupancyMaxActiveBlocksPerMultiprocessor_fn, numBlocks, f, blockSize, dynSharedMemPerBlk) -HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags, hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags, hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags_fn, numBlocks, f, blockSize, dynSharedMemPerBlk, flags) -HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipOccupancyMaxPotentialBlockSize, hipOccupancyMaxPotentialBlockSize, hipOccupancyMaxPotentialBlockSize_fn, gridSize, blockSize, f, dynSharedMemPerBlk, blockSizeLimit) +HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipOccupancyMaxActiveBlocksPerMultiprocessor, hipOccupancyMaxActiveBlocksPerMultiprocessor, hipOccupancyMaxActiveBlocksPerMultiprocessor_fn, numBlocks, func, blockSize, dynSharedMemPerBlk) +HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags, hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags, hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags_fn, numBlocks, func, blockSize, dynSharedMemPerBlk, flags) +HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipOccupancyMaxPotentialBlockSize, hipOccupancyMaxPotentialBlockSize, hipOccupancyMaxPotentialBlockSize_fn, gridSize, blockSize, func, dynSharedMemPerBlk, blockSizeLimit) HIP_API_INFO_DEFINITION_0(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipPeekAtLastError, hipPeekAtLastError, hipPeekAtLastError_fn) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipPointerGetAttribute, hipPointerGetAttribute, hipPointerGetAttribute_fn, data, attribute, ptr) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipPointerGetAttributes, hipPointerGetAttributes, hipPointerGetAttributes_fn, attributes, ptr) @@ -464,8 +464,8 @@ HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNT HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipUserObjectRetain, hipUserObjectRetain, hipUserObjectRetain_fn, object, count) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipWaitExternalSemaphoresAsync, hipWaitExternalSemaphoresAsync, hipWaitExternalSemaphoresAsync_fn, extSemArray, paramsArray, numExtSems, stream) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipCreateChannelDesc, hipCreateChannelDesc, hipCreateChannelDesc_fn, x, y, z, w, f) -HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipExtModuleLaunchKernel, hipExtModuleLaunchKernel, hipExtModuleLaunchKernel_fn, f, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, localWorkSizeX, localWorkSizeY, localWorkSizeZ, sharedMemBytes, hStream, kernelParams, extra, startEvent, stopEvent, flags) -HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipHccModuleLaunchKernel, hipHccModuleLaunchKernel, hipHccModuleLaunchKernel_fn, f, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, localWorkSizeX, localWorkSizeY, localWorkSizeZ, sharedMemBytes, hStream, kernelParams, extra, startEvent, stopEvent) +HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipExtModuleLaunchKernel, hipExtModuleLaunchKernel, hipExtModuleLaunchKernel_fn, func, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, localWorkSizeX, localWorkSizeY, localWorkSizeZ, sharedMemBytes, stream, kernelParams, extra, startEvent, stopEvent, flags) +HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipHccModuleLaunchKernel, hipHccModuleLaunchKernel, hipHccModuleLaunchKernel_fn, func, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, localWorkSizeX, localWorkSizeY, localWorkSizeZ, sharedMemBytes, stream, kernelParams, extra, startEvent, stopEvent) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpy_spt, hipMemcpy_spt, hipMemcpy_spt_fn, dst, src, sizeBytes, kind) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyToSymbol_spt, hipMemcpyToSymbol_spt, hipMemcpyToSymbol_spt_fn, symbol, src, sizeBytes, offset, kind) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipMemcpyFromSymbol_spt, hipMemcpyFromSymbol_spt, hipMemcpyFromSymbol_spt_fn, dst, symbol, sizeBytes, offset, kind) @@ -494,7 +494,7 @@ HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNT HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamGetFlags_spt, hipStreamGetFlags_spt, hipStreamGetFlags_spt_fn, stream, flags) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamAddCallback_spt, hipStreamAddCallback_spt, hipStreamAddCallback_spt_fn, stream, callback, userData, flags) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipEventRecord_spt, hipEventRecord_spt, hipEventRecord_spt_fn, event, stream) -HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipLaunchCooperativeKernel_spt, hipLaunchCooperativeKernel_spt, hipLaunchCooperativeKernel_spt_fn, f, gridDim, blockDim, kernelParams, sharedMemBytes, hStream) +HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipLaunchCooperativeKernel_spt, hipLaunchCooperativeKernel_spt, hipLaunchCooperativeKernel_spt_fn, func, gridDim, blockDim, kernelParams, sharedMemBytes, stream) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipLaunchKernel_spt, hipLaunchKernel_spt, hipLaunchKernel_spt_fn, function_address, numBlocks, dimBlocks, args, sharedMemBytes, stream) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphLaunch_spt, hipGraphLaunch_spt, hipGraphLaunch_spt_fn, graphExec, stream) HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamBeginCapture_spt, hipStreamBeginCapture_spt, hipStreamBeginCapture_spt_fn, stream, mode) diff --git a/source/lib/rocprofiler-sdk/hip/hip.hpp b/source/lib/rocprofiler-sdk/hip/hip.hpp index 0146fc504a..4d39385be5 100644 --- a/source/lib/rocprofiler-sdk/hip/hip.hpp +++ b/source/lib/rocprofiler-sdk/hip/hip.hpp @@ -99,6 +99,7 @@ void iterate_args(uint32_t id, const rocprofiler_callback_tracing_hip_api_data_t& data, rocprofiler_callback_tracing_operation_args_cb_t callback, + int32_t max_deref, void* user_data); template diff --git a/source/lib/rocprofiler-sdk/hip/utils.hpp b/source/lib/rocprofiler-sdk/hip/utils.hpp index 0e2ae5f431..0ee23cc97c 100644 --- a/source/lib/rocprofiler-sdk/hip/utils.hpp +++ b/source/lib/rocprofiler-sdk/hip/utils.hpp @@ -25,6 +25,7 @@ #include #include "lib/common/mpl.hpp" +#include "lib/common/stringize_arg.hpp" #include "lib/rocprofiler-sdk/hip/details/ostream.hpp" #include "fmt/core.h" @@ -53,37 +54,12 @@ template auto stringize_impl(const Tp& _v) { - using nonpointer_type = typename std::remove_pointer_t; + using value_type = std::decay_t; - if constexpr(common::mpl::is_pair::value) - { - return std::make_pair(stringize_impl(_v.first), stringize_impl(_v.second)); - } - else if constexpr(std::is_constructible::value) - { - auto _ss = std::stringstream{}; - _ss << _v; - return _ss.str(); - } - else if constexpr(fmt::is_formattable::value && !std::is_pointer::value) + if constexpr(fmt::is_formattable::value && !std::is_pointer::value) { return fmt::format("{}", _v); } - else if constexpr(std::is_pointer::value && !std::is_pointer::value && - common::mpl::is_type_complete_v && - !std::is_void::value) - { - if(_v) - { - return stringize_impl(*_v); - } - else - { - auto _ss = std::stringstream{}; - _ss << _v; - return _ss.str(); - } - } else { auto _ss = std::stringstream{}; @@ -94,9 +70,10 @@ stringize_impl(const Tp& _v) template auto -stringize(Args... args) +stringize(int32_t max_deref, Args... args) { - return std::vector>{stringize_impl(args)...}; + return std::vector{common::stringize_arg( + max_deref, args, [](const auto& _v) { return stringize_impl(_v); })...}; } } // namespace utils } // namespace hip diff --git a/source/lib/rocprofiler-sdk/hsa/code_object.cpp b/source/lib/rocprofiler-sdk/hsa/code_object.cpp index c620b7552b..1cfec5e377 100644 --- a/source/lib/rocprofiler-sdk/hsa/code_object.cpp +++ b/source/lib/rocprofiler-sdk/hsa/code_object.cpp @@ -926,24 +926,10 @@ code_object_init(HsaApiTable* table) uint64_t get_kernel_id(uint64_t kernel_object) { - // return get_code_objects().rlock([kernel_object](const code_object_array_t& _data) -> uint64_t - // { - // for(const auto& itr : _data) - // { - // for(const auto& ditr : itr->symbols) - // { - // if(kernel_object == ditr->rocp_data.kernel_object) return - // ditr->rocp_data.kernel_id; - // } - // } - // return 0; - // }); - return get_kernel_object_map().rlock( [](const kernel_object_map_t& object_map, uint64_t _kern_obj) -> uint64_t { auto itr = object_map.find(_kern_obj); return (itr == object_map.end()) ? 0 : itr->second; - // return object_map.at(_kern_obj); }, kernel_object); } diff --git a/source/lib/rocprofiler-sdk/hsa/defines.hpp b/source/lib/rocprofiler-sdk/hsa/defines.hpp index d67f30fc32..d9b1d0568f 100644 --- a/source/lib/rocprofiler-sdk/hsa/defines.hpp +++ b/source/lib/rocprofiler-sdk/hsa/defines.hpp @@ -136,8 +136,9 @@ return std::vector{}; \ } \ \ - static std::vector> as_arg_list( \ - rocprofiler_callback_tracing_hsa_api_data_t) \ + static std::vector as_arg_list( \ + rocprofiler_callback_tracing_hsa_api_data_t, \ + int32_t) \ { \ return {}; \ } \ @@ -217,9 +218,11 @@ GET_ADDR_MEMBER_FIELDS(get_api_data_args(trace_data.args), __VA_ARGS__)}; \ } \ \ - static auto as_arg_list(rocprofiler_callback_tracing_hsa_api_data_t trace_data) \ + static auto as_arg_list(rocprofiler_callback_tracing_hsa_api_data_t trace_data, \ + int32_t max_deref) \ { \ return utils::stringize( \ + max_deref, \ GET_NAMED_MEMBER_FIELDS(get_api_data_args(trace_data.args), __VA_ARGS__)); \ } \ }; \ diff --git a/source/lib/rocprofiler-sdk/hsa/hsa.cpp b/source/lib/rocprofiler-sdk/hsa/hsa.cpp index 22c985e3a3..969d3bd901 100644 --- a/source/lib/rocprofiler-sdk/hsa/hsa.cpp +++ b/source/lib/rocprofiler-sdk/hsa/hsa.cpp @@ -496,29 +496,34 @@ void iterate_args(const uint32_t id, const rocprofiler_callback_tracing_hsa_api_data_t& data, rocprofiler_callback_tracing_operation_args_cb_t func, + int32_t max_deref, void* user_data, std::index_sequence) { if(OpIdx == id) { using info_type = hsa_api_info; - auto&& arg_list = info_type::as_arg_list(data); + auto&& arg_list = info_type::as_arg_list(data, max_deref); auto&& arg_addr = info_type::as_arg_addr(data); for(size_t i = 0; i < std::min(arg_list.size(), arg_addr.size()); ++i) { - auto ret = func(info_type::callback_domain_idx, // kind - id, // operation - i, // arg_number - arg_list.at(i).first.c_str(), // arg_name - arg_list.at(i).second.c_str(), // arg_value_str - arg_addr.at(i), // arg_value_addr + auto ret = func(info_type::callback_domain_idx, // kind + id, // operation + i, // arg_number + arg_addr.at(i), // arg_value_addr + arg_list.at(i).indirection_level, // indirection + arg_list.at(i).type, // arg_type + arg_list.at(i).name.c_str(), // arg_name + arg_list.at(i).value.c_str(), // arg_value_str + arg_list.at(i).dereference_count, // num deref in str user_data); if(ret != 0) break; } return; } if constexpr(sizeof...(IdxTail) > 0) - iterate_args(id, data, func, user_data, std::index_sequence{}); + iterate_args( + id, data, func, max_deref, user_data, std::index_sequence{}); } bool @@ -683,12 +688,14 @@ void iterate_args(uint32_t id, const rocprofiler_callback_tracing_hsa_api_data_t& data, rocprofiler_callback_tracing_operation_args_cb_t callback, + int32_t max_deref, void* user_data) { if(callback) iterate_args(id, data, callback, + max_deref, user_data, std::make_index_sequence::last>{}); } @@ -727,7 +734,7 @@ using iterate_args_cb_t = rocprofiler_callback_tracing_operation_args_cb_t; template std::vector get_ids(); \ template std::vector get_names(); \ template void iterate_args( \ - uint32_t, const iterate_args_data_t&, iterate_args_cb_t, void*); + uint32_t, const iterate_args_data_t&, iterate_args_cb_t, int32_t, void*); INSTANTIATE_HSA_TABLE_FUNC(hsa_core_table_t, ROCPROFILER_HSA_TABLE_ID_Core) INSTANTIATE_HSA_TABLE_FUNC(hsa_amd_ext_table_t, ROCPROFILER_HSA_TABLE_ID_AmdExt) diff --git a/source/lib/rocprofiler-sdk/hsa/hsa.hpp b/source/lib/rocprofiler-sdk/hsa/hsa.hpp index 508514ec48..0c5b08ee47 100644 --- a/source/lib/rocprofiler-sdk/hsa/hsa.hpp +++ b/source/lib/rocprofiler-sdk/hsa/hsa.hpp @@ -121,6 +121,7 @@ void iterate_args(uint32_t id, const rocprofiler_callback_tracing_hsa_api_data_t& data, rocprofiler_callback_tracing_operation_args_cb_t callback, + int32_t max_deref, void* user_data); template diff --git a/source/lib/rocprofiler-sdk/hsa/queue_controller.cpp b/source/lib/rocprofiler-sdk/hsa/queue_controller.cpp index 179025d4a5..65f737b674 100644 --- a/source/lib/rocprofiler-sdk/hsa/queue_controller.cpp +++ b/source/lib/rocprofiler-sdk/hsa/queue_controller.cpp @@ -76,7 +76,7 @@ create_queue(hsa_agent_t agent, hsa_status_t destroy_queue(hsa_queue_t* hsa_queue) { - get_queue_controller().destory_queue(hsa_queue); + get_queue_controller().destroy_queue(hsa_queue); return HSA_STATUS_SUCCESS; } @@ -106,7 +106,7 @@ QueueController::add_queue(hsa_queue_t* id, std::unique_ptr queue) } void -QueueController::destory_queue(hsa_queue_t* id) +QueueController::destroy_queue(hsa_queue_t* id) { const auto* queue = get_queue_controller().get_queue(*id); std::unique_lock cvlock(queue->cv_mutex); @@ -243,8 +243,8 @@ QueueController::init(CoreApiTable& core_table, AmdExtTable& ext_table) if(enable_intercepter) { - core_table.hsa_queue_create_fn = create_queue; - core_table.hsa_queue_destroy_fn = destroy_queue; + core_table.hsa_queue_create_fn = hsa::create_queue; + core_table.hsa_queue_destroy_fn = hsa::destroy_queue; } } diff --git a/source/lib/rocprofiler-sdk/hsa/queue_controller.hpp b/source/lib/rocprofiler-sdk/hsa/queue_controller.hpp index aaba4ca309..a2bce3d45c 100644 --- a/source/lib/rocprofiler-sdk/hsa/queue_controller.hpp +++ b/source/lib/rocprofiler-sdk/hsa/queue_controller.hpp @@ -73,7 +73,7 @@ public: // Called to add a queue that was created by the user program void add_queue(hsa_queue_t*, std::unique_ptr); - void destory_queue(hsa_queue_t*); + void destroy_queue(hsa_queue_t*); // Add callback to queues associated with the agent. Returns a client // id that can be used by callers to remove the callback. If no agent diff --git a/source/lib/rocprofiler-sdk/hsa/utils.hpp b/source/lib/rocprofiler-sdk/hsa/utils.hpp index 8faac60888..914a74ce35 100644 --- a/source/lib/rocprofiler-sdk/hsa/utils.hpp +++ b/source/lib/rocprofiler-sdk/hsa/utils.hpp @@ -25,15 +25,16 @@ #include #include "lib/common/mpl.hpp" +#include "lib/common/stringize_arg.hpp" -#include "fmt/core.h" -#include "fmt/ranges.h" - +#include +#include #include #include #include #include +#include #include #include #include @@ -56,37 +57,12 @@ template auto stringize_impl(const Tp& _v) { - using nonpointer_type = typename std::remove_pointer_t; + using value_type = std::decay_t; - if constexpr(common::mpl::is_pair::value) - { - return std::make_pair(stringize_impl(_v.first), stringize_impl(_v.second)); - } - else if constexpr(std::is_constructible::value) - { - auto _ss = std::stringstream{}; - _ss << _v; - return _ss.str(); - } - else if constexpr(fmt::is_formattable::value && !std::is_pointer::value) + if constexpr(fmt::is_formattable::value && !std::is_pointer::value) { return fmt::format("{}", _v); } - else if constexpr(std::is_pointer::value && !std::is_pointer::value && - common::mpl::is_type_complete_v && - !std::is_void::value) - { - if(_v) - { - return stringize_impl(*_v); - } - else - { - auto _ss = std::stringstream{}; - _ss << _v; - return _ss.str(); - } - } else { auto _ss = std::stringstream{}; @@ -97,9 +73,10 @@ stringize_impl(const Tp& _v) template auto -stringize(Args... args) +stringize(int32_t max_deref, Args... args) { - return std::vector>{stringize_impl(args)...}; + return std::vector{common::stringize_arg( + max_deref, args, [](const auto& _v) { return stringize_impl(_v); })...}; } template diff --git a/source/lib/rocprofiler-sdk/marker/defines.hpp b/source/lib/rocprofiler-sdk/marker/defines.hpp index 2c987fa585..4ba956fc2e 100644 --- a/source/lib/rocprofiler-sdk/marker/defines.hpp +++ b/source/lib/rocprofiler-sdk/marker/defines.hpp @@ -99,7 +99,7 @@ \ static std::vector as_arg_addr(callback_data_type) { return std::vector{}; } \ \ - static std::vector> as_arg_list(callback_data_type) \ + static std::vector as_arg_list(callback_data_type, int32_t) \ { \ return {}; \ } \ @@ -188,9 +188,10 @@ GET_ADDR_MEMBER_FIELDS(get_api_data_args(trace_data.args), __VA_ARGS__)}; \ } \ \ - static auto as_arg_list(callback_data_type trace_data) \ + static auto as_arg_list(callback_data_type trace_data, int32_t max_deref) \ { \ return utils::stringize( \ + max_deref, \ GET_NAMED_MEMBER_FIELDS(get_api_data_args(trace_data.args), __VA_ARGS__)); \ } \ }; \ diff --git a/source/lib/rocprofiler-sdk/marker/marker.cpp b/source/lib/rocprofiler-sdk/marker/marker.cpp index 24bff90e31..aac6da1f19 100644 --- a/source/lib/rocprofiler-sdk/marker/marker.cpp +++ b/source/lib/rocprofiler-sdk/marker/marker.cpp @@ -403,29 +403,34 @@ void iterate_args(const uint32_t id, const rocprofiler_callback_tracing_marker_api_data_t& data, rocprofiler_callback_tracing_operation_args_cb_t func, + int32_t max_deref, void* user_data, std::index_sequence) { if(OpIdx == id) { using info_type = roctx_api_info; - auto&& arg_list = info_type::as_arg_list(data); + auto&& arg_list = info_type::as_arg_list(data, max_deref); auto&& arg_addr = info_type::as_arg_addr(data); for(size_t i = 0; i < std::min(arg_list.size(), arg_addr.size()); ++i) { - auto ret = func(info_type::callback_domain_idx, // kind - id, // operation - i, // arg_number - arg_list.at(i).first.c_str(), // arg_name - arg_list.at(i).second.c_str(), // arg_value_str - arg_addr.at(i), // arg_value_addr + auto ret = func(info_type::callback_domain_idx, // kind + id, // operation + i, // arg_number + arg_addr.at(i), // arg_value_addr + arg_list.at(i).indirection_level, // indirection + arg_list.at(i).type, // arg_type + arg_list.at(i).name.c_str(), // arg_name + arg_list.at(i).value.c_str(), // arg_value_str + arg_list.at(i).dereference_count, // num deref in str user_data); if(ret != 0) break; } return; } if constexpr(sizeof...(OpIdxTail) > 0) - iterate_args(id, data, func, user_data, std::index_sequence{}); + iterate_args( + id, data, func, max_deref, user_data, std::index_sequence{}); } bool @@ -584,12 +589,14 @@ void iterate_args(uint32_t id, const rocprofiler_callback_tracing_marker_api_data_t& data, rocprofiler_callback_tracing_operation_args_cb_t callback, + int32_t max_deref, void* user_data) { if(callback) iterate_args(id, data, callback, + max_deref, user_data, std::make_index_sequence::last>{}); } @@ -625,7 +632,7 @@ using iterate_args_cb_t = rocprofiler_callback_tracing_operation_args_cb_t; template std::vector get_ids(); \ template std::vector get_names(); \ template void iterate_args( \ - uint32_t, const iterate_args_data_t&, iterate_args_cb_t, void*); + uint32_t, const iterate_args_data_t&, iterate_args_cb_t, int32_t, void*); INSTANTIATE_MARKER_TABLE_FUNC(roctx_core_api_table_t, ROCPROFILER_MARKER_TABLE_ID_RoctxCore) INSTANTIATE_MARKER_TABLE_FUNC(roctx_ctrl_api_table_t, ROCPROFILER_MARKER_TABLE_ID_RoctxControl) diff --git a/source/lib/rocprofiler-sdk/marker/marker.hpp b/source/lib/rocprofiler-sdk/marker/marker.hpp index 862f1e826a..fefe606d32 100644 --- a/source/lib/rocprofiler-sdk/marker/marker.hpp +++ b/source/lib/rocprofiler-sdk/marker/marker.hpp @@ -87,6 +87,7 @@ void iterate_args(uint32_t id, const rocprofiler_callback_tracing_marker_api_data_t& data, rocprofiler_callback_tracing_operation_args_cb_t callback, + int32_t max_deref, void* user_data); template diff --git a/source/lib/rocprofiler-sdk/marker/utils.hpp b/source/lib/rocprofiler-sdk/marker/utils.hpp index 224f718ab9..404d92ab48 100644 --- a/source/lib/rocprofiler-sdk/marker/utils.hpp +++ b/source/lib/rocprofiler-sdk/marker/utils.hpp @@ -26,9 +26,10 @@ #include #include "lib/common/mpl.hpp" +#include "lib/common/stringize_arg.hpp" -#include "fmt/core.h" -#include "fmt/ranges.h" +#include +#include #include #include @@ -47,37 +48,12 @@ template auto stringize_impl(const Tp& _v) { - using nonpointer_type = typename std::remove_pointer_t; + using value_type = std::decay_t; - if constexpr(common::mpl::is_pair::value) - { - return std::make_pair(stringize_impl(_v.first), stringize_impl(_v.second)); - } - else if constexpr(std::is_constructible::value) - { - auto _ss = std::stringstream{}; - _ss << _v; - return _ss.str(); - } - else if constexpr(fmt::is_formattable::value && !std::is_pointer::value) + if constexpr(fmt::is_formattable::value && !std::is_pointer::value) { return fmt::format("{}", _v); } - else if constexpr(std::is_pointer::value && !std::is_pointer::value && - common::mpl::is_type_complete_v && - !std::is_void::value) - { - if(_v) - { - return stringize_impl(*_v); - } - else - { - auto _ss = std::stringstream{}; - _ss << _v; - return _ss.str(); - } - } else { auto _ss = std::stringstream{}; @@ -88,9 +64,10 @@ stringize_impl(const Tp& _v) template auto -stringize(Args... args) +stringize(int32_t max_deref, Args... args) { - return std::vector>{stringize_impl(args)...}; + return std::vector{common::stringize_arg( + max_deref, args, [](const auto& _v) { return stringize_impl(_v); })...}; } template diff --git a/source/lib/rocprofiler-sdk/registration.cpp b/source/lib/rocprofiler-sdk/registration.cpp index 1f819a338e..a7c90ddd81 100644 --- a/source/lib/rocprofiler-sdk/registration.cpp +++ b/source/lib/rocprofiler-sdk/registration.cpp @@ -726,8 +726,10 @@ rocprofiler_set_api_table(const char* name, else if(std::string_view{name} == "roctx") { // pass to roctx init - LOG_IF(ERROR, num_tables >= 3) - << " rocprofiler expected ROCTX library to pass 1 API table, not " << num_tables; + LOG_IF(FATAL, num_tables < 3) + << " rocprofiler expected ROCTX library to pass 3 API tables, not " << num_tables; + LOG_IF(ERROR, num_tables > 3) + << " rocprofiler expected ROCTX library to pass 3 API tables, not " << num_tables; auto* roctx_core = static_cast(tables[0]); auto* roctx_ctrl = static_cast(tables[1]); diff --git a/source/lib/rocprofiler-sdk/tests/registration.cpp b/source/lib/rocprofiler-sdk/tests/registration.cpp index be3184aa60..bceff11ade 100644 --- a/source/lib/rocprofiler-sdk/tests/registration.cpp +++ b/source/lib/rocprofiler-sdk/tests/registration.cpp @@ -90,23 +90,29 @@ tool_tracing_callback(rocprofiler_callback_tracing_record_t record, auto info_data_cb = [](rocprofiler_callback_tracing_kind_t, uint32_t, uint32_t arg_num, + const void* const arg_value_addr, + int32_t arg_indir_cnt, + const char* arg_type, const char* arg_name, const char* arg_value_str, - const void* const arg_value_addr, + int32_t arg_deref_cnt, void* data) -> int { auto& info = *static_cast(data); info.arg_ss << ((arg_num == 0) ? "(" : ", "); info.arg_ss << arg_num << ": " << arg_name << "=" << arg_value_str; + EXPECT_NE(arg_type, nullptr); EXPECT_NE(arg_name, nullptr); EXPECT_NE(arg_value_str, nullptr); EXPECT_NE(arg_value_addr, nullptr); EXPECT_EQ(arg_num, info.num_args); + EXPECT_GE(arg_indir_cnt, 0); + EXPECT_LE(arg_deref_cnt, arg_indir_cnt); info.num_args++; return 0; }; ROCPROFILER_CALL(rocprofiler_iterate_callback_tracing_kind_operation_args( - record, info_data_cb, static_cast(&info_data_v)), + record, info_data_cb, record.phase, static_cast(&info_data_v)), "Failure iterating trace operation args"); if(record.kind == ROCPROFILER_CALLBACK_TRACING_HSA_CORE_API && !(record.operation == ROCPROFILER_HSA_CORE_API_ID_hsa_init || diff --git a/source/lib/rocprofiler-sdk/tests/roctx.cpp b/source/lib/rocprofiler-sdk/tests/roctx.cpp index a55a6f9792..3590925f8e 100644 --- a/source/lib/rocprofiler-sdk/tests/roctx.cpp +++ b/source/lib/rocprofiler-sdk/tests/roctx.cpp @@ -167,23 +167,29 @@ tool_tracing_callback(rocprofiler_callback_tracing_record_t record, auto info_data_cb = [](rocprofiler_callback_tracing_kind_t, uint32_t, uint32_t arg_num, + const void* const arg_value_addr, + int32_t arg_indir_cnt, + const char* arg_type, const char* arg_name, const char* arg_value_str, - const void* const arg_value_addr, + int32_t arg_deref_cnt, void* data) -> int { auto& info = *static_cast(data); info.arg_ss << ((arg_num == 0) ? "(" : ", "); info.arg_ss << arg_num << ": " << arg_name << "=" << arg_value_str; + EXPECT_NE(arg_type, nullptr); EXPECT_NE(arg_name, nullptr); EXPECT_NE(arg_value_str, nullptr); EXPECT_NE(arg_value_addr, nullptr); EXPECT_EQ(arg_num, info.num_args); + EXPECT_GE(arg_indir_cnt, 0); + EXPECT_LE(arg_deref_cnt, arg_indir_cnt); info.num_args++; return 0; }; ROCPROFILER_CALL(rocprofiler_iterate_callback_tracing_kind_operation_args( - record, info_data_cb, static_cast(&info_data_v)), + record, info_data_cb, record.phase, static_cast(&info_data_v)), "Failure iterating trace operation args"); if(record.kind == ROCPROFILER_CALLBACK_TRACING_MARKER_CORE_API) { diff --git a/tests/tools/json-tool.cpp b/tests/tools/json-tool.cpp index 61b536d049..82d41948ba 100644 --- a/tests/tools/json-tool.cpp +++ b/tests/tools/json-tool.cpp @@ -376,18 +376,34 @@ serialize_args(ArchiveT& ar, const callback_arg_array_t& data) } } +template +void +consume_args(Args&&...) +{} + int -save_args(rocprofiler_callback_tracing_kind_t, - uint32_t, - uint32_t, - const char* arg_name, - const char* arg_value_str, - const void* const, - void* data) +save_args(rocprofiler_callback_tracing_kind_t domain_idx, + uint32_t op_idx, + uint32_t arg_num, + const void* const arg_value_addr, + int32_t arg_indirection_count, + const char* arg_type, + const char* arg_name, + const char* arg_value_str, + int32_t arg_dereference_count, + void* data) { auto* argvec = static_cast(data); argvec->emplace_back(arg_name, arg_value_str); return 0; + + consume_args(domain_idx, + op_idx, + arg_num, + arg_value_addr, + arg_indirection_count, + arg_type, + arg_dereference_count); } struct code_object_callback_record_t @@ -635,8 +651,9 @@ tool_tracing_callback(rocprofiler_callback_tracing_record_t record, { auto* data = static_cast(record.payload); auto args = callback_arg_array_t{}; - if(record.phase == ROCPROFILER_CALLBACK_PHASE_ENTER) - rocprofiler_iterate_callback_tracing_kind_operation_args(record, save_args, &args); + if(record.phase == ROCPROFILER_CALLBACK_PHASE_EXIT) + rocprofiler_iterate_callback_tracing_kind_operation_args( + record, save_args, record.phase, &args); static auto _mutex = std::mutex{}; auto _lk = std::unique_lock{_mutex}; @@ -648,8 +665,9 @@ tool_tracing_callback(rocprofiler_callback_tracing_record_t record, { auto* data = static_cast(record.payload); auto args = callback_arg_array_t{}; - if(record.phase == ROCPROFILER_CALLBACK_PHASE_ENTER) - rocprofiler_iterate_callback_tracing_kind_operation_args(record, save_args, &args); + if(record.phase == ROCPROFILER_CALLBACK_PHASE_EXIT) + rocprofiler_iterate_callback_tracing_kind_operation_args( + record, save_args, record.phase, &args); static auto _mutex = std::mutex{}; auto _lk = std::unique_lock{_mutex}; @@ -662,8 +680,9 @@ tool_tracing_callback(rocprofiler_callback_tracing_record_t record, { auto* data = static_cast(record.payload); auto args = callback_arg_array_t{}; - if(record.phase == ROCPROFILER_CALLBACK_PHASE_ENTER) - rocprofiler_iterate_callback_tracing_kind_operation_args(record, save_args, &args); + if(record.phase == ROCPROFILER_CALLBACK_PHASE_EXIT) + rocprofiler_iterate_callback_tracing_kind_operation_args( + record, save_args, record.phase, &args); static auto _mutex = std::mutex{}; auto _lk = std::unique_lock{_mutex};