/*! \file policy.hpp \author Ha NGUYEN \since 06 Oct 2015 \date 06 Oct 2015 \brief Some useful policies for templated classes */ #ifndef __XIOS_POLICY_HPP__ #define __XIOS_POLICY_HPP__ #include #include "mpi.hpp" namespace xios { class DivideCommByTwo { protected: void computeMPICommLevel(const MPI_Comm& mpiCommRoot, int levels); protected: std::vector commLevel_; private: // Divide MPI communicator on each level recursively void divideMPICommLevel(const MPI_Comm& mpiCommLevel, int level); }; class DivideAdaptiveComm { protected: DivideAdaptiveComm(const MPI_Comm& mpiComm); void computeMPICommLevel(); const std::vector& getGroupBegin() { return groupBegin_; } const std::vector& getNbInGroup() { return nbInGroup_; } const std::vector >& getGroupParentsBegin() { return groupParentsBegin_; } const std::vector >& getNbInGroupParents() { return nbInGroupParents_; } int getNbLevel() { return level_; } protected: const MPI_Comm& internalComm_; std::vector > groupParentsBegin_; std::vector > nbInGroupParents_; int level_; std::vector groupBegin_; //! Rank beginning of a group std::vector nbInGroup_; //! Number of process in each group bool computed_; // std::vector > child_; /*!< List of child rank for each level */ // std::vector nbChild_; /*!< Number of child for each level */ }; } #endif // __XIOS_POLICY_HPP__