Support ROCP_TOOL_LIBRARIES env + librocprofiler-sdk.so (#48)
* Fix support for version in find_package(rocprofiler-register <version>)
* Update lib/rocprofiler-register/rocprofiler-register.cpp
- change rocprofiler library name to librocprofiler-sdk.so
- add helper function rocp_load_rocprofiler_lib for dlopen of rocprofiler library
- support ROCP_TOOL_LIBRARIES environment variable
- reworked rocprofiler_register_error_string
* Update tests/rocprofiler
- rename library to librocprofiler-sdk
- remove rocprofiler_configure within librocprofiler-sdk.so
* Add tests/generic-tool
- provides implementation of rocprofiler_configure
* Update tests/CMakeLists.txt
- use libgeneric-tool.so
- LD_PRELOAD libgeneric-tool.so instead of librocprofiler
- Add tests which use ROCP_TOOL_LIBRARIES
* Update tests/generic-tool/generic-tool.cpp
- include <cstdint>
[ROCm/rocprofiler-register commit: ab02cb6570]
This commit is contained in:
committed by
GitHub
parent
d0b69ad2b6
commit
0f8430700d
@@ -3,6 +3,7 @@
|
||||
#include <hsa-runtime/hsa-runtime.hpp>
|
||||
#include <roctx/roctx.hpp>
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <pthread.h>
|
||||
#include <stdexcept>
|
||||
#include <string_view>
|
||||
@@ -42,49 +43,10 @@ roctx_range_pop(const char* name)
|
||||
} // namespace rocprofiler
|
||||
|
||||
extern "C" {
|
||||
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);
|
||||
|
||||
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;
|
||||
|
||||
rocprofiler_tool_configure_result_t*
|
||||
rocprofiler_configure(uint32_t, const char*, uint32_t, rocprofiler_client_id_t*)
|
||||
__attribute__((visibility("default")));
|
||||
|
||||
int
|
||||
rocprofiler_set_api_table(const char*, uint64_t, uint64_t, void**, uint64_t)
|
||||
__attribute__((visibility("default")));
|
||||
|
||||
rocprofiler_tool_configure_result_t*
|
||||
rocprofiler_configure(uint32_t version,
|
||||
const char* runtime_version,
|
||||
uint32_t priority,
|
||||
rocprofiler_client_id_t* tool_id)
|
||||
{
|
||||
(void) version;
|
||||
(void) runtime_version;
|
||||
(void) priority;
|
||||
(void) tool_id;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int
|
||||
rocprofiler_set_api_table(const char* name,
|
||||
uint64_t lib_version,
|
||||
@@ -99,6 +61,20 @@ rocprofiler_set_api_table(const char* name,
|
||||
lib_instance,
|
||||
num_tables);
|
||||
|
||||
auto* _tool_libs = std::getenv("ROCP_TOOL_LIBRARIES");
|
||||
if(_tool_libs)
|
||||
{
|
||||
auto* _handle = dlopen(_tool_libs, RTLD_GLOBAL | RTLD_LAZY);
|
||||
if(!_handle)
|
||||
throw std::runtime_error{ std::string{ "error opening tool library " } +
|
||||
_tool_libs };
|
||||
auto* _sym = dlsym(_handle, "rocprofiler_configure");
|
||||
if(!_sym)
|
||||
throw std::runtime_error{ std::string{ "tool library " } +
|
||||
std::string{ _tool_libs } +
|
||||
" did not contain rocprofiler_configure symbol" };
|
||||
}
|
||||
|
||||
using hip_table_t = hip::HipApiTable;
|
||||
using hsa_table_t = hsa::HsaApiTable;
|
||||
using roctx_table_t = roctx::ROCTxApiTable;
|
||||
|
||||
Reference in New Issue
Block a user