#include <deal.II/base/thread_management.h>
#include <deal.II/base/utilities.h>
-#ifdef DEAL_II_WITH_MPI
-# include <mpi.h>
-#endif
-
#include <string>
#include <list>
#include <map>
*/
Timer ();
-#ifdef DEAL_II_WITH_MPI
/**
* Constructor that takes an MPI communicator as input. A timer constructed
* this way will sum up the CPU times over all processors in the MPI network
* only works if you stop() the timer before querying for the wall time. The
* time for the MPI operations are not included in the timing but may slow
* down your program.
- *
- * This constructor is only available if deal.II is compiled with MPI support.
*/
Timer (MPI_Comm mpi_communicator,
const bool sync_wall_time = false);
template <class StreamType>
void print_total_data(StreamType &stream) const;
-#endif
/**
* Re-start the timer at the point where it was stopped. This way a
*/
MPI_Comm mpi_communicator;
-#ifdef DEAL_II_WITH_MPI
/**
* Store whether the wall time is synchronized between machines.
*/
* number of MPI processes in the MPI_Comm for the total run time.
*/
Utilities::MPI::MinMaxAvg mpi_total_data;
-#endif
};
const enum OutputFrequency output_frequency,
const enum OutputType output_type);
-#ifdef DEAL_II_WITH_MPI
/**
* Constructor that takes an MPI communicator as input. A timer constructed
* this way will sum up the CPU times over all processors in the MPI network
const enum OutputFrequency output_frequency,
const enum OutputType output_type);
-
-
-
-#endif
-
/**
* Destructor. Calls print_summary() in case the option for writing the
* summary output is set.
-#ifdef DEAL_II_WITH_MPI
-
inline
const Utilities::MPI::MinMaxAvg &
Timer::get_data() const
<< statistic.min_index << ", avg=" << statistic.avg << std::endl;
}
-#endif
-
inline
-// in case we use an MPI compiler, use
-// the communicator given from input
-#ifdef DEAL_II_WITH_MPI
Timer::Timer(MPI_Comm mpi_communicator,
const bool sync_wall_time_)
:
mpi_communicator (mpi_communicator),
sync_wall_time(sync_wall_time_)
{
-#ifdef DEAL_II_WITH_MPI
mpi_data.sum = mpi_data.min = mpi_data.max = mpi_data.avg = numbers::signaling_nan<double>();
mpi_data.min_index = mpi_data.max_index = numbers::invalid_unsigned_int;
mpi_total_data.sum = mpi_total_data.min = mpi_total_data.max = mpi_total_data.avg = 0.;
mpi_total_data.min_index = mpi_total_data.max_index = 0;
-#endif
start();
}
-#endif
void Timer::start ()
{
- running = true;
-
+ running = true;
#ifdef DEAL_II_WITH_MPI
if (sync_wall_time)
{
# error Unsupported platform. Porting not finished.
#endif
-#ifdef DEAL_II_WITH_MPI
this->mpi_data = Utilities::MPI::min_max_avg (last_lap_time,
mpi_communicator);
if (sync_wall_time && Utilities::MPI::job_supports_mpi())
accumulated_cpu_time += last_lap_cpu_time;
this->mpi_total_data = Utilities::MPI::min_max_avg (accumulated_wall_time,
mpi_communicator);
-#else
- accumulated_wall_time += last_lap_time;
- accumulated_cpu_time += last_lap_cpu_time;
-#endif
}
return accumulated_cpu_time;
}
accumulated_cpu_time = 0.;
accumulated_wall_time = 0.;
running = false;
-#ifdef DEAL_II_WITH_MPI
mpi_data.sum = mpi_data.min = mpi_data.max = mpi_data.avg = numbers::signaling_nan<double>();
mpi_data.min_index = mpi_data.max_index = numbers::invalid_unsigned_int;
mpi_total_data.sum = mpi_total_data.min = mpi_total_data.max = mpi_total_data.avg = 0.;
mpi_total_data.min_index = mpi_total_data.max_index = 0;
-#endif
}
output_frequency (output_frequency),
output_type (output_type),
out_stream (stream, true),
- output_is_enabled (true)
-#ifdef DEAL_II_WITH_MPI
- , mpi_communicator (MPI_COMM_SELF)
-#endif
+ output_is_enabled (true),
+ mpi_communicator (MPI_COMM_SELF)
{}
output_frequency (output_frequency),
output_type (output_type),
out_stream (stream),
- output_is_enabled (true)
-#ifdef DEAL_II_WITH_MPI
- , mpi_communicator (MPI_COMM_SELF)
-#endif
+ output_is_enabled (true),
+ mpi_communicator (MPI_COMM_SELF)
{}
-#ifdef DEAL_II_WITH_MPI
TimerOutput::TimerOutput (MPI_Comm mpi_communicator,
std::ostream &stream,
mpi_communicator (mpi_communicator)
{}
-#endif
TimerOutput::~TimerOutput()
if (sections.find (section_name) == sections.end())
{
-#ifdef DEAL_II_WITH_MPI
if (mpi_communicator != MPI_COMM_SELF)
{
// create a new timer for this section. the second argument
// among all processes inside mpi_communicator.
sections[section_name].timer = Timer(mpi_communicator, true);
}
-#endif
sections[section_name].total_cpu_time = 0;