Loading src/TNL/Solvers/ODE/Euler_impl.h +6 −2 Original line number Diff line number Diff line Loading @@ -231,7 +231,11 @@ void Euler< Problem > :: computeNewTimeLevel( DofVectorPointer& u, localResidue /= tau * ( RealType ) size; MPIAllreduce( localResidue, currentResidue, 1, MPI_SUM, this->solver_comm ); #ifdef USE_MPI TNLMPI::Allreduce( localResidue, currentResidue, 1, MPI_SUM); #else currentResidue=localResidue; #endif } Loading src/TNL/Solvers/ODE/ExplicitSolver.h +0 −4 Original line number Diff line number Diff line Loading @@ -64,8 +64,6 @@ class ExplicitSolver : public IterativeSolver< typename Problem::RealType, const RealType& getMaxTau() const; void setMPIComm( MPI_Comm comm ); void setVerbose( IndexType v ); void setTimer( Timer* timer ); Loading Loading @@ -97,8 +95,6 @@ protected: RealType maxTau; MPI_Comm solver_comm; IndexType verbosity; Timer* timer; Loading src/TNL/Solvers/ODE/ExplicitSolver_impl.h +0 −9 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ ExplicitSolver() stopTime( 0.0 ), tau( 0.0 ), maxTau( DBL_MAX ), solver_comm( MPI_COMM_WORLD ), verbosity( 0 ), timer( &defaultTimer ), testingMode( false ), Loading Loading @@ -123,14 +122,6 @@ setStopTime( const RealType& stopTime ) this->stopTime = stopTime; } template< class Problem > void ExplicitSolver< Problem >:: setMPIComm( MPI_Comm comm ) { this->solver_comm = comm; }; template< class Problem > void ExplicitSolver< Problem >:: Loading src/TNL/Solvers/ODE/Merson_impl.h +14 −3 Original line number Diff line number Diff line Loading @@ -213,7 +213,9 @@ bool Merson< Problem > :: solve( DofVectorPointer& u ) { currentTau *= 0.8 * ::pow( adaptivity / eps, 0.2 ); currentTau = min( currentTau, this->getMaxTau() ); MPIBcast( currentTau, 1, 0, this->solver_comm ); #ifdef USE_MPI TNLMPI::Bcast( currentTau, 1, 0 ); #endif } if( time + currentTau > this->getStopTime() ) currentTau = this->getStopTime() - time; //we don't want to keep such tau Loading Loading @@ -419,7 +421,11 @@ typename Problem :: RealType Merson< Problem > :: computeError( const RealType t } #endif } MPIAllreduce( eps, maxEps, 1, MPI_MAX, this->solver_comm ); #ifdef USE_MPI TNLMPI::Allreduce( eps, maxEps, 1, MPI_MAX); #else maxEps=eps; #endif return maxEps; } Loading Loading @@ -484,8 +490,13 @@ void Merson< Problem >::computeNewTimeLevel( DofVectorPointer& u, #endif } localResidue /= tau * ( RealType ) size; MPIAllreduce( localResidue, currentResidue, 1, MPI_SUM, this->solver_comm ); #ifdef USE_MPI TNLMPI::Allreduce( localResidue, currentResidue, 1, MPI_SUM); #else currentResidue=localResidue; #endif } Loading src/TNL/mpi-supp.h +27 −44 Original line number Diff line number Diff line Loading @@ -10,54 +10,12 @@ #pragma once #include <iostream> #include <cstdlib> #ifdef USE_MPI #include <mpi.h> #else typedef int MPI_Comm; typedef int MPI_Op; #define MPI_COMM_WORLD 0 #define MPI_MAX 0 #define MPI_SUM 0 template< typename T > void MPIAllreduce( T& data, T& reduced_data, int, MPI_Op, MPI_Comm ) { reduced_data = data; }; template< typename T > void MPIReduce( T& data, T& reduced_data, int, MPI_Op, int, MPI_Comm ) { reduced_data = data; }; template< typename T > void MPIBcast( T&, int, int, MPI_Comm = MPI_COMM_WORLD ) { }; #endif namespace TNL { namespace TNLMPI{ #ifdef USE_MPI inline MPI_Datatype MPIDataType( const signed char ) { return MPI_CHAR; }; inline MPI_Datatype MPIDataType( const signed short int ) { return MPI_SHORT; }; inline MPI_Datatype MPIDataType( const signed int ) { return MPI_INT; }; Loading @@ -82,7 +40,32 @@ namespace TNL { return MPI::COMM_WORLD.Irecv((void*) data, count, MPIDataType(*data) , src, 0); } #endif template< typename T > void Bcast( T& data, int count, int root) { MPI::COMM_WORLD.Bcast((void*) &data, count, MPIDataType(data), root); }; template< typename T > void Allreduce( T& data, T& reduced_data, int count, const MPI_Op &op) { MPI::COMM_WORLD.Allreduce((void*) &data, (void*) &reduced_data,count,MPIDataType(data),op); }; template< typename T > void Reduce( T& data, T& reduced_data, int count, MPI_Op &op, int root) { MPI::COMM_WORLD.Reduce((void*) &data, (void*) &reduced_data,count,MPIDataType(data),op,root); }; }//namespace MPI } // namespace TNL #endif Loading
src/TNL/Solvers/ODE/Euler_impl.h +6 −2 Original line number Diff line number Diff line Loading @@ -231,7 +231,11 @@ void Euler< Problem > :: computeNewTimeLevel( DofVectorPointer& u, localResidue /= tau * ( RealType ) size; MPIAllreduce( localResidue, currentResidue, 1, MPI_SUM, this->solver_comm ); #ifdef USE_MPI TNLMPI::Allreduce( localResidue, currentResidue, 1, MPI_SUM); #else currentResidue=localResidue; #endif } Loading
src/TNL/Solvers/ODE/ExplicitSolver.h +0 −4 Original line number Diff line number Diff line Loading @@ -64,8 +64,6 @@ class ExplicitSolver : public IterativeSolver< typename Problem::RealType, const RealType& getMaxTau() const; void setMPIComm( MPI_Comm comm ); void setVerbose( IndexType v ); void setTimer( Timer* timer ); Loading Loading @@ -97,8 +95,6 @@ protected: RealType maxTau; MPI_Comm solver_comm; IndexType verbosity; Timer* timer; Loading
src/TNL/Solvers/ODE/ExplicitSolver_impl.h +0 −9 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ ExplicitSolver() stopTime( 0.0 ), tau( 0.0 ), maxTau( DBL_MAX ), solver_comm( MPI_COMM_WORLD ), verbosity( 0 ), timer( &defaultTimer ), testingMode( false ), Loading Loading @@ -123,14 +122,6 @@ setStopTime( const RealType& stopTime ) this->stopTime = stopTime; } template< class Problem > void ExplicitSolver< Problem >:: setMPIComm( MPI_Comm comm ) { this->solver_comm = comm; }; template< class Problem > void ExplicitSolver< Problem >:: Loading
src/TNL/Solvers/ODE/Merson_impl.h +14 −3 Original line number Diff line number Diff line Loading @@ -213,7 +213,9 @@ bool Merson< Problem > :: solve( DofVectorPointer& u ) { currentTau *= 0.8 * ::pow( adaptivity / eps, 0.2 ); currentTau = min( currentTau, this->getMaxTau() ); MPIBcast( currentTau, 1, 0, this->solver_comm ); #ifdef USE_MPI TNLMPI::Bcast( currentTau, 1, 0 ); #endif } if( time + currentTau > this->getStopTime() ) currentTau = this->getStopTime() - time; //we don't want to keep such tau Loading Loading @@ -419,7 +421,11 @@ typename Problem :: RealType Merson< Problem > :: computeError( const RealType t } #endif } MPIAllreduce( eps, maxEps, 1, MPI_MAX, this->solver_comm ); #ifdef USE_MPI TNLMPI::Allreduce( eps, maxEps, 1, MPI_MAX); #else maxEps=eps; #endif return maxEps; } Loading Loading @@ -484,8 +490,13 @@ void Merson< Problem >::computeNewTimeLevel( DofVectorPointer& u, #endif } localResidue /= tau * ( RealType ) size; MPIAllreduce( localResidue, currentResidue, 1, MPI_SUM, this->solver_comm ); #ifdef USE_MPI TNLMPI::Allreduce( localResidue, currentResidue, 1, MPI_SUM); #else currentResidue=localResidue; #endif } Loading
src/TNL/mpi-supp.h +27 −44 Original line number Diff line number Diff line Loading @@ -10,54 +10,12 @@ #pragma once #include <iostream> #include <cstdlib> #ifdef USE_MPI #include <mpi.h> #else typedef int MPI_Comm; typedef int MPI_Op; #define MPI_COMM_WORLD 0 #define MPI_MAX 0 #define MPI_SUM 0 template< typename T > void MPIAllreduce( T& data, T& reduced_data, int, MPI_Op, MPI_Comm ) { reduced_data = data; }; template< typename T > void MPIReduce( T& data, T& reduced_data, int, MPI_Op, int, MPI_Comm ) { reduced_data = data; }; template< typename T > void MPIBcast( T&, int, int, MPI_Comm = MPI_COMM_WORLD ) { }; #endif namespace TNL { namespace TNLMPI{ #ifdef USE_MPI inline MPI_Datatype MPIDataType( const signed char ) { return MPI_CHAR; }; inline MPI_Datatype MPIDataType( const signed short int ) { return MPI_SHORT; }; inline MPI_Datatype MPIDataType( const signed int ) { return MPI_INT; }; Loading @@ -82,7 +40,32 @@ namespace TNL { return MPI::COMM_WORLD.Irecv((void*) data, count, MPIDataType(*data) , src, 0); } #endif template< typename T > void Bcast( T& data, int count, int root) { MPI::COMM_WORLD.Bcast((void*) &data, count, MPIDataType(data), root); }; template< typename T > void Allreduce( T& data, T& reduced_data, int count, const MPI_Op &op) { MPI::COMM_WORLD.Allreduce((void*) &data, (void*) &reduced_data,count,MPIDataType(data),op); }; template< typename T > void Reduce( T& data, T& reduced_data, int count, MPI_Op &op, int root) { MPI::COMM_WORLD.Reduce((void*) &data, (void*) &reduced_data,count,MPIDataType(data),op,root); }; }//namespace MPI } // namespace TNL #endif