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
This commit is contained in:
+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;
|
||||
@@ -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 @@
|
||||
{ global: OnLoad; OnUnload; local: *; };
|
||||
{ global: HSA_AMD_TOOL_PRIORITY; OnLoad; OnUnload; local: *; };
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user