|
|
|
@ -176,6 +176,7 @@ void PopEvent(const std::string& name, const DeviceContext* dev_ctx) {
|
|
|
|
|
|
|
|
|
|
RecordEvent::RecordEvent(const std::string& name, const DeviceContext* dev_ctx)
|
|
|
|
|
: is_enabled_(false), start_ns_(PosixInNsec()) {
|
|
|
|
|
std::lock_guard<std::mutex> l(profiler_mu);
|
|
|
|
|
if (g_state == ProfilerState::kDisabled) return;
|
|
|
|
|
is_enabled_ = true;
|
|
|
|
|
dev_ctx_ = dev_ctx;
|
|
|
|
@ -186,6 +187,7 @@ RecordEvent::RecordEvent(const std::string& name, const DeviceContext* dev_ctx)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RecordEvent::~RecordEvent() {
|
|
|
|
|
std::lock_guard<std::mutex> l(profiler_mu);
|
|
|
|
|
if (g_state == ProfilerState::kDisabled || !is_enabled_) return;
|
|
|
|
|
DeviceTracer* tracer = GetDeviceTracer();
|
|
|
|
|
if (tracer) {
|
|
|
|
@ -198,6 +200,7 @@ RecordEvent::~RecordEvent() {
|
|
|
|
|
|
|
|
|
|
RecordBlock::RecordBlock(int block_id)
|
|
|
|
|
: is_enabled_(false), start_ns_(PosixInNsec()) {
|
|
|
|
|
std::lock_guard<std::mutex> l(profiler_mu);
|
|
|
|
|
if (g_state == ProfilerState::kDisabled) return;
|
|
|
|
|
is_enabled_ = true;
|
|
|
|
|
SetCurBlock(block_id);
|
|
|
|
@ -205,6 +208,7 @@ RecordBlock::RecordBlock(int block_id)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RecordBlock::~RecordBlock() {
|
|
|
|
|
std::lock_guard<std::mutex> l(profiler_mu);
|
|
|
|
|
if (g_state == ProfilerState::kDisabled || !is_enabled_) return;
|
|
|
|
|
DeviceTracer* tracer = GetDeviceTracer();
|
|
|
|
|
if (tracer) {
|
|
|
|
@ -217,11 +221,13 @@ RecordBlock::~RecordBlock() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RecordThread::RecordThread(int thread_id) {
|
|
|
|
|
std::lock_guard<std::mutex> l(profiler_mu);
|
|
|
|
|
if (g_state == ProfilerState::kDisabled) return;
|
|
|
|
|
SetCurThread(thread_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RecordThread::~RecordThread() {
|
|
|
|
|
std::lock_guard<std::mutex> l(profiler_mu);
|
|
|
|
|
if (g_state == ProfilerState::kDisabled) return;
|
|
|
|
|
ClearCurThread();
|
|
|
|
|
}
|
|
|
|
|