Loading src/TNL/Communicators/MpiCommunicator.h +36 −48 Original line number Original line Diff line number Diff line Loading @@ -146,11 +146,6 @@ class MpiCommunicator { { #ifdef HAVE_MPI #ifdef HAVE_MPI MPI_Init( &argc, &argv ); MPI_Init( &argc, &argv ); NullRequest=MPI_REQUEST_NULL; AllGroup=MPI_COMM_WORLD; NullGroup=MPI_COMM_NULL; redirect = true; selectGPU(); selectGPU(); #endif #endif } } Loading @@ -171,9 +166,8 @@ class MpiCommunicator //redirect output to files... //redirect output to files... if(GetRank(AllGroup)!=0) if(GetRank(AllGroup)!=0) { { std::cout<< GetRank(AllGroup) <<": Redirecting std::out to file" <<std::endl; std::cout << GetRank(AllGroup) << ": Redirecting std::cout to file" << std::endl; String stdoutFile; const String stdoutFile = String("./stdout-") + convertToString(GetRank(AllGroup)) + String(".txt"); stdoutFile=String( "./stdout-")+convertToString(GetRank(MPI_COMM_WORLD))+String(".txt"); filestr.open(stdoutFile.getString()); filestr.open(stdoutFile.getString()); psbuf = filestr.rdbuf(); psbuf = filestr.rdbuf(); std::cout.rdbuf(psbuf); std::cout.rdbuf(psbuf); Loading Loading @@ -434,16 +428,15 @@ class MpiCommunicator static MPI_Comm AllGroup; static MPI_Comm AllGroup; static MPI_Comm NullGroup; static MPI_Comm NullGroup; #else #else static int NullRequest; static constexpr int NullRequest = -1; static int AllGroup; static constexpr int AllGroup = 1; static int NullGroup; static constexpr int NullGroup = 0; #endif #endif private : private : static std::streambuf* psbuf; static std::streambuf* psbuf; static std::streambuf* backup; static std::streambuf* backup; static std::ofstream filestr; static std::ofstream filestr; static bool redirect; static bool redirect; static bool inited; static void selectGPU(void) static void selectGPU(void) { { Loading Loading @@ -489,25 +482,20 @@ class MpiCommunicator }; }; #ifdef HAVE_MPI #ifdef HAVE_MPI MPI_Request MpiCommunicator::NullRequest; MPI_Request MpiCommunicator::NullRequest = MPI_REQUEST_NULL; MPI_Comm MpiCommunicator::AllGroup; MPI_Comm MpiCommunicator::AllGroup = MPI_COMM_WORLD; MPI_Comm MpiCommunicator::NullGroup; MPI_Comm MpiCommunicator::NullGroup = MPI_COMM_NULL; #else int MpiCommunicator::NullRequest; int MpiCommunicator::AllGroup; int MpiCommunicator::NullGroup; #endif #endif std::streambuf *MpiCommunicator::psbuf; std::streambuf* MpiCommunicator::psbuf = nullptr; std::streambuf *MpiCommunicator::backup; std::streambuf* MpiCommunicator::backup = nullptr; std::ofstream MpiCommunicator::filestr; std::ofstream MpiCommunicator::filestr; bool MpiCommunicator::redirect; bool MpiCommunicator::redirect = true; bool MpiCommunicator::inited; #ifdef HAVE_MPI #ifdef HAVE_MPI // TODO: this duplicates MpiCommunicator::MPIDataType template<typename Type> template<typename Type> class MPITypeResolver struct MPITypeResolver { { public: static inline MPI_Datatype getType() static inline MPI_Datatype getType() { { TNL_ASSERT_TRUE(false, "Fatal Error - Unknown MPI Type"); TNL_ASSERT_TRUE(false, "Fatal Error - Unknown MPI Type"); Loading @@ -515,54 +503,54 @@ class MPITypeResolver }; }; }; }; template<> class MPITypeResolver<char> template<> struct MPITypeResolver<char> { { public:static inline MPI_Datatype getType(){return MPI_CHAR;}; static inline MPI_Datatype getType(){return MPI_CHAR;}; }; }; template<> class MPITypeResolver<short int> template<> struct MPITypeResolver<short int> { { public:static inline MPI_Datatype getType(){return MPI_SHORT;}; static inline MPI_Datatype getType(){return MPI_SHORT;}; }; }; template<> class MPITypeResolver<long int> template<> struct MPITypeResolver<long int> { { public:static inline MPI_Datatype getType(){return MPI_LONG;}; static inline MPI_Datatype getType(){return MPI_LONG;}; }; }; template<> class MPITypeResolver<unsigned char> template<> struct MPITypeResolver<unsigned char> { { public:static inline MPI_Datatype getType(){return MPI_UNSIGNED_CHAR;}; static inline MPI_Datatype getType(){return MPI_UNSIGNED_CHAR;}; }; }; template<> class MPITypeResolver<unsigned short int> template<> struct MPITypeResolver<unsigned short int> { { public:static inline MPI_Datatype getType(){return MPI_UNSIGNED_SHORT;}; static inline MPI_Datatype getType(){return MPI_UNSIGNED_SHORT;}; }; }; template<> class MPITypeResolver<unsigned int> template<> struct MPITypeResolver<unsigned int> { { public:static inline MPI_Datatype getType(){return MPI_UNSIGNED;}; static inline MPI_Datatype getType(){return MPI_UNSIGNED;}; }; }; template<> class MPITypeResolver<unsigned long int> template<> struct MPITypeResolver<unsigned long int> { { public:static inline MPI_Datatype getType(){return MPI_UNSIGNED_LONG;}; static inline MPI_Datatype getType(){return MPI_UNSIGNED_LONG;}; }; }; template<> class MPITypeResolver<float> template<> struct MPITypeResolver<float> { { public:static inline MPI_Datatype getType(){return MPI_FLOAT;}; static inline MPI_Datatype getType(){return MPI_FLOAT;}; }; }; template<> class MPITypeResolver<double> template<> struct MPITypeResolver<double> { { public:static inline MPI_Datatype getType(){return MPI_DOUBLE;}; static inline MPI_Datatype getType(){return MPI_DOUBLE;}; }; }; template<> class MPITypeResolver<long double> template<> struct MPITypeResolver<long double> { { public:static inline MPI_Datatype getType(){return MPI_LONG_DOUBLE;}; static inline MPI_Datatype getType(){return MPI_LONG_DOUBLE;}; }; }; #endif #endif Loading src/TNL/Communicators/NoDistrCommunicator.h +4 −14 Original line number Original line Diff line number Diff line Loading @@ -29,9 +29,9 @@ class NoDistrCommunicator typedef int Request; typedef int Request; typedef int CommunicationGroup; typedef int CommunicationGroup; static Request NullRequest; static constexpr Request NullRequest = -1; static CommunicationGroup AllGroup; static constexpr CommunicationGroup AllGroup = 1; static CommunicationGroup NullGroup; static constexpr CommunicationGroup NullGroup = 0; static void configSetup( Config::ConfigDescription& config, const String& prefix = "" ){}; static void configSetup( Config::ConfigDescription& config, const String& prefix = "" ){}; Loading @@ -41,12 +41,7 @@ class NoDistrCommunicator return true; return true; } } static void Init(int argc, char **argv, bool redirect=false) static void Init(int argc, char **argv, bool redirect=false) {} { NullRequest = -1; AllGroup = 1; NullGroup = 0; } static void setRedirection( bool redirect_ ) {} static void setRedirection( bool redirect_ ) {} Loading Loading @@ -136,11 +131,6 @@ class NoDistrCommunicator static void writeProlog( Logger& logger ){}; static void writeProlog( Logger& logger ){}; }; }; int NoDistrCommunicator::NullRequest; int NoDistrCommunicator::AllGroup; int NoDistrCommunicator::NullGroup; } // namespace <unnamed> } // namespace <unnamed> } // namespace Communicators } // namespace Communicators } // namespace TNL } // namespace TNL Loading
src/TNL/Communicators/MpiCommunicator.h +36 −48 Original line number Original line Diff line number Diff line Loading @@ -146,11 +146,6 @@ class MpiCommunicator { { #ifdef HAVE_MPI #ifdef HAVE_MPI MPI_Init( &argc, &argv ); MPI_Init( &argc, &argv ); NullRequest=MPI_REQUEST_NULL; AllGroup=MPI_COMM_WORLD; NullGroup=MPI_COMM_NULL; redirect = true; selectGPU(); selectGPU(); #endif #endif } } Loading @@ -171,9 +166,8 @@ class MpiCommunicator //redirect output to files... //redirect output to files... if(GetRank(AllGroup)!=0) if(GetRank(AllGroup)!=0) { { std::cout<< GetRank(AllGroup) <<": Redirecting std::out to file" <<std::endl; std::cout << GetRank(AllGroup) << ": Redirecting std::cout to file" << std::endl; String stdoutFile; const String stdoutFile = String("./stdout-") + convertToString(GetRank(AllGroup)) + String(".txt"); stdoutFile=String( "./stdout-")+convertToString(GetRank(MPI_COMM_WORLD))+String(".txt"); filestr.open(stdoutFile.getString()); filestr.open(stdoutFile.getString()); psbuf = filestr.rdbuf(); psbuf = filestr.rdbuf(); std::cout.rdbuf(psbuf); std::cout.rdbuf(psbuf); Loading Loading @@ -434,16 +428,15 @@ class MpiCommunicator static MPI_Comm AllGroup; static MPI_Comm AllGroup; static MPI_Comm NullGroup; static MPI_Comm NullGroup; #else #else static int NullRequest; static constexpr int NullRequest = -1; static int AllGroup; static constexpr int AllGroup = 1; static int NullGroup; static constexpr int NullGroup = 0; #endif #endif private : private : static std::streambuf* psbuf; static std::streambuf* psbuf; static std::streambuf* backup; static std::streambuf* backup; static std::ofstream filestr; static std::ofstream filestr; static bool redirect; static bool redirect; static bool inited; static void selectGPU(void) static void selectGPU(void) { { Loading Loading @@ -489,25 +482,20 @@ class MpiCommunicator }; }; #ifdef HAVE_MPI #ifdef HAVE_MPI MPI_Request MpiCommunicator::NullRequest; MPI_Request MpiCommunicator::NullRequest = MPI_REQUEST_NULL; MPI_Comm MpiCommunicator::AllGroup; MPI_Comm MpiCommunicator::AllGroup = MPI_COMM_WORLD; MPI_Comm MpiCommunicator::NullGroup; MPI_Comm MpiCommunicator::NullGroup = MPI_COMM_NULL; #else int MpiCommunicator::NullRequest; int MpiCommunicator::AllGroup; int MpiCommunicator::NullGroup; #endif #endif std::streambuf *MpiCommunicator::psbuf; std::streambuf* MpiCommunicator::psbuf = nullptr; std::streambuf *MpiCommunicator::backup; std::streambuf* MpiCommunicator::backup = nullptr; std::ofstream MpiCommunicator::filestr; std::ofstream MpiCommunicator::filestr; bool MpiCommunicator::redirect; bool MpiCommunicator::redirect = true; bool MpiCommunicator::inited; #ifdef HAVE_MPI #ifdef HAVE_MPI // TODO: this duplicates MpiCommunicator::MPIDataType template<typename Type> template<typename Type> class MPITypeResolver struct MPITypeResolver { { public: static inline MPI_Datatype getType() static inline MPI_Datatype getType() { { TNL_ASSERT_TRUE(false, "Fatal Error - Unknown MPI Type"); TNL_ASSERT_TRUE(false, "Fatal Error - Unknown MPI Type"); Loading @@ -515,54 +503,54 @@ class MPITypeResolver }; }; }; }; template<> class MPITypeResolver<char> template<> struct MPITypeResolver<char> { { public:static inline MPI_Datatype getType(){return MPI_CHAR;}; static inline MPI_Datatype getType(){return MPI_CHAR;}; }; }; template<> class MPITypeResolver<short int> template<> struct MPITypeResolver<short int> { { public:static inline MPI_Datatype getType(){return MPI_SHORT;}; static inline MPI_Datatype getType(){return MPI_SHORT;}; }; }; template<> class MPITypeResolver<long int> template<> struct MPITypeResolver<long int> { { public:static inline MPI_Datatype getType(){return MPI_LONG;}; static inline MPI_Datatype getType(){return MPI_LONG;}; }; }; template<> class MPITypeResolver<unsigned char> template<> struct MPITypeResolver<unsigned char> { { public:static inline MPI_Datatype getType(){return MPI_UNSIGNED_CHAR;}; static inline MPI_Datatype getType(){return MPI_UNSIGNED_CHAR;}; }; }; template<> class MPITypeResolver<unsigned short int> template<> struct MPITypeResolver<unsigned short int> { { public:static inline MPI_Datatype getType(){return MPI_UNSIGNED_SHORT;}; static inline MPI_Datatype getType(){return MPI_UNSIGNED_SHORT;}; }; }; template<> class MPITypeResolver<unsigned int> template<> struct MPITypeResolver<unsigned int> { { public:static inline MPI_Datatype getType(){return MPI_UNSIGNED;}; static inline MPI_Datatype getType(){return MPI_UNSIGNED;}; }; }; template<> class MPITypeResolver<unsigned long int> template<> struct MPITypeResolver<unsigned long int> { { public:static inline MPI_Datatype getType(){return MPI_UNSIGNED_LONG;}; static inline MPI_Datatype getType(){return MPI_UNSIGNED_LONG;}; }; }; template<> class MPITypeResolver<float> template<> struct MPITypeResolver<float> { { public:static inline MPI_Datatype getType(){return MPI_FLOAT;}; static inline MPI_Datatype getType(){return MPI_FLOAT;}; }; }; template<> class MPITypeResolver<double> template<> struct MPITypeResolver<double> { { public:static inline MPI_Datatype getType(){return MPI_DOUBLE;}; static inline MPI_Datatype getType(){return MPI_DOUBLE;}; }; }; template<> class MPITypeResolver<long double> template<> struct MPITypeResolver<long double> { { public:static inline MPI_Datatype getType(){return MPI_LONG_DOUBLE;}; static inline MPI_Datatype getType(){return MPI_LONG_DOUBLE;}; }; }; #endif #endif Loading
src/TNL/Communicators/NoDistrCommunicator.h +4 −14 Original line number Original line Diff line number Diff line Loading @@ -29,9 +29,9 @@ class NoDistrCommunicator typedef int Request; typedef int Request; typedef int CommunicationGroup; typedef int CommunicationGroup; static Request NullRequest; static constexpr Request NullRequest = -1; static CommunicationGroup AllGroup; static constexpr CommunicationGroup AllGroup = 1; static CommunicationGroup NullGroup; static constexpr CommunicationGroup NullGroup = 0; static void configSetup( Config::ConfigDescription& config, const String& prefix = "" ){}; static void configSetup( Config::ConfigDescription& config, const String& prefix = "" ){}; Loading @@ -41,12 +41,7 @@ class NoDistrCommunicator return true; return true; } } static void Init(int argc, char **argv, bool redirect=false) static void Init(int argc, char **argv, bool redirect=false) {} { NullRequest = -1; AllGroup = 1; NullGroup = 0; } static void setRedirection( bool redirect_ ) {} static void setRedirection( bool redirect_ ) {} Loading Loading @@ -136,11 +131,6 @@ class NoDistrCommunicator static void writeProlog( Logger& logger ){}; static void writeProlog( Logger& logger ){}; }; }; int NoDistrCommunicator::NullRequest; int NoDistrCommunicator::AllGroup; int NoDistrCommunicator::NullGroup; } // namespace <unnamed> } // namespace <unnamed> } // namespace Communicators } // namespace Communicators } // namespace TNL } // namespace TNL