Contexts, tracing, include reorg, registration, thread-pool (#65)
* Update scripts/update-doxygen.sh
- ensure build-docs folder exists
* Update scripts/run-ci.py
- exclude files in details subdirectory from code coverage
* Update scripts/thread-sanitizer-suppr.txt
- exclude races in glog
* Update docs/rocprofiler.dox.in
- exclude defines in include/rocprofiler/defines.h from doxygen
- Tweak EXCLUDE_PATTERNS and EXAMPLE_PATTERNS
* Update docs workflow
- trigger workflow whenever there is a change to the public headers (which may be doxygen comments)
* Update include/rocprofiler (reorg and overhaul)
- rocprofiler_status_t additions
- CONTEXT_NOT_FOUND
- CONTEXT_ERROR
- INVALID_CONTEXT_ID
- INVALID_CONTEXT
- BUFFER_BUSY
- rocprofiler_context_is_active func
- rocprofiler_context_is_valid func
- rocprofiler_service_callback_tracing_kind_t update
- remove ROCPROFILER_SERVICE_CALLBACK_TRACING_HELPER_THREAD
- Remove rocprofiler_tracing_helper_thread_operation_t
- Remove rocprofiler_helper_thread_callback_tracer_data_t
- Added rocprofiler_internal_thread_library_t
- Added rocprofiler_at_internal_thread_create
- split rocprofiler.h into several smaller headers
- reworked rocprofiler_status_t values
- added doxygen comments for enums
- replaced rocprofiler_trace_record_operation_kind_t with rocprofiler_trace_operation_t
- use @ instead of / in doxygen comment in rocprofiler_plugin.h
- fix ref to ROCPROFILER_SERVICE_CALLBACK_TRACING_MARKER_API
- end group in fwd.h
- remove PROFILE_COUNTING group in dispatch_profile.h
- remove premature group close in callback_tracing.h
- hsa.h: remove rocprofiler_hsa_trace_data_t
- fwd.h: remove rocprofiler_tracer_callback_data_t
- rename rocprofiler_correlation_id_t.handle to rocprofiler_correlation_id_t.id (consistency)
- fwd.h: add rocprofiler_callback_tracing_record_t
- callback_tracing.h: update rocprofiler_hsa_api_callback_tracer_data_t
- callback_tracing.h: add size fields
- simplify rocprofiler_tracer_callback_t
- removed ROCPROFILER_NONNULL from rocprofiler_get_version
- added rocprofiler_get_timestamp
- ROCPROFILER_STATUS_ERROR_CONFIGURATION_LOCKED in rocprofiler_status_t
- add ROCPROFILER_STATUS_ERROR_THREAD_NOT_FOUND rocprofiler_status_t
- add rocprofiler_buffer_category_t
- rocprofiler_trace_operation_t -> rocprofiler_tracing_operation_t
- rocprofiler_user_data_t union
- tweak rocprofiler_callback_tracing_record_t
- make external_correlation_id non-pointer
- add rocprofiler_user_data_t data field
- tweak rocprofiler_record_header_t
- instead of single uint64_t kind field, have union for category + kind (two u32) with u64 hash
- API extensions for kind id <-> kind string
- API extensions for operation id <-> operation string
- rocprofiler_callback_trace_kind_name_cb_t
- rocprofiler_callback_trace_operation_name_cb_t
- rocprofiler_iterate_callback_trace_kind_names
- rocprofiler_iterate_callback_trace_kind_operation_names
- modify rocprofiler_hsa_api_callback_tracer_data_t data members (remove pointers)
- add rocprofiler_callback_trace_operation_args_cb_t function pointer typedef
- add rocprofiler_iterate_callback_trace_operation_args function
- fixed inconsistent use of *_trace_* vs. *_tracing_* (opting for tracing)
- removed rocprofiler_query_callback_trace_kind_name
- removed rocprofiler_query_callback_kind_operation_name
- Add include/rocprofiler/registration.h
- header dedicated to registering a tool/client with rocprofiler
- this header is not intended to be included by rocprofiler.h
- rocprofiler_client_id_t
- identifier for client tool
- rocprofiler_client_finalize_t
- function pointer prototype for tool-initiated finalization
- rocprofiler_tool_initialize_t
- function pointer prototype for tool initialization (i.e. configuration)
- rocprofiler_tool_finalize_t
- function pointer prototype for tool finalization
- rocprofiler_tool_configure_result_t
- struct returned by tool/client to rocprofiler
- rocprofiler_is_initialized
- function for querying whether tool-induced initialization is possible
- rocprofiler_is_finalized
- function for querying whether rocprofiler has been finalized
- rocprofiler_configure prototype
- this is the function tools implement
- prototype is always marked as having default visibility
- no implementation in rocprofiler
- added typedef for rocprofiler_configure function pointer
- added rocprofiler_force_configure to explicitly invoke rocprofiler_configure instead of relying on lazy init
- made callback typedef names more consistent (_cb_t suffix)
- typedef for rocprofiler_internal_thread_library_cb_t function pointer
- added rocprofiler_at_internal_thread_create function
- added rocprofiler_callback_thread_t struct
- added rocprofiler_create_callback_thread function
- added rocprofiler_assign_callback_thread function
- removed rocprofiler_buffer_tracing_record_header_t in favor of kind and correlation id in each record type
- added rocprofiler_buffer_tracing_kind_name_cb_t typedef
- added rocprofiler_buffer_tracing_operation_name_cb_t typedef
- added rocprofiler_iterate_buffer_tracing_kind_names function
- added rocprofiler_iterate_buffer_tracing_kind_operation_names function
- removed rocprofiler_query_buffer_trace_kind_name function
- removed rocprofiler_query_buffer_kind_operation_name function
* Update lib/common/container/stable_vector.hpp
- include limits header
- reserve_size struct
- overload stable_vector constructor to support reserving as part of construction
* Update lib/common/container/record_header_buffer.{hpp,cpp}
- add emplace member function accepting category and kind (two u32 variables) instead of one u64 kind
- use std::shared_mutex to prevent data-race when reading m_headers
- record_header_buffer is now multiple writer, single reader
- add read_lock member function (shared)
- add read_unlock member function (shared)
- lock member function gets exclusive lock
- unlock member function releases exclusive lock
* Rename "config" to "context" + restructure + implement
- Restructure config files + license
- move config files into lib/rocprofiler/config subfolder
- rename some files
- add license to some files which were missing it
- Rename config/helpers.hpp
- rename to allocator.hpp
- remove get_domain_max_ops
- Create config/domain.{hpp,cpp}
- structures for handling tracing domains and ops
- Update config/config.{hpp,cpp}
- buffer_instance struct
- callback_tracing_service struct
- buffer_tracing_service struct
- config struct
- allocate_{config,buffer} func
- {validate,start,stop}_config funcs
- get_registered_configs func
- get_active_configs func
- get_buffers func
- Update rocprofiler.cpp
- Implement rocprofiler_create_context
- Implement rocprofiler_start_context
- Implement rocprofiler_stop_context
- Implement rocprofiler_context_is_active
- Implement rocprofiler_context_is_valid
- Implement rocprofiler_flush_buffer
- Implement rocprofiler_destroy_buffer
- Implement rocprofiler_create_buffer
- Update lib/rocprofiler/hsa
- use rocprofiler_tracer_activity_domain_t instead of rocprofiler_tracer_activity_domain_t
- remove ROCPROFILER_TRACER_ACTIVITY_DOMAIN_HSA_API fromHSA_API_INFO_DEFINITION_* macros
- Update lib/rocprofiler/context/domain.*
- fixes for domain_info (i.e. use correct enums)
- update rocprofiler_status_t codes
- fix template instantiations
- Update lib/rocprofiler/context/context.*
- use rocprofiler_service_callback_tracing_kind_t instead of rocprofiler_tracer_activity_domain_t
- rename correlation_context to correlation_tracing_service
- fix domains in callback_tracing_service and buffer_tracing_service
- unique_ptr for callback_tracer and buffered_tracer in context
- Update lib/rocprofiler/rocprofiler.cpp
- implement rocprofiler_configure_callback_tracing_service
- Update lib/rocprofiler/hsa/ostream.hpp
- include rocprofiler.h instead of tracer.hpp
- Update lib/rocprofiler/hsa
- migration to use rocprofiler_hsa_api_callback_tracer_data_t instead of rocprofiler_hsa_trace_data_t
- restructure hsa_api_impl<Idx>
- remove phase_enter and phase_exit
- add set_data_args (partial replacement for phase_enter)
- functor handles the contexts
- Update lib/rocprofiler/rocprofiler.cpp
- implement rocprofiler_get_version
- Update lib/rocprofiler/hsa/hsa.{hpp,cpp}
- remove hsa_api_ prefix for functions already in hsa namespace
- Update lib/rocprofiler/context/context.{hpp,cpp}
- add client_idx to context struct (tool identifier)
- add push_client function to set client_idx before context is allocated
- add pop_client function to remove client identifier from future context creations
- implemented {registered,active}_contexts and buffers to use new container::reserve_size overload to stable_vector
- fix implementation of start_context
- fix implementation of stop_context
- Update lib/rocprofiler/rocprofiler.cpp
- prevent context creation, buffer creation, pc sampling config, etc. after initialization
- add nullptr checks to rocprofiler_context_is_valid
- fix rocprofiler_configure_callback_tracing_service
- was checking size of buffers, not registered context
- implement rocprofiler_iterate_callback_trace_kind_names
- implement rocprofiler_iterate_callback_trace_kind_operation_names
- Update lib/rocprofiler/CMakeLists.txt
- add registration.{hpp,cpp} to rocprofiler-library target sources
- Update lib/rocprofiler/hsa/utils.hpp
- fix using fmt::formt with const char* strings
- remove join functions (no longer used)
- Update lib/rocprofiler/hsa/hsa.{hpp,cpp}
- remove args_string function
- remove named_args_string function
- update iterate_args function
- change callback type
- accept user data
- rework the hsa_api_impl<Idx>::functor function
- save the rocprofiler_callback_tracing_record_t between callbacks
- update update_table function
- check buffered_tracer domains
- remove comments
- Update lib/rocprofiler/hsa/defines.hpp
- remove MEMBER_<N> macros
- add ADDR_MEMBER_<N> macros
- remove doxygen comments for GET_MEMBER_FIELDS
- add GET_ADDR_MEMBER_FIELDS
- update HSA_API_INFO_DEFINITION_{0,V}
- rename domain_idx to callback_domain_idx
- add buffered_domain_idx
- add as_arg_addr function
- Update lib/rocprofiler/rocprofiler.cpp
- implement rocprofiler_iterate_callback_trace_operation_args
- Remove lib/rocprofiler/tracing.{hpp,cpp} and lib/rocprofiler/CMakeLists.txt
- unused
- Update lib/rocprofiler/hsa/hsa.{hpp,cpp}
- support buffered tracing in hsa_api_impl<Idx>::functor
- rocprofiler_callback_trace_operation_args_cb_t -> rocprofiler_callback_tracing_operation_args_cb_t
- i.e. trace -> tracing
- Update lib/rocprofiler/context/context.{hpp,cpp}
- removed buffer_instance struct
- removed allocate_buffer function
- removed get_buffers function
- changed buffer_tracing_service::buffer_array_t
- Update lib/rocprofiler/hsa: hsa.cpp, ostream.hpp, details folder
- move ostream.hpp into details folder to prevent from contributing to code coverage
- update cmake build system for new directory
* Add lib/rocprofiler/registration.{hpp,cpp}
- implements rocprofiler_set_api_table (called by rocprofiler-register)
- miscellaneous functions for client configure/initialize/finalize
- functions for querying the init/fini status
- relocated OnLoad HSA workaround to this file
- at present, this is used to workaround ROCr not having rocprofiler-register integration yet
- implement rocprofiler_force_configure function
- implement rocprofiler_is_initialized function
- implement rocprofiler_is_finalized function
- ensure configure functions only invoked once
- ensure internal thread creation notification functions are invoked
- get_status is pair of atomics
- fix heap-use-after-free in init_logging
- update finalize
- invoke hsa_shut_down
- set all active contexts to null pointers
* Add lib/rocprofiler/buffer_tracing.cpp
- contains implementations of buffer_tracing (i.e. rocprofiler/buffer_tracing.h)
- previous implementation may have been moved out of lib/rocprofiler/rocprofiler.cpp
* Add lib/rocprofiler/buffer.{hpp,cpp}
- contains implementations of buffer (i.e. rocprofiler/buffer.h) and misc internal access functions
- previous implementation may have been moved out of lib/rocprofiler/rocprofiler.cpp and lib/rocprofiler/context/context.{hpp,cpp}
* Add lib/rocprofiler/callback_tracing.cpp
- contains implementations of callback_tracing (i.e. rocprofiler/callback_tracing.h)
- previous implementation may have been moved out of lib/rocprofiler/rocprofiler.cpp
* Add lib/rocprofiler/context.cpp
- contains implementations of context public API functions (i.e. rocprofiler/context.h)
- previous implementation may have been moved out of lib/rocprofiler/rocprofiler.cpp
* Add lib/rocprofiler/internal_threading.{hpp,cpp}
- contains implementations of internal_threading (i.e. rocprofiler/internal_threading.h)
- also contains implementations of internal access functions
- update finalize function
- join all task groups and destroy all thread pools first, then reset unique_ptr
* Update lib/rocprofiler/rocprofiler.cpp
- rocprofiler_get_version returns status
- implement rocprofiler_get_timestamp
- remove misc implementations that were split into other files
* Update lib/rocprofiler/CMakeLists.txt
- compile new implementation files
- buffer.cpp
- buffer_tracing.cpp
- callback_tracing.cpp
- context.cpp
- internal_threading.cpp
* Update lib/tests/buffering/buffering-*.cpp
- update to reflect changes to rocprofiler_record_header_t
* Update CMakeLists.txt
- increase minimum cmake version to 3.21 which added HIP support as a language
* Add samples/apps/transpose
- simple HIP application for testing
* Add samples/api_callback_tracing
- HIP application and tool library
- This effectively demos how to setup HSA API tracing
- For each function called in tool, it stores the func/file/line and prints it during finalization
- client.hpp and client.cpp are the tool library
- Implement use of rocprofiler_iterate_callback_trace_operation_args
- add demo of using rocprofiler_get_version
- add_test
- remove PASS_REGULAR_EXPRESSION
- causing false passes during memcheck
- add ROCPROFILER_MEMCHECK_PRELOAD_ENV to environment
- check if rocprofiler is initialized before stopping context
* Add samples/api_buffered_tracing
- Sample demonstrating tracing the HSA API via buffering
- demo rocprofiler_record_header_compute_hash
- throw exceptions for unexpected buffer data
- add_test
- remove PASS_REGULAR_EXPRESSION
- causing false passes during memcheck
- add ROCPROFILER_MEMCHECK_PRELOAD_ENV to environment
* Update samples/CMakeLists.txt
- add subdirectory for api_callback_tracing
- add subdirectory api_buffered_tracing
* Update samples/pc_sampling/common.h
- fix processing of headers
* Update lib/rocprofiler/hsa/details/ostream.hpp
- fix data race on HSA_depth_max_cnt and recursion
- HSA_depth_max_cnt and recursion is now thread-local static instead of global static
- replace std::string usage with std::string_view
* Actions update
- add dependabot.yml
- use actions/checkout@v4
- install latest libasan and libtsan in sanitizer containers
* Add PTL (Parallel Tasking Library) submodule
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
06f7b780f9
Коммит
d3eaacd610
@@ -6,8 +6,30 @@
|
||||
configure_file(${CMAKE_CURRENT_LIST_DIR}/version.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/version.h @ONLY)
|
||||
|
||||
set(ROCPROFILER_HEADER_FILES config.h defines.h hip.h hsa.h marker.h rocprofiler.h
|
||||
rocprofiler_plugin.h ${CMAKE_CURRENT_BINARY_DIR}/version.h)
|
||||
set(ROCPROFILER_HEADER_FILES
|
||||
# core headers
|
||||
rocprofiler.h
|
||||
rocprofiler_plugin.h
|
||||
# secondary headers
|
||||
agent.h
|
||||
agent_profile.h
|
||||
buffer.h
|
||||
buffer_tracing.h
|
||||
callback_tracing.h
|
||||
context.h
|
||||
counters.h
|
||||
defines.h
|
||||
dispatch_profile.h
|
||||
external_correlation.h
|
||||
fwd.h
|
||||
hip.h
|
||||
hsa.h
|
||||
internal_threading.h
|
||||
marker.h
|
||||
pc_sampling.h
|
||||
profile_config.h
|
||||
spm.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/version.h)
|
||||
|
||||
install(FILES ${ROCPROFILER_HEADER_FILES}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler)
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2023 ROCm Developer Tools
|
||||
//
|
||||
// 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 <rocprofiler/defines.h>
|
||||
#include <rocprofiler/fwd.h>
|
||||
|
||||
ROCPROFILER_EXTERN_C_INIT
|
||||
|
||||
/** @defgroup AGENTS Agent Information
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Agent.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
rocprofiler_agent_id_t id;
|
||||
rocprofiler_agent_type_t type;
|
||||
const char* name;
|
||||
rocprofiler_pc_sampling_config_array_t pc_sampling_configs;
|
||||
} rocprofiler_agent_t;
|
||||
|
||||
/**
|
||||
* @brief Callback function type for querying the available agents
|
||||
*
|
||||
* @param [in] agents Array of pointers to agents
|
||||
* @param [in] num_agents Number of agents in array
|
||||
* @param [in] user_data Data pointer passback
|
||||
* @return ::rocprofiler_status_t
|
||||
*/
|
||||
typedef rocprofiler_status_t (*rocprofiler_available_agents_cb_t)(rocprofiler_agent_t** agents,
|
||||
size_t num_agents,
|
||||
void* user_data);
|
||||
|
||||
/**
|
||||
* @brief Receive synchronous callback with an array of available agents at moment of invocation
|
||||
*
|
||||
* @param [in] callback Callback function accepting list of agents
|
||||
* @param [in] agent_size Should be set to sizeof(rocprofiler_agent_t)
|
||||
* @param [in] user_data Data pointer provided to callback
|
||||
* @return ::rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_query_available_agents(rocprofiler_available_agents_cb_t callback,
|
||||
size_t agent_size,
|
||||
void* user_data) ROCPROFILER_NONNULL(1);
|
||||
|
||||
/** @} */
|
||||
|
||||
ROCPROFILER_EXTERN_C_FINI
|
||||
@@ -0,0 +1,70 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2023 ROCm Developer Tools
|
||||
//
|
||||
// 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 <rocprofiler/defines.h>
|
||||
#include <rocprofiler/fwd.h>
|
||||
|
||||
ROCPROFILER_EXTERN_C_INIT
|
||||
|
||||
/** @defgroup AGENT_PROFILE_COUNTING_SERVICE Agent Profile Counting Service
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Agent Profile Counting Data.
|
||||
*
|
||||
* Counters, including identifiers to get counter information and Counters values
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/**
|
||||
*/
|
||||
rocprofiler_record_counter_t* counters;
|
||||
uint64_t counters_count;
|
||||
} rocprofiler_agent_profile_counting_data_t;
|
||||
|
||||
/**
|
||||
* @brief Configure Profile Counting Service for agent.
|
||||
*
|
||||
* @param [in] buffer_id
|
||||
* @param [in] profile_config_id
|
||||
* @return ::rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_configure_agent_profile_counting_service(
|
||||
rocprofiler_buffer_id_t buffer_id,
|
||||
rocprofiler_profile_config_id_t profile_config_id);
|
||||
|
||||
/**
|
||||
* @brief Sample Profile Counting Service for agent.
|
||||
*
|
||||
* @param [out] data // It is always a size of one
|
||||
* @return ::rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_sample_agent_profile_counting_service(rocprofiler_agent_profile_counting_data_t* data);
|
||||
|
||||
/** @} */
|
||||
|
||||
ROCPROFILER_EXTERN_C_FINI
|
||||
@@ -0,0 +1,106 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2023 ROCm Developer Tools
|
||||
//
|
||||
// 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 <rocprofiler/defines.h>
|
||||
#include <rocprofiler/fwd.h>
|
||||
|
||||
ROCPROFILER_EXTERN_C_INIT
|
||||
|
||||
/** @defgroup BUFFER_HANDLING Buffer
|
||||
* @{
|
||||
*
|
||||
* Every Buffer is associated with a specific service kind.
|
||||
* OR
|
||||
* Every Buffer is associated with a specific service ID.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Async callback function.
|
||||
*
|
||||
* @code{.cpp}
|
||||
* for(size_t i = 0; i < num_headers; ++i)
|
||||
* {
|
||||
* rocprofiler_record_header_t* hdr = headers[i];
|
||||
* if(hdr->kind == ROCPROFILER_RECORD_KIND_PC_SAMPLE)
|
||||
* {
|
||||
* auto* data = static_cast<rocprofiler_pc_sample_t*>(&hdr->payload);
|
||||
* ...
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
typedef void (*rocprofiler_buffer_tracing_cb_t)(rocprofiler_context_id_t context,
|
||||
rocprofiler_buffer_id_t buffer_id,
|
||||
rocprofiler_record_header_t** headers,
|
||||
size_t num_headers,
|
||||
void* data,
|
||||
uint64_t drop_count);
|
||||
|
||||
/**
|
||||
* @brief Create buffer.
|
||||
*
|
||||
* @param [in] context Context identifier associated with buffer
|
||||
* @param [in] size Size of the buffer in bytes
|
||||
* @param [in] watermark - watermark size, where the callback is called, if set
|
||||
* to 0 then the callback will be called on every record
|
||||
* @param [in] policy Behavior policy when buffer is full
|
||||
* @param [in] callback Callback to invoke when buffer is flushed/full
|
||||
* @param [in] callback_data Data to provide in callback function
|
||||
* @param [out] buffer_id Identification handle for buffer
|
||||
* @return ::rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_create_buffer(rocprofiler_context_id_t context,
|
||||
size_t size,
|
||||
size_t watermark,
|
||||
rocprofiler_buffer_policy_t policy,
|
||||
rocprofiler_buffer_tracing_cb_t callback,
|
||||
void* callback_data,
|
||||
rocprofiler_buffer_id_t* buffer_id) ROCPROFILER_NONNULL(5, 7);
|
||||
|
||||
/**
|
||||
* @brief Destroy buffer.
|
||||
*
|
||||
* @param [in] buffer_id
|
||||
* @return ::rocprofiler_status_t
|
||||
*
|
||||
* Note: This will destroy the buffer even if it is not empty. The user can
|
||||
* call @ref ::rocprofiler_flush_buffer before it to make sure the buffer is empty.
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_destroy_buffer(rocprofiler_buffer_id_t buffer_id);
|
||||
|
||||
/**
|
||||
* @brief Flush buffer.
|
||||
*
|
||||
* @param [in] buffer_id
|
||||
* @return ::rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_flush_buffer(rocprofiler_buffer_id_t buffer_id);
|
||||
|
||||
/** @} */
|
||||
|
||||
ROCPROFILER_EXTERN_C_FINI
|
||||
@@ -0,0 +1,278 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2023 ROCm Developer Tools
|
||||
//
|
||||
// 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 <rocprofiler/defines.h>
|
||||
#include <rocprofiler/fwd.h>
|
||||
|
||||
ROCPROFILER_EXTERN_C_INIT
|
||||
|
||||
/** @defgroup BUFFER_TRACING_SERVICE Asynchronous Tracing Service
|
||||
*
|
||||
* Receive callbacks for batches of records from an internal (background) thread
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Buffer HSA API Tracer Record.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
rocprofiler_service_buffer_tracing_kind_t kind;
|
||||
rocprofiler_correlation_id_t correlation_id;
|
||||
rocprofiler_tracing_operation_t operation; // rocprofiler/hsa.h
|
||||
rocprofiler_timestamp_t start_timestamp;
|
||||
rocprofiler_timestamp_t end_timestamp;
|
||||
rocprofiler_thread_id_t thread_id;
|
||||
} rocprofiler_buffer_tracing_hsa_api_record_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Buffer HIP API Tracer Record.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
rocprofiler_service_buffer_tracing_kind_t kind;
|
||||
rocprofiler_correlation_id_t correlation_id;
|
||||
rocprofiler_tracing_operation_t operation; // rocprofiler/hip.h
|
||||
rocprofiler_timestamp_t start_timestamp;
|
||||
rocprofiler_timestamp_t end_timestamp;
|
||||
rocprofiler_thread_id_t thread_id;
|
||||
} rocprofiler_buffer_tracing_hip_api_record_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Buffer Marker Tracer Record.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
rocprofiler_service_buffer_tracing_kind_t kind;
|
||||
rocprofiler_correlation_id_t correlation_id;
|
||||
rocprofiler_tracing_operation_t operation; // rocprofiler/marker.h
|
||||
rocprofiler_timestamp_t timestamp;
|
||||
rocprofiler_thread_id_t thread_id;
|
||||
uint64_t marker_id; // rocprofiler_marker_id_t
|
||||
// const char* message; // (Need Review?)
|
||||
} rocprofiler_buffer_tracing_marker_record_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Buffer Memory Copy Tracer Record.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
rocprofiler_service_buffer_tracing_kind_t kind;
|
||||
rocprofiler_correlation_id_t correlation_id;
|
||||
/**
|
||||
* Memory copy operation that can be derived from
|
||||
* ::rocprofiler_tracing_operation_t
|
||||
*/
|
||||
uint32_t operation;
|
||||
rocprofiler_timestamp_t start_timestamp;
|
||||
rocprofiler_timestamp_t end_timestamp;
|
||||
rocprofiler_queue_id_t queue_id;
|
||||
} rocprofiler_buffer_tracing_memory_copy_record_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Buffer Kernel Dispatch Tracer Record.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
rocprofiler_service_buffer_tracing_kind_t kind;
|
||||
rocprofiler_correlation_id_t correlation_id;
|
||||
rocprofiler_timestamp_t start_timestamp;
|
||||
rocprofiler_timestamp_t end_timestamp;
|
||||
rocprofiler_queue_id_t queue_id;
|
||||
const char* kernel_name;
|
||||
} rocprofiler_buffer_tracing_kernel_dispatch_record_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Buffer Page Migration Tracer Record.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
rocprofiler_service_buffer_tracing_kind_t kind;
|
||||
rocprofiler_correlation_id_t correlation_id;
|
||||
rocprofiler_timestamp_t start_timestamp;
|
||||
rocprofiler_timestamp_t end_timestamp;
|
||||
rocprofiler_queue_id_t queue_id;
|
||||
// Not Sure What is the info needed here?
|
||||
} rocprofiler_buffer_tracing_page_migration_record_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Buffer Scratch Memory Tracer Record.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
rocprofiler_service_buffer_tracing_kind_t kind;
|
||||
rocprofiler_correlation_id_t correlation_id;
|
||||
rocprofiler_timestamp_t start_timestamp;
|
||||
rocprofiler_timestamp_t end_timestamp;
|
||||
rocprofiler_queue_id_t queue_id;
|
||||
// Not Sure What is the info needed here?
|
||||
} rocprofiler_buffer_tracing_scratch_memory_record_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Buffer Queue Scheduling Tracer Record.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
rocprofiler_service_buffer_tracing_kind_t kind;
|
||||
rocprofiler_correlation_id_t correlation_id;
|
||||
rocprofiler_timestamp_t start_timestamp;
|
||||
rocprofiler_timestamp_t end_timestamp;
|
||||
rocprofiler_queue_id_t queue_id;
|
||||
// Not Sure What is the info needed here?
|
||||
} rocprofiler_buffer_tracing_queue_scheduling_record_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Code Object Tracer Buffer Record.
|
||||
*
|
||||
* We need to guarantee that these records are in the buffer before the
|
||||
* corresponding Exit Phase API calls are called.
|
||||
*/
|
||||
// typedef struct {
|
||||
// rocprofiler_buffer_tracing_record_header_t header;
|
||||
// rocprofiler_tracing_code_object_kind_id_t kind;
|
||||
// } rocprofiler_buffer_tracing_code_object_header_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Code Object Load Tracer Buffer Record.
|
||||
*
|
||||
*/
|
||||
// typedef struct {
|
||||
// rocprofiler_buffer_tracing_code_object_header_t header;
|
||||
// uint64_t load_base; // code object load base
|
||||
// uint64_t load_size; // code object load size
|
||||
// const char *uri; // URI string (NULL terminated)
|
||||
// rocprofiler_timestamp_t timestamp;
|
||||
// // uint32_t storage_type; // code object storage type (Need Review?)
|
||||
// // int storage_file; // origin file descriptor (Need Review?)
|
||||
// // uint64_t memory_base; // origin memory base (Need Review?)
|
||||
// // uint64_t memory_size; // origin memory size (Need Review?)
|
||||
// // uint64_t load_delta; // code object load delta (Need Review?)
|
||||
// } rocprofiler_buffer_tracing_code_object_load_record_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Code Object UnLoad Tracer Buffer Record.
|
||||
*
|
||||
*/
|
||||
// typedef struct {
|
||||
// rocprofiler_buffer_tracing_code_object_header_t header;
|
||||
// uint64_t load_base; // code object load base
|
||||
// rocprofiler_timestamp_t timestamp;
|
||||
// } rocprofiler_buffer_tracing_code_object_unload_record_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Code Object Kernel Symbol Tracer Buffer Record.
|
||||
*
|
||||
*/
|
||||
// typedef struct {
|
||||
// rocprofiler_buffer_tracing_code_object_header_t header;
|
||||
// const char *kernel_name; // kernel name string (NULL terminated)
|
||||
// uint64_t kernel_descriptor; // kernel descriptor (Need to be changed from
|
||||
// // uint64_t to ::rocprofiler_address_t)
|
||||
// // rocprofiler_timestamp_t timestamp; // (Need Review?)
|
||||
// } rocprofiler_buffer_tracing_code_object_kernel_symbol_record_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Buffer External Correlation Tracer Record.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
rocprofiler_service_buffer_tracing_kind_t kind;
|
||||
rocprofiler_correlation_id_t correlation_id;
|
||||
rocprofiler_external_correlation_id_t external_correlation_id;
|
||||
} rocprofiler_buffer_tracing_external_correlation_record_t;
|
||||
|
||||
/**
|
||||
* @brief Callback function for mapping @ref rocprofiler_service_buffer_tracing_kind_t ids to
|
||||
* string names. @see rocprofiler_iterate_buffer_trace_kind_names.
|
||||
*/
|
||||
typedef int (*rocprofiler_buffer_tracing_kind_name_cb_t)(
|
||||
rocprofiler_service_buffer_tracing_kind_t kind,
|
||||
const char* kind_name,
|
||||
void* data);
|
||||
|
||||
/**
|
||||
* @brief Callback function for mapping the operations of a given @ref
|
||||
* rocprofiler_service_buffer_tracing_kind_t to string names. @see
|
||||
* rocprofiler_iterate_buffer_trace_kind_operation_names.
|
||||
*/
|
||||
typedef int (*rocprofiler_buffer_tracing_operation_name_cb_t)(
|
||||
rocprofiler_service_buffer_tracing_kind_t kind,
|
||||
uint32_t operation,
|
||||
const char* operation_name,
|
||||
void* data);
|
||||
|
||||
/**
|
||||
* @brief Configure Buffer Tracing Service.
|
||||
*
|
||||
* @param [in] context_id
|
||||
* @param [in] kind
|
||||
* @param [in] operations
|
||||
* @param [in] operations_count
|
||||
* @param [in] buffer_id
|
||||
* @return ::rocprofiler_status_t
|
||||
*
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_configure_buffer_tracing_service(rocprofiler_context_id_t context_id,
|
||||
rocprofiler_service_buffer_tracing_kind_t kind,
|
||||
rocprofiler_tracing_operation_t* operations,
|
||||
size_t operations_count,
|
||||
rocprofiler_buffer_id_t buffer_id);
|
||||
|
||||
/**
|
||||
* @brief Iterate over all the mappings of the callback tracing kinds and get a callback with the id
|
||||
* mapped to a constant string. The strings provided in the arg will be valid pointers for the
|
||||
* entire duration of the program. It is recommended to call this function once and cache this data
|
||||
* in the client instead of making multiple on-demand calls.
|
||||
*
|
||||
* @param [in] callback Callback function invoked for each enumeration value in @ref
|
||||
* rocprofiler_service_buffer_tracing_kind_t with the exception of the `NONE` and `LAST` values.
|
||||
* @param [in] data User data passed back into the callback
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_iterate_buffer_tracing_kind_names(rocprofiler_buffer_tracing_kind_name_cb_t callback,
|
||||
void* data) ROCPROFILER_NONNULL(1);
|
||||
|
||||
/**
|
||||
* @brief Iterates over all the mappings of the operations for a given @ref
|
||||
* rocprofiler_service_buffer_tracing_kind_t and invokes the callback with the kind, operation id,
|
||||
* and the string mapping to the operation id. The strings provided in the callback arg will be
|
||||
* valid pointers for the entire duration of the program. It is recommended to call this function
|
||||
* once per kind, and cache this data in the client instead of making multiple on-demand calls.
|
||||
*
|
||||
* @param [in] kind which buffer tracing kind operations to iterate over
|
||||
* @param [in] callback Callback function invoked for each operation associated with @ref
|
||||
* rocprofiler_service_buffer_tracing_kind_t with the exception of the `NONE` and `LAST` values.
|
||||
* @param [in] data User data passed back into the callback
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_iterate_buffer_tracing_kind_operation_names(
|
||||
rocprofiler_service_buffer_tracing_kind_t kind,
|
||||
rocprofiler_buffer_tracing_operation_name_cb_t callback,
|
||||
void* data) ROCPROFILER_NONNULL(2);
|
||||
|
||||
/** @} */
|
||||
|
||||
ROCPROFILER_EXTERN_C_FINI
|
||||
@@ -0,0 +1,252 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2023 ROCm Developer Tools
|
||||
//
|
||||
// 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 <rocprofiler/defines.h>
|
||||
#include <rocprofiler/fwd.h>
|
||||
#include <rocprofiler/hsa.h>
|
||||
|
||||
ROCPROFILER_EXTERN_C_INIT
|
||||
|
||||
/** @defgroup CALLBACK_TRACING_SERVICE Synchronous Tracing Services
|
||||
*
|
||||
* Receive immediate callbacks on the calling thread
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler HSA API Callback Data.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
size_t size; ///< provides the size of this struct
|
||||
rocprofiler_hsa_api_args_t args;
|
||||
rocprofiler_hsa_api_retval_t retval;
|
||||
} rocprofiler_hsa_api_callback_tracer_data_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler HIP API Callback Data.
|
||||
*
|
||||
* Depending on the operation kind, the data can be casted to the corresponding
|
||||
* structure.
|
||||
*
|
||||
*/
|
||||
typedef void* rocprofiler_hip_api_callback_api_data_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler HIP API Tracer Callback Data.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
size_t size;
|
||||
rocprofiler_correlation_id_t correlation_id;
|
||||
rocprofiler_address_t host_kernel_address;
|
||||
rocprofiler_hip_api_callback_api_data_t data; // Arguments or api_data?
|
||||
} rocprofiler_hip_api_callback_tracer_data_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Marker Callback Data.
|
||||
*
|
||||
* Depending on the operation kind, the data can be casted to the corresponding
|
||||
* structure.
|
||||
*
|
||||
*/
|
||||
typedef void* rocprofiler_marker_callback_api_data_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Marker Tracer Callback Data.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
size_t size;
|
||||
rocprofiler_correlation_id_t correlation_id;
|
||||
rocprofiler_marker_callback_api_data_t data; // Arguments or api_data?
|
||||
} rocprofiler_marker_callback_tracer_data_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Code Object Load Tracer Callback Record.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint64_t load_base; // code object load base
|
||||
uint64_t load_size; // code object load size
|
||||
const char* uri; // URI string (NULL terminated)
|
||||
// uint32_t storage_type; // code object storage type (Need Review?)
|
||||
// int storage_file; // origin file descriptor (Need Review?)
|
||||
// uint64_t memory_base; // origin memory base (Need Review?)
|
||||
// uint64_t memory_size; // origin memory size (Need Review?)
|
||||
// uint64_t load_delta; // code object load delta (Need Review?)
|
||||
} rocprofiler_callback_tracer_code_object_load_data_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Code Object UnLoad Tracer Callback Record.
|
||||
*
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint64_t load_base; // code object load base
|
||||
} rocprofiler_callback_tracer_code_object_unload_data_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Code Object Device Kernel Symbol Tracer Callback Record.
|
||||
*
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
const char* kernel_name; // kernel name string (NULL terminated)
|
||||
rocprofiler_address_t kernel_descriptor; // kernel descriptor
|
||||
} rocprofiler_callback_tracer_code_object_device_kernel_symbol_data_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Code Object Register Host Kernel Symbol Tracer Callback
|
||||
* Record.
|
||||
*
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
rocprofiler_address_t host_address; // host address
|
||||
// Should this be nullptr if it is unregister?
|
||||
const char* kernel_name; // kernel name string (NULL terminated)
|
||||
rocprofiler_address_t kernel_descriptor; // kernel descriptor
|
||||
} rocprofiler_callback_tracer_code_object_register_host_kernel_symbol_data_t;
|
||||
|
||||
/**
|
||||
* @brief API Tracing callback function.
|
||||
*/
|
||||
typedef void (*rocprofiler_callback_tracing_cb_t)(rocprofiler_callback_tracing_record_t record,
|
||||
void* user_data);
|
||||
|
||||
/**
|
||||
* @brief Callback function for mapping @ref rocprofiler_service_callback_tracing_kind_t ids to
|
||||
* string names. @see rocprofiler_iterate_callback_tracing_kind_names.
|
||||
*/
|
||||
typedef int (*rocprofiler_callback_tracing_kind_name_cb_t)(
|
||||
rocprofiler_service_callback_tracing_kind_t kind,
|
||||
const char* kind_name,
|
||||
void* data);
|
||||
|
||||
/**
|
||||
* @brief Callback function for mapping the operations of a given @ref
|
||||
* rocprofiler_service_callback_tracing_kind_t to string names. @see
|
||||
* rocprofiler_iterate_callback_tracing_kind_operation_names.
|
||||
*/
|
||||
typedef int (*rocprofiler_callback_tracing_operation_name_cb_t)(
|
||||
rocprofiler_service_callback_tracing_kind_t kind,
|
||||
uint32_t operation,
|
||||
const char* operation_name,
|
||||
void* data);
|
||||
|
||||
/**
|
||||
* @brief Callback function for iterating over the function arguments to a traced function.
|
||||
* This function will be invoked for each argument.
|
||||
* @see rocprofiler_iterate_callback_tracing_operation_args
|
||||
*
|
||||
* @param kind [in] domain
|
||||
* @param operation [in] associated domain operation
|
||||
* @param arg_number [in] the argument number, starting at zero
|
||||
* @param arg_name [in] the name of the argument in the prototype (or rocprofiler union)
|
||||
* @param arg_value_str [in] conversion of the argument to a string, e.g. operator<< overload
|
||||
* @param arg_value_addr [in] the address of the argument stored by rocprofiler.
|
||||
* @param data [in] user data
|
||||
*/
|
||||
typedef int (*rocprofiler_callback_tracing_operation_args_cb_t)(
|
||||
rocprofiler_service_callback_tracing_kind_t kind,
|
||||
uint32_t operation,
|
||||
uint32_t arg_number,
|
||||
const char* arg_name,
|
||||
const char* arg_value_str,
|
||||
const void* const arg_value_addr,
|
||||
void* data);
|
||||
|
||||
/**
|
||||
* @brief Configure Callback Tracing Service.
|
||||
*
|
||||
* @param [in] context_id
|
||||
* @param [in] kind
|
||||
* @param [in] operations
|
||||
* @param [in] operations_count
|
||||
* @param [in] callback
|
||||
* @param [in] callback_args
|
||||
* @return ::rocprofiler_status_t
|
||||
*
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_configure_callback_tracing_service(rocprofiler_context_id_t context_id,
|
||||
rocprofiler_service_callback_tracing_kind_t kind,
|
||||
rocprofiler_tracing_operation_t* operations,
|
||||
size_t operations_count,
|
||||
rocprofiler_callback_tracing_cb_t callback,
|
||||
void* callback_args);
|
||||
|
||||
/**
|
||||
* @brief Iterate over all the mappings of the callback tracing kinds and get a callback with the id
|
||||
* mapped to a constant string. The strings provided in the arg will be valid pointers for the
|
||||
* entire duration of the program. It is recommended to call this function once and cache this data
|
||||
* in the client instead of making multiple on-demand calls.
|
||||
*
|
||||
* @param [in] callback Callback function invoked for each enumeration value in @ref
|
||||
* rocprofiler_service_callback_tracing_kind_t with the exception of the `NONE` and `LAST` values.
|
||||
* @param [in] data User data passed back into the callback
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_iterate_callback_tracing_kind_names(
|
||||
rocprofiler_callback_tracing_kind_name_cb_t callback,
|
||||
void* data) ROCPROFILER_NONNULL(1);
|
||||
|
||||
/**
|
||||
* @brief Iterates over all the mappings of the operations for a given @ref
|
||||
* rocprofiler_service_callback_tracing_kind_t and invokes the callback with the kind, operation id,
|
||||
* and the string mapping to the operation id. The strings provided in the callback arg will be
|
||||
* valid pointers for the entire duration of the program. It is recommended to call this function
|
||||
* once per kind, and cache this data in the client instead of making multiple on-demand calls.
|
||||
*
|
||||
* @param [in] kind which tracing callback kind operations to iterate over
|
||||
* @param [in] callback Callback function invoked for each operation associated with @ref
|
||||
* rocprofiler_service_callback_tracing_kind_t with the exception of the `NONE` and `LAST` values.
|
||||
* @param [in] data User data passed back into the callback
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_iterate_callback_tracing_kind_operation_names(
|
||||
rocprofiler_service_callback_tracing_kind_t kind,
|
||||
rocprofiler_callback_tracing_operation_name_cb_t callback,
|
||||
void* data) ROCPROFILER_NONNULL(2);
|
||||
|
||||
/**
|
||||
* @brief Iterates over all the arguments for the traced function (when available). This is
|
||||
* particularly useful when tools want to annotate traces with the function arguments. See
|
||||
* @example samples/api_callback_tracing/client.cpp for a usage example.
|
||||
*
|
||||
* @param[in] record Record provided by service callback
|
||||
* @param[in] callback The callback function which will be invoked for each argument
|
||||
* @param[in] user_data Data to be passed to each invocation of the callback
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_iterate_callback_tracing_operation_args(
|
||||
rocprofiler_callback_tracing_record_t record,
|
||||
rocprofiler_callback_tracing_operation_args_cb_t callback,
|
||||
void* user_data) ROCPROFILER_NONNULL(2);
|
||||
|
||||
/** @} */
|
||||
|
||||
ROCPROFILER_EXTERN_C_FINI
|
||||
@@ -1,210 +0,0 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2023 ROCm Developer Tools
|
||||
//
|
||||
// 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 <rocprofiler/rocprofiler.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ROCPROFILER_API_VERSION_ID 1
|
||||
#define ROCPROFILER_DOMAIN_OPS_MAX 512
|
||||
#define ROCPROFILER_DOMAIN_OPS_RESERVED \
|
||||
((ROCPROFILER_DOMAIN_OPS_MAX * ROCPROFILER_TRACER_ACTIVITY_DOMAIN_LAST / 8))
|
||||
|
||||
typedef uint64_t (*rocprofiler_external_cid_cb_t)(rocprofiler_tracer_activity_domain_t,
|
||||
uint32_t,
|
||||
uint64_t);
|
||||
typedef int (*rocprofiler_filter_name_t)(const char*);
|
||||
typedef int (*rocprofiler_filter_op_id_t)(uint32_t);
|
||||
typedef int (*rocprofiler_filter_range_t)(uint32_t, uint32_t);
|
||||
typedef int (*rocprofiler_filter_dispatch_id_t)(uint64_t);
|
||||
|
||||
/// permits tools opportunity to modify the correlation id based on the domain, op, and
|
||||
/// the rocprofiler generated correlation id
|
||||
struct rocprofiler_correlation_config
|
||||
{
|
||||
rocprofiler_external_cid_cb_t external_id_callback;
|
||||
};
|
||||
|
||||
/// how the tools specify the tracing domain and (optionally) which operations in the
|
||||
/// domain they want to trace
|
||||
struct rocprofiler_domain_config
|
||||
{
|
||||
rocprofiler_tracer_callback_t callback;
|
||||
char reserved0[sizeof(uint64_t)];
|
||||
char reserved1[ROCPROFILER_DOMAIN_OPS_RESERVED];
|
||||
};
|
||||
|
||||
/// for buffered callbacks, the tool provides a callback to create a buffer and the size
|
||||
struct rocprofiler_buffer_config
|
||||
{
|
||||
rocprofiler_buffer_callback_t callback;
|
||||
uint64_t buffer_size;
|
||||
// void* reserved0;
|
||||
char reserved1[sizeof(uint64_t)];
|
||||
};
|
||||
|
||||
/// filters are available to make quick decisions about whether rocprofiler should
|
||||
/// assemble the data necessary for a callback. This is more for convenience and
|
||||
/// performance -- anything decisions here could be made in the callback but rocprofiler
|
||||
/// has to first assemble all the infomation on the callback before it (eventually) gets
|
||||
/// discarded because the tool has decided it (after configuration), that it no longer
|
||||
/// wants info meeting certain requirements
|
||||
struct rocprofiler_filter_config
|
||||
{
|
||||
// filter callbacks
|
||||
rocprofiler_filter_name_t name;
|
||||
rocprofiler_filter_op_id_t hip_function_id;
|
||||
rocprofiler_filter_op_id_t hsa_function_id;
|
||||
rocprofiler_filter_range_t range;
|
||||
rocprofiler_filter_dispatch_id_t dispatch_id;
|
||||
|
||||
// reserved padding
|
||||
char padding[24 * sizeof(void*)];
|
||||
};
|
||||
|
||||
/// this is the "single source of truth" for the capabilities of rocprofiler.
|
||||
/// you can one configuration that activates all the capabilities you want
|
||||
/// and holistically start/stop the sum of those features. Alternatively,
|
||||
/// you can have multiple configurations in order to activate certain features
|
||||
/// modularly.
|
||||
///
|
||||
/// The general workflow is:
|
||||
///
|
||||
/// 1. invoke rocprofiler_allocate_config(...)
|
||||
/// - rocprofiler allocates any space internally needed for the config
|
||||
/// - rocprofiler sets a few initial values:
|
||||
/// - "size" to the size of the config structure used internally
|
||||
/// - "api_version" to the version id of the API in the rocprofiler library that
|
||||
/// is being used.
|
||||
/// - these two values can be used by the tool to identify any potential
|
||||
/// incompatibilities that the tool might want to know about
|
||||
/// - rocprofiler checks whether it is too late to configure the tool, e.g.
|
||||
/// something went wrong and rocprofiler was not able to set itself up as
|
||||
/// the intercepter
|
||||
/// 2. tool sets up the configuration struct and sets the "size" variable to the size of
|
||||
/// their configuration struct and sets the "compat_version" field to the
|
||||
/// ROCPROFILER_API_VERSION_ID defined by the rocprofiler headers when the tool was
|
||||
/// built
|
||||
/// - in other words, the user can communicate to rocprofiler, don't read
|
||||
/// past this distance in my configuration struct and I built against X version
|
||||
/// so assume the default behavior and capabilties of version X.
|
||||
/// 3. tool passes this struct to rocprofiler_validate_config(...)
|
||||
/// - this step checks the config in isolation and will communicate any potential
|
||||
/// warnings/issues with that configuration, e.g. rocprofiler_X_config is needed,
|
||||
/// to HW counters XYZ are not available, etc. The tool then has an opportunity
|
||||
/// to address these issues however they see fit.
|
||||
/// 4. tool passes this struct to rocprofiler_start_config(...)
|
||||
/// - internally, we make a call to rocprofiler_validate_config(...) and if any
|
||||
/// issues still exist with the config in isolation, rocprofiler tells the app
|
||||
/// to abort -- mechanisms were provided to prevent aborting prior to this call,
|
||||
/// aborting the app at this point is to guard against rocprofiler "silently"
|
||||
/// not working because error codes were ignored
|
||||
/// - rocprofiler then checks whether this config can actually be activated
|
||||
/// alongside any other active configuration, e.g. this config wants 4 HW counters
|
||||
/// and another wants 4 HW counters but we can only activate 6 out of 8 of
|
||||
/// them in this run. Any issues here will not abort execution but, instead,
|
||||
/// the features of this configuration will not happen (i.e. config won't be
|
||||
/// activated) and the issues will be communicated with error codes -- giving
|
||||
/// the tool the opportunity to address the conflicts (i.e. only request tracing
|
||||
/// and no HW counters) before attempting to activate the modified config.
|
||||
/// - once rocprofiler determines all features of a config can be activated, it
|
||||
/// makes an internal copy of the config and returns an identifier for that
|
||||
/// configuration. The tool is then free to delete the config and any modification
|
||||
/// to the config will NOT be reflected in the behavior of rocprofiler.
|
||||
///
|
||||
///
|
||||
struct rocprofiler_config
|
||||
{
|
||||
// size is used to ensure that we never read past the end of the version
|
||||
size_t size; // = sizeof(rocprofiler_config)
|
||||
uint32_t compat_version; // set by user
|
||||
uint32_t api_version; // set by rocprofiler
|
||||
uint64_t reserved0; // internal field
|
||||
void* user_data; // data passed to callbacks
|
||||
struct rocprofiler_correlation_config* correlation_id; // = &my_cid_config (optional)
|
||||
struct rocprofiler_buffer_config* buffer; // = &my_buffer_config (required)
|
||||
struct rocprofiler_domain_config* domain; // = &my_domain_config (required)
|
||||
struct rocprofiler_filter_config* filter; // = &my_filter_config (optional)
|
||||
};
|
||||
|
||||
/// \brief returns a properly initialized config struct and allocates any data structures
|
||||
/// necessary for the config to be used
|
||||
///
|
||||
/// \param [out] cfg may adjust config or assign values within structs.
|
||||
rocprofiler_status_t
|
||||
rocprofiler_allocate_config(struct rocprofiler_config* cfg);
|
||||
|
||||
/// \brief rocprofiler validates config, checks for conflicts, etc. Ensures that
|
||||
/// the configuration is valid *in isolation*, e.g. it may check that the user
|
||||
/// set the compat_version field and that required config fields, such as buffer
|
||||
/// are set. This function will be called before \ref rocprofiler_start_config
|
||||
/// but is provided to help the user validate one or more configs without starting
|
||||
/// them
|
||||
///
|
||||
/// \param [in] cfg configuration to validate
|
||||
rocprofiler_status_t
|
||||
rocprofiler_validate_config(const struct rocprofiler_config* cfg);
|
||||
|
||||
/// \brief rocprofiler activates configuration and provides a context identifier
|
||||
/// \param [in] cfg may adjust config or assign values within structs. If error
|
||||
/// occurs, could nullptr valid sub-configs and leave the pointers to
|
||||
/// invalid configs
|
||||
/// \param [out] id the context identifier for this config.
|
||||
rocprofiler_status_t
|
||||
rocprofiler_start_config(struct rocprofiler_config*, rocprofiler_context_id_t* id);
|
||||
|
||||
/// \brief disable the configuration.
|
||||
rocprofiler_status_t rocprofiler_stop_config(rocprofiler_context_id_t);
|
||||
|
||||
///
|
||||
///
|
||||
/// the following 4 functions may be changed to permit removing domain/ops and/or
|
||||
/// identifying domains and operations via strings
|
||||
///
|
||||
///
|
||||
rocprofiler_status_t
|
||||
rocprofiler_domain_set_domain(struct rocprofiler_domain_config*,
|
||||
rocprofiler_tracer_activity_domain_t);
|
||||
|
||||
rocprofiler_status_t
|
||||
rocprofiler_domain_add_domains(struct rocprofiler_domain_config*,
|
||||
rocprofiler_tracer_activity_domain_t*,
|
||||
size_t);
|
||||
|
||||
rocprofiler_status_t
|
||||
rocprofiler_domain_add_op(struct rocprofiler_domain_config*,
|
||||
rocprofiler_tracer_activity_domain_t,
|
||||
uint32_t);
|
||||
|
||||
rocprofiler_status_t
|
||||
rocprofiler_domain_add_ops(struct rocprofiler_domain_config*,
|
||||
rocprofiler_tracer_activity_domain_t,
|
||||
uint32_t*,
|
||||
size_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,91 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2023 ROCm Developer Tools
|
||||
//
|
||||
// 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 <rocprofiler/defines.h>
|
||||
#include <rocprofiler/fwd.h>
|
||||
|
||||
ROCPROFILER_EXTERN_C_INIT
|
||||
|
||||
/**
|
||||
* @defgroup CONTEXT_OPERATIONS Context
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The NULL Context handle.
|
||||
*/
|
||||
#define ROCPROFILER_CONTEXT_NONE ROCPROFILER_HANDLE_LITERAL(rocprofiler_context_id_t, UINT64_MAX)
|
||||
|
||||
/**
|
||||
* @brief Create context.
|
||||
*
|
||||
* @param context_id [out] Context identifier
|
||||
* @return ::rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_create_context(rocprofiler_context_id_t* context_id) ROCPROFILER_NONNULL(1);
|
||||
|
||||
/**
|
||||
* @brief Start context.
|
||||
*
|
||||
* @param [in] context_id
|
||||
* @return ::rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_start_context(rocprofiler_context_id_t context_id);
|
||||
|
||||
/**
|
||||
* @brief Stop context.
|
||||
*
|
||||
* @param [in] context_id
|
||||
* @return ::rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_stop_context(rocprofiler_context_id_t context_id);
|
||||
|
||||
/**
|
||||
* @brief Query whether context is active.
|
||||
*
|
||||
* @param [in] context_id
|
||||
* @param [out] status If context is active, this will be a nonzero value
|
||||
* @return ::rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_context_is_active(rocprofiler_context_id_t context_id, int* status)
|
||||
ROCPROFILER_NONNULL(2);
|
||||
|
||||
/**
|
||||
* @brief Query whether the context is valid
|
||||
*
|
||||
* @param [in] context_id
|
||||
* @param [out] status If context is invalid, this will be a nonzero value
|
||||
* @return ::rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_context_is_valid(rocprofiler_context_id_t context_id, int* status)
|
||||
ROCPROFILER_NONNULL(2);
|
||||
|
||||
/** @} */
|
||||
|
||||
ROCPROFILER_EXTERN_C_FINI
|
||||
@@ -0,0 +1,73 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2023 ROCm Developer Tools
|
||||
//
|
||||
// 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 <rocprofiler/agent.h>
|
||||
#include <rocprofiler/defines.h>
|
||||
#include <rocprofiler/fwd.h>
|
||||
|
||||
ROCPROFILER_EXTERN_C_INIT
|
||||
|
||||
/** @defgroup COUNTERS Hardware counters
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Query Counter name.
|
||||
*
|
||||
* @param [in] counter_id
|
||||
* @param [out] name if nullptr, size will be returned
|
||||
* @param [out] size
|
||||
* @return ::rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_query_counter_name(rocprofiler_counter_id_t counter_id, const char* name, size_t* size)
|
||||
ROCPROFILER_NONNULL(3);
|
||||
|
||||
/**
|
||||
* @brief Query Counter Instances Count.
|
||||
*
|
||||
* @param [in] counter_id
|
||||
* @param [out] instance_count
|
||||
* @return rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_query_counter_instance_count(rocprofiler_counter_id_t counter_id,
|
||||
size_t* instance_count) ROCPROFILER_NONNULL(2);
|
||||
|
||||
/**
|
||||
* @brief Query Agent Counters Availability.
|
||||
*
|
||||
* @param [in] agent
|
||||
* @param [out] counters_list
|
||||
* @param [out] counters_count
|
||||
* @return ::rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_query_agent_supported_counters(rocprofiler_agent_t agent,
|
||||
rocprofiler_counter_id_t* counters_list,
|
||||
size_t* counters_count) ROCPROFILER_NONNULL(2, 3);
|
||||
|
||||
/** @} */
|
||||
|
||||
ROCPROFILER_EXTERN_C_FINI
|
||||
@@ -22,6 +22,29 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
/** @defgroup SYMBOL_VERSIONING_GROUP Symbol Versions
|
||||
*
|
||||
* The names used for the shared library versioned symbols.
|
||||
*
|
||||
* Every function is annotated with one of the version macros defined in this
|
||||
* section. Each macro specifies a corresponding symbol version string. After
|
||||
* dynamically loading the shared library with @p dlopen, the address of each
|
||||
* function can be obtained using @p dlsym with the name of the function and
|
||||
* its corresponding symbol version string. An error will be reported by @p
|
||||
* dlvsym if the installed library does not support the version for the
|
||||
* function specified in this version of the interface.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief The function was introduced in version 10.0 of the interface and has the
|
||||
* symbol version string of ``"ROCPROFILER_10.0"``.
|
||||
*/
|
||||
#define ROCPROFILER_VERSION_10_0
|
||||
|
||||
/** @} */
|
||||
|
||||
#if !defined(ROCPROFILER_ATTRIBUTE)
|
||||
# if defined(_MSC_VER)
|
||||
# define ROCPROFILER_ATTRIBUTE(...) __declspec(__VA_ARGS__)
|
||||
@@ -95,3 +118,11 @@
|
||||
value \
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define ROCPROFILER_EXTERN_C_INIT extern "C" {
|
||||
# define ROCPROFILER_EXTERN_C_FINI }
|
||||
#else
|
||||
# define ROCPROFILER_EXTERN_C_INIT
|
||||
# define ROCPROFILER_EXTERN_C_FINI
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2023 ROCm Developer Tools
|
||||
//
|
||||
// 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 <rocprofiler/agent.h>
|
||||
#include <rocprofiler/defines.h>
|
||||
#include <rocprofiler/fwd.h>
|
||||
#include <rocprofiler/hsa.h>
|
||||
#include <rocprofiler/profile_config.h>
|
||||
|
||||
ROCPROFILER_EXTERN_C_INIT
|
||||
|
||||
/** @defgroup DISPATCH_PROFILE_COUNTING_SERVICE Dispatch Profile Counting
|
||||
* Service
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Profile Counting Data.
|
||||
*
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
rocprofiler_timestamp_t start_timestamp;
|
||||
rocprofiler_timestamp_t end_timestamp;
|
||||
/**
|
||||
* Counters, including identifiers to get counter information and Counters
|
||||
* values
|
||||
*
|
||||
* Should it be a record per counter?
|
||||
*/
|
||||
rocprofiler_record_counter_t* counters;
|
||||
uint64_t counters_count;
|
||||
rocprofiler_correlation_id_t correlation_id;
|
||||
} rocprofiler_dispatch_profile_counting_record_t;
|
||||
|
||||
/**
|
||||
* @brief Kernel Dispatch Callback
|
||||
*
|
||||
* @param [out] queue_id
|
||||
* @param [out] agent_id
|
||||
* @param [out] correlation_id
|
||||
* @param [out] dispatch_packet It can be used to get the kernel descriptor and then using
|
||||
* code_object tracing, we can get the kernel name. `dispatch_packet->reserved2` is the
|
||||
* correlation_id used to correlate the dispatch packet with the corresponding API call.
|
||||
* @param [out] callback_data_args
|
||||
* @param [in] config
|
||||
*/
|
||||
typedef void (*rocprofiler_profile_counting_dispatch_callback_t)(
|
||||
rocprofiler_queue_id_t queue_id,
|
||||
rocprofiler_agent_t agent_id,
|
||||
rocprofiler_correlation_id_t correlation_id,
|
||||
const hsa_kernel_dispatch_packet_t* dispatch_packet,
|
||||
void* callback_data_args,
|
||||
rocprofiler_profile_config_id_t* config);
|
||||
|
||||
/**
|
||||
* @brief Configure Dispatch Profile Counting Service.
|
||||
*
|
||||
* @param [in] context_id
|
||||
* @param [in] agent_id
|
||||
* @param [in] buffer_id
|
||||
* @param [in] callback
|
||||
* @param [in] callback_data_args
|
||||
* @return ::rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_configure_dispatch_profile_counting_service(
|
||||
rocprofiler_context_id_t context_id,
|
||||
rocprofiler_agent_t agent_id,
|
||||
rocprofiler_buffer_id_t buffer_id,
|
||||
rocprofiler_profile_counting_dispatch_callback_t callback,
|
||||
void* callback_data_args);
|
||||
|
||||
/** @} */
|
||||
|
||||
ROCPROFILER_EXTERN_C_FINI
|
||||
@@ -0,0 +1,60 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2023 ROCm Developer Tools
|
||||
//
|
||||
// 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 <rocprofiler/defines.h>
|
||||
#include <rocprofiler/fwd.h>
|
||||
|
||||
ROCPROFILER_EXTERN_C_INIT
|
||||
|
||||
/**
|
||||
* @defgroup EXTERNAL_CORRELATION External Correlation IDs
|
||||
*
|
||||
* User-defined correlation identifiers to supplement rocprofiler generated correlation ids
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Push External Correlation ID.
|
||||
*
|
||||
* @param external_correlation_id
|
||||
* @return rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_push_external_correlation_id(
|
||||
rocprofiler_external_correlation_id_t external_correlation_id);
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Push External Correlation ID.
|
||||
*
|
||||
* @param external_correlation_id
|
||||
* @return rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_pop_external_correlation_id(
|
||||
rocprofiler_external_correlation_id_t* external_correlation_id);
|
||||
|
||||
ROCPROFILER_EXTERN_C_FINI
|
||||
@@ -0,0 +1,457 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2023 ROCm Developer Tools
|
||||
//
|
||||
// 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 <rocprofiler/defines.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
ROCPROFILER_EXTERN_C_INIT
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
//
|
||||
// ENUMERATIONS
|
||||
//
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
/**
|
||||
* @defgroup BASIC_DATA_TYPES Basic data types
|
||||
*
|
||||
* Basic data types and typedefs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Status codes.
|
||||
*/
|
||||
typedef enum // NOLINT(performance-enum-size)
|
||||
{
|
||||
ROCPROFILER_STATUS_SUCCESS = 0, ///< No error occurred
|
||||
ROCPROFILER_STATUS_ERROR, ///< Generalized error
|
||||
ROCPROFILER_STATUS_ERROR_CONTEXT_NOT_FOUND, ///< No valid context for given context id
|
||||
ROCPROFILER_STATUS_ERROR_BUFFER_NOT_FOUND, ///< No valid buffer for given buffer id
|
||||
ROCPROFILER_STATUS_ERROR_DOMAIN_NOT_FOUND, ///< Domain identifier is invalid
|
||||
ROCPROFILER_STATUS_ERROR_OPERATION_NOT_FOUND, ///< Operation identifier is invalid for domain
|
||||
ROCPROFILER_STATUS_ERROR_THREAD_NOT_FOUND, ///< No valid thread for given thread id
|
||||
ROCPROFILER_STATUS_ERROR_CONTEXT_ERROR, ///> Generalized context error
|
||||
ROCPROFILER_STATUS_ERROR_CONTEXT_INVALID, ///< Context configuration is not valid
|
||||
ROCPROFILER_STATUS_ERROR_CONTEXT_NOT_STARTED, ///< Context was not started (maybe already
|
||||
///< started or atomic swap into active array
|
||||
///< failed)
|
||||
ROCPROFILER_STATUS_ERROR_BUFFER_BUSY, ///< buffer operation failed because it currently busy
|
||||
///< handling another request (e.g. flushing)
|
||||
ROCPROFILER_STATUS_ERROR_SERVICE_ALREADY_CONFIGURED, ///< service has already been configured
|
||||
///< in context
|
||||
ROCPROFILER_STATUS_ERROR_CONFIGURATION_LOCKED, ///< Function call is not valid outside of
|
||||
///< rocprofiler configuration (i.e.
|
||||
///< function called post-initialization)
|
||||
ROCPROFILER_STATUS_ERROR_NOT_IMPLEMENTED, ///< Function is not implemented
|
||||
ROCPROFILER_STATUS_LAST,
|
||||
} rocprofiler_status_t;
|
||||
|
||||
/**
|
||||
* @brief Buffer record categories. This enumeration type is encoded in @ref
|
||||
* rocprofiler_record_header_t category field
|
||||
*/
|
||||
typedef enum // NOLINT(performance-enum-size)
|
||||
{
|
||||
ROCPROFILER_BUFFER_CATEGORY_NONE = 0,
|
||||
ROCPROFILER_BUFFER_CATEGORY_TRACING,
|
||||
ROCPROFILER_BUFFER_CATEGORY_PC_SAMPLING,
|
||||
ROCPROFILER_BUFFER_CATEGORY_LAST,
|
||||
} rocprofiler_buffer_category_t;
|
||||
|
||||
/**
|
||||
* @brief Agent type.
|
||||
*/
|
||||
typedef enum // NOLINT(performance-enum-size)
|
||||
{
|
||||
ROCPROFILER_AGENT_TYPE_NONE = 0, ///< Agent type is unknown
|
||||
ROCPROFILER_AGENT_TYPE_CPU, ///< Agent type is a CPU
|
||||
ROCPROFILER_AGENT_TYPE_GPU, ///< Agent type is a GPU
|
||||
ROCPROFILER_AGENT_TYPE_LAST,
|
||||
} rocprofiler_agent_type_t;
|
||||
|
||||
/**
|
||||
* @brief Service Callback Phase.
|
||||
*/
|
||||
typedef enum // NOLINT(performance-enum-size)
|
||||
{
|
||||
ROCPROFILER_SERVICE_CALLBACK_PHASE_NONE = 0, ///< Callback has no phase
|
||||
ROCPROFILER_SERVICE_CALLBACK_PHASE_ENTER, ///< Callback invoked prior to function execution
|
||||
ROCPROFILER_SERVICE_CALLBACK_PHASE_EXIT, ///< Callback invoked after to function execution
|
||||
ROCPROFILER_SERVICE_CALLBACK_PHASE_LAST,
|
||||
} rocprofiler_service_callback_phase_t;
|
||||
|
||||
/**
|
||||
* @brief Service Callback Tracing Kind.
|
||||
*/
|
||||
typedef enum // NOLINT(performance-enum-size)
|
||||
{
|
||||
ROCPROFILER_SERVICE_CALLBACK_TRACING_NONE = 0,
|
||||
ROCPROFILER_SERVICE_CALLBACK_TRACING_HSA_API, ///< Callbacks for HSA functions
|
||||
ROCPROFILER_SERVICE_CALLBACK_TRACING_HIP_API, ///< Callbacks for HIP functions
|
||||
ROCPROFILER_SERVICE_CALLBACK_TRACING_MARKER_API, ///< Callbacks for ROCTx functions
|
||||
ROCPROFILER_SERVICE_CALLBACK_TRACING_CODE_OBJECT, ///< Callbacks for code object info
|
||||
ROCPROFILER_SERVICE_CALLBACK_TRACING_KERNEL_DISPATCH, ///< Callbacks for kernel dispatches
|
||||
ROCPROFILER_SERVICE_CALLBACK_TRACING_LAST,
|
||||
} rocprofiler_service_callback_tracing_kind_t;
|
||||
|
||||
/**
|
||||
* @brief Service Buffer Tracing Kind.
|
||||
*/
|
||||
typedef enum // NOLINT(performance-enum-size)
|
||||
{
|
||||
ROCPROFILER_SERVICE_BUFFER_TRACING_NONE = 0,
|
||||
ROCPROFILER_SERVICE_BUFFER_TRACING_HSA_API, ///< Buffer HSA function calls
|
||||
ROCPROFILER_SERVICE_BUFFER_TRACING_HIP_API, ///< Buffer HIP function calls
|
||||
ROCPROFILER_SERVICE_BUFFER_TRACING_MARKER_API, ///< Buffer ROCTx function calls
|
||||
ROCPROFILER_SERVICE_BUFFER_TRACING_MEMORY_COPY, ///< Buffer memory copy info
|
||||
ROCPROFILER_SERVICE_BUFFER_TRACING_KERNEL_DISPATCH, ///< Buffer kernel dispatch info
|
||||
ROCPROFILER_SERVICE_BUFFER_TRACING_PAGE_MIGRATION, ///< Buffer page migration info
|
||||
ROCPROFILER_SERVICE_BUFFER_TRACING_SCRATCH_MEMORY, ///< Buffer scratch memory reclaimation info
|
||||
ROCPROFILER_SERVICE_BUFFER_TRACING_EXTERNAL_CORRELATION, ///< Buffer external correlation info
|
||||
// To determine if this is possible to implement?
|
||||
// ROCPROFILER_SERVICE_BUFFER_TRACING_QUEUE_SCHEDULING,
|
||||
ROCPROFILER_SERVICE_BUFFER_TRACING_LAST,
|
||||
} rocprofiler_service_buffer_tracing_kind_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Code Object Tracer Operation.
|
||||
*/
|
||||
typedef enum // NOLINT(performance-enum-size)
|
||||
{
|
||||
ROCPROFILER_CALLBACK_TRACING_CODE_OBJECT_NONE = 0,
|
||||
ROCPROFILER_CALLBACK_TRACING_CODE_OBJECT_LOAD,
|
||||
ROCPROFILER_CALLBACK_TRACING_CODE_OBJECT_UNLOAD,
|
||||
ROCPROFILER_CALLBACK_TRACING_CODE_OBJECT_DEVICE_KERNEL_SYMBOL_REGISTER,
|
||||
ROCPROFILER_CALLBACK_TRACING_CODE_OBJECT_DEVICE_KERNEL_SYMBOL_UNREGISTER,
|
||||
// next two are part of hipRegisterFunction API.
|
||||
// ROCPROFILER_CALLBACK_TRACING_CODE_OBJECT_HOST_KERNEL_SYMBOL_REGISTER,
|
||||
// ROCPROFILER_CALLBACK_TRACING_CODE_OBJECT_HOST_KERNEL_SYMBOL_UNREGISTER,
|
||||
ROCPROFILER_CALLBACK_TRACING_CODE_OBJECT_LAST,
|
||||
} rocprofiler_callback_tracing_code_object_operation_t;
|
||||
|
||||
/**
|
||||
* @brief Memory Copy Operation.
|
||||
*/
|
||||
typedef enum // NOLINT(performance-enum-size)
|
||||
{
|
||||
ROCPROFILER_BUFFER_TRACING_MEMORY_COPY_NONE = 0,
|
||||
ROCPROFILER_BUFFER_TRACING_MEMORY_COPY_DEVICE_TO_HOST,
|
||||
ROCPROFILER_BUFFER_TRACING_MEMORY_COPY_HOST_TO_DEVICE,
|
||||
ROCPROFILER_BUFFER_TRACING_MEMORY_COPY_DEVICE_TO_DEVICE,
|
||||
ROCPROFILER_BUFFER_TRACING_MEMORY_COPY_LAST,
|
||||
} rocprofiler_buffer_tracing_memory_copy_operation_t;
|
||||
|
||||
/**
|
||||
* @brief PC Sampling Method.
|
||||
*/
|
||||
typedef enum // NOLINT(performance-enum-size)
|
||||
{
|
||||
ROCPROFILER_PC_SAMPLING_METHOD_NONE = 0,
|
||||
ROCPROFILER_PC_SAMPLING_METHOD_STOCHASTIC,
|
||||
ROCPROFILER_PC_SAMPLING_METHOD_HOST_TRAP,
|
||||
ROCPROFILER_PC_SAMPLING_METHOD_LAST,
|
||||
} rocprofiler_pc_sampling_method_t;
|
||||
|
||||
/**
|
||||
* @brief PC Sampling Unit.
|
||||
*/
|
||||
typedef enum // NOLINT(performance-enum-size)
|
||||
{
|
||||
ROCPROFILER_PC_SAMPLING_UNIT_NONE = 0, ///< Sample interval has unspecified units
|
||||
ROCPROFILER_PC_SAMPLING_UNIT_INSTRUCTIONS, ///< Sample interval is in instructions
|
||||
ROCPROFILER_PC_SAMPLING_UNIT_CYCLES, ///< Sample interval is in cycles
|
||||
ROCPROFILER_PC_SAMPLING_UNIT_TIME, ///< Sample internval is in nanoseconds
|
||||
ROCPROFILER_PC_SAMPLING_UNIT_LAST,
|
||||
} rocprofiler_pc_sampling_unit_t;
|
||||
|
||||
/**
|
||||
* @brief Actions when Buffer is full.
|
||||
*/
|
||||
typedef enum // NOLINT(performance-enum-size)
|
||||
{
|
||||
ROCPROFILER_BUFFER_POLICY_NONE = 0, ///< No policy has been set
|
||||
ROCPROFILER_BUFFER_POLICY_DISCARD, ///< Drop records when buffer is full
|
||||
ROCPROFILER_BUFFER_POLICY_LOSSLESS, ///< Block when buffer is full
|
||||
ROCPROFILER_BUFFER_POLICY_LAST,
|
||||
} rocprofiler_buffer_policy_t;
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
//
|
||||
// ALIASES
|
||||
//
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Timestamp.
|
||||
*/
|
||||
typedef uint64_t rocprofiler_timestamp_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Address.
|
||||
*/
|
||||
typedef uint64_t rocprofiler_address_t;
|
||||
|
||||
/**
|
||||
* @brief Thread ID. Value will be equivalent to `syscall(__NR_gettid)`
|
||||
*/
|
||||
typedef uint64_t rocprofiler_thread_id_t;
|
||||
|
||||
/**
|
||||
* @brief Tracing Operation ID. Depending on the kind, operations can be determined.
|
||||
* If the value is equal to zero that means all operations will be considered
|
||||
* for tracing.
|
||||
*/
|
||||
typedef uint32_t rocprofiler_tracing_operation_t;
|
||||
|
||||
/**
|
||||
* @brief Needs non-typedef specification?
|
||||
*/
|
||||
typedef uint32_t rocprofiler_counter_instance_id_t;
|
||||
|
||||
// forward declaration of struct
|
||||
typedef struct rocprofiler_pc_sampling_configuration_s rocprofiler_pc_sampling_configuration_t;
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
//
|
||||
// UNIONS
|
||||
//
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
/**
|
||||
* @brief User-assignable data type
|
||||
*
|
||||
*/
|
||||
typedef union rocprofiler_user_data_t
|
||||
{
|
||||
uint64_t value;
|
||||
void* ptr;
|
||||
} rocprofiler_user_data_t;
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
//
|
||||
// STRUCTS
|
||||
//
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
/**
|
||||
* @brief Context ID.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint64_t handle;
|
||||
} rocprofiler_context_id_t;
|
||||
|
||||
/**
|
||||
* @brief Queue ID.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint64_t handle;
|
||||
} rocprofiler_queue_id_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Record Correlation ID.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint64_t id;
|
||||
} rocprofiler_correlation_id_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler External Correlation ID.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint64_t id;
|
||||
} rocprofiler_external_correlation_id_t;
|
||||
|
||||
/**
|
||||
* @brief Buffer ID.
|
||||
* @addtogroup BUFFER_HANDLING
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint64_t handle;
|
||||
} rocprofiler_buffer_id_t;
|
||||
|
||||
/**
|
||||
* @brief Agent Identifier
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint64_t handle;
|
||||
} rocprofiler_agent_id_t;
|
||||
|
||||
/**
|
||||
* @brief Counter ID.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint64_t handle;
|
||||
} rocprofiler_counter_id_t;
|
||||
|
||||
/**
|
||||
* @brief Profile Configurations
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint64_t handle;
|
||||
} rocprofiler_profile_config_id_t;
|
||||
|
||||
/**
|
||||
* @brief Array of PC Sampling Configurations
|
||||
*/
|
||||
typedef struct rocprofiler_pc_sampling_config_array_s
|
||||
{
|
||||
rocprofiler_pc_sampling_configuration_t* data;
|
||||
size_t size;
|
||||
} rocprofiler_pc_sampling_config_array_t;
|
||||
|
||||
/**
|
||||
* @brief Tracing record
|
||||
*
|
||||
*/
|
||||
typedef struct rocprofiler_callback_tracing_record_t
|
||||
{
|
||||
rocprofiler_thread_id_t thread_id;
|
||||
rocprofiler_correlation_id_t correlation_id;
|
||||
rocprofiler_external_correlation_id_t external_correlation_id;
|
||||
rocprofiler_service_callback_tracing_kind_t kind;
|
||||
uint32_t operation;
|
||||
rocprofiler_service_callback_phase_t phase;
|
||||
rocprofiler_user_data_t data;
|
||||
void* payload;
|
||||
} rocprofiler_callback_tracing_record_t;
|
||||
|
||||
/**
|
||||
* @brief Generic record with type identifier(s) and a pointer to data. This data type is used with
|
||||
* buffered data.
|
||||
*
|
||||
* @code{.cpp}
|
||||
* void
|
||||
* tool_tracing_callback(rocprofiler_record_header_t** headers,
|
||||
* size_t num_headers)
|
||||
* {
|
||||
* for(size_t i = 0; i < num_headers; ++i)
|
||||
* {
|
||||
* rocprofiler_record_header_t* header = headers[i];
|
||||
*
|
||||
* if(header->category == ROCPROFILER_BUFFER_CATEGORY_TRACING &&
|
||||
* header->kind == ROCPROFILER_SERVICE_BUFFER_TRACING_HSA_API)
|
||||
* {
|
||||
* // cast to rocprofiler_buffer_tracing_hsa_api_record_t which
|
||||
* // is type associated with this category + kind
|
||||
* auto* record =
|
||||
* static_cast<rocprofiler_buffer_tracing_hsa_api_record_t*>(header->payload);
|
||||
*
|
||||
* // trivial test
|
||||
* assert(record->start_timestamp <= record->end_timestamp);
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @endcode
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint32_t category; ///< rocprofiler_buffer_category_t
|
||||
uint32_t kind; ///< domain
|
||||
};
|
||||
uint64_t hash; ///< generic identifier. You can compute this via: `uint64_t hash = category
|
||||
///< | ((uint64_t)(kind) << 32)`, e.g.
|
||||
};
|
||||
void* payload;
|
||||
} rocprofiler_record_header_t;
|
||||
|
||||
/**
|
||||
* @brief Function for computing the unsigned 64-bit hash value in @ref rocprofiler_record_header_t
|
||||
* from a category and kind (two unsigned 32-bit values)
|
||||
*
|
||||
* @param category [in] a value from @ref rocprofiler_buffer_category_t
|
||||
* @param kind [in] depending on the category, this is the domain value, e.g., @ref
|
||||
* rocprofiler_service_buffer_tracing_kind_t value
|
||||
* @return uint64_t hash value of category and kind
|
||||
*/
|
||||
static inline uint64_t
|
||||
rocprofiler_record_header_compute_hash(uint32_t category, uint32_t kind)
|
||||
{
|
||||
uint64_t value = category;
|
||||
value |= ((uint64_t)(kind)) << 32;
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Profile Counting Counter per instance.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
rocprofiler_counter_id_t counter_id;
|
||||
rocprofiler_counter_instance_id_t instance_id;
|
||||
double counter_value;
|
||||
} rocprofiler_record_counter_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler PC Sampling Record.
|
||||
*
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint64_t pc;
|
||||
uint64_t dispatch_id;
|
||||
uint64_t timestamp;
|
||||
uint64_t hardware_id;
|
||||
union
|
||||
{
|
||||
uint8_t arb_value;
|
||||
};
|
||||
union
|
||||
{
|
||||
void* data;
|
||||
};
|
||||
} rocprofiler_pc_sampling_record_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler SPM Record.
|
||||
*
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/**
|
||||
* Counters, including identifiers to get counter information and Counters
|
||||
* values
|
||||
*/
|
||||
rocprofiler_record_counter_t* counters;
|
||||
uint64_t counters_count;
|
||||
} rocprofiler_spm_record_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
ROCPROFILER_EXTERN_C_FINI
|
||||
@@ -27,7 +27,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef uint32_t rocprofiler_trace_record_hip_operation_kind_t;
|
||||
typedef struct rocprofiler_hip_trace_data_s rocprofiler_hip_trace_data_t;
|
||||
typedef struct rocprofiler_hip_api_data_s rocprofiler_hip_api_data_t;
|
||||
|
||||
|
||||
@@ -30,33 +30,14 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef uint32_t rocprofiler_trace_record_hsa_operation_kind_t;
|
||||
typedef struct hsa_kernel_dispatch_packet_s hsa_kernel_dispatch_packet_t;
|
||||
typedef struct rocprofiler_hsa_trace_data_s rocprofiler_hsa_trace_data_t;
|
||||
typedef struct rocprofiler_hsa_api_data_s rocprofiler_hsa_api_data_t;
|
||||
|
||||
struct rocprofiler_hsa_api_data_s
|
||||
{
|
||||
uint64_t correlation_id;
|
||||
uint32_t phase;
|
||||
union
|
||||
{
|
||||
uint64_t uint64_t_retval;
|
||||
uint32_t uint32_t_retval;
|
||||
hsa_signal_value_t hsa_signal_value_t_retval;
|
||||
hsa_status_t hsa_status_t_retval;
|
||||
};
|
||||
rocprofiler_hsa_api_args_t args;
|
||||
uint64_t* phase_data;
|
||||
};
|
||||
|
||||
struct rocprofiler_hsa_trace_data_s
|
||||
{
|
||||
rocprofiler_hsa_api_data_t api_data;
|
||||
uint64_t phase_enter_timestamp;
|
||||
uint64_t phase_exit_timestamp;
|
||||
uint64_t phase_data;
|
||||
|
||||
void (*phase_enter)(rocprofiler_hsa_api_id_t operation_id, rocprofiler_hsa_trace_data_t* data);
|
||||
void (*phase_exit)(rocprofiler_hsa_api_id_t operation_id, rocprofiler_hsa_trace_data_t* data);
|
||||
uint64_t correlation_id;
|
||||
uint32_t phase;
|
||||
rocprofiler_hsa_api_args_t args;
|
||||
rocprofiler_hsa_api_retval_t retval;
|
||||
uint64_t* phase_data;
|
||||
};
|
||||
|
||||
@@ -26,6 +26,14 @@
|
||||
#include <hsa/hsa_ext_image.h>
|
||||
#include <rocprofiler/version.h>
|
||||
|
||||
typedef union rocprofiler_hsa_api_retval_u
|
||||
{
|
||||
uint64_t uint64_t_retval;
|
||||
uint32_t uint32_t_retval;
|
||||
hsa_signal_value_t hsa_signal_value_t_retval;
|
||||
hsa_status_t hsa_status_t_retval;
|
||||
} rocprofiler_hsa_api_retval_t;
|
||||
|
||||
typedef union rocprofiler_hsa_api_args_u
|
||||
{
|
||||
// block: CoreApi API
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2023 ROCm Developer Tools
|
||||
//
|
||||
// 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 <rocprofiler/defines.h>
|
||||
#include <rocprofiler/fwd.h>
|
||||
|
||||
ROCPROFILER_EXTERN_C_INIT
|
||||
|
||||
/** @defgroup INTERNAL_THREADING Internal thread handling
|
||||
*
|
||||
* Callbacks before and after threads created internally by libraries
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enumeration for specifying which libraries you want callbacks before and after the library
|
||||
* creates an internal thread. These callbacks will be invoked on the thread that is about to create
|
||||
* the new thread (not on the newly created thread). In thread-aware tools that wrap pthread_create,
|
||||
* this can be used to disable the wrapper before the pthread_create invocation and re-enable the
|
||||
* wrapper afterwards. In many cases, tools will want to ignore the thread(s) created by rocprofiler
|
||||
* since these threads do not exist in the normal application execution, whereas the internal
|
||||
* threads for HSA, HIP, etc. are created in normal application execution; however, the HIP, HSA,
|
||||
* etc. internal threads are typically background threads which just monitor kernel completion and
|
||||
* are unlikely to contribute to any performance issues.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ROCPROFILER_LIBRARY = (1 << 0),
|
||||
ROCPROFILER_HSA_LIBRARY = (1 << 1),
|
||||
ROCPROFILER_HIP_LIBRARY = (1 << 2),
|
||||
ROCPROFILER_MARKER_LIBRARY = (1 << 3),
|
||||
ROCPROFILER_LIBRARY_LAST = ROCPROFILER_MARKER_LIBRARY,
|
||||
} rocprofiler_internal_thread_library_t;
|
||||
|
||||
/**
|
||||
* @brief Callback type before and after internal thread creation. @see
|
||||
* rocprofiler_at_internal_thread_create
|
||||
*
|
||||
*/
|
||||
typedef void (*rocprofiler_internal_thread_library_cb_t)(rocprofiler_internal_thread_library_t,
|
||||
void*);
|
||||
|
||||
/**
|
||||
* @brief Invoke this function to receive callbacks before and after the creation of an internal
|
||||
* thread by a library which as invoked on the thread which is creating the internal thread(s).
|
||||
* Please note that the postcreate callback is guaranteed to be invoked after the underlying
|
||||
* system call to create a new thread but it does not guarantee that the new thread has been
|
||||
* started. Please note, that once these callbacks are registered, they cannot be removed so the
|
||||
* caller is responsible for ignoring these callbacks if they want to ignore them beyond a certain
|
||||
* point in the application.
|
||||
*
|
||||
* @param precreate [in] Callback invoked immediately before a new internal thread is created
|
||||
* @param postcreate [in] Callback invoked immediately after a new internal thread is created
|
||||
* @param libs [in] Bitwise-or of libraries, e.g. `ROCPROFILER_LIBRARY | ROCPROFILER_MARKER_LIBRARY`
|
||||
* means the callbacks will be invoked whenever rocprofiler and/or the marker library create
|
||||
* internal threads but not when the HSA or HIP libraries create internal threads.
|
||||
* @param data [in] Data shared between callbacks
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_at_internal_thread_create(rocprofiler_internal_thread_library_cb_t precreate,
|
||||
rocprofiler_internal_thread_library_cb_t postcreate,
|
||||
int libs,
|
||||
void* data);
|
||||
|
||||
/**
|
||||
* @brief opaque handle to an internal thread identifier which delivers callbacks for buffers
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint64_t handle;
|
||||
} rocprofiler_callback_thread_t;
|
||||
|
||||
/**
|
||||
* @brief Create a handle to a unique thread (created by rocprofiler) which, when associated with a
|
||||
* particular buffer, will guarantee those buffered results always get delivered on the same thread.
|
||||
* This is useful to prevent/control thread-safety issues and/or enable multithreaded processing of
|
||||
* buffers with non-overlapping data
|
||||
*
|
||||
* @param [in] cb_thread_id User-provided pointer to a @ref rocprofiler_callback_thread_t
|
||||
* @return ::rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_create_callback_thread(rocprofiler_callback_thread_t* cb_thread_id)
|
||||
ROCPROFILER_NONNULL(1);
|
||||
|
||||
/**
|
||||
* @brief By default, all buffered results are delivered on the same thread. Using @ref
|
||||
* rocprofiler_create_callback_thread, one or more buffers can be assigned to deliever their results
|
||||
* on a unique, dedicated thread.
|
||||
*
|
||||
* @param [in] buffer_id Buffer identifier
|
||||
* @param [in] cb_thread_id Callback thread identifier via @ref rocprofiler_create_callback_thread
|
||||
* @return ::rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_assign_callback_thread(rocprofiler_buffer_id_t buffer_id,
|
||||
rocprofiler_callback_thread_t cb_thread_id);
|
||||
|
||||
/** @} */
|
||||
|
||||
ROCPROFILER_EXTERN_C_FINI
|
||||
@@ -24,9 +24,6 @@
|
||||
|
||||
#include <rocprofiler/marker/api_args.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef uint32_t rocprofiler_trace_record_marker_operation_kind_t;
|
||||
typedef struct rocprofiler_roctx_api_data_s rocprofiler_roctx_api_data_t;
|
||||
|
||||
struct rocprofiler_roctx_api_data_s
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2023 ROCm Developer Tools
|
||||
//
|
||||
// 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 <rocprofiler/agent.h>
|
||||
#include <rocprofiler/defines.h>
|
||||
#include <rocprofiler/fwd.h>
|
||||
|
||||
ROCPROFILER_EXTERN_C_INIT
|
||||
|
||||
/** @defgroup PC_SAMPLING_SERVICE PC Sampling Service
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Create PC Sampling Service.
|
||||
*
|
||||
* @param [in] context_id
|
||||
* @param [in] agent
|
||||
* @param [in] method
|
||||
* @param [in] unit
|
||||
* @param [in] interval
|
||||
* @param [in] buffer_id
|
||||
* @return ::rocprofiler_status_t
|
||||
*
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_configure_pc_sampling_service(rocprofiler_context_id_t context_id,
|
||||
rocprofiler_agent_t agent,
|
||||
rocprofiler_pc_sampling_method_t method,
|
||||
rocprofiler_pc_sampling_unit_t unit,
|
||||
uint64_t interval,
|
||||
rocprofiler_buffer_id_t buffer_id);
|
||||
|
||||
struct rocprofiler_pc_sampling_configuration_s
|
||||
{
|
||||
rocprofiler_pc_sampling_method_t method;
|
||||
rocprofiler_pc_sampling_unit_t unit;
|
||||
size_t min_interval;
|
||||
size_t max_interval;
|
||||
uint64_t flags;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Query PC Sampling Configuration.
|
||||
*
|
||||
* @param [in] agent
|
||||
* @param [out] config
|
||||
* @param [out] config_count
|
||||
* @return ::rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_query_pc_sampling_agent_configurations(rocprofiler_agent_t agent,
|
||||
rocprofiler_pc_sampling_configuration_t* config,
|
||||
size_t* config_count) ROCPROFILER_NONNULL(2, 3);
|
||||
|
||||
/** @} */
|
||||
|
||||
ROCPROFILER_EXTERN_C_FINI
|
||||
@@ -0,0 +1,63 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2023 ROCm Developer Tools
|
||||
//
|
||||
// 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 <rocprofiler/agent.h>
|
||||
#include <rocprofiler/defines.h>
|
||||
#include <rocprofiler/fwd.h>
|
||||
|
||||
ROCPROFILER_EXTERN_C_INIT
|
||||
|
||||
/** @defgroup PROFILE_CONFIG Profile Configurations
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Create Profile Configuration.
|
||||
*
|
||||
* @param [in] agent Agent identifier
|
||||
* @param [in] counters_list List of GPU counters
|
||||
* @param [in] counters_count Size of counters list
|
||||
* @param [out] config_id Identifier for GPU counters group
|
||||
* @return ::rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_create_profile_config(rocprofiler_agent_t agent,
|
||||
rocprofiler_counter_id_t* counters_list,
|
||||
size_t counters_count,
|
||||
rocprofiler_profile_config_id_t* config_id)
|
||||
ROCPROFILER_NONNULL(4);
|
||||
|
||||
/**
|
||||
* @brief Destroy Profile Configuration.
|
||||
*
|
||||
* @param [in] config_id
|
||||
* @return ::rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_destroy_profile_config(rocprofiler_profile_config_id_t config_id);
|
||||
|
||||
/** @} */
|
||||
|
||||
ROCPROFILER_EXTERN_C_FINI
|
||||
@@ -0,0 +1,220 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2023 ROCm Developer Tools
|
||||
//
|
||||
// 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 <rocprofiler/defines.h>
|
||||
#include <rocprofiler/fwd.h>
|
||||
|
||||
ROCPROFILER_EXTERN_C_INIT
|
||||
|
||||
/**
|
||||
* @defgroup REGISTRATION_GROUP Tool registration
|
||||
*
|
||||
* Data types and functions for tool registration with rocprofiler
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief A pointer to this data structure is provided to the client tool initialization function.
|
||||
* The name member can be set by the client to assist with debugging (e.g. rocprofiler cannot start
|
||||
* your context because there is a conflicting context started by `<name>` -- at least that is the
|
||||
* plan). The handle member is a unique identifer assigned by rocprofiler for the client and the
|
||||
* client can store it and pass it to the @ref rocprofiler_client_finalize_t function to force
|
||||
* finalization (i.e. deactivate all of it's contexts) for the client.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
const char* name; ///< clients should set this value for debugging
|
||||
const uint32_t handle; ///< internal handle
|
||||
} rocprofiler_client_id_t;
|
||||
|
||||
typedef void (*rocprofiler_client_finalize_t)(rocprofiler_client_id_t);
|
||||
|
||||
typedef int (*rocprofiler_tool_initialize_t)(rocprofiler_client_finalize_t finalize_func,
|
||||
void* tool_data);
|
||||
|
||||
typedef void (*rocprofiler_tool_finalize_t)(void* tool_data);
|
||||
|
||||
/**
|
||||
* @brief Data structure containing a initialization, finalization, and data
|
||||
*
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
size_t size; ///< in case of future extensions
|
||||
rocprofiler_tool_initialize_t initialize; ///< context creation
|
||||
rocprofiler_tool_finalize_t finalize; ///< cleanup
|
||||
void* tool_data; ///< data to provide to init and fini callbacks
|
||||
} rocprofiler_tool_configure_result_t;
|
||||
|
||||
/**
|
||||
* @brief Query whether rocprofiler has already scanned the binary for all the instances of @ref
|
||||
* rocprofiler_configure (or is currently scanning). If rocprofiler has completed it's scan, clients
|
||||
* can directly register themselves with rocprofiler.
|
||||
*
|
||||
* @param [out] status 0 indicates rocprofiler has not been initialized (i.e. configured), 1
|
||||
* indicates rocprofiler has been initialized, -1 indicates rocprofiler is currently initializing.
|
||||
* @return rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t
|
||||
rocprofiler_is_initialized(int* status) ROCPROFILER_API;
|
||||
|
||||
/**
|
||||
* @brief Query rocprofiler finalization status.
|
||||
*
|
||||
* @param [out] status 0 indicates rocprofiler has not been finalized, 1 indicates rocprofiler has
|
||||
* been finalized, -1 indicates rocprofiler is currently finalizing.
|
||||
* @return rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t
|
||||
rocprofiler_is_finalized(int* status) ROCPROFILER_API;
|
||||
|
||||
/**
|
||||
* @brief This is the special function that tools define to enable rocprofiler support. The tool
|
||||
* should return a pointer to
|
||||
* @ref rocprofiler_tool_configure_result_t which will contain a function pointer to (1) an
|
||||
* initialization function where all the contexts are created, (2) a finalization function (if
|
||||
* necessary) which will be invoked when rocprofiler shutdown and, (3) a pointer to any data that
|
||||
* the tool wants communicated between the @ref rocprofiler_tool_configure_result_t::initialize and
|
||||
* @ref rocprofiler_tool_configure_result_t::finalize functions. If the user
|
||||
*
|
||||
* @param [in] version The version of rocprofiler: `(10000 * major) + (100 * minor) + patch`
|
||||
* @param [in] runtime_version String descriptor of the rocprofiler version and other relevant info.
|
||||
* @param [in] priority How many client tools were initialized before this client tool
|
||||
* @param [in, out] client_id tool identifier value.
|
||||
* @return rocprofiler_tool_configure_result_t*
|
||||
*
|
||||
* @code{.cpp}
|
||||
* #include <rocprofiler/registration.h>
|
||||
*
|
||||
* static rocprofiler_client_id_t my_client_id;
|
||||
* static rocprofiler_client_finalize_t my_fini_func;
|
||||
* static int my_tool_data = 1234;
|
||||
*
|
||||
* static int my_init_func(rocprofiler_client_finalize_t fini_func,
|
||||
* void* tool_data)
|
||||
* {
|
||||
* my_fini_func = fini_func;
|
||||
*
|
||||
* assert(*static_cast<int*>(tool_data) == 1234 && "tool_data is wrong");
|
||||
*
|
||||
* rocprofiler_context_id_t ctx;
|
||||
* rocprofiler_create_context(&ctx);
|
||||
*
|
||||
* if(int valid_ctx = 0;
|
||||
* rocprofiler_context_is_valid(ctx, &valid_ctx) != ROCPROFILER_STATUS_SUCCESS ||
|
||||
* valid_ctx != 0)
|
||||
* {
|
||||
* // notify rocprofiler that initialization failed
|
||||
* // and all the contexts, buffers, etc. created
|
||||
* // should be ignored
|
||||
* return -1;
|
||||
* }
|
||||
*
|
||||
* if(rocprofiler_start_context(ctx) != ROCPROFILER_STATUS_SUCCESS)
|
||||
* {
|
||||
* // notify rocprofiler that initialization failed
|
||||
* // and all the contexts, buffers, etc. created
|
||||
* // should be ignored
|
||||
* return -1;
|
||||
* }
|
||||
*
|
||||
* // no errors
|
||||
* return 0;
|
||||
* }
|
||||
*
|
||||
* static int my_fini_func(void* tool_data)
|
||||
* {
|
||||
* assert(*static_cast<int*>(tool_data) == 1234 && "tool_data is wrong");
|
||||
* }
|
||||
*
|
||||
* rocprofiler_tool_configure_result_t*
|
||||
* rocprofiler_configure(uint32_t version,
|
||||
* const char* runtime_version,
|
||||
* uint32_t priority,
|
||||
* rocprofiler_client_id_t* client_id)
|
||||
* {
|
||||
* // only activate if main tool
|
||||
* if(priority > 0) return nullptr;
|
||||
*
|
||||
* // set the client name
|
||||
* client_id->name = "ExampleTool";
|
||||
*
|
||||
* // make a copy of client info
|
||||
* my_client_id = *client_id;
|
||||
*
|
||||
* // compute major/minor/patch version info
|
||||
* uint32_t major = version / 10000;
|
||||
* uint32_t minor = (version % 10000) / 100;
|
||||
* uint32_t patch = version % 100;
|
||||
*
|
||||
* // print info
|
||||
* printf("Configuring rocprofiler (v%u.%u.%u) [%s]\n", major, minor, patch, runtime_version);
|
||||
*
|
||||
* // create configure data
|
||||
* static auto cfg = rocprofiler_tool_configure_result_t{ &my_init_func,
|
||||
* &my_fini_func,
|
||||
* &my_tool_data };
|
||||
*
|
||||
* // return pointer to configure data
|
||||
* return &cfg;
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
rocprofiler_tool_configure_result_t*
|
||||
rocprofiler_configure(uint32_t version,
|
||||
const char* runtime_version,
|
||||
uint32_t priority,
|
||||
rocprofiler_client_id_t* client_id) ROCPROFILER_PUBLIC_API;
|
||||
|
||||
// NOTE: we use ROCPROFILER_PUBLIC_API above instead of ROCPROFILER_API because we always
|
||||
// want the symbol to be visible when the user includes the header for the prototype
|
||||
|
||||
/**
|
||||
* @brief Function pointer typedef for @ref rocprofiler_configure function
|
||||
* @param [in] version The version of rocprofiler: `(10000 * major) + (100 * minor) + patch`
|
||||
* @param [in] runtime_version String descriptor of the rocprofiler version and other relevant info.
|
||||
* @param [in] priority How many client tools were initialized before this client tool
|
||||
* @param [in, out] client_id tool identifier value.
|
||||
*/
|
||||
typedef rocprofiler_tool_configure_result_t* (*rocprofiler_configure_func_t)(
|
||||
uint32_t version,
|
||||
const char* runtime_version,
|
||||
uint32_t priority,
|
||||
rocprofiler_client_id_t* client_id);
|
||||
|
||||
/**
|
||||
* @brief Function for explicitly registering a configuration with rocprofiler. This can be invoked
|
||||
* before any ROCm runtimes (lazily) initialize and context(s) can be started before the runtimes
|
||||
* initialize.
|
||||
* @param [in] configure_func Address of @ref rocprofiler_configure function. A null pointer is
|
||||
* acceptable if the address is not known
|
||||
* @returns rocprofiler_status_t If rocprofiler has already been configured, or is currently being
|
||||
* configured, this function will return @ref ROCPROFILER_STATUS_ERROR_CONFIGURATION_LOCKED.
|
||||
*/
|
||||
rocprofiler_status_t
|
||||
rocprofiler_force_configure(rocprofiler_configure_func_t configure_func) ROCPROFILER_API;
|
||||
|
||||
/** @} */
|
||||
|
||||
ROCPROFILER_EXTERN_C_FINI
|
||||
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -20,7 +20,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
/** \section rocprofiler_plugin_api ROCProfiler Plugin API
|
||||
/** @section rocprofiler_plugin_api ROCProfiler Plugin API
|
||||
*
|
||||
* The ROCProfiler Plugin API is used by the ROCProfiler Tool to output all
|
||||
* profiling information. Different implementations of the ROCProfiler Plugin
|
||||
@@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* @file
|
||||
* ROCProfiler Tool Plugin API interface.
|
||||
*/
|
||||
|
||||
@@ -47,44 +47,42 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
ROCPROFILER_EXTERN_C_INIT /* __cplusplus */
|
||||
|
||||
/** \defgroup rocprofiler_plugins ROCProfiler Plugin API Specification
|
||||
* @{
|
||||
*/
|
||||
/** @defgroup rocprofiler_plugins ROCProfiler Plugin API Specification
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** \defgroup initialization_group Initialization and Finalization
|
||||
* \ingroup rocprofiler_plugins
|
||||
*
|
||||
* The ROCProfiler Plugin API must be initialized before using any of the
|
||||
* operations to report trace data, and finalized after the last trace data has
|
||||
* been reported.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/** @defgroup initialization_group Initialization and Finalization
|
||||
* @ingroup rocprofiler_plugins
|
||||
*
|
||||
* The ROCProfiler Plugin API must be initialized before using any of the
|
||||
* operations to report trace data, and finalized after the last trace data has
|
||||
* been reported.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initialize plugin.
|
||||
* Must be called before any other operation.
|
||||
*
|
||||
* @param[in] rocprofiler_major_version The major version of the ROCProfiler API
|
||||
* being used by the ROCProfiler Tool. An error is reported if this does not
|
||||
* match the major version of the ROCProfiler API used to build the plugin
|
||||
* library. This ensures compatibility of the trace data format.
|
||||
* @param[in] rocprofiler_minor_version The minor version of the ROCProfiler API
|
||||
* being used by the ROCProfiler Tool. An error is reported if the
|
||||
* \p rocprofiler_major_version matches and this is greater than the minor
|
||||
* version of the ROCProfiler API used to build the plugin library. This ensures
|
||||
* compatibility of the trace data format.
|
||||
* @param[in] data Pointer to the data passed to the ROCProfiler Plugin by the tool
|
||||
* @return Returns 0 on success and -1 on error.
|
||||
*/
|
||||
ROCPROFILER_EXPORT int
|
||||
rocprofiler_plugin_initialize(uint32_t rocprofiler_major_version,
|
||||
uint32_t rocprofiler_minor_version,
|
||||
void* data);
|
||||
/**
|
||||
* Initialize plugin.
|
||||
* Must be called before any other operation.
|
||||
*
|
||||
* @param[in] rocprofiler_major_version The major version of the ROCProfiler API
|
||||
* being used by the ROCProfiler Tool. An error is reported if this does not
|
||||
* match the major version of the ROCProfiler API used to build the plugin
|
||||
* library. This ensures compatibility of the trace data format.
|
||||
* @param[in] rocprofiler_minor_version The minor version of the ROCProfiler API
|
||||
* being used by the ROCProfiler Tool. An error is reported if the
|
||||
* @p rocprofiler_major_version matches and this is greater than the minor
|
||||
* version of the ROCProfiler API used to build the plugin library. This ensures
|
||||
* compatibility of the trace data format.
|
||||
* @param[in] data Pointer to the data passed to the ROCProfiler Plugin by the tool
|
||||
* @return Returns 0 on success and -1 on error.
|
||||
*/
|
||||
ROCPROFILER_EXPORT int
|
||||
rocprofiler_plugin_initialize(uint32_t rocprofiler_major_version,
|
||||
uint32_t rocprofiler_minor_version,
|
||||
void* data);
|
||||
|
||||
/**
|
||||
* Finalize plugin.
|
||||
@@ -97,8 +95,8 @@ rocprofiler_plugin_finalize();
|
||||
|
||||
/** @} */
|
||||
|
||||
/** \defgroup profiling_record_write_functions Profiling data reporting
|
||||
* \ingroup rocprofiler_plugins
|
||||
/** @defgroup profiling_record_write_functions Profiling data reporting
|
||||
* @ingroup rocprofiler_plugins
|
||||
* Operations to output profiling data.
|
||||
* @{
|
||||
*/
|
||||
@@ -128,12 +126,10 @@ rocprofiler_plugin_write_buffer_records(rocprofiler_context_id_t context_id
|
||||
*/
|
||||
|
||||
ROCPROFILER_EXPORT int
|
||||
rocprofiler_plugin_write_record(rocprofiler_record_tracer_t record);
|
||||
rocprofiler_plugin_write_record(rocprofiler_record_header_t record);
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif /* __cplusplus */
|
||||
ROCPROFILER_EXTERN_C_FINI
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2023 ROCm Developer Tools
|
||||
//
|
||||
// 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 <rocprofiler/defines.h>
|
||||
#include <rocprofiler/fwd.h>
|
||||
|
||||
ROCPROFILER_EXTERN_C_INIT
|
||||
|
||||
/** @defgroup SPM_SERVICE SPM Service
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Configure SPM Service.
|
||||
*
|
||||
* @param [in] context_id
|
||||
* @param [in] buffer_id
|
||||
* @param [in] profile_config
|
||||
* @param [in] interval
|
||||
* @return ::rocprofiler_status_t
|
||||
*/
|
||||
rocprofiler_status_t ROCPROFILER_API
|
||||
rocprofiler_configure_spm_service(rocprofiler_context_id_t context_id,
|
||||
rocprofiler_buffer_id_t buffer_id,
|
||||
rocprofiler_profile_config_id_t profile_config,
|
||||
uint64_t interval);
|
||||
|
||||
/** @} */
|
||||
|
||||
ROCPROFILER_EXTERN_C_FINI
|
||||
Ссылка в новой задаче
Block a user