Skip to content

Commit 7a4f3be

Browse files
author
Yibing Liu
committed
Fix profiler place bug
1 parent df3b250 commit 7a4f3be

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

paddle/platform/profiler.cc

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ std::vector<std::vector<Event>> DisableProfiler() {
181181

182182
void ParseEvents(std::vector<std::vector<Event>>& events,
183183
EventSortingKey sorted_by) {
184+
if (g_profiler_place == "") return;
184185
std::vector<std::vector<EventItem>> events_table;
185186
size_t max_name_width = 0;
186187
for (size_t i = 0; i < events.size(); i++) {
@@ -199,7 +200,7 @@ void ParseEvents(std::vector<std::vector<Event>>& events,
199200
}
200201

201202
if (rit != pushed_events.rend()) {
202-
double event_time = (g_state == ProfilerState::kCUDA)
203+
double event_time = (g_profiler_place == "CUDA")
203204
? rit->CudaElapsedMs(events[i][j])
204205
: rit->CpuElapsedMs(events[i][j]);
205206
std::string event_name =
@@ -224,7 +225,7 @@ void ParseEvents(std::vector<std::vector<Event>>& events,
224225
std::max(event_time, event_items[index].max_time);
225226
}
226227

227-
// remove the start marker from the list
228+
// remove the push marker from the list
228229
pushed_events.erase((++rit).base());
229230
} else {
230231
LOG(WARNING) << "Cannot find the push marker of event \'"
@@ -257,13 +258,11 @@ void ParseEvents(std::vector<std::vector<Event>>& events,
257258
}
258259

259260
events_table.push_back(event_items);
260-
// To check whether there are events with `push` but without `pop`
261+
// log warning if there are events with `push` but without `pop`
261262
std::list<Event>::reverse_iterator rit = pushed_events.rbegin();
262263
while (rit != pushed_events.rend()) {
263-
if (rit->kind() == "push") {
264-
LOG(WARNING) << "Cannot find the pop marker of event \'" << rit->name()
265-
<< "\', which will be ignored in profiling report.";
266-
}
264+
LOG(WARNING) << "Cannot find the pop marker of event \'" << rit->name()
265+
<< "\', which will be ignored in profiling report.";
267266
++rit;
268267
}
269268
}
@@ -275,7 +274,6 @@ void ParseEvents(std::vector<std::vector<Event>>& events,
275274
void PrintProfilingReport(std::vector<std::vector<EventItem>>& events_table,
276275
EventSortingKey sorted_by, const size_t name_width,
277276
const size_t data_width) {
278-
if (g_profiler_place == "") return;
279277
// Output header information
280278
std::cout << "\n------------------------->"
281279
<< " Profiling Report "

0 commit comments

Comments
 (0)