2
0

Support Tool Intercept API Tables (#165)

* Update include/rocprofiler

- intercept_table.h header
- generic rocprofiler_runtime_library_t
- rocprofiler_internal_thread_library_t is not typedef for rocprofiler_runtime_library_t
- rocprofiler_at_runtime_api_registration

* Update lib/rocprofiler

- minor tweaks to context.cpp
  - check if none context early
  - disallow stop_context when finalizing
- add intercept_table.hpp and intercept_table.cpp
  - implement rocprofiler_at_runtime_api_registration
  - implement notify_runtime_api_registration
- update registration.cpp
  - invoke notify_runtime_api_registration
  - tweak to fini status when invoking client finalizer

* Update lib/rocprofiler/tests

- add tests for intercept table

* Add samples/intercept_table

- demonstrate how to install custom API function wrappers instead of relying on HSA callback tracing

* Update lib/rocprofiler/tests/intercept_table.cpp

- remove _SERVICE from ROCPROFILER_SERVICE_

* Update include/rocprofiler/intercept_table.h

- Update doxygen comments

* Update lib/rocprofiler/intercept_table.cpp

- return error config locked if already initialized

* Update lib/rocprofiler/intercept_table.cpp

- remove unnecessary alias

* Apply suggestions from code review

Co-authored-by: Tony Tye <Tony.Tye@amd.com>

* Update doxygen comments

- clarify when rocprofiler_at_runtime_api_registration can be invoked

* Use rocprofiler_runtime_library_t for intercept table and internal threading

- remove rocprofiler_intercept_library_t alias to rocprofiler_runtime_library_t
- remove rocprofiler_internal_thread_library_t alias to rocprofiler_runtime_library_t
- move around documentation with regard to rocprofiler_runtime_library_t enumeration
- added some extra doxygen documentation to internal threading functions

---------

Co-authored-by: Tony Tye <Tony.Tye@amd.com>

[ROCm/rocprofiler-sdk commit: 4f2dc896d3]
Este cometimento está contido em:
Jonathan R. Madsen
2023-11-02 19:10:10 -05:00
cometido por GitHub
ascendente 1e2a80ef8e
cometimento 370a86830b
22 ficheiros modificados com 1823 adições e 52 eliminações
@@ -26,6 +26,7 @@
#include "lib/rocprofiler/hsa/hsa.hpp"
#include "lib/rocprofiler/hsa/queue.hpp"
#include "lib/rocprofiler/hsa/queue_controller.hpp"
#include "lib/rocprofiler/intercept_table.hpp"
#include "lib/rocprofiler/internal_threading.hpp"
#include <rocprofiler/context.h>
@@ -369,7 +370,10 @@ invoke_client_finalizer(rocprofiler_client_id_t client_id)
{
if(itr.configure_result && itr.configure_result->finalize)
{
auto _fini_status = get_fini_status();
if(_fini_status == 0) set_fini_status(-1);
itr.configure_result->finalize(itr.configure_result->tool_data);
if(_fini_status == 0) set_fini_status(_fini_status);
// set to nullptr so finalize only gets called once
itr.configure_result->finalize = nullptr;
}
@@ -553,7 +557,12 @@ rocprofiler_set_api_table(const char* name,
auto& saved_hsa_api_table = rocprofiler::hsa::get_table();
::copyTables(hsa_api_table, &saved_hsa_api_table);
// install rocprofiler API wrappers
rocprofiler::hsa::update_table(hsa_api_table);
// allow tools to install API wrappers
rocprofiler::intercept_table::notify_runtime_api_registration(
ROCPROFILER_HSA_LIBRARY, lib_version, lib_instance, std::make_tuple(hsa_api_table));
}
else if(std::string_view{name} == "roctx")
{