Ignore:
Timestamp:
01/22/21 12:00:29 (3 years ago)
Author:
yushan
Message:

Graph intermedia commit to a tmp branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_trunk_graph/src/transformation/generic_algorithm_transformation.hpp

    r1686 r2019  
    1414#include "array_new.hpp" 
    1515#include "client_client_dht_template.hpp" 
     16#include "local_view.hpp" 
     17#include "transform_connector.hpp" 
     18#include "weight_transform_connector.hpp" 
    1619 
    17 namespace xios { 
     20namespace xios 
     21{ 
    1822  class CGrid; 
    1923  class CDomain; 
    2024  class CAxis; 
    2125  class CScalar; 
     26  class CGridAlgorithm ; 
     27  class CTransformFilter ; 
     28  class CGarbageCollector ; 
    2229 
    2330  /*! 
     
    2734class CGenericAlgorithmTransformation 
    2835{ 
    29 public: 
    30   enum AlgoTransType { 
    31     ELEMENT_GENERATION = 0, 
    32     ELEMENT_MODIFICATION_WITHOUT_DATA = 1, 
    33     ELEMENT_MODIFICATION_WITH_DATA = 2, 
    34     ELEMENT_NO_MODIFICATION_WITH_DATA = 3, 
    35     ELEMENT_NO_MODIFICATION_WITHOUT_DATA = 4 
    36   } ; 
     36  public :  
     37    CGenericAlgorithmTransformation(bool isSource) ; 
     38    virtual CGridAlgorithm* createGridAlgorithm(CGrid* gridSrc, CGrid* newGrid, int pos) ; 
     39    virtual CTransformFilter* createTransformFilter(CGarbageCollector& gc, CGridAlgorithm* algo, bool detectMissingValues, double defaultValue) ; 
     40    virtual void apply(int dimBefore, int dimAfter, const CArray<double,1>& dataIn, CArray<double,1>& dataOut) { abort() ;} //=0 
     41    virtual void apply(int dimBefore, int dimAfter, const CArray<double,1>& dataIn, const vector<CArray<double,1>>& auxData, CArray<double,1>& dataOut) { abort() ;} //=0 
     42    virtual bool isGenerateTransformation(void) { return false ;} 
    3743 
    38 public: 
    39   // Mapping between global index map of DESTINATION and its local index with pair of global index of SOURCE and weights 
    40   typedef std::unordered_map<int, std::unordered_map<size_t, std::vector<std::pair<size_t,double> > > > SourceDestinationIndexMap; 
     44    virtual vector<string> getAuxFieldId(void) ; 
     45  protected : 
     46    typedef std::unordered_map<int, std::vector<int> > TransformationIndexMap; 
     47    typedef std::unordered_map<int, std::vector<double> > TransformationWeightMap; 
     48  
     49    CLocalElement* recvElement_=nullptr ; 
     50    bool isSource_ ; 
    4151 
    42 protected: 
    43   typedef std::unordered_map<size_t,int> GlobalLocalMap; 
    44 protected: 
    45   typedef std::unordered_map<int, std::vector<int> > TransformationIndexMap; 
    46   typedef std::unordered_map<int, std::vector<double> > TransformationWeightMap; 
    47   typedef std::unordered_map<int, std::vector<int> > TransformationPositionMap; 
    48  
    49 public: 
    50   CGenericAlgorithmTransformation(); 
    51  
    52   virtual ~CGenericAlgorithmTransformation() {} 
    53  
    54   bool isDistributedTransformation(int elementPositionInGrid, CGrid* gridSrc, CGrid* gridDst) ; 
    55  
    56   void computeGlobalSourceIndex(int elementPositionInGrid, 
    57                                CGrid* gridSrc, 
    58                                CGrid* gridDst, 
    59                                SourceDestinationIndexMap& globaIndexWeightFromSrcToDst); 
    60  
    61     /*! 
    62     Apply a operation on local data. 
    63     \param [in] localIndex vector contains local index of local data output and the corresponding weight 
    64     \param [in] dataInput Pointer to the first element of data input array (in form of buffer) 
    65     \param [in/out] dataOut Array contains local data 
    66     \param [in/out] flagInitial vector of boolean to mark the local index already initialized. True means there is a need for initalization 
    67     \param [in] ignoreMissingValue don't count missing value in operation if this flag is true 
    68     \param [in] firstPass indicate if it is the first time the apply funtion is called for a same transformation, in order to make a clean initialization  
    69   */ 
    70   virtual void apply(const std::vector<std::pair<int,double> >& localIndex, 
    71                      const double* dataInput, 
    72                      CArray<double,1>& dataOut, 
    73                      std::vector<bool>& flagInitial,                      
    74                      bool ignoreMissingValue, bool firstPass); 
    75  
    76   virtual StdString getName() {return "Generic Trans. Filter";} 
    77  
    78   /*! 
    79    * Update whole dataOut (on necessary). 
    80    * (Example:  Impose a weight, whose value is only known after being applied an operation, on dataOut) 
    81    * \param [in/out] dataOut dataOut 
    82    */ 
    83   virtual void updateData(CArray<double,1>& dataOut); 
    84  
    85   std::vector<StdString> getIdAuxInputs(); 
    86   AlgoTransType type(); 
    87   /*! 
    88   Compute global index mapping from one element of destination grid to the corresponding element of source grid 
    89   */ 
    90   void computeIndexSourceMapping(const std::vector<CArray<double,1>* >& dataAuxInputs = std::vector<CArray<double,1>* >()); 
    91   void computeTransformationMappingNonDistributed(int elementPositionInGrid, CGrid* gridSrc, CGrid* gridDst, 
    92                                                   vector<int>& localSrc, vector<int>& localDst, vector<double>& weight, int& nbLocalIndexOnGridDest); 
    93   void nonDistributedrecursiveFunct(int currentPos, bool masked, int elementPositionInGrid,  vector< CArray<bool,1>* >& maskSrc, vector< CArray<bool,1>* >& maskDst, 
    94                                     int& srcInd, int& srcIndCompressed, vector<int>& nIndexSrc, 
    95                                     int& t, vector<vector<vector<pair<int,double> > > >& dstIndWeight, int currentInd, 
    96                                     vector<int>& localSrc, vector<int>& localDst, vector<double>& weight) ; 
    97  
    98 protected: 
    99   virtual void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >&) = 0; 
    100  
    101   /*! 
    102   Compute proc which contains global index of an element 
    103     \param[in] globalElementIndex demanding global index of an element of source grid 
    104     \param[in] elementType type of source element, 2: domain, 1: axis and 0: scalar 
    105     \param[out] globalElementIndexOnProc Proc contains the demanding global index 
    106   */ 
    107   virtual void computeExchangeGlobalIndex(const CArray<size_t,1>& globalElementIndex, 
    108                                           int elementType, 
    109                                           CClientClientDHTInt::Index2VectorInfoTypeMap& globalElementIndexOnProc) = 0; 
    110  
    111 protected: 
    112   void computeGlobalGridIndexMapping(int elementPositionInGrid, 
    113                                      const std::vector<int>& srcRank, 
    114                                      std::unordered_map<int, std::vector<std::pair<int,double> > >& src2DstMap, 
    115                                      CGrid* gridDst, 
    116                                      CGrid* gridSrc, 
    117                                      std::vector<std::unordered_map<int,std::vector<size_t> > >& globalElementIndexOnProc, 
    118                                      SourceDestinationIndexMap& globaIndexWeightFromSrcToDst); 
    119  
    120   void computeExchangeDomainIndex(CDomain* domainDst, 
    121                                   CDomain* domainSrc, 
    122                                   CArray<size_t,1>& destGlobalIndexPositionInGrid, 
    123                                   std::unordered_map<int,std::vector<size_t> >& globalDomainIndexOnProc); 
    124  
    125   void computeExchangeAxisIndex(CAxis* axisDst, 
    126                                 CAxis* axisSrc, 
    127                                 CArray<size_t,1>& destGlobalIndexPositionInGrid, 
    128                                 std::unordered_map<int,std::vector<size_t> >& globalAxisIndexOnProc); 
    129  
    130   void computeExchangeScalarIndex(CScalar* scalarDst, 
    131                                   CScalar* scalarSrc, 
    132                                   CArray<size_t,1>& destGlobalIndexPositionInGrid, 
    133                                   std::unordered_map<int,std::vector<size_t> >& globalScalarIndexOnProc); 
    134  
    135   void computePositionElements(CGrid* dst, CGrid* src); 
    136  
    137 protected: 
    138   //! indicate if the transformation is performed on a distributed element 
    139   bool isDistributed_ ; 
    140   //! indicate if the method  isDistributedTransformation has been called before 
    141   bool isDistributedComputed_ ; 
     52  public: 
     53    CLocalElement* getRecvElement(void) { return recvElement_ ;} 
    14254   
    143   //! Map between global index of destination element and source element 
    144   std::vector<TransformationIndexMap> transformationMapping_; 
    145   //! Weight corresponding of source to destination 
    146   std::vector<TransformationWeightMap> transformationWeight_; 
    147   //! Map of global index of destination element and corresponding global index of other elements in the same grid 
    148   //! By default, one index of an element corresponds to all index of remaining element in the grid. So it's empty 
    149   std::vector<TransformationPositionMap> transformationPosition_; 
    150  
    151   //! Id of auxillary inputs which helps doing transformation dynamically 
    152   std::vector<StdString> idAuxInputs_; 
    153   AlgoTransType type_; 
    154  
    155   std::set<StdSize> indexElementSrc_; 
    156  
    157   std::vector<std::unordered_map<int,std::vector<size_t> > > globalElementIndexOnProc_; 
    158  
    159   std::vector<int> procContainSrcElementIdx_;  // List of processes containing source index of transformed elements 
    160 //  std::set<int> procOfNonTransformedElements_; // Processes contain the source index of non-transformed elements 
    161   std::set<int> commonProc_; 
    162   std::vector< set<int> > procElementList_ ; // List of processes containing source index of elements 
    163  
    164   CClientClientDHTInt::Index2VectorInfoTypeMap globalIndexOfTransformedElementOnProc_; 
    165    
    166   bool computedProcSrcNonTransformedElement_; // Flag to indicate whether we computed proc containing non transformed elements 
    167  
    168   std::map<int, int> elementPositionInGridSrc2AxisPosition_, elementPositionInGridSrc2DomainPosition_, elementPositionInGridSrc2ScalarPosition_; 
    169   std::map<int, int> elementPositionInGridDst2AxisPosition_, elementPositionInGridDst2DomainPosition_, elementPositionInGridDst2ScalarPosition_; 
    170  
    171   bool eliminateRedondantSrc_ ; // flag to indicate if the transformation must select only one global source point for all proc. 
    172                                // In this case it will choose preferentially the current process  
    17355}; 
    17456 
Note: See TracChangeset for help on using the changeset viewer.