Skip to content
Snippets Groups Projects
Commit c9e5cec5 authored by René Fritze's avatar René Fritze
Browse files

[common] new profiler output

parent 8edee7b1
No related branches found
No related tags found
No related merge requests found
...@@ -249,13 +249,39 @@ void Profiler::setOutputdir(const std::string dir) ...@@ -249,13 +249,39 @@ void Profiler::setOutputdir(const std::string dir)
Dune::Stuff::Common::testCreateDirectory(output_dir_); Dune::Stuff::Common::testCreateDirectory(output_dir_);
} }
void Profiler::outputTimings(const std::string /*csv*/) const void Profiler::outputTimings(const std::string csv) const
{ {
const auto& comm = Dune::MPIHelper::getCollectiveCommunication(); const auto& comm = Dune::MPIHelper::getCollectiveCommunication();
boost::filesystem::path filename(output_dir_); boost::filesystem::path dir(output_dir_);
filename /= (boost::format("timings_p%08d.csv") % comm.rank()).str(); boost::filesystem::path filename = dir / (boost::format("%s_p%08d.csv") % csv % comm.rank()).str();
boost::filesystem::ofstream out(filename); boost::filesystem::ofstream out(filename);
outputTimings(out); outputTimings(out);
if (comm.rank() == 0) {
boost::filesystem::path a_filename = dir / (boost::format("%s.csv") % csv).str();
boost::filesystem::ofstream a_out(a_filename);
outputTimingsAll(a_out);
}
}
void Profiler::outputTimingsAll(std::ostream& out) const
{
if (datamaps_.size() < 1)
return;
// csv header:
const auto& comm = Dune::MPIHelper::getCollectiveCommunication();
out << "run";
for (const auto& section : datamaps_[0]) {
out << csv_sep << section.first << "_avg" << csv_sep << section.first << "_sum";
}
int i = 0;
for (const auto& datamap : datamaps_) {
out << std::endl << i;
for (const auto& section : datamap) {
auto sum = comm.sum(section.second);
out << csv_sep << sum / float(comm.size()) << csv_sep << sum;
}
out << std::endl;
}
} }
void Profiler::outputTimings(std::ostream& out) const void Profiler::outputTimings(std::ostream& out) const
......
...@@ -123,8 +123,9 @@ public: ...@@ -123,8 +123,9 @@ public:
void outputMap(const InfoContainerMap& run_infos_map, const double scale_factor = 1.0) const; void outputMap(const InfoContainerMap& run_infos_map, const double scale_factor = 1.0) const;
//! file-output the named sections only //! file-output the named sections only
void outputTimings(const std::string filename) const; void outputTimings(const std::string filename = "timings") const;
void outputTimings(std::ostream& out = std::cout) const; void outputTimings(std::ostream& out = std::cout) const;
void outputTimingsAll(std::ostream& out = std::cout) const;
/** call this with correct numRuns <b> before </b> starting any profiling /** call this with correct numRuns <b> before </b> starting any profiling
* if you're planning on doing more than one iteration of your code * if you're planning on doing more than one iteration of your code
* called once fromm ctor with numRuns=1 * called once fromm ctor with numRuns=1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment