source: XIOS/trunk/src/policy.hpp @ 833

Last change on this file since 833 was 833, checked in by mhnguyen, 5 years ago

Improvements for dht

+) Implement adaptive hierarchy for dht, level of hierarchy depends on number of processes
+) Remove some redundant codes

Test
+) On Curie
+) All tests are correct

File size: 1.5 KB
Line 
1/*!
2   \file policy.hpp
3   \author Ha NGUYEN
4   \since 06 Oct 2015
5   \date 06 Oct 2015
6
7   \brief Some useful policies for templated classes
8 */
9
10#ifndef __XIOS_POLICY_HPP__
11#define __XIOS_POLICY_HPP__
12
13#include <vector>
14#include "mpi.hpp"
15
16namespace xios
17{
18class DivideCommByTwo
19{
20protected:
21  void computeMPICommLevel(const MPI_Comm& mpiCommRoot, int levels);
22
23protected:
24  std::vector<MPI_Comm> commLevel_;
25private:
26  // Divide MPI communicator on each level recursively
27  void divideMPICommLevel(const MPI_Comm& mpiCommLevel, int level);
28};
29
30class DivideAdaptiveComm
31{
32protected:
33  DivideAdaptiveComm(const MPI_Comm& mpiComm);
34
35  void computeMPICommLevel();
36  const std::vector<int>& getGroupBegin() { return groupBegin_; }
37  const std::vector<int>& getNbInGroup() { return nbInGroup_; }
38  const std::vector<std::vector<int> >& getGroupParentsBegin() { return groupParentsBegin_; }
39  const std::vector<std::vector<int> >& getNbInGroupParents() { return nbInGroupParents_; }
40  int getNbLevel() { return level_; }
41
42protected:
43  const MPI_Comm& internalComm_;
44  std::vector<std::vector<int> > groupParentsBegin_;
45  std::vector<std::vector<int> > nbInGroupParents_;
46
47  int level_;
48  std::vector<int> groupBegin_;  //! Rank beginning of a group
49  std::vector<int> nbInGroup_; //! Number of process in each group
50  bool computed_;
51//  std::vector<std::vector<int> > child_; /*!< List of child rank for each level */
52//  std::vector<int> nbChild_;         /*!< Number of child for each level */
53};
54
55}
56
57#endif // __XIOS_POLICY_HPP__
Note: See TracBrowser for help on using the repository browser.