1 | /*! |
---|
2 | \file server_distribution_description.hpp |
---|
3 | \author Ha NGUYEN |
---|
4 | \since 04 Jan 2015 |
---|
5 | \date 11 Jan 2016 |
---|
6 | |
---|
7 | \brief Description of index distribution on server(s). |
---|
8 | */ |
---|
9 | |
---|
10 | #ifndef __XIOS_SERVER_DISTRIBUTION_DESCRIPTION_HPP |
---|
11 | #define __XIOS_SERVER_DISTRIBUTION_DESCRIPTION_HPP |
---|
12 | |
---|
13 | #include "xios_spl.hpp" |
---|
14 | #include "array_new.hpp" |
---|
15 | #include <boost/unordered_map.hpp> |
---|
16 | |
---|
17 | namespace xios |
---|
18 | { |
---|
19 | /*! |
---|
20 | \class CServerDistributionDescription |
---|
21 | This class contains information that describe distribution of servers. |
---|
22 | */ |
---|
23 | class CServerDistributionDescription |
---|
24 | { |
---|
25 | public: |
---|
26 | enum ServerDistributionType |
---|
27 | { |
---|
28 | BAND_DISTRIBUTION, PLAN_DISTRIBUTION |
---|
29 | }; |
---|
30 | |
---|
31 | /** Default constructor */ |
---|
32 | CServerDistributionDescription(const std::vector<int>& globalDimensionSize, |
---|
33 | int nServer, |
---|
34 | ServerDistributionType serType=BAND_DISTRIBUTION); |
---|
35 | |
---|
36 | /** Default destructor */ |
---|
37 | virtual ~CServerDistributionDescription(); |
---|
38 | |
---|
39 | void computeServerDistribution(bool doComputeGlobalIndex = false, int positionDimensionDistributed = 1); |
---|
40 | std::vector<int> computeServerGlobalIndexInRange(const std::pair<size_t, size_t>& indexBeginEnd, int positionDimensionDistributed = 1); |
---|
41 | std::vector<int> computeServerGlobalByElement(std::vector<boost::unordered_map<size_t,std::vector<int> > >& indexServerOnElement, |
---|
42 | int rank, |
---|
43 | int clientSize, |
---|
44 | const CArray<int,1>& axisDomainOrder, |
---|
45 | int positionDimensionDistributed = 1); |
---|
46 | |
---|
47 | std::vector<std::vector<int> > getServerIndexBegin() const; |
---|
48 | std::vector<std::vector<int> > getServerDimensionSizes() const; |
---|
49 | const std::vector<CArray<size_t,1> >& getGlobalIndex() const; |
---|
50 | const boost::unordered_map<size_t,int>& getGlobalIndexRange() const; |
---|
51 | int getDimensionDistributed(); |
---|
52 | |
---|
53 | static int defaultDistributedDimension(int gridDimension, |
---|
54 | ServerDistributionType serType=BAND_DISTRIBUTION); |
---|
55 | |
---|
56 | protected: |
---|
57 | int computeBandDistribution(int nServer, int positionDimensionDistributed = 1); |
---|
58 | void computePlanDistribution(int nServer); |
---|
59 | void computeRangeProcIndex(int clientRank, |
---|
60 | int clientSize, |
---|
61 | int rangeProcSize, |
---|
62 | int& rangeBegin, |
---|
63 | int& rangeSize); |
---|
64 | |
---|
65 | private: |
---|
66 | std::vector<std::vector<int> > indexBegin_; //!< Begin index of each dimension |
---|
67 | std::vector<std::vector<int> > dimensionSizes_; //!< Size of each dimension |
---|
68 | std::vector<int> nGlobal_; //!< Global size of each dimension |
---|
69 | |
---|
70 | //!< General case, index describes distribution of each server (rarely use) |
---|
71 | std::vector<CArray<size_t,1> > vecGlobalIndex_; |
---|
72 | |
---|
73 | //!< In case we need only global index of one server with specific rank |
---|
74 | boost::unordered_map<size_t,int> globalIndex_; |
---|
75 | |
---|
76 | //!< Type of distribution on server side |
---|
77 | ServerDistributionType serverType_; |
---|
78 | |
---|
79 | //!< Number of server |
---|
80 | int nServer_; |
---|
81 | |
---|
82 | //!< Position of dimension distributed on server side (by default, the second dimension) |
---|
83 | int positionDimensionDistributed_; |
---|
84 | }; |
---|
85 | |
---|
86 | } // namespace xios |
---|
87 | #endif // __XIOS_SERVER_DISTRIBUTION_DESCRIPTION_HPP |
---|