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