source: XIOS/trunk/src/server_distribution_description.hpp @ 1314

Last change on this file since 1314 was 887, checked in by mhnguyen, 8 years ago

Adding a new type of element into grid: Scalar

+) Add a new node Scalar for xml
+) Make some change on writing scalar value
+) Reorganize some codes
+) Remove some redundant codes

Test
+) On Curie
+) All tests pass

File size: 3.0 KB
RevLine 
[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"
[568]15#include <boost/unordered_map.hpp>
[553]16
17namespace xios
18{
19/*!
20   \class CServerDistributionDescription
21   This class contains information that describe distribution of servers.
22*/
23class CServerDistributionDescription
24{
25  public:
26    enum ServerDistributionType
27    {
28      BAND_DISTRIBUTION, PLAN_DISTRIBUTION
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);
40    void computeServerGlobalIndexInRange(const std::pair<size_t, size_t>& indexBeginEnd, int positionDimensionDistributed = 1);
[865]41    void computeServerGlobalByElement(std::vector<boost::unordered_map<size_t,std::vector<int> > >& indexServerOnElement,
42                                      int rank,
43                                      int clientSize,
[887]44                                      const CArray<int,1>& axisDomainOrder,
[865]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;
[568]50    const boost::unordered_map<size_t,int>& getGlobalIndexRange() const;
[815]51    int getDimensionDistributed();
[554]52
[553]53  protected:
[657]54    void computeBandDistribution(int nServer, int positionDimensionDistributed = 1);
[553]55    void computePlanDistribution(int nServer);
[865]56    void computeRangeProcIndex(int clientRank,
57                               int clientSize,
58                               int rangeProcSize,
59                               int& rangeBegin,
60                               int& rangeSize);
[553]61
62  private:
63    std::vector<std::vector<int> > indexBegin_;     //!< Begin index of each dimension
64    std::vector<std::vector<int> > dimensionSizes_; //!< Size of each dimension
65    std::vector<int> nGlobal_; //!< Global size of each dimension
66
67    //!< General case, index describes distribution of each server (rarely use)
[653]68    std::vector<CArray<size_t,1> > vecGlobalIndex_;
[553]69
70    //!< In case we need only global index of one server with specific rank
[568]71    boost::unordered_map<size_t,int> globalIndex_;
[815]72
73    //!< Type of distribution on server side
74    ServerDistributionType serverType_;
75
76    //!< Number of server
77    int nServer_;
78
79    //!< Position of dimension distributed on server side (by default, the second dimension)
80    int positionDimensionDistributed_;
[553]81};
82
83} // namespace xios
84#endif // __XIOS_SERVER_DISTRIBUTION_DESCRIPTION_HPP
Note: See TracBrowser for help on using the repository browser.