Use the new ROCR support to automatically load tool libraries

The ROCR now detects already loaded tool libraries and calls OnLoad/
OnUnload in the order specified with HSA_AMD_TOOL_ORDER.

It is no longer necessary to set the HSA_TOOLS_LIB environment variable
to load the roctracer API. The roctracer tool library should be
pre-loaded with LD_PRELOAD.

Change-Id: I6de1b1bd4f93caa08d3554aad2376d242c74fb7e
Этот коммит содержится в:
Laurent Morichetti
2022-06-20 14:19:15 -07:00
родитель 8c28237a2c
Коммит d32cf96cd4
5 изменённых файлов: 44 добавлений и 29 удалений
+16 -15
Просмотреть файл
@@ -1,17 +1,9 @@
ROCTRACER_4.0 {
global: roctracer_flush_buf;
roctracer_load;
roctracer_unload;
};
ROCTRACER_4.1 {
global: OnLoad;
OnUnload;
roctracer_activity_pop_external_correlation_id;
roctracer_activity_push_external_correlation_id;
roctracer_close_pool;
roctracer_close_pool_expl;
roctracer_default_pool;
roctracer_default_pool_expl;
roctracer_disable_activity;
roctracer_disable_callback;
@@ -19,29 +11,38 @@ global: OnLoad;
roctracer_disable_domain_callback;
roctracer_disable_op_activity;
roctracer_disable_op_callback;
roctracer_enable_activity;
roctracer_enable_activity_expl;
roctracer_enable_callback;
roctracer_enable_domain_activity;
roctracer_enable_domain_activity_expl;
roctracer_enable_domain_callback;
roctracer_enable_op_activity;
roctracer_enable_op_activity_expl;
roctracer_enable_op_callback;
roctracer_error_string;
roctracer_flush_activity;
roctracer_flush_activity_expl;
roctracer_flush_buf;
roctracer_get_timestamp;
roctracer_load;
roctracer_mark;
roctracer_next_record;
roctracer_op_code;
roctracer_open_pool;
roctracer_open_pool_expl;
roctracer_op_string;
roctracer_set_properties;
roctracer_start;
roctracer_stop;
roctracer_unload;
roctracer_version_major;
roctracer_version_minor;
local: *;
} ROCTRACER_4.0;
};
ROCTRACER_4.1 {
global: HSA_AMD_TOOL_PRIORITY;
roctracer_close_pool;
roctracer_default_pool;
roctracer_enable_activity;
roctracer_enable_domain_activity;
roctracer_enable_op_activity;
roctracer_flush_activity;
roctracer_next_record;
roctracer_open_pool;
} ROCTRACER_4.0;
+11 -4
Просмотреть файл
@@ -1238,12 +1238,19 @@ __attribute__((destructor)) void destructor() {
ONLOAD_TRACE_END();
}
extern "C" {
// The HSA_AMD_TOOL_PRIORITY variable must be a constant value type initialized by the loader
// itself, not by code during _init. 'extern const' seems do that although that is not a guarantee.
ROCTRACER_EXPORT extern const uint32_t HSA_AMD_TOOL_PRIORITY = 50;
// HSA-runtime tool on-load method
extern "C" ROCTRACER_EXPORT bool OnLoad(HsaApiTable* table, uint64_t runtime_version,
uint64_t failed_tool_count,
const char* const* failed_tool_names) {
ROCTRACER_EXPORT bool OnLoad(HsaApiTable* table, uint64_t runtime_version,
uint64_t failed_tool_count, const char* const* failed_tool_names) {
hsa_support::SaveHsaApi(table);
return true;
}
extern "C" ROCTRACER_EXPORT void OnUnload() {}
ROCTRACER_EXPORT void OnUnload() {}
} // extern "C"
+1 -1
Просмотреть файл
@@ -1 +1 @@
{ global: OnLoad; OnUnload; local: *; };
{ global: HSA_AMD_TOOL_PRIORITY; OnLoad; OnUnload; local: *; };
+11 -4
Просмотреть файл
@@ -795,10 +795,15 @@ void tool_load() {
ONLOAD_TRACE_END();
}
extern "C" {
// The HSA_AMD_TOOL_PRIORITY variable must be a constant value type initialized by the loader
// itself, not by code during _init. 'extern const' seems do that although that is not a guarantee.
ROCTRACER_EXPORT extern const uint32_t HSA_AMD_TOOL_PRIORITY = 1050;
// HSA-runtime tool on-load method
extern "C" ROCTRACER_EXPORT bool OnLoad(HsaApiTable* table, uint64_t runtime_version,
uint64_t failed_tool_count,
const char* const* failed_tool_names) {
ROCTRACER_EXPORT bool OnLoad(HsaApiTable* table, uint64_t runtime_version,
uint64_t failed_tool_count, const char* const* failed_tool_names) {
ONLOAD_TRACE_BEG();
roctracer::hip_support::HIP_depth_max = 0;
@@ -927,8 +932,10 @@ extern "C" ROCTRACER_EXPORT bool OnLoad(HsaApiTable* table, uint64_t runtime_ver
}
// HSA-runtime on-unload method
extern "C" ROCTRACER_EXPORT void OnUnload() {
ROCTRACER_EXPORT void OnUnload() {
ONLOAD_TRACE_BEG();
tool_unload();
ONLOAD_TRACE_END();
}
} // extern "C"
+5 -5
Просмотреть файл
@@ -111,15 +111,15 @@ eval_test "MatrixTranspose dry run" ./test/MatrixTranspose MatrixTranspose_dryru
eval_test "copy dry run" ./test/copy copy_dryrun_trace
# Standalone test
# rocTrecer is used explicitely by test
# ROCtracer is used explicitely by test
eval_test "standalone C test" "./test/MatrixTranspose_ctest" MatrixTranspose_ctest_trace
eval_test "standalone HIP test" "./test/MatrixTranspose_test" MatrixTranspose_test_trace
eval_test "standalone HIP hipaact test" "./test/MatrixTranspose_hipaact_test" MatrixTranspose_hipaact_test_trace
eval_test "standalone HIP MGPU test" "./test/MatrixTranspose_mgpu" MatrixTranspose_mgpu_trace
# Tool test
# rocTracer/tool is loaded by HSA runtime
export HSA_TOOLS_LIB="$ROCTRACER_LIB_PATH/libroctracer64.so $ROCTRACER_TOOL_PATH/libroctracer_tool.so"
# ROCtracer/tool is loaded by HSA runtime
export LD_PRELOAD="$ROCTRACER_TOOL_PATH/libroctracer_tool.so"
# ROCTX test
export ROCTRACER_DOMAIN="roctx"
@@ -166,11 +166,11 @@ unset ROCP_INPUT
# Check that the tracer tool can be unloaded and then reloaded.
eval_test "Load/Unload/Reload the tracer tool" ./test/load_unload_reload_test load_unload_reload_trace
export HSA_TOOLS_LIB="$ROCTRACER_LIB_PATH/libroctracer64.so ./test/libhsaco_test.so"
export HSA_TOOLS_LIB="./test/libhsaco_test.so"
eval_test "tool HSA codeobj" ./test/MatrixTranspose hsa_co_trace
export ROCP_TOOL_LIB=./test/libcodeobj_test.so
export HSA_TOOLS_LIB="$ROCTRACER_LIB_PATH/libroctracer64.so librocprofiler64.so"
export HSA_TOOLS_LIB="librocprofiler64.so"
eval_test "tool tracer codeobj" ./test/MatrixTranspose code_obj_trace
#valgrind --leak-check=full $tbin