56 char *dst = malloc(strlen(src) + 1);
67 if (strcmp(routine_name,
timed_routines[routine].routine_name) == 0)
109 double *self_time,
int *number_of_calls) {
113 *number_of_calls = 0;
130 const double self_time) {
132 "Requested routine not found!");
161 const double end = omp_get_wtime();
162 const double my_run_time = end -
stack->start_time;
164 *run_time = my_run_time;
165 *self_time = my_run_time -
stack->time_of_called_routines;
169 stack->time_of_called_routines += my_run_time;
181 const double max_total_time_a =
183 const double max_total_time_b =
185 if (max_total_time_a < max_total_time_b) {
187 }
else if (max_total_time_a > max_total_time_b) {
216 const int output_unit) {
218 fwrite(msg, 1, msglen, stdout);
230 const int output_unit,
const char *format, ...) {
233 va_start(args, format);
234 const int length = vsnprintf(buffer,
sizeof(buffer), format, args);
238 length < (
int)
sizeof(buffer) ? length : (
int)
sizeof(buffer) - 1,
255 const int output_unit,
265 "FFT timer not initialized on every rank. Timing report is not "
280 for (
int routine = 0; routine < number_of_routines; routine++) {
282 rank == 0 ? (int)strlen(
timed_routines[routine].routine_name) + 1 : 0;
284 char *routine_name = malloc((
size_t)length);
291 double total_time, self_time;
294 double summed_info[2] = {total_time, self_time};
296 double max_info[2] = {total_time, self_time};
301 statistics[routine].
avg_total_time = summed_info[0] / number_of_ranks;
302 statistics[routine].
avg_self_time = summed_info[1] / number_of_ranks;
315 " -------------------------------------------------------"
316 "------------------------\n"
319 " - FFT TIMING REPORT "
323 " -------------------------------------------------------"
324 "------------------------\n"
326 "SELF TIME TOTAL TIME\n"
328 "AVERAGE MAXIMUM AVERAGE MAXIMUM\n");
329 for (
int routine = 0; routine < number_of_routines; routine++) {
330 if (statistics[routine].max_total_time >=
331 threshold * statistics[0].max_total_time &&
332 statistics[routine].number_of_calls > 0)
334 " %-30s %7i %9.3f %9.3f %9.3f %9.3f\n",
335 statistics[routine].routine_name,
336 statistics[routine].number_of_calls,
337 statistics[routine].avg_self_time,
338 statistics[routine].max_self_time,
339 statistics[routine].avg_total_time,
340 statistics[routine].max_total_time);
341 free(statistics[routine].routine_name);
344 " -------------------------------------------------------"
345 "------------------------\n");
388 if (omp_get_thread_num() == 0) {
405 if (omp_get_thread_num() == 0) {
408 double total_time, self_time;
411 "Incorrect order of timing regions!\n");
415 const char routine_name[] =
"library";
#define cp_assert(condition)
int cp_mpi_comm_size(const cp_mpi_comm_t comm)
Wrapper around MPI_Comm_size.
void cp_mpi_bcast_char(char *buf, const int count, const int root, const cp_mpi_comm_t comm)
Wrapper around MPI_Bcast for datatype MPI_CHAR.
void cp_mpi_barrier(const cp_mpi_comm_t comm)
Wrapper around MPI_Barrier; a null communicator is a no-op.
void cp_mpi_max_root_double(double *values, const int count, const int root, const cp_mpi_comm_t comm)
Wrapper around MPI_Reduce for op MPI_MAX and datatype MPI_DOUBLE.
void cp_mpi_sum_int(int *values, const int count, const cp_mpi_comm_t comm)
Wrapper around MPI_Allreduce for op MPI_SUM and datatype MPI_INT.
void cp_mpi_sum_root_double(double *values, const int count, const int root, const cp_mpi_comm_t comm)
Wrapper around MPI_Reduce for op MPI_SUM and datatype MPI_DOUBLE.
void cp_mpi_bcast_int(int *buf, const int count, const int root, const cp_mpi_comm_t comm)
Wrapper around MPI_Bcast for datatype MPI_INT.
int cp_mpi_comm_rank(const cp_mpi_comm_t comm)
Wrapper around MPI_Comm_rank.
static void print_func(const char *msg, int msglen, int output_unit)
Wrapper for printf, passed to dbm_library_print_stats.
void(* fft_print_func_t)(const char *, int, int)
static void fft_report_printf(fft_print_func_t print_func, const int output_unit, const char *format,...)
Format and emit one FFT timing-report line through a callback.
static bool timers_initialized
static int find_routine_by_name(const char *routine_name)
Find the index of a timed routine by name.
static struct fft_stack_type * stack
void push_on_stack(const int handle)
Push new routine on function stack.
int compare_fft_timing_statistics(const void *a, const void *b)
Comparator for sorting FFT timing entries by maximum total time.
void fft_stop_timer(const int handle)
Stop a timing.
void update_routine(const int handle, const double total_time, const double self_time)
Get a routine handle to a given routine name.
void fft_init_timer()
Initializes the internal timer.
static fft_timed_routine * timed_routines
int fft_start_timer(const char *routine_name)
Start a timing section.
void get_routine_infos(const char *routine_name, double *total_time, double *self_time, int *number_of_calls)
Get a routine handle to a given routine name.
static int number_of_timed_routines
static int buffer_size_timed_routines
void pop_from_stack(int *handle, double *run_time, double *self_time)
Removes the element on top of the stack and returns its data.
int get_routine_handle(const char *routine_name)
Get a routine handle to a given routine name.
void fft_print_timing_report_unit(const double threshold, fft_print_func_t print_func, const int output_unit, const cp_mpi_comm_t comm)
Prints the timing report.
static char * fft_strdup(const char *src)
String duplication. Can be removed with migration to C23.
void fft_print_timing_report(const double threshold, const cp_mpi_comm_t comm)
Print the FFT timing report to standard output.
void fft_finalize_timer()
Finalizes the internal timer.
static void fft_print_to_stdout(const char *msg, const int msglen, const int output_unit)
Write an FFT timing message to standard output.
void offload_timestop(void)
Ends a timing range.
void offload_timeset(const char *message)
Starts a timing range.
double time_of_called_routines
struct fft_stack_type * next