unload and destruct normalizing

This commit is contained in:
Evgeny
2019-08-10 00:14:04 -05:00
parent e49c1789fb
commit 603e469149
4 changed files with 67 additions and 29 deletions
+19 -5
View File
@@ -367,6 +367,7 @@ FILE* open_output_file(const char* prefix, const char* name) {
// HSA-runtime tool on-load method
extern "C" PUBLIC_API bool OnLoad(HsaApiTable* table, uint64_t runtime_version, uint64_t failed_tool_count,
const char* const* failed_tool_names) {
// printf("TOOL OnLoad\n"); fflush(stdout);
timer = new hsa_rt_utils::Timer(table->core_->hsa_system_get_info_fn);
// API traces switches
@@ -497,11 +498,13 @@ extern "C" PUBLIC_API bool OnLoad(HsaApiTable* table, uint64_t runtime_version,
roctracer_set_properties(ACTIVITY_DOMAIN_HIP_API, (void*)mark_api_callback);
}
// printf("TOOL OnLoad end\n"); fflush(stdout);
return roctracer_load(table, runtime_version, failed_tool_count, failed_tool_names);
}
// tool unload method
void tool_unload(bool destruct) {
// printf("TOOL tool_unload\n"); fflush(stdout);
static bool is_unloaded = false;
if (is_unloaded) {
return;
@@ -530,13 +533,24 @@ void tool_unload(bool destruct) {
if (destruct == false) hip_api_trace_buffer.Flush();
fclose(hip_api_file_handle);
fclose(hcc_activity_file_handle);
if (hip_api_file_handle != stdout) fclose(hip_api_file_handle);
if (hcc_activity_file_handle != stdout) fclose(hcc_activity_file_handle);
}
// printf("TOOL tool_unload end\n"); fflush(stdout);
}
// HSA-runtime on-unload method
extern "C" PUBLIC_API void OnUnload() { tool_unload(false); }
extern "C" PUBLIC_API void OnUnload() {
// printf("TOOL OnUnload\n"); fflush(stdout);
tool_unload(false);
// printf("TOOL OnUnload end\n"); fflush(stdout);
}
extern "C" CONSTRUCTOR_API void constructor() {}
extern "C" DESTRUCTOR_API void destructor() { tool_unload(true); }
extern "C" CONSTRUCTOR_API void constructor() {
// printf("TOOL constructor ...end\n"); fflush(stdout);
}
extern "C" DESTRUCTOR_API void destructor() {
// printf("TOOL destructor\n"); fflush(stdout);
tool_unload(true);
// printf("TOOL destructor end\n"); fflush(stdout);
}