Loading src/TNL/Communicators/CMakeLists.txt +1 −0 Original line number Diff line number Diff line SET( headers MpiCommunicator.h MpiDefs.h MPIPrint.h MPITypeResolver.h NoDistrCommunicator.h ScopedInitializer.h Loading src/TNL/Communicators/MpiCommunicator.h +0 −48 Original line number Diff line number Diff line Loading @@ -541,51 +541,3 @@ bool MpiCommunicator::redirect = true; } // namespace Communicators } // namespace TNL #ifdef HAVE_MPI #define TNL_MPI_PRINT( message ) \ if( ! TNL::Communicators::MpiCommunicator::IsInitialized() ) \ std::cerr << message << std::endl; \ else \ for( int __tnl_mpi_print_j = 0; \ __tnl_mpi_print_j < TNL::Communicators::MpiCommunicator::GetSize( TNL::Communicators::MpiCommunicator::AllGroup ); \ __tnl_mpi_print_j++ ) \ { \ if( __tnl_mpi_print_j == TNL::Communicators::MpiCommunicator::GetRank( TNL::Communicators::MpiCommunicator::AllGroup ) ) \ { \ std::cerr << "Node " << __tnl_mpi_print_j << " of " \ << TNL::Communicators::MpiCommunicator::GetSize( TNL::Communicators::MpiCommunicator::AllGroup ) \ << " : " << message << std::endl << std::flush; \ } \ TNL::Communicators::MpiCommunicator::Barrier( TNL::Communicators::MpiCommunicator::AllGroup ); \ } #else #define TNL_MPI_PRINT( message ) \ std::cerr << message << std::endl; #endif #ifdef HAVE_MPI #define TNL_MPI_PRINT_COND( condition, message ) \ if( ! TNL::Communicators::MpiCommunicator::IsInitialized() ) \ { \ if( condition ) std::cerr << message << std::endl; \ } \ else \ { \ for( int __tnl_mpi_print_j = 0; \ __tnl_mpi_print_j < TNL::Communicators::MpiCommunicator::GetSize( TNL::Communicators::MpiCommunicator::AllGroup ); \ __tnl_mpi_print_j++ ) \ { \ if( __tnl_mpi_print_j == TNL::Communicators::MpiCommunicator::GetRank( TNL::Communicators::MpiCommunicator::AllGroup ) ) \ { \ if( condition ) \ std::cerr << "Node " << __tnl_mpi_print_j << " of " \ << TNL::Communicators::MpiCommunicator::GetSize( TNL::Communicators::MpiCommunicator::AllGroup ) \ << " : " << message << std::endl << std::flush; \ } \ TNL::Communicators::MpiCommunicator::Barrier( TNL::Communicators::MpiCommunicator::AllGroup ); \ } \ } #else #define TNL_MPI_PRINT_COND( condition, message ) \ if( condition ) std::cerr << message << std::endl; #endif src/TNL/Meshes/DistributedMeshes/DistributedGridSynchronizer.h +2 −2 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ #include <TNL/Containers/Array.h> #include <TNL/Meshes/DistributedMeshes/BufferEntitiesHelper.h> #include <TNL/Meshes/DistributedMeshes/Directions.h> #include <TNL/Communicators/MPIPrint.h> namespace TNL { namespace Functions{ Loading Loading @@ -123,7 +124,6 @@ class DistributedMeshSynchronizer< Functions::MeshFunction< Grid< MeshDimension, recieveBegin[i]=tmp; } } } } Loading src/TNL/String.h +18 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,10 @@ #include <vector> #include <string> #ifdef HAVE_MPI #include <mpi.h> #endif namespace TNL { class String; Loading Loading @@ -210,8 +214,21 @@ public: /// @param separator Character, which separates substrings in given string. std::vector< String > split( const char separator = ' ', bool skipEmpty = false ) const; #ifdef HAVE_MPI /**** * \brief Sends the string to the target MPI process. */ void send( int target, int tag = 0, MPI_Comm mpi_comm = MPI_COMM_WORLD ); /**** * \brief Receives a string from the source MPI process. */ void receive( int source, int tag = 0, MPI_Comm mpi_comm = MPI_COMM_WORLD ); //! Broadcast to other nodes in MPI cluster // void MPIBcast( int root, MPI_Comm mpi_comm = MPI_COMM_WORLD ); #endif }; /// \brief Returns concatenation of \e string1 and \e string2. Loading src/TNL/String_impl.h +21 −8 Original line number Diff line number Diff line Loading @@ -13,9 +13,9 @@ #include <TNL/String.h> #include <TNL/Assert.h> #include <TNL/Math.h> //#ifdef USE_MPI // #include <mpi.h> //#endif #ifdef HAVE_MPI #include <mpi.h> #endif namespace TNL { Loading Loading @@ -233,18 +233,32 @@ String::split( const char separator, bool skipEmpty ) const return parts; } #ifdef HAVE_MPI inline void String::send( int target, int tag, MPI_Comm mpi_comm ) { int size = this->getSize(); MPI_Send( &size, 1, MPI_INT, target, tag, mpi_comm ); MPI_Send( this->getString(), this->length(), MPI_CHAR, target, tag, mpi_comm ); } inline void String::receive( int source, int tag, MPI_Comm mpi_comm ) { int size; MPI_Status status; MPI_Recv( &size, 1, MPI_INT, source, tag, mpi_comm, &status ); this->setSize( size ); MPI_Recv( const_cast< void* >( ( const void* ) this->data() ), size, MPI_CHAR, source, tag, mpi_comm, &status ); } /* inline void String :: MPIBcast( int root, MPI_Comm comm ) { #ifdef USE_MPI dbgFunctionName( "mString", "MPIBcast" ); int iproc; MPI_Comm_rank( MPI_COMM_WORLD, &iproc ); TNL_ASSERT( string, ); int len = strlen( string ); MPI_Bcast( &len, 1, MPI_INT, root, comm ); dbgExpr( iproc ); dbgExpr( len ); if( iproc != root ) { if( length < len ) Loading @@ -256,11 +270,10 @@ inline void String :: MPIBcast( int root, MPI_Comm comm ) } MPI_Bcast( string, len + 1, MPI_CHAR, root, comm ); dbgExpr( iproc ); dbgExpr( string ); #endif } */ #endif inline String operator+( char string1, const String& string2 ) { Loading Loading
src/TNL/Communicators/CMakeLists.txt +1 −0 Original line number Diff line number Diff line SET( headers MpiCommunicator.h MpiDefs.h MPIPrint.h MPITypeResolver.h NoDistrCommunicator.h ScopedInitializer.h Loading
src/TNL/Communicators/MpiCommunicator.h +0 −48 Original line number Diff line number Diff line Loading @@ -541,51 +541,3 @@ bool MpiCommunicator::redirect = true; } // namespace Communicators } // namespace TNL #ifdef HAVE_MPI #define TNL_MPI_PRINT( message ) \ if( ! TNL::Communicators::MpiCommunicator::IsInitialized() ) \ std::cerr << message << std::endl; \ else \ for( int __tnl_mpi_print_j = 0; \ __tnl_mpi_print_j < TNL::Communicators::MpiCommunicator::GetSize( TNL::Communicators::MpiCommunicator::AllGroup ); \ __tnl_mpi_print_j++ ) \ { \ if( __tnl_mpi_print_j == TNL::Communicators::MpiCommunicator::GetRank( TNL::Communicators::MpiCommunicator::AllGroup ) ) \ { \ std::cerr << "Node " << __tnl_mpi_print_j << " of " \ << TNL::Communicators::MpiCommunicator::GetSize( TNL::Communicators::MpiCommunicator::AllGroup ) \ << " : " << message << std::endl << std::flush; \ } \ TNL::Communicators::MpiCommunicator::Barrier( TNL::Communicators::MpiCommunicator::AllGroup ); \ } #else #define TNL_MPI_PRINT( message ) \ std::cerr << message << std::endl; #endif #ifdef HAVE_MPI #define TNL_MPI_PRINT_COND( condition, message ) \ if( ! TNL::Communicators::MpiCommunicator::IsInitialized() ) \ { \ if( condition ) std::cerr << message << std::endl; \ } \ else \ { \ for( int __tnl_mpi_print_j = 0; \ __tnl_mpi_print_j < TNL::Communicators::MpiCommunicator::GetSize( TNL::Communicators::MpiCommunicator::AllGroup ); \ __tnl_mpi_print_j++ ) \ { \ if( __tnl_mpi_print_j == TNL::Communicators::MpiCommunicator::GetRank( TNL::Communicators::MpiCommunicator::AllGroup ) ) \ { \ if( condition ) \ std::cerr << "Node " << __tnl_mpi_print_j << " of " \ << TNL::Communicators::MpiCommunicator::GetSize( TNL::Communicators::MpiCommunicator::AllGroup ) \ << " : " << message << std::endl << std::flush; \ } \ TNL::Communicators::MpiCommunicator::Barrier( TNL::Communicators::MpiCommunicator::AllGroup ); \ } \ } #else #define TNL_MPI_PRINT_COND( condition, message ) \ if( condition ) std::cerr << message << std::endl; #endif
src/TNL/Meshes/DistributedMeshes/DistributedGridSynchronizer.h +2 −2 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ #include <TNL/Containers/Array.h> #include <TNL/Meshes/DistributedMeshes/BufferEntitiesHelper.h> #include <TNL/Meshes/DistributedMeshes/Directions.h> #include <TNL/Communicators/MPIPrint.h> namespace TNL { namespace Functions{ Loading Loading @@ -123,7 +124,6 @@ class DistributedMeshSynchronizer< Functions::MeshFunction< Grid< MeshDimension, recieveBegin[i]=tmp; } } } } Loading
src/TNL/String.h +18 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,10 @@ #include <vector> #include <string> #ifdef HAVE_MPI #include <mpi.h> #endif namespace TNL { class String; Loading Loading @@ -210,8 +214,21 @@ public: /// @param separator Character, which separates substrings in given string. std::vector< String > split( const char separator = ' ', bool skipEmpty = false ) const; #ifdef HAVE_MPI /**** * \brief Sends the string to the target MPI process. */ void send( int target, int tag = 0, MPI_Comm mpi_comm = MPI_COMM_WORLD ); /**** * \brief Receives a string from the source MPI process. */ void receive( int source, int tag = 0, MPI_Comm mpi_comm = MPI_COMM_WORLD ); //! Broadcast to other nodes in MPI cluster // void MPIBcast( int root, MPI_Comm mpi_comm = MPI_COMM_WORLD ); #endif }; /// \brief Returns concatenation of \e string1 and \e string2. Loading
src/TNL/String_impl.h +21 −8 Original line number Diff line number Diff line Loading @@ -13,9 +13,9 @@ #include <TNL/String.h> #include <TNL/Assert.h> #include <TNL/Math.h> //#ifdef USE_MPI // #include <mpi.h> //#endif #ifdef HAVE_MPI #include <mpi.h> #endif namespace TNL { Loading Loading @@ -233,18 +233,32 @@ String::split( const char separator, bool skipEmpty ) const return parts; } #ifdef HAVE_MPI inline void String::send( int target, int tag, MPI_Comm mpi_comm ) { int size = this->getSize(); MPI_Send( &size, 1, MPI_INT, target, tag, mpi_comm ); MPI_Send( this->getString(), this->length(), MPI_CHAR, target, tag, mpi_comm ); } inline void String::receive( int source, int tag, MPI_Comm mpi_comm ) { int size; MPI_Status status; MPI_Recv( &size, 1, MPI_INT, source, tag, mpi_comm, &status ); this->setSize( size ); MPI_Recv( const_cast< void* >( ( const void* ) this->data() ), size, MPI_CHAR, source, tag, mpi_comm, &status ); } /* inline void String :: MPIBcast( int root, MPI_Comm comm ) { #ifdef USE_MPI dbgFunctionName( "mString", "MPIBcast" ); int iproc; MPI_Comm_rank( MPI_COMM_WORLD, &iproc ); TNL_ASSERT( string, ); int len = strlen( string ); MPI_Bcast( &len, 1, MPI_INT, root, comm ); dbgExpr( iproc ); dbgExpr( len ); if( iproc != root ) { if( length < len ) Loading @@ -256,11 +270,10 @@ inline void String :: MPIBcast( int root, MPI_Comm comm ) } MPI_Bcast( string, len + 1, MPI_CHAR, root, comm ); dbgExpr( iproc ); dbgExpr( string ); #endif } */ #endif inline String operator+( char string1, const String& string2 ) { Loading