Split ROCTx API tables and update intercept table API (#421)
* Update include/rocprofiler-sdk
- buffer_tracing.h
- fix doxygen for rocprofiler_buffer_tracing_hip_api_record_t
- update doxygen for rocprofiler_buffer_tracing_marker_api_record_t
- remove unused marker_id field
- fwd.h
- Split ROCPROFILER_CALLBACK_TRACING_MARKER_API into ROCPROFILER_CALLBACK_TRACING_MARKER_{CORE,CONTROL,NAME}_API
- Split ROCPROFILER_BUFFER_TRACING_MARKER_API into ROCPROFILER_BUFFER_TRACING_MARKER_{CORE,CONTROL,NAME}_API
- split rocprofiler_runtime_library_t into rocprofiler_runtime_library_t and rocprofiler_intercept_table_t
- after split of ROCTx into 3 tables, specifying rocprofiler_at_internal_thread_create became confusing
* Update include/rocprofiler-sdk-roctx/api_trace.h
- Split into three tables: core, control, and name
- core: what it sounds like
- control: functions for controling the profiler
- name: functions for giving resources names
* Update lib/rocprofiler-sdk-roctx/roctx.cpp
- modifications following split into multiple tables
* Update lib/rocprofiler-sdk/marker/*
- modifications following split of ROCTx API into multiple intercept tables
* Update lib/rocprofiler-sdk/tests
- common.hpp
- add enums to get_callback_tracing_names() and get_buffer_tracing_names()
- intercept_table.cpp
- update test to use rocprofiler_intercept_table_t (and enums) instead of rocproifler_runtime_library_t
- update OR combos tested
- roctx.cpp
- updates following split of ROCTx API table into multiple tables
- use simplified specification of control API
* Update lib/rocprofiler-sdk
- buffer_tracing.cpp
- Updates for ROCPROFILER_BUFFER_TRACING_MARKER_{CORE,CONTROL,NAME}_API enum values
- callback_tracing.cpp
- Updates for ROCPROFILER_CALLBACK_TRACING_MARKER_{CORE,CONTROL,NAME}_API enum values
- intercept_table.hpp
- notify_runtime_api_registration -> notify_intercept_table_registration
- intercept_table.cpp
- updates for new rocprofiler_intercept_table_t enum and new ROCTx tables
- registration.cpp
- updates for new rocprofiler_intercept_table_t enum and new ROCTx tables
- updates for notify_runtime_api_registration -> notify_intercept_table_registration
* Update lib/rocprofiler-sdk-tool
- helper.cpp
- Updates for new enums in get_callback_id_names() and get_buffer_id_names()
- tool.cpp
- migrate to new enums for split ROCTx tables
- use simplified split for control table vs. core+name tables
* Update samples/{api_callback_tracing,intercept_table}
- intercept_table/client.cpp
- rocprofiler_runtime_library_t -> rocprofiler_intercept_table_t
- api_callback_tracing/client.cpp
- Updates for new enums in get_callback_id_names()
- use simplified split for control table vs. core+name tables
- migrate to new enums for split ROCTx tables
* Update tests
- rocprofv3/tracing/validate.py
- handle new marker domain names
- tools/json-tool.cpp
- Updates for new enums in get_callback_id_names() and get_buffer_id_names()
- use simplified split for control table vs. core+name tables
- migrate to new enums for split ROCTx tables
* Update tests/rocprofv3/tracing/CMakeLists.txt
- fix FAIL_REGULAR_EXPRESSION for rocprofv3-test-trace-execute
* Update lib/rocprofiler-sdk-tool/{output_file,tool}.*
- logging in output_file dtor
- support stdout/stderr
* Update lib/common/container/record_header_buffer.hpp
- reduce probability of is_empty() returning true while emplace is happening
* Update lib/rocprofiler-sdk-tool/tool.cpp
- logging for buffered_tracing_callback
- counter collection uses CSV encoder
* Update bin/rocprofv3
- remove -i flag from help menu
This commit is contained in:
zatwierdzone przez
GitHub
rodzic
75264b5587
commit
9efafc4d23
@@ -46,21 +46,23 @@ namespace intercept_table
|
||||
{
|
||||
namespace
|
||||
{
|
||||
template <rocprofiler_runtime_library_t... Idx>
|
||||
using library_sequence_t = std::integer_sequence<rocprofiler_runtime_library_t, Idx...>;
|
||||
template <rocprofiler_intercept_table_t... Idx>
|
||||
using library_sequence_t = std::integer_sequence<rocprofiler_intercept_table_t, Idx...>;
|
||||
|
||||
// this is used to loop over the different libraries
|
||||
constexpr auto intercept_library_seq = library_sequence_t<ROCPROFILER_HSA_LIBRARY,
|
||||
ROCPROFILER_HIP_RUNTIME_LIBRARY,
|
||||
ROCPROFILER_MARKER_LIBRARY,
|
||||
ROCPROFILER_HIP_COMPILER_LIBRARY>{};
|
||||
constexpr auto intercept_library_seq = library_sequence_t<ROCPROFILER_HSA_TABLE,
|
||||
ROCPROFILER_HIP_RUNTIME_TABLE,
|
||||
ROCPROFILER_HIP_COMPILER_TABLE,
|
||||
ROCPROFILER_MARKER_CORE_TABLE,
|
||||
ROCPROFILER_MARKER_CONTROL_TABLE,
|
||||
ROCPROFILER_MARKER_NAME_TABLE>{};
|
||||
|
||||
// check that intercept_library_seq is up to date
|
||||
static_assert((1 << (intercept_library_seq.size())) == ROCPROFILER_LIBRARY_LAST,
|
||||
static_assert((1 << (intercept_library_seq.size() - 1)) == ROCPROFILER_TABLE_LAST,
|
||||
"Update intercept_library_seq to include new libraries");
|
||||
|
||||
// data structure holding list of callbacks
|
||||
template <rocprofiler_runtime_library_t LibT>
|
||||
template <rocprofiler_intercept_table_t LibT>
|
||||
struct intercept
|
||||
{
|
||||
static constexpr auto value = LibT;
|
||||
@@ -71,7 +73,7 @@ struct intercept
|
||||
};
|
||||
|
||||
// static accessor for intercept instance
|
||||
template <rocprofiler_runtime_library_t LibT>
|
||||
template <rocprofiler_intercept_table_t LibT>
|
||||
auto&
|
||||
get_intercept()
|
||||
{
|
||||
@@ -80,7 +82,7 @@ get_intercept()
|
||||
}
|
||||
|
||||
// adds callbacks to intercept instance(s)
|
||||
template <rocprofiler_runtime_library_t... Idx>
|
||||
template <rocprofiler_intercept_table_t... Idx>
|
||||
void
|
||||
update_intercepts(rocprofiler_intercept_library_cb_t cb,
|
||||
int libs,
|
||||
@@ -109,13 +111,13 @@ get_void_array(std::tuple<Tp*...> data, std::index_sequence<Idx...>)
|
||||
};
|
||||
|
||||
// invokes creation notifiers
|
||||
template <typename... ApiTableT, rocprofiler_runtime_library_t... Idx>
|
||||
template <typename... ApiTableT, rocprofiler_intercept_table_t... Idx>
|
||||
void
|
||||
execute_intercepts(rocprofiler_runtime_library_t lib,
|
||||
execute_intercepts(rocprofiler_intercept_table_t lib,
|
||||
uint64_t lib_version,
|
||||
uint64_t lib_instance,
|
||||
std::tuple<ApiTableT*...> tables,
|
||||
std::integer_sequence<rocprofiler_runtime_library_t, Idx...>)
|
||||
std::integer_sequence<rocprofiler_intercept_table_t, Idx...>)
|
||||
{
|
||||
auto execute = [lib, lib_version, lib_instance, tables](auto& notifier) {
|
||||
if(((lib & notifier.value) == notifier.value))
|
||||
@@ -145,52 +147,59 @@ execute_intercepts(rocprofiler_runtime_library_t lib,
|
||||
|
||||
template <typename... ApiTableT>
|
||||
void
|
||||
notify_runtime_api_registration(rocprofiler_runtime_library_t lib,
|
||||
uint64_t lib_version,
|
||||
uint64_t lib_instance,
|
||||
std::tuple<ApiTableT*...> tables)
|
||||
notify_intercept_table_registration(rocprofiler_intercept_table_t lib,
|
||||
uint64_t lib_version,
|
||||
uint64_t lib_instance,
|
||||
std::tuple<ApiTableT*...> tables)
|
||||
{
|
||||
execute_intercepts(lib, lib_version, lib_instance, tables, intercept_library_seq);
|
||||
}
|
||||
|
||||
// template instantiation for HsaApiTable
|
||||
template void notify_runtime_api_registration(rocprofiler_runtime_library_t,
|
||||
uint64_t,
|
||||
uint64_t,
|
||||
std::tuple<HsaApiTable*>);
|
||||
template void notify_intercept_table_registration(rocprofiler_intercept_table_t,
|
||||
uint64_t,
|
||||
uint64_t,
|
||||
std::tuple<HsaApiTable*>);
|
||||
|
||||
template void notify_runtime_api_registration(rocprofiler_runtime_library_t,
|
||||
uint64_t,
|
||||
uint64_t,
|
||||
std::tuple<roctxApiTable_t*>);
|
||||
template void notify_intercept_table_registration(rocprofiler_intercept_table_t,
|
||||
uint64_t,
|
||||
uint64_t,
|
||||
std::tuple<roctxCoreApiTable_t*>);
|
||||
|
||||
template void notify_runtime_api_registration(rocprofiler_runtime_library_t,
|
||||
uint64_t,
|
||||
uint64_t,
|
||||
std::tuple<HipDispatchTable*>);
|
||||
template void notify_intercept_table_registration(rocprofiler_intercept_table_t,
|
||||
uint64_t,
|
||||
uint64_t,
|
||||
std::tuple<roctxControlApiTable_t*>);
|
||||
|
||||
template void notify_runtime_api_registration(rocprofiler_runtime_library_t,
|
||||
uint64_t,
|
||||
uint64_t,
|
||||
std::tuple<HipCompilerDispatchTable*>);
|
||||
template void notify_intercept_table_registration(rocprofiler_intercept_table_t,
|
||||
uint64_t,
|
||||
uint64_t,
|
||||
std::tuple<roctxNameApiTable_t*>);
|
||||
|
||||
template void notify_intercept_table_registration(rocprofiler_intercept_table_t,
|
||||
uint64_t,
|
||||
uint64_t,
|
||||
std::tuple<HipDispatchTable*>);
|
||||
|
||||
template void notify_intercept_table_registration(rocprofiler_intercept_table_t,
|
||||
uint64_t,
|
||||
uint64_t,
|
||||
std::tuple<HipCompilerDispatchTable*>);
|
||||
} // namespace intercept_table
|
||||
} // namespace rocprofiler
|
||||
|
||||
extern "C" {
|
||||
rocprofiler_status_t
|
||||
rocprofiler_at_runtime_api_registration(rocprofiler_intercept_library_cb_t callback,
|
||||
int libs,
|
||||
void* data)
|
||||
rocprofiler_at_intercept_table_registration(rocprofiler_intercept_library_cb_t callback,
|
||||
int libs,
|
||||
void* data)
|
||||
{
|
||||
// if this function is invoked after initialization, we cannot guarantee that the runtime
|
||||
// intercept API has not already be registered and returned to the runtime.
|
||||
if(rocprofiler::registration::get_init_status() > 0)
|
||||
return ROCPROFILER_STATUS_ERROR_CONFIGURATION_LOCKED;
|
||||
|
||||
if((libs & ROCPROFILER_LIBRARY) == ROCPROFILER_LIBRARY)
|
||||
return ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
else if((libs & ROCPROFILER_MARKER_LIBRARY) == ROCPROFILER_MARKER_LIBRARY)
|
||||
return ROCPROFILER_STATUS_ERROR_NOT_IMPLEMENTED;
|
||||
LOG_IF(WARNING, libs == 0) << "invoking " << __FUNCTION__ << " with a value of zero is a no-op";
|
||||
|
||||
rocprofiler::intercept_table::update_intercepts(
|
||||
callback, libs, data, rocprofiler::intercept_table::intercept_library_seq);
|
||||
|
||||
Reference in New Issue
Block a user