]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Implement the new function in namespace Utilities::MPI instead. Give it a simpler...
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 26 Sep 2011 12:02:41 +0000 (12:02 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 26 Sep 2011 12:02:41 +0000 (12:02 +0000)
git-svn-id: https://svn.dealii.org/trunk@24416 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/include/deal.II/base/utilities.h
tests/mpi/collective_02.cc

index 4d059b040f71e7136d7cb794507c641f59f8816c..9abc3929003dda74df6d112daebff2318b23e39f 100644 (file)
@@ -297,7 +297,7 @@ and DoF handlers embedded in higher dimensional space have been added.
 <h3>Specific improvements</h3>
 
 <ol>
-<li> New: The function Utilities::System::calculate_collective_mpi_sum
+<li> New: The function Utilities::MPI::sum
 function can be used to compute the sum of values over a number of
 MPI processes without having to deal with the underlying MPI functions.
 <br>
index e3f08d2ffc660fd92d1d6d9a6968c10c71106234..d268d61942efc932ba4e4f3e3b1cb2e77442c5b5 100644 (file)
@@ -274,6 +274,34 @@ namespace Utilities
   std::vector<unsigned int>
   invert_permutation (const std::vector<unsigned int> &permutation);
 
+                                   /**
+                                    * A namespace for utility functions that
+                                    * abstract certain operations using the
+                                   * Message Passing Interface (MPI) or
+                                   * provide fallback operations in
+                                   * case deal.II is configured not to use
+                                   * MPI at all.
+                                    *
+                                    * @ingroup utilities
+                                    */
+  namespace MPI
+  {    
+    /**
+     * Return the sum over all processors of the value @p t. This function
+     * is collective over all processors given in the communicator. If
+     * deal.II is not configured for use of MPI, this function simply
+     * returns the value of @p t. This function corresponds to the
+     * <code>MPI_Allreduce</code> function, i.e. all processors receive
+     * the result of this operation.
+     * 
+     * @note This function is only implemented for certain template
+     * arguments <code>T</code>, namely <code>float, double, int, 
+     * unsigned int</code>.
+     */
+    template <typename T>
+    T sum (const T &t,
+          const MPI_Comm &mpi_communicator);
+  }
                                    /**
                                     * A namespace for utility functions that
                                     * probe system properties.
@@ -440,23 +468,6 @@ namespace Utilities
                                      */
     MPI_Comm duplicate_communicator (const MPI_Comm &mpi_communicator);
 
-    
-    /**
-     * Return the sum over all processors of the value @p t. This function
-     * is collective over all processors given in the communicator. If
-     * deal.II is not configured for use of MPI, this function simply
-     * returns the value of @p t. This function corresponds to the
-     * <code>MPI_Allreduce</code> function, i.e. all processors receive
-     * the result of this operation.
-     * 
-     * @note This function is only implemented for certain template
-     * arguments <code>T</code>, namely <code>float, double, int, 
-     * unsigned int</code>.
-     */
-    template <typename T>
-    T calculate_collective_mpi_sum (const T &t,
-                                   const MPI_Comm &mpi_communicator);
-
                                     /**
                                      * Data structure to store the result of
                                      * calculate_collective_mpi_min_max_avg.
@@ -881,7 +892,7 @@ namespace Utilities
   }
   
   
-  namespace System
+  namespace MPI
   {
     namespace internal
     {
@@ -916,8 +927,8 @@ namespace Utilities
     
     template <typename T>
     inline
-    T calculate_collective_mpi_sum (const T &t,
-                                   const MPI_Comm &mpi_communicator)
+    T sum (const T &t,
+          const MPI_Comm &mpi_communicator)
     {
 #ifdef DEAL_II_COMPILER_SUPPORTS_MPI
       T sum;
index 386b1be0ae1f72e5621b17450f908593a42366d3..a0e97f198352284882a4a426a4fda80abcf09c5d 100644 (file)
@@ -27,20 +27,20 @@ void test()
   int int_sum, uint_sum, double_sum, float_sum;
   int_sum
     =
-    Utilities::System::calculate_collective_mpi_sum<int>(myid+1,
-                                                        MPI_COMM_WORLD);
+    Utilities::MPI::sum<int>(myid+1,
+                            MPI_COMM_WORLD);
   uint_sum
     =
-    Utilities::System::calculate_collective_mpi_sum<unsigned int>(myid+1,
-                                                                 MPI_COMM_WORLD);
+    Utilities::MPI::sum<unsigned int>(myid+1,
+                                     MPI_COMM_WORLD);
   float_sum
     =
-    Utilities::System::calculate_collective_mpi_sum<float>(myid+1,
-                                                          MPI_COMM_WORLD);
+    Utilities::MPI::sum<float>(myid+1,
+                              MPI_COMM_WORLD);
   double_sum
     =
-    Utilities::System::calculate_collective_mpi_sum<double>(myid+1,
-                                                           MPI_COMM_WORLD);
+    Utilities::MPI::sum<double>(myid+1,
+                               MPI_COMM_WORLD);
 
   if (myid==0)
     deallog << int_sum << ' ' << uint_sum << ' ' << double_sum << ' ' << float_sum << std::endl;

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.