Commit 2558dacd authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Added in-place version of Allreduce to communicators

parent 4847fc94
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -340,6 +340,21 @@ class MpiCommunicator
#endif
        }

        // in-place variant of Allreduce
        template< typename T >
        static void Allreduce( T* data,
                               int count,
                               const MPI_Op &op,
                               CommunicationGroup group)
        {
#ifdef HAVE_MPI
            TNL_ASSERT_NE(group, NullGroup, "Allreduce cannot be called with NullGroup");
            MPI_Allreduce( MPI_IN_PLACE, (void*) data,count,MPIDataType(data),op,group);
#else
            throw Exceptions::MPISupportMissing();
#endif
        }


         template< typename T >
         static void Reduce( const T* data,
+9 −0
Original line number Diff line number Diff line
@@ -108,6 +108,15 @@ class NoDistrCommunicator
         memcpy( ( void* ) reduced_data, ( const void* ) data, count * sizeof( T ) );
      }

      // in-place variant of Allreduce
      template< typename T >
      static void Allreduce( T* data,
                             int count,
                             const MPI_Op &op,
                             CommunicationGroup group )
      {
      }

      template< typename T >
      static void Reduce( T* data,
                          T* reduced_data,