Skip to content

Commit

Permalink
Fixing bug where apex::dump is called multiple times, the tasktree hi…
Browse files Browse the repository at this point in the history
…erarchy has a static set that contains a collection of the processed tree nodes. That set needs to be reset each time that the CSV tree writer is called, otherwise subsequent writes will have an empty file.
  • Loading branch information
khuck committed Oct 4, 2024
1 parent ccf1ac8 commit bf89683
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/apex/dependency_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,12 @@ void Node::addAccumulated(double value, double incl, bool is_resume, uint64_t th
m.unlock();
}

double Node::writeNodeCSV(std::stringstream& outfile, double total, int node_id, int num_papi_counters) {
double Node::writeNodeCSV(std::stringstream& outfile, double total, int node_id, int num_papi_counters, bool topLevel) {
static size_t depth = 0;
static std::set<std::shared_ptr<Node>> processed;
// because dump can get called multiple times during execution, we need
// to reset the set of processed nodes.
if (topLevel) { processed.clear(); }
if (processed.count(shared_from_this())) return getAccumulated();
processed.insert(shared_from_this());
APEX_ASSERT(total > 0.0);
Expand Down
2 changes: 1 addition & 1 deletion src/apex/dependency_tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Node : public std::enable_shared_from_this<Node> {
std::string getName() const { return data->get_name(); };
void writeNode(std::ofstream& outfile, double total);
double writeNodeASCII(std::ofstream& outfile, double total, size_t indent);
double writeNodeCSV(std::stringstream& outfile, double total, int node_id, int num_papi_counters);
double writeNodeCSV(std::stringstream& outfile, double total, int node_id, int num_papi_counters, bool topLevel = false);
double writeNodeJSON(std::ofstream& outfile, double total, size_t indent);
void writeTAUCallpath(std::ofstream& outfile, std::string prefix);
static size_t getNodeCount() {
Expand Down
2 changes: 1 addition & 1 deletion src/apex/profiler_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ std::unordered_set<profile*> free_profiles;
header_stream << "\n";
//}
stringstream tree_stream;
root->tree_node->writeNodeCSV(tree_stream, wall_clock_main, node_id, num_papi_counters);
root->tree_node->writeNodeCSV(tree_stream, wall_clock_main, node_id, num_papi_counters, true);
std::string filename{"apex_tasktree.csv"};
reduce_profiles(header_stream, tree_stream, filename, false);
}
Expand Down

0 comments on commit bf89683

Please sign in to comment.