(git:e70887f)
Loading...
Searching...
No Matches
fft_timer.c File Reference
#include "fft_timer.h"
#include "../offload/offload_library.h"
#include "../base/cp_assert.h"
#include <omp.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Data Structures

struct  fft_timed_routine
struct  fft_timing_statistics
struct  fft_stack_type

Functions

static char * fft_strdup (const char *src)
 String duplication. Can be removed with migration to C23.
static int find_routine_by_name (const char *routine_name)
 Find the index of a timed routine by name.
int get_routine_handle (const char *routine_name)
 Get a routine handle to a given routine name.
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.
void update_routine (const int handle, const double total_time, const double self_time)
 Get a routine handle to a given routine name.
void push_on_stack (const int handle)
 Push new routine on function stack.
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 compare_fft_timing_statistics (const void *a, const void *b)
 Comparator for sorting FFT timing entries by maximum total time.
void fft_init_timer ()
 Initializes 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.
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.
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.
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.
int fft_start_timer (const char *routine_name)
 Start a timing section.
void fft_stop_timer (const int handle)
 Stop a timing.

Variables

static fft_timed_routine * timed_routines = NULL
static struct fft_stack_type * stack = NULL
static bool timers_initialized = false
static int number_of_timed_routines = 0
static int buffer_size_timed_routines = 0

Function Documentation

◆ fft_strdup()

char * fft_strdup ( const char * src)
static

String duplication. Can be removed with migration to C23.

Parameters
handleHandle of the pushed function
srcSource string to duplicate.
Author
Frederick Stein

Definition at line 55 of file fft_timer.c.

Here is the caller graph for this function:

◆ find_routine_by_name()

int find_routine_by_name ( const char * routine_name)
static

Find the index of a timed routine by name.

Definition at line 65 of file fft_timer.c.

Here is the caller graph for this function:

◆ get_routine_handle()

int get_routine_handle ( const char * routine_name)

Get a routine handle to a given routine name.

Parameters
routine_nameName of the timed routine.
Author
Frederick Stein

Definition at line 77 of file fft_timer.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_routine_infos()

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.

Parameters
handleHandle of the pushed function
routine_nameName of the timed routine.
total_timeTotal time of the timed routine.
self_timeSelf time of the timed routine.
number_of_callsNumber of calls of the timed routine.
Author
Frederick Stein

Definition at line 108 of file fft_timer.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_routine()

void update_routine ( const int handle,
const double total_time,
const double self_time )

Get a routine handle to a given routine name.

Parameters
handleHandle of the pushed function
total_timeTotal time of the timed routine.
self_timeSelf time of the timed routine.
Author
Frederick Stein

Definition at line 129 of file fft_timer.c.

Here is the caller graph for this function:

◆ push_on_stack()

void push_on_stack ( const int handle)

Push new routine on function stack.

Parameters
handleHandle of the pushed function
Author
Frederick Stein

Definition at line 144 of file fft_timer.c.

Here is the caller graph for this function:

◆ pop_from_stack()

void pop_from_stack ( int * handle,
double * run_time,
double * self_time )

Removes the element on top of the stack and returns its data.

Parameters
handleHandle of the routines (for external checks)
run_timeTotal run time of the routine
self_timeTime spent within the routine without called routines
Author
Frederick Stein

Definition at line 160 of file fft_timer.c.

Here is the caller graph for this function:

◆ compare_fft_timing_statistics()

int compare_fft_timing_statistics ( const void * a,
const void * b )

Comparator for sorting FFT timing entries by maximum total time.

Parameters
aFirst timing entry.
bSecond timing entry.
Returns
Negative, zero, or positive according to the sort order.
Author
Frederick Stein

Definition at line 180 of file fft_timer.c.

Here is the caller graph for this function:

◆ fft_init_timer()

void fft_init_timer ( )

Initializes the internal timer.

Note
To be called by all threads or outside of a parallel region.
Author
Frederick Stein

Definition at line 199 of file fft_timer.c.

Here is the caller graph for this function:

◆ fft_print_to_stdout()

void fft_print_to_stdout ( const char * msg,
const int msglen,
const int output_unit )
static

Write an FFT timing message to standard output.

Parameters
msgMessage buffer.
msglenNumber of characters to write.
output_unitUnused stdout marker.
Author
Frederick Stein

Definition at line 215 of file fft_timer.c.

Here is the caller graph for this function:

◆ fft_report_printf()

void fft_report_printf ( fft_print_func_t print_func,
const int output_unit,
const char * format,
... )
static

Format and emit one FFT timing-report line through a callback.

Parameters
print_funcOutput callback.
output_unitDestination output unit.
formatprintf-style format string.
...Optional format arguments.
Author
Frederick Stein

Definition at line 229 of file fft_timer.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fft_print_timing_report_unit()

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.

Note
To be called by all threads or outside of a parallel region.
To be called by all MPI ranks
Parameters
thresholdMinimum relative timing value to report.
print_funcCallback used to print the timing report.
output_unitDestination output unit.
commMPI communicator.
Author
Frederick Stein

Definition at line 253 of file fft_timer.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fft_print_timing_report()

void fft_print_timing_report ( const double threshold,
const cp_mpi_comm_t comm )

Print the FFT timing report to standard output.

Prints the timing report.

Parameters
thresholdMinimum relative timing value to report.
commMPI communicator used to aggregate timing data.
Author
Frederick Stein

Definition at line 357 of file fft_timer.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fft_finalize_timer()

void fft_finalize_timer ( )

Finalizes the internal timer.

Note
Thread-safe. Only the master-thread does something.
Author
Frederick Stein

Definition at line 367 of file fft_timer.c.

Here is the caller graph for this function:

◆ fft_start_timer()

int fft_start_timer ( const char * routine_name)

Start a timing section.

Note
Thread-safe. Only the master-thread does something.
Parameters
routine_nameName of the timed routine.
Author
Frederick Stein

Definition at line 386 of file fft_timer.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fft_stop_timer()

void fft_stop_timer ( const int handle)

Stop a timing.

Note
Thread-safe. Only the master-thread does something.
Parameters
handleTimer handle.
Author
Frederick Stein

Definition at line 402 of file fft_timer.c.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ timed_routines

fft_timed_routine* timed_routines = NULL
static

Definition at line 42 of file fft_timer.c.

◆ stack

struct fft_stack_type* stack = NULL
static

Definition at line 43 of file fft_timer.c.

◆ timers_initialized

bool timers_initialized = false
static

Definition at line 45 of file fft_timer.c.

◆ number_of_timed_routines

int number_of_timed_routines = 0
static

Definition at line 46 of file fft_timer.c.

◆ buffer_size_timed_routines

int buffer_size_timed_routines = 0
static

Definition at line 47 of file fft_timer.c.