[553] | 1 | /*! |
---|
| 2 | \file server_distribution_description.hpp |
---|
| 3 | \author Ha NGUYEN |
---|
| 4 | \since 04 Jan 2015 |
---|
[657] | 5 | \date 24 Jul 2015 |
---|
[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" |
---|
[568] | 15 | #include <boost/unordered_map.hpp> |
---|
[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 | { |
---|
| 28 | BAND_DISTRIBUTION, PLAN_DISTRIBUTION |
---|
| 29 | }; |
---|
| 30 | |
---|
| 31 | /** Default constructor */ |
---|
| 32 | CServerDistributionDescription(const std::vector<int>& globalDimensionSize); |
---|
| 33 | /** Default destructor */ |
---|
| 34 | virtual ~CServerDistributionDescription(); |
---|
| 35 | |
---|
[657] | 36 | void computeServerDistribution(int nServer, int positionDimensionDistributed = 1, |
---|
| 37 | bool doComputeGlobalIndex = false, |
---|
[553] | 38 | ServerDistributionType type = BAND_DISTRIBUTION); |
---|
| 39 | |
---|
[568] | 40 | void computeServerGlobalIndexInRange(int nServer, |
---|
| 41 | const std::pair<size_t, size_t>& indexBeginEnd, |
---|
[657] | 42 | int positionDimensionDistributed = 1, |
---|
[568] | 43 | ServerDistributionType = BAND_DISTRIBUTION); |
---|
[553] | 44 | |
---|
| 45 | std::vector<std::vector<int> > getServerIndexBegin() const; |
---|
| 46 | std::vector<std::vector<int> > getServerDimensionSizes() const; |
---|
[653] | 47 | const std::vector<CArray<size_t,1> >& getGlobalIndex() const; |
---|
[568] | 48 | const boost::unordered_map<size_t,int>& getGlobalIndexRange() const; |
---|
[554] | 49 | |
---|
[553] | 50 | protected: |
---|
[657] | 51 | void computeBandDistribution(int nServer, int positionDimensionDistributed = 1); |
---|
[553] | 52 | void computePlanDistribution(int nServer); |
---|
| 53 | |
---|
| 54 | private: |
---|
| 55 | std::vector<std::vector<int> > indexBegin_; //!< Begin index of each dimension |
---|
| 56 | std::vector<std::vector<int> > dimensionSizes_; //!< Size of each dimension |
---|
| 57 | std::vector<int> nGlobal_; //!< Global size of each dimension |
---|
| 58 | |
---|
| 59 | //!< General case, index describes distribution of each server (rarely use) |
---|
[653] | 60 | std::vector<CArray<size_t,1> > vecGlobalIndex_; |
---|
[553] | 61 | |
---|
| 62 | //!< In case we need only global index of one server with specific rank |
---|
[568] | 63 | boost::unordered_map<size_t,int> globalIndex_; |
---|
[553] | 64 | }; |
---|
| 65 | |
---|
| 66 | } // namespace xios |
---|
| 67 | #endif // __XIOS_SERVER_DISTRIBUTION_DESCRIPTION_HPP |
---|