Highly Efficient FFT for Exascale: HeFFTe v2.4
Loading...
Searching...
No Matches
heffte_trace.h
1/*
2 -- heFFTe --
3 Univ. of Tennessee, Knoxville
4 @date
5*/
6
7#ifndef HEFFTE_TRACE_H
8#define HEFFTE_TRACE_H
9
10#include "heffte_utils.h"
11
45
46namespace heffte {
47
48 #ifdef Heffte_ENABLE_TRACING
56 struct event {
58 std::string name;
60 double start_time;
62 double duration;
63 };
64
69 extern std::deque<event> event_log;
74 extern std::string log_filename;
75
84 struct add_trace {
86 add_trace(std::string s) : name(s), start_time(MPI_Wtime()){}
89 double duration = MPI_Wtime() - start_time;
90 event_log.push_back({std::move(name), start_time, duration});
91 }
92
93 std::string name;
95 double start_time;
96 };
97
102 inline void init_tracing(std::string root_filename){
103 event_log = std::deque<event>();
104 log_filename = root_filename + "_" + std::to_string(mpi::world_rank()) + ".log";
105 }
106
111 inline void finalize_tracing(){
112 std::ofstream ofs(log_filename);
113 ofs.precision(12);
114
115 for(auto const &e : event_log)
116 ofs << std::setw(40) << e.name << std::setw(20) << e.start_time << std::setw(20) << e.duration << "\n";
117 }
118
119 #else
120
121 struct add_trace{
122 add_trace(std::string){}
123 };
124 inline void init_tracing(std::string){}
125 inline void finalize_tracing(){}
126
127 #endif
128
129}
130
131#endif // #ifndef HEFFTE_TRACE_H
bool world_rank(int rank)
Returns true if this process has the me rank within the MPI_COMM_WORLD (useful for debugging).
Definition heffte_utils.h:98
void finalize_tracing()
Finalize tracing and write the result to a file, see the Detailed Description.
Definition heffte_trace.h:111
std::deque< event > event_log
Logs the list of events (declared in heffte_reshape3d.cpp).
std::string log_filename
Root filename to write out the traces (decaled in heffte_reshape3d.cpp).
void init_tracing(std::string root_filename)
Initialize tracing and remember the root filename for output, see the Detailed Description.
Definition heffte_trace.h:102
Namespace containing all HeFFTe methods and classes.
Definition heffte_backend_cuda.h:38
add_trace(std::string s)
Defines a trace.
Definition heffte_trace.h:86
std::string name
Defines the name of a trace.
Definition heffte_trace.h:93
~add_trace()
Saves a trace.
Definition heffte_trace.h:88
double start_time
Saves the starting wall-clock-time of the trace.
Definition heffte_trace.h:95
A tracing event.
Definition heffte_trace.h:56
double duration
Duration according to the MPI high-precision clock.
Definition heffte_trace.h:62
double start_time
Start time according to MPI high-precision clock.
Definition heffte_trace.h:60
std::string name
Name of the event.
Definition heffte_trace.h:58