optimized tool stats

Change-Id: Ia9c06879f6e2e195e589c53299c2cafe96a4bfe5
This commit is contained in:
Evgeny
2020-08-11 04:44:08 -05:00
orang tua 2f608e067a
melakukan ddcb68d0a8
5 mengubah file dengan 166 tambahan dan 36 penghapusan
+7 -5
Melihat File
@@ -218,11 +218,12 @@ template<> bool act_en_functor_t::fun(const act_en_functor_t::record_t& record)
void hsa_async_copy_handler(::proxy::Tracker::entry_t* entry);
void hsa_kernel_handler(::proxy::Tracker::entry_t* entry);
TraceBuffer<trace_entry_t>::flush_prm_t trace_buffer_prm[] = {
constexpr TraceBuffer<trace_entry_t>::flush_prm_t trace_buffer_prm[] = {
{COPY_ENTRY_TYPE, hsa_async_copy_handler},
{KERNEL_ENTRY_TYPE, hsa_kernel_handler}
};
TraceBuffer<trace_entry_t> trace_buffer("HSA GPU", 0x200000, trace_buffer_prm, 2);
TraceBuffer<trace_entry_t>* trace_buffer = NULL;
//TraceBuffer<trace_entry_t> trace_buffer("HSA GPU", 0x200000, trace_buffer_prm, 2);
namespace hsa_support {
// callbacks table
@@ -567,7 +568,7 @@ hsa_status_t hsa_amd_memory_async_copy_interceptor(
{
hsa_status_t status = HSA_STATUS_SUCCESS;
if (hsa_support::async_copy_callback_enabled) {
trace_entry_t* entry = trace_buffer.GetEntry();
trace_entry_t* entry = trace_buffer->GetEntry();
::proxy::Tracker::Enable(COPY_ENTRY_TYPE, hsa_agent_t{}, completion_signal, entry);
status = hsa_amd_memory_async_copy_fn(dst, dst_agent, src,
src_agent, size, num_dep_signals,
@@ -591,7 +592,7 @@ hsa_status_t hsa_amd_memory_async_copy_rect_interceptor(
{
hsa_status_t status = HSA_STATUS_SUCCESS;
if (hsa_support::async_copy_callback_enabled) {
trace_entry_t* entry = trace_buffer.GetEntry();
trace_entry_t* entry = trace_buffer->GetEntry();
::proxy::Tracker::Enable(COPY_ENTRY_TYPE, hsa_agent_t{}, completion_signal, entry);
status = hsa_amd_memory_async_copy_rect_fn(dst, dst_offset, src,
src_offset, range, copy_agent,
@@ -1289,13 +1290,14 @@ PUBLIC_API void roctracer_unload() {
PUBLIC_API void roctracer_flush_buf() {
ONLOAD_TRACE_BEG();
roctracer::trace_buffer.Flush();
roctracer::trace_buffer->Flush();
ONLOAD_TRACE_END();
}
CONSTRUCTOR_API void constructor() {
ONLOAD_TRACE_BEG();
roctracer::util::Logger::Create();
roctracer::trace_buffer = new roctracer::TraceBuffer<roctracer::trace_entry_t>("HSA GPU", 0x200000, roctracer::trace_buffer_prm, 2);
roctracer_load();
ONLOAD_TRACE_END();
}
+17 -4
Melihat File
@@ -124,7 +124,7 @@ class TraceBuffer : protected TraceBufferBase {
callback_t fun;
};
TraceBuffer(const char* name, uint32_t size, flush_prm_t* flush_prm_arr, uint32_t flush_prm_count) :
TraceBuffer(const char* name, uint32_t size, const flush_prm_t* flush_prm_arr, uint32_t flush_prm_count, uint32_t prior = 0) :
is_flushed_(false),
work_thread_started_(false)
{
@@ -139,12 +139,14 @@ class TraceBuffer : protected TraceBufferBase {
flush_prm_arr_ = flush_prm_arr;
flush_prm_count_ = flush_prm_count;
priority_ = prior;
TraceBufferBase::Push(this);
}
~TraceBuffer() {
StopWorkerThread();
Flush();
FlushAll();
}
void StartWorkerThread() {
@@ -176,14 +178,24 @@ class TraceBuffer : protected TraceBufferBase {
}
void Flush() { flush_buf(); }
void Flush(const bool& b) {
DisableFlushing(!b);
flush_buf();
}
void DisableFlushing(const bool& b) { is_flushed_.exchange(b, std::memory_order_acquire); }
private:
void flush_buf() {
std::lock_guard<mutex_t> lck(mutex_);
const bool is_flushed = is_flushed_.exchange(true, std::memory_order_acquire);
if (priority_ != 0) {
priority_ -= 1;
return;
}
if (is_flushed == false) {
for (flush_prm_t* prm = flush_prm_arr_; prm < flush_prm_arr_ + flush_prm_count_; prm++) {
for (const flush_prm_t* prm = flush_prm_arr_; prm < flush_prm_arr_ + flush_prm_count_; prm++) {
// Flushed entries type
uint32_t type = prm->type;
// Flushing function
@@ -253,8 +265,9 @@ class TraceBuffer : protected TraceBufferBase {
volatile std::atomic<pointer_t> end_pointer_;
std::list<Entry*> buf_list_;
flush_prm_t* flush_prm_arr_;
const flush_prm_t* flush_prm_arr_;
uint32_t flush_prm_count_;
uint32_t priority_;
volatile std::atomic<bool> is_flushed_;
pthread_t work_thread_;
+2 -2
Melihat File
@@ -39,7 +39,7 @@ THE SOFTWARE.
#include "util/hsa_rsrc_factory.h"
#include "util/exception.h"
namespace roctracer { extern TraceBuffer<trace_entry_t> trace_buffer; }
namespace roctracer { extern TraceBuffer<trace_entry_t>* trace_buffer; }
namespace rocprofiler {
extern decltype(hsa_queue_create)* hsa_queue_create_fn;
@@ -160,7 +160,7 @@ class InterceptQueue {
const char* kernel_name = GetKernelName(kernel_symbol);
// Adding kernel timing tracker
::proxy::Tracker::entry_t* entry = roctracer::trace_buffer.GetEntry();
::proxy::Tracker::entry_t* entry = roctracer::trace_buffer->GetEntry();
entry->kernel.tid = syscall(__NR_gettid);
entry->kernel.name = kernel_name;
::proxy::Tracker::Enable(roctracer::KERNEL_ENTRY_TYPE, obj->agent_info_->dev_id, completion_signal, entry);