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]
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
15302ff11d
Коммит
cb6b79c323
@@ -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<std::stringstream*>(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<void*>(&info_data)),
|
||||
record, info_data_cb, max_deref, static_cast<void*>(&info_data)),
|
||||
"Failure iterating trace operation args");
|
||||
|
||||
auto info_data_str = info_data.str();
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -13,6 +13,7 @@ set(common_headers
|
||||
mpl.hpp
|
||||
scope_destructor.hpp
|
||||
static_object.hpp
|
||||
stringize_arg.hpp
|
||||
synchronized.hpp
|
||||
utility.hpp
|
||||
xml.hpp)
|
||||
|
||||
@@ -126,6 +126,27 @@ constexpr bool is_type_complete_v = false; // NOLINT(misc-definitions-in-header
|
||||
|
||||
template <typename T> // NOLINTNEXTLINE(misc-definitions-in-headers)
|
||||
constexpr bool is_type_complete_v<T, std::void_t<decltype(sizeof(T))>> = true;
|
||||
|
||||
template <typename Tp, size_t N>
|
||||
struct indirection_level_impl_n
|
||||
{
|
||||
using value_type = std::conditional_t<std::is_function<Tp>::value, Tp, std::decay_t<Tp>>;
|
||||
static_assert(!std::is_pointer<value_type>::value, "missing overload");
|
||||
static constexpr size_t value = N;
|
||||
};
|
||||
|
||||
template <typename Tp, size_t N>
|
||||
struct indirection_level_impl_n<Tp*, N> : indirection_level_impl_n<Tp, N + 1>
|
||||
{};
|
||||
|
||||
template <typename Tp, size_t N>
|
||||
struct indirection_level_impl_n<Tp* const, N> : indirection_level_impl_n<Tp, N + 1>
|
||||
{};
|
||||
|
||||
template <typename Tp>
|
||||
struct indirection_level
|
||||
: indirection_level_impl_n<std::remove_cv_t<std::remove_reference_t<std::decay_t<Tp>>>, 0>
|
||||
{};
|
||||
} // namespace mpl
|
||||
} // namespace common
|
||||
} // namespace rocprofiler
|
||||
|
||||
@@ -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 <fmt/core.h>
|
||||
#include <fmt/ranges.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
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 <typename Tp, typename FuncT>
|
||||
auto
|
||||
stringize_arg_impl(const Tp& _v, const int32_t max_deref, int32_t& deref_cnt, FuncT&& impl)
|
||||
{
|
||||
using value_type = std::decay_t<Tp>;
|
||||
using nonpointer_type = std::remove_pointer_t<Tp>;
|
||||
|
||||
if constexpr(common::mpl::is_string_type<value_type>::value &&
|
||||
!std::is_pointer<nonpointer_type>::value)
|
||||
{
|
||||
if constexpr(std::is_pointer<value_type>::value)
|
||||
{
|
||||
if(!_v) return std::string{"(null)"};
|
||||
}
|
||||
|
||||
return std::string{_v};
|
||||
}
|
||||
else if constexpr(fmt::is_formattable<value_type>::value && !std::is_pointer<value_type>::value)
|
||||
{
|
||||
return fmt::format("{}", _v);
|
||||
}
|
||||
else if constexpr(std::is_pointer<value_type>::value &&
|
||||
!std::is_pointer<nonpointer_type>::value &&
|
||||
common::mpl::is_type_complete_v<nonpointer_type> &&
|
||||
!std::is_void<nonpointer_type>::value)
|
||||
{
|
||||
if(_v && deref_cnt < max_deref)
|
||||
return stringize_arg_impl(*_v, max_deref, ++deref_cnt, std::forward<FuncT>(impl));
|
||||
else if(_v)
|
||||
return std::forward<FuncT>(impl)(_v);
|
||||
else
|
||||
return std::string{"(null)"};
|
||||
}
|
||||
else if constexpr(std::is_pointer<value_type>::value && std::is_pointer<nonpointer_type>::value)
|
||||
{
|
||||
using next_nonpointer_type = std::remove_pointer_t<nonpointer_type>;
|
||||
|
||||
if(_v)
|
||||
{
|
||||
if constexpr(!std::is_void<next_nonpointer_type>::value)
|
||||
{
|
||||
if(deref_cnt < max_deref)
|
||||
return stringize_arg_impl(
|
||||
*_v, max_deref, ++deref_cnt, std::forward<FuncT>(impl));
|
||||
else
|
||||
return std::forward<FuncT>(impl)(_v);
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::forward<FuncT>(impl)(_v);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::string{"(null)"};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::forward<FuncT>(impl)(_v);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Tp, typename FuncT>
|
||||
common::stringified_argument
|
||||
stringize_arg(int32_t max_deref, const std::pair<const char*, Tp>& arg, FuncT&& impl)
|
||||
{
|
||||
auto _arg = common::stringified_argument{};
|
||||
_arg.indirection_level = mpl::indirection_level<Tp>::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<FuncT>(impl));
|
||||
return _arg;
|
||||
}
|
||||
} // namespace common
|
||||
} // namespace rocprofiler
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@
|
||||
\
|
||||
static std::vector<void*> as_arg_addr(callback_data_type) { return std::vector<void*>{}; } \
|
||||
\
|
||||
static std::vector<std::pair<std::string, std::string>> as_arg_list(callback_data_type) \
|
||||
static std::vector<common::stringified_argument> 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__)); \
|
||||
} \
|
||||
}; \
|
||||
|
||||
@@ -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<OpIdx, OpIdxTail...>)
|
||||
{
|
||||
if(OpIdx == id)
|
||||
{
|
||||
using info_type = hip_api_info<TableIdx, OpIdx>;
|
||||
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<TableIdx>(id, data, func, user_data, std::index_sequence<OpIdxTail...>{});
|
||||
iterate_args<TableIdx>(
|
||||
id, data, func, max_deref, user_data, std::index_sequence<OpIdxTail...>{});
|
||||
}
|
||||
|
||||
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<TableIdx>(id,
|
||||
data,
|
||||
callback,
|
||||
max_deref,
|
||||
user_data,
|
||||
std::make_index_sequence<hip_domain_info<TableIdx>::last>{});
|
||||
}
|
||||
@@ -656,7 +663,8 @@ using hip_op_args_cb_t = rocprofiler_callback_tracing_operation_args_cb_t;
|
||||
template uint32_t id_by_name<TABLE_IDX>(const char*); \
|
||||
template std::vector<uint32_t> get_ids<TABLE_IDX>(); \
|
||||
template std::vector<const char*> get_names<TABLE_IDX>(); \
|
||||
template void iterate_args<TABLE_IDX>(uint32_t, const hip_api_data_t&, hip_op_args_cb_t, void*);
|
||||
template void iterate_args<TABLE_IDX>( \
|
||||
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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 <typename TableT>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <rocprofiler-sdk/version.h>
|
||||
|
||||
#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 <typename Tp>
|
||||
auto
|
||||
stringize_impl(const Tp& _v)
|
||||
{
|
||||
using nonpointer_type = typename std::remove_pointer_t<Tp>;
|
||||
using value_type = std::decay_t<Tp>;
|
||||
|
||||
if constexpr(common::mpl::is_pair<Tp>::value)
|
||||
{
|
||||
return std::make_pair(stringize_impl(_v.first), stringize_impl(_v.second));
|
||||
}
|
||||
else if constexpr(std::is_constructible<std::string_view, Tp>::value)
|
||||
{
|
||||
auto _ss = std::stringstream{};
|
||||
_ss << _v;
|
||||
return _ss.str();
|
||||
}
|
||||
else if constexpr(fmt::is_formattable<Tp>::value && !std::is_pointer<Tp>::value)
|
||||
if constexpr(fmt::is_formattable<value_type>::value && !std::is_pointer<value_type>::value)
|
||||
{
|
||||
return fmt::format("{}", _v);
|
||||
}
|
||||
else if constexpr(std::is_pointer<Tp>::value && !std::is_pointer<nonpointer_type>::value &&
|
||||
common::mpl::is_type_complete_v<nonpointer_type> &&
|
||||
!std::is_void<nonpointer_type>::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 <typename... Args>
|
||||
auto
|
||||
stringize(Args... args)
|
||||
stringize(int32_t max_deref, Args... args)
|
||||
{
|
||||
return std::vector<std::pair<std::string, std::string>>{stringize_impl(args)...};
|
||||
return std::vector<common::stringified_argument>{common::stringize_arg(
|
||||
max_deref, args, [](const auto& _v) { return stringize_impl(_v); })...};
|
||||
}
|
||||
} // namespace utils
|
||||
} // namespace hip
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -136,8 +136,9 @@
|
||||
return std::vector<void*>{}; \
|
||||
} \
|
||||
\
|
||||
static std::vector<std::pair<std::string, std::string>> as_arg_list( \
|
||||
rocprofiler_callback_tracing_hsa_api_data_t) \
|
||||
static std::vector<common::stringified_argument> 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__)); \
|
||||
} \
|
||||
}; \
|
||||
|
||||
@@ -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<OpIdx, IdxTail...>)
|
||||
{
|
||||
if(OpIdx == id)
|
||||
{
|
||||
using info_type = hsa_api_info<TableIdx, OpIdx>;
|
||||
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<TableIdx>(id, data, func, user_data, std::index_sequence<IdxTail...>{});
|
||||
iterate_args<TableIdx>(
|
||||
id, data, func, max_deref, user_data, std::index_sequence<IdxTail...>{});
|
||||
}
|
||||
|
||||
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<TableIdx>(id,
|
||||
data,
|
||||
callback,
|
||||
max_deref,
|
||||
user_data,
|
||||
std::make_index_sequence<hsa_domain_info<TableIdx>::last>{});
|
||||
}
|
||||
@@ -727,7 +734,7 @@ using iterate_args_cb_t = rocprofiler_callback_tracing_operation_args_cb_t;
|
||||
template std::vector<uint32_t> get_ids<TABLE_IDX>(); \
|
||||
template std::vector<const char*> get_names<TABLE_IDX>(); \
|
||||
template void iterate_args<TABLE_IDX>( \
|
||||
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)
|
||||
|
||||
@@ -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 <typename TableT>
|
||||
|
||||
@@ -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> 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<std::mutex> 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<Queue>);
|
||||
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
|
||||
|
||||
@@ -25,15 +25,16 @@
|
||||
#include <rocprofiler-sdk/version.h>
|
||||
|
||||
#include "lib/common/mpl.hpp"
|
||||
#include "lib/common/stringize_arg.hpp"
|
||||
|
||||
#include "fmt/core.h"
|
||||
#include "fmt/ranges.h"
|
||||
|
||||
#include <fmt/core.h>
|
||||
#include <fmt/ranges.h>
|
||||
#include <hsa/hsa.h>
|
||||
#include <hsa/hsa_ext_amd.h>
|
||||
#include <hsa/hsa_ext_finalize.h>
|
||||
#include <hsa/hsa_ext_image.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
@@ -56,37 +57,12 @@ template <typename Tp>
|
||||
auto
|
||||
stringize_impl(const Tp& _v)
|
||||
{
|
||||
using nonpointer_type = typename std::remove_pointer_t<Tp>;
|
||||
using value_type = std::decay_t<Tp>;
|
||||
|
||||
if constexpr(common::mpl::is_pair<Tp>::value)
|
||||
{
|
||||
return std::make_pair(stringize_impl(_v.first), stringize_impl(_v.second));
|
||||
}
|
||||
else if constexpr(std::is_constructible<std::string_view, Tp>::value)
|
||||
{
|
||||
auto _ss = std::stringstream{};
|
||||
_ss << _v;
|
||||
return _ss.str();
|
||||
}
|
||||
else if constexpr(fmt::is_formattable<Tp>::value && !std::is_pointer<Tp>::value)
|
||||
if constexpr(fmt::is_formattable<value_type>::value && !std::is_pointer<value_type>::value)
|
||||
{
|
||||
return fmt::format("{}", _v);
|
||||
}
|
||||
else if constexpr(std::is_pointer<Tp>::value && !std::is_pointer<nonpointer_type>::value &&
|
||||
common::mpl::is_type_complete_v<nonpointer_type> &&
|
||||
!std::is_void<nonpointer_type>::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 <typename... Args>
|
||||
auto
|
||||
stringize(Args... args)
|
||||
stringize(int32_t max_deref, Args... args)
|
||||
{
|
||||
return std::vector<std::pair<std::string, std::string>>{stringize_impl(args)...};
|
||||
return std::vector<common::stringified_argument>{common::stringize_arg(
|
||||
max_deref, args, [](const auto& _v) { return stringize_impl(_v); })...};
|
||||
}
|
||||
|
||||
template <typename Tp>
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
\
|
||||
static std::vector<void*> as_arg_addr(callback_data_type) { return std::vector<void*>{}; } \
|
||||
\
|
||||
static std::vector<std::pair<std::string, std::string>> as_arg_list(callback_data_type) \
|
||||
static std::vector<common::stringified_argument> 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__)); \
|
||||
} \
|
||||
}; \
|
||||
|
||||
@@ -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<OpIdx, OpIdxTail...>)
|
||||
{
|
||||
if(OpIdx == id)
|
||||
{
|
||||
using info_type = roctx_api_info<TableIdx, OpIdx>;
|
||||
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<TableIdx>(id, data, func, user_data, std::index_sequence<OpIdxTail...>{});
|
||||
iterate_args<TableIdx>(
|
||||
id, data, func, max_deref, user_data, std::index_sequence<OpIdxTail...>{});
|
||||
}
|
||||
|
||||
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<TableIdx>(id,
|
||||
data,
|
||||
callback,
|
||||
max_deref,
|
||||
user_data,
|
||||
std::make_index_sequence<roctx_domain_info<TableIdx>::last>{});
|
||||
}
|
||||
@@ -625,7 +632,7 @@ using iterate_args_cb_t = rocprofiler_callback_tracing_operation_args_cb_t;
|
||||
template std::vector<uint32_t> get_ids<TABLE_IDX>(); \
|
||||
template std::vector<const char*> get_names<TABLE_IDX>(); \
|
||||
template void iterate_args<TABLE_IDX>( \
|
||||
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)
|
||||
|
||||
@@ -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 <typename TableT>
|
||||
|
||||
@@ -26,9 +26,10 @@
|
||||
#include <rocprofiler-sdk/version.h>
|
||||
|
||||
#include "lib/common/mpl.hpp"
|
||||
#include "lib/common/stringize_arg.hpp"
|
||||
|
||||
#include "fmt/core.h"
|
||||
#include "fmt/ranges.h"
|
||||
#include <fmt/core.h>
|
||||
#include <fmt/ranges.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
@@ -47,37 +48,12 @@ template <typename Tp>
|
||||
auto
|
||||
stringize_impl(const Tp& _v)
|
||||
{
|
||||
using nonpointer_type = typename std::remove_pointer_t<Tp>;
|
||||
using value_type = std::decay_t<Tp>;
|
||||
|
||||
if constexpr(common::mpl::is_pair<Tp>::value)
|
||||
{
|
||||
return std::make_pair(stringize_impl(_v.first), stringize_impl(_v.second));
|
||||
}
|
||||
else if constexpr(std::is_constructible<std::string_view, Tp>::value)
|
||||
{
|
||||
auto _ss = std::stringstream{};
|
||||
_ss << _v;
|
||||
return _ss.str();
|
||||
}
|
||||
else if constexpr(fmt::is_formattable<Tp>::value && !std::is_pointer<Tp>::value)
|
||||
if constexpr(fmt::is_formattable<value_type>::value && !std::is_pointer<value_type>::value)
|
||||
{
|
||||
return fmt::format("{}", _v);
|
||||
}
|
||||
else if constexpr(std::is_pointer<Tp>::value && !std::is_pointer<nonpointer_type>::value &&
|
||||
common::mpl::is_type_complete_v<nonpointer_type> &&
|
||||
!std::is_void<nonpointer_type>::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 <typename... Args>
|
||||
auto
|
||||
stringize(Args... args)
|
||||
stringize(int32_t max_deref, Args... args)
|
||||
{
|
||||
return std::vector<std::pair<std::string, std::string>>{stringize_impl(args)...};
|
||||
return std::vector<common::stringified_argument>{common::stringize_arg(
|
||||
max_deref, args, [](const auto& _v) { return stringize_impl(_v); })...};
|
||||
}
|
||||
|
||||
template <typename Tp>
|
||||
|
||||
@@ -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<roctxCoreApiTable_t*>(tables[0]);
|
||||
auto* roctx_ctrl = static_cast<roctxControlApiTable_t*>(tables[1]);
|
||||
|
||||
@@ -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<info_data*>(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<void*>(&info_data_v)),
|
||||
record, info_data_cb, record.phase, static_cast<void*>(&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 ||
|
||||
|
||||
@@ -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<info_data*>(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<void*>(&info_data_v)),
|
||||
record, info_data_cb, record.phase, static_cast<void*>(&info_data_v)),
|
||||
"Failure iterating trace operation args");
|
||||
if(record.kind == ROCPROFILER_CALLBACK_TRACING_MARKER_CORE_API)
|
||||
{
|
||||
|
||||
@@ -376,18 +376,34 @@ serialize_args(ArchiveT& ar, const callback_arg_array_t& data)
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
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<callback_arg_array_t*>(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<rocprofiler_callback_tracing_hsa_api_data_t*>(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<std::mutex>{_mutex};
|
||||
@@ -648,8 +665,9 @@ tool_tracing_callback(rocprofiler_callback_tracing_record_t record,
|
||||
{
|
||||
auto* data = static_cast<rocprofiler_callback_tracing_hip_api_data_t*>(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<std::mutex>{_mutex};
|
||||
@@ -662,8 +680,9 @@ tool_tracing_callback(rocprofiler_callback_tracing_record_t record,
|
||||
{
|
||||
auto* data = static_cast<rocprofiler_callback_tracing_marker_api_data_t*>(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<std::mutex>{_mutex};
|
||||
|
||||
Ссылка в новой задаче
Block a user