diff --git a/projects/roctracer/src/core/trace_buffer.h b/projects/roctracer/src/core/trace_buffer.h index a32e995307..0cbcb5bdda 100644 --- a/projects/roctracer/src/core/trace_buffer.h +++ b/projects/roctracer/src/core/trace_buffer.h @@ -1,6 +1,7 @@ #ifndef SRC_CORE_TRACE_BUFFER_H_ #define SRC_CORE_TRACE_BUFFER_H_ +#include #include #include #include @@ -66,7 +67,7 @@ class TraceBuffer { }; TraceBuffer(const char* name, uint32_t size, flush_prm_t* flush_prm_arr, uint32_t flush_prm_count) : - is_flushed_(ATOMIC_FLAG_INIT) + is_flushed_(false) { name_ = strdup(name); size_ = size; @@ -108,7 +109,7 @@ class TraceBuffer { private: void flush_buf() { std::lock_guard lck(mutex_); - const bool is_flushed = atomic_flag_test_and_set_explicit(&is_flushed_, std::memory_order_acquire); + const bool is_flushed = is_flushed_.exchange(true, std::memory_order_acquire); if (is_flushed == false) { for (flush_prm_t* prm = flush_prm_arr_; prm < flush_prm_arr_ + flush_prm_count_; prm++) { @@ -183,7 +184,7 @@ class TraceBuffer { flush_prm_t* flush_prm_arr_; uint32_t flush_prm_count_; - volatile std::atomic_flag is_flushed_; + volatile std::atomic is_flushed_; pthread_t work_thread_; pthread_mutex_t work_mutex_; diff --git a/projects/roctracer/src/roctx/roctx.cpp b/projects/roctracer/src/roctx/roctx.cpp index 907065484c..61916f146a 100644 --- a/projects/roctracer/src/roctx/roctx.cpp +++ b/projects/roctracer/src/roctx/roctx.cpp @@ -64,8 +64,10 @@ THE SOFTWARE. static thread_local std::stack message_stack; +#if 0 static inline uint32_t GetPid() { return syscall(__NR_getpid); } static inline uint32_t GetTid() { return syscall(__NR_gettid); } +#endif //////////////////////////////////////////////////////////////////////////////// // Library errors enumaration diff --git a/projects/roctracer/src/util/hsa_rsrc_factory.h b/projects/roctracer/src/util/hsa_rsrc_factory.h index 8cc8c1254b..51824a5212 100644 --- a/projects/roctracer/src/util/hsa_rsrc_factory.h +++ b/projects/roctracer/src/util/hsa_rsrc_factory.h @@ -225,7 +225,7 @@ class HsaRsrcFactory { static void Destroy() { std::lock_guard lck(mutex_); - if (instance_) delete instance_; + if (instance_) delete instance_.load(); instance_ = NULL; } diff --git a/projects/roctracer/src/util/logger.h b/projects/roctracer/src/util/logger.h index 42539e7127..cd8dd470c3 100644 --- a/projects/roctracer/src/util/logger.h +++ b/projects/roctracer/src/util/logger.h @@ -90,7 +90,7 @@ class Logger { static void Destroy() { std::lock_guard lck(mutex_); - if (instance_ != NULL) delete instance_; + if (instance_ != NULL) delete instance_.load(); instance_ = NULL; } diff --git a/projects/roctracer/test/tool/tracer_tool.cpp b/projects/roctracer/test/tool/tracer_tool.cpp index 370b83f6d8..15d24c9a82 100644 --- a/projects/roctracer/test/tool/tracer_tool.cpp +++ b/projects/roctracer/test/tool/tracer_tool.cpp @@ -251,7 +251,7 @@ void mark_api_callback( entry->pid = GetPid(); entry->tid = GetTid(); entry->data = {}; - entry->name = name; + entry->name = strdup(name); entry->ptr = NULL; } @@ -300,7 +300,7 @@ void hip_api_flush_cb(hip_api_trace_entry_t* entry) { fprintf(hip_api_file_handle, "%s()\n", oss.str().c_str()); } } else { - fprintf(hip_api_file_handle, "%s(%s)\n", oss.str().c_str(), entry->name); + fprintf(hip_api_file_handle, "%s(name(%s))\n", oss.str().c_str(), entry->name); } fflush(hip_api_file_handle);