Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix host event recorder #37944

Merged
merged 23 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8744ba7
add align for WorkQueue
liutiexing Sep 22, 2021
4759bc8
Merge branch 'develop' of https://github.com/liutiexing/Paddle into d…
liutiexing Sep 22, 2021
6f00ace
add spinlock
liutiexing Sep 23, 2021
2d6f1cf
merge develop
liutiexing Sep 23, 2021
f5099be
Merge branch 'develop' of https://github.com/liutiexing/Paddle into d…
liutiexing Sep 26, 2021
54aa332
merge develop
liutiexing Oct 12, 2021
1d1bd82
merge
liutiexing Oct 12, 2021
dfbf3e4
Merge remote-tracking branch 'upstream/develop' into develop
liutiexing Oct 12, 2021
a5392b3
Merge remote-tracking branch 'upstream/develop' into develop
liutiexing Oct 14, 2021
e206173
Add EventsWaiter
liutiexing Oct 15, 2021
0a3dcd9
Revert "Add EventsWaiter"
liutiexing Oct 15, 2021
4689bb5
Merge remote-tracking branch 'upstream/develop' into develop
liutiexing Oct 15, 2021
0cec99a
Merge remote-tracking branch 'upstream/develop' into develop
liutiexing Oct 20, 2021
481c4fa
Merge branch 'PaddlePaddle:develop' into develop
liutiexing Oct 27, 2021
83db84e
Merge branch 'PaddlePaddle:develop' into develop
liutiexing Oct 29, 2021
7010e0d
Merge branch 'PaddlePaddle:develop' into develop
liutiexing Nov 16, 2021
ec2a363
Merge branch 'PaddlePaddle:develop' into develop
liutiexing Nov 23, 2021
90a59ec
Merge branch 'PaddlePaddle:develop' into develop
liutiexing Nov 26, 2021
1445bbe
Merge branch 'PaddlePaddle:develop' into develop
liutiexing Nov 29, 2021
a2c74ab
Merge branch 'PaddlePaddle:develop' into develop
liutiexing Dec 1, 2021
1c09b4e
Merge branch 'PaddlePaddle:develop' into develop
liutiexing Dec 2, 2021
cb8cf7d
Merge branch 'PaddlePaddle:develop' into develop
liutiexing Dec 8, 2021
ac1f450
Fix RecordEvent
Dec 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions paddle/fluid/platform/profiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ RecordEvent::RecordEvent(const char *name, const EventRole role) {
#endif
#endif
if (UNLIKELY(g_enable_host_event_recorder_hook == false)) {
RecordEvent(name, role, "none");
OriginalConstruct(name, role, "none");
return;
}
shallow_copy_name_ = name;
Expand All @@ -371,7 +371,7 @@ RecordEvent::RecordEvent(const std::string &name, const EventRole role) {
#endif
#endif
if (UNLIKELY(g_enable_host_event_recorder_hook == false)) {
RecordEvent(name, role, "none");
OriginalConstruct(name, role, "none");
return;
}
name_ = new std::string(name);
Expand All @@ -389,13 +389,18 @@ RecordEvent::RecordEvent(const std::string &name, const EventRole role,
}
#endif
#endif
if (g_enable_host_event_recorder_hook) {
name_ = new std::string(name);
start_ns_ = PosixInNsec();
attr_ = new std::string(attr);
if (UNLIKELY(g_enable_host_event_recorder_hook == false)) {
OriginalConstruct(name, role, attr);
return;
}
name_ = new std::string(name);
start_ns_ = PosixInNsec();
attr_ = new std::string(attr);
}

void RecordEvent::OriginalConstruct(const std::string &name,
const EventRole role,
const std::string &attr) {
if (g_state == ProfilerState::kDisabled || name.empty()) return;

// do some initialization
Expand All @@ -408,7 +413,7 @@ RecordEvent::RecordEvent(const std::string &name, const EventRole role,
// Maybe need the same push/pop behavior.
Event *e = PushEvent(name, role, attr);
SetCurAnnotation(e);
// name_ = e->name();
*name_ = e->name();
}

RecordEvent::~RecordEvent() {
Expand All @@ -431,10 +436,10 @@ RecordEvent::~RecordEvent() {
} else {
HostEventRecorder::GetInstance().RecordEvent(*name_, start_ns_, end_ns,
role_, *attr_);
delete attr_;
}
delete name_;
}
delete name_;
delete attr_;
return;
}

Expand Down
7 changes: 5 additions & 2 deletions paddle/fluid/platform/profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,20 @@ struct RecordEvent {

~RecordEvent();

void OriginalConstruct(const std::string& name, const EventRole role,
const std::string& attr);

bool is_enabled_{false};
bool is_pushed_{false};
// Event name
const std::string* name_{nullptr};
std::string* name_{nullptr};
const char* shallow_copy_name_{nullptr};
uint64_t start_ns_;
// Need to distinguish name by op type, block_id, program_id and perhaps
// different kernel invocations within an op.
// std::string full_name_;
EventRole role_{EventRole::kOrdinary};
const std::string* attr_{nullptr};
std::string* attr_{nullptr};
};

/*class RecordRPCEvent {
Expand Down