unloading and flush fix
This commit is contained in:
+13
-5
@@ -88,7 +88,9 @@ THE SOFTWARE.
|
||||
(void)err; \
|
||||
return X;
|
||||
|
||||
#ifndef onload_debug
|
||||
#define onload_debug false
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Mark callback
|
||||
@@ -464,6 +466,10 @@ FILE* open_output_file(const char* prefix, const char* name) {
|
||||
return file_handle;
|
||||
}
|
||||
|
||||
void close_output_file(FILE* file_handle) {
|
||||
if ((file_handle != NULL) && (file_handle != stdout)) fclose(file_handle);
|
||||
}
|
||||
|
||||
FILE* kernel_file_handle = NULL;
|
||||
void hsa_kernel_handler(::proxy::Tracker::entry_t* entry) {
|
||||
static uint64_t index = 0;
|
||||
@@ -998,14 +1004,16 @@ PUBLIC_API bool roctracer_load(HsaApiTable* table, uint64_t runtime_version, uin
|
||||
}
|
||||
|
||||
PUBLIC_API void roctracer_unload(bool destruct) {
|
||||
if (onload_debug) printf("LIB roctracer_unload (%d)\n", (int)destruct); fflush(stdout);
|
||||
static bool is_unloaded = false;
|
||||
if (is_unloaded) return;
|
||||
|
||||
if (onload_debug) printf("LIB roctracer_unload (%d, %d)\n", (int)destruct, (int)is_unloaded); fflush(stdout);
|
||||
if (destruct == false) return;
|
||||
if (is_unloaded == true) return;
|
||||
is_unloaded = true;
|
||||
|
||||
//if (destruct == false) roctracer::trace_buffer.Flush();
|
||||
if ((roctracer::hsa_support::output_prefix != NULL) && (roctracer::kernel_file_handle != NULL)) fclose(roctracer::kernel_file_handle);
|
||||
if (onload_debug) printf("LIB roctracer_unload (%d) end\n", (int)destruct); fflush(stdout);
|
||||
roctracer::trace_buffer.Flush();
|
||||
roctracer::close_output_file(roctracer::kernel_file_handle);
|
||||
if (onload_debug) printf("LIB roctracer_unload end\n"); fflush(stdout);
|
||||
}
|
||||
|
||||
PUBLIC_API bool OnLoad(HsaApiTable* table, uint64_t runtime_version, uint64_t failed_tool_count,
|
||||
|
||||
Reference in New Issue
Block a user