Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:khuck/xpress-apex into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
khuck committed May 19, 2021
2 parents 7e225a9 + 42bcafd commit f09fb06
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 29 deletions.
12 changes: 6 additions & 6 deletions src/apex/profiler_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ std::unordered_set<profile*> free_profiles;
<< "'" << p->get_task_id()->get_name() << "'" << endl;
int loc0 = task_scatterplot_samples.tellp();
if (loc0 > 32768) {
task_scatterplot_sample_file << task_scatterplot_samples.rdbuf();
task_scatterplot_sample_file() << task_scatterplot_samples.rdbuf();
// reset the stringstream
task_scatterplot_samples.str("");
}
Expand All @@ -393,7 +393,7 @@ std::unordered_set<profile*> free_profiles;
<< "'" << p->get_task_id()->get_name() << "'" << endl;
int loc0 = task_scatterplot_samples.tellp();
if (loc0 > 32768) {
counter_scatterplot_sample_file << counter_scatterplot_samples.rdbuf();
counter_scatterplot_sample_file() << counter_scatterplot_samples.rdbuf();
// reset the stringstream
counter_scatterplot_samples.str("");
}
Expand Down Expand Up @@ -1466,10 +1466,10 @@ if (rc != 0) cout << "PAPI error! " << name << ": " << PAPI_strerror(rc) << endl
write_profile();
}
if (apex_options::task_scatterplot()) {
task_scatterplot_sample_file << task_scatterplot_samples.rdbuf();
task_scatterplot_sample_file.close();
counter_scatterplot_sample_file << counter_scatterplot_samples.rdbuf();
counter_scatterplot_sample_file.close();
task_scatterplot_sample_file() << task_scatterplot_samples.rdbuf();
task_scatterplot_sample_file().close();
counter_scatterplot_sample_file() << counter_scatterplot_samples.rdbuf();
counter_scatterplot_sample_file().close();
}
if (data.reset) {
reset_all();
Expand Down
55 changes: 32 additions & 23 deletions src/apex/profiler_listener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ class profiler_listener : public event_listener {
std::thread * consumer_thread;
#endif
semaphore queue_signal;
std::ofstream task_scatterplot_sample_file;
std::ofstream counter_scatterplot_sample_file;
std::ofstream _task_scatterplot_sample_file;
std::ofstream _counter_scatterplot_sample_file;
std::stringstream task_scatterplot_samples;
std::stringstream counter_scatterplot_samples;
public:
Expand All @@ -164,27 +164,6 @@ class profiler_listener : public event_listener {
num_papi_counters = 0;
#endif
if (apex_options::task_scatterplot()) {
std::stringstream ss;
ss << apex_options::output_file_path();
ss << filesystem_separator();
ss << task_scatterplot_sample_filename << node_id << ".csv";
// open the file
task_scatterplot_sample_file.open(ss.str(), std::ofstream::out);
if (!task_scatterplot_sample_file.is_open()) {
perror("opening scatterplot sample file");
}
APEX_ASSERT(task_scatterplot_sample_file.is_open());

ss.str("");
ss << apex_options::output_file_path();
ss << filesystem_separator();
ss << counter_scatterplot_sample_filename << node_id << ".csv";
// open the file
counter_scatterplot_sample_file.open(ss.str(), std::ofstream::out);
if (!counter_scatterplot_sample_file.is_open()) {
perror("opening scatterplot sample file");
}
APEX_ASSERT(counter_scatterplot_sample_file.is_open());
profiler::get_global_start();
}
};
Expand All @@ -210,6 +189,36 @@ class profiler_listener : public event_listener {
void on_send(message_event_data &data);
void on_recv(message_event_data &data);
// other methods
std::ofstream& task_scatterplot_sample_file() {
if (!_task_scatterplot_sample_file.is_open()) {
std::stringstream ss;
ss << apex_options::output_file_path();
ss << filesystem_separator();
ss << task_scatterplot_sample_filename << node_id << ".csv";
// open the file
_task_scatterplot_sample_file.open(ss.str(), std::ofstream::out);
if (!_task_scatterplot_sample_file.is_open()) {
perror("opening scatterplot sample file");
}
APEX_ASSERT(_task_scatterplot_sample_file.is_open());
}
return _task_scatterplot_sample_file;
}
std::ofstream& counter_scatterplot_sample_file () {
if (!_counter_scatterplot_sample_file.is_open()) {
std::stringstream ss;
ss << apex_options::output_file_path();
ss << filesystem_separator();
ss << counter_scatterplot_sample_filename << node_id << ".csv";
// open the file
_counter_scatterplot_sample_file.open(ss.str(), std::ofstream::out);
if (!_counter_scatterplot_sample_file.is_open()) {
perror("opening scatterplot sample file");
}
APEX_ASSERT(_counter_scatterplot_sample_file.is_open());
}
return _counter_scatterplot_sample_file;
}
void reset(task_identifier * id);
void reset_all(void);
profile * get_profile(const task_identifier &id);
Expand Down

0 comments on commit f09fb06

Please sign in to comment.