Skip to content

Commit

Permalink
Fixing measurement output when dump is called multiple times.
Browse files Browse the repository at this point in the history
  • Loading branch information
khuck committed Apr 2, 2021
1 parent 95cd5b4 commit 5bef4b2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/apex/profiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ class profiler {
return value;
} else {
using namespace std::chrono;
if (!stopped) {
end = MYCLOCK::now();
}
duration<double> time_span =
duration_cast<duration<double>>(end - start);
if (scaled) {
Expand Down
17 changes: 13 additions & 4 deletions src/apex/profiler_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1338,8 +1338,10 @@ if (rc != 0) cout << "PAPI error! " << name << ": " << PAPI_strerror(rc) << endl
if (_done) { return; }

// stop the main timer, and process that profile?
stop_main_timer();
yield_main_timer();
push_profiler((unsigned int)thread_instance::get_id(), main_timer);
// restart the main timer
resume_main_timer();

// trigger statistics updating
#ifdef APEX_HAVE_HPX
Expand Down Expand Up @@ -1447,9 +1449,6 @@ if (rc != 0) cout << "PAPI error! " << name << ": " << PAPI_strerror(rc) << endl
close(task_scatterplot_sample_file);
}
#endif
// restart the main timer
main_timer = std::make_shared<profiler>(
task_wrapper::get_apex_main_wrapper());
if (data.reset) {
reset_all();
}
Expand Down Expand Up @@ -1751,6 +1750,16 @@ if (rc != 0) cout << "PAPI error! " << name << ": " << PAPI_strerror(rc) << endl

}

void profiler_listener::yield_main_timer(void) {
APEX_ASSERT(main_timer != nullptr);
main_timer->stop(true);
}

void profiler_listener::resume_main_timer(void) {
APEX_ASSERT(main_timer != nullptr);
main_timer->restart();
}

void profiler_listener::stop_main_timer(void) {
static bool stopped{false};
if (!stopped) {
Expand Down
4 changes: 3 additions & 1 deletion src/apex/profiler_listener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class profiler_listener : public event_listener {
bool _initialized;
std::atomic<bool> _done;
std::atomic<int> active_tasks;
std::shared_ptr<profiler> main_timer; // not a shared pointer, yet...
std::shared_ptr<profiler> main_timer;
void write_one_timer(task_identifier &task_id, profile * p,
std::stringstream &screen_output,
std::stringstream &csv_output,
Expand Down Expand Up @@ -252,6 +252,8 @@ class profiler_listener : public event_listener {
std::vector<std::string>& get_metric_names(void) { return metric_names; };
#endif
void stop_main_timer(void);
void yield_main_timer(void);
void resume_main_timer(void);
void push_profiler_public(std::shared_ptr<profiler> &p);
};

Expand Down

0 comments on commit 5bef4b2

Please sign in to comment.