//---------------------------------------------------------------------------
// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
* information. Filled after calling
* stop().
*/
- const Utilities::System::MinMaxAvg & get_data() const;
+ const Utilities::MPI::MinMaxAvg & get_data() const;
/**
* Prints the data to the given stream.
*/
bool running;
-#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
/**
* Store whether the timer is presently
* running.
*/
MPI_Comm mpi_communicator;
+#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
/**
* Store whether the wall time is
* synchronized between machines.
}
+ inline MPI_Datatype mpi_type_id (const long int *)
+ {
+ return MPI_LONG;
+ }
+
+
inline MPI_Datatype mpi_type_id (const unsigned int *)
{
return MPI_UNSIGNED;
}
+ inline MPI_Datatype mpi_type_id (const unsigned long int *)
+ {
+ return MPI_UNSIGNED_LONG;
+ }
+
+
inline MPI_Datatype mpi_type_id (const float *)
{
return MPI_FLOAT;
// in case we just want to have the time
// of a single thread, since then the
// communicator is MPI_COMM_SELF
-#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
- double local_time = dtime - start_time + dtime_children
- - start_time_children + cumulative_time;
-
- int mpiInitialized;
- MPI_Initialized(&mpiInitialized);
-
- if ( mpiInitialized )
- {
- double global_time = 0.;
- MPI_Allreduce (&local_time, &global_time, 1, MPI_DOUBLE, MPI_SUM,
- mpi_communicator);
- return global_time;
- }
- else
- return local_time;
-#else
- return dtime - start_time + dtime_children - start_time_children + cumulative_time;
-#endif
+ return Utilities::MPI::sum (dtime - start_time + dtime_children
+ - start_time_children + cumulative_time,
+ mpi_communicator);
}
else
-#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
- {
- int mpiInitialized;
- MPI_Initialized(&mpiInitialized);
-
- if ( mpiInitialized )
- {
- double local_time = cumulative_time;
- double global_time = 0.;
- MPI_Allreduce (&local_time, &global_time, 1, MPI_DOUBLE, MPI_SUM,
- mpi_communicator);
- return global_time;
- }
- else
- return cumulative_time;
- }
-#else
- return cumulative_time;
-#endif
+ return Utilities::MPI::sum (cumulative_time, mpi_communicator);
}
// itself, but we didn't initialize
// the Timers here according to that
double cpu_time = sections[actual_section_name].timer();
- {
-
- // On MPI, sum up all the local CPU
- // times.
-#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
- double total_cpu_time = 0.;
- int mpiInitialized;
- MPI_Initialized(&mpiInitialized);
-
- if( mpiInitialized )
- {
- MPI_Allreduce (&cpu_time, &total_cpu_time, 1, MPI_DOUBLE, MPI_SUM,
- mpi_communicator);
- cpu_time = total_cpu_time;
- }
-#endif
- sections[actual_section_name].total_cpu_time += cpu_time;
- }
-
+ sections[actual_section_name].total_cpu_time
+ += Utilities::MPI::sum (cpu_time, mpi_communicator);
// in case we have to print out
// something, do that here...
// in case we want to write CPU times
if (output_type != wall_times)
{
- double total_cpu_time;
-
-#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
- {
- double my_cpu_time = timer_all();
- int mpiInitialized;
- MPI_Initialized(&mpiInitialized);
-
- if( mpiInitialized )
- {
- MPI_Allreduce (&my_cpu_time, &total_cpu_time, 1, MPI_DOUBLE,
- MPI_SUM, mpi_communicator);
- }
- else
- total_cpu_time = my_cpu_time;
- }
-#else
- total_cpu_time = timer_all();
-#endif
+ double total_cpu_time = Utilities::MPI::sum (timer_all(),
+ mpi_communicator);
// check that the sum of all times is
// less or equal than the total
// communicate the maximal
// number of destinations they
// have
- unsigned int my_n_destinations = destinations.size();
- unsigned int max_n_destinations = 0;
-
- MPI_Allreduce (&my_n_destinations, &max_n_destinations, 1, MPI_UNSIGNED,
- MPI_MAX, mpi_comm);
+ const unsigned int max_n_destinations
+ = Utilities::MPI::max (destinations.size(), mpi_comm);
// now that we know the number
// of data packets every
AssertThrow(ierr == MPI_SUCCESS, ExcInternalError());
ierr = MPI_Type_commit(&type);
- ierr = MPI_Allreduce ( &in, &result, 1, type, op, mpi_communicator );
+ ierr = MPI_Allreduce (&in, &result, 1, type, op, mpi_communicator);
AssertThrow(ierr == MPI_SUCCESS, ExcInternalError());
ierr = MPI_Type_free (&type);
unsigned int my_size = oss_str.size();
// determine maximum size of IndexSet
- unsigned int max_size;
-
- MPI_Allreduce(&my_size, &max_size, 1, MPI_UNSIGNED, MPI_MAX, tr->get_communicator());
+ const unsigned int max_size
+ = Utilities::MPI::max (my_size, tr->get_communicator());
// as we are reading past the end, we
// need to increase the size of the
ExcInternalError());
// reduce information from all CPUs
-#ifdef DEAL_II_USE_P4EST
-#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
+#if defined(DEAL_II_USE_P4EST) && defined(DEAL_II_COMPILER_SUPPORTS_MPI)
const unsigned int dim = DH::dimension;
const unsigned int spacedim = DH::space_dimension;
MPI_Allreduce ( &local_dof_count[0], &dofs_per_component[0], n_target_components,
MPI_UNSIGNED, MPI_SUM, tria->get_communicator());
}
-#endif
#endif
}
#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
if (const parallel::distributed::Triangulation<dim,spacedim>* p_tria
= dynamic_cast<const parallel::distributed::Triangulation<dim,spacedim>*>(&triangulation))
- MPI_Allreduce (&local_volume, &global_volume, 1, MPI_DOUBLE,
- MPI_SUM,
- p_tria->get_communicator());
+ global_volume = Utilities::MPI::sum (local_volume, p_tria->get_communicator());
else
global_volume = local_volume;
#else