Ignore:
Timestamp:
11/15/17 12:14:34 (6 years ago)
Author:
yushan
Message:

dev_omp

Location:
XIOS/dev/branch_openmp/src/transformation
Files:
34 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_openmp/src/transformation/Functions/average_reduction.cpp

    r1205 r1328  
    3131                                       CArray<double,1>& dataOut, 
    3232                                       std::vector<bool>& flagInitial,                      
    33                                        bool ignoreMissingValue) 
     33                                       bool ignoreMissingValue, bool firstPass) 
    3434{ 
    3535  if (resetWeight_) { weights_.resize(flagInitial.size()); weights_ = 1.0; resetWeight_ = false; }   
     
    3939    int nbLocalIndex = localIndex.size(); 
    4040    int currentlocalIndex = 0; 
    41     double currentWeight  = 0.0;     
     41    double currentWeight  = 0.0; 
     42 
     43    if (firstPass) dataOut=std::numeric_limits<double>::quiet_NaN(); 
    4244 
    4345    for (int idx = 0; idx < nbLocalIndex; ++idx) 
     
    5759          weights_(currentlocalIndex) += 1.0; 
    5860        } 
    59       } 
    60       else 
    61       { 
    62         if (flagInitial[currentlocalIndex])  
    63           dataOut(currentlocalIndex) = std::numeric_limits<double>::quiet_NaN(); 
    6461      } 
    6562    } 
  • XIOS/dev/branch_openmp/src/transformation/Functions/average_reduction.hpp

    r1076 r1328  
    2727                     CArray<double,1>& dataOut, 
    2828                     std::vector<bool>& flagInitial,                      
    29                      bool ignoreMissingValue); 
     29                     bool ignoreMissingValue, bool firstPass); 
    3030 
    3131  virtual void updateData(CArray<double,1>& dataOut); 
  • XIOS/dev/branch_openmp/src/transformation/Functions/extract.cpp

    r1076 r1328  
    3030                                       CArray<double,1>& dataOut, 
    3131                                       std::vector<bool>& flagInitial, 
    32                                        bool ignoreMissingValue) 
     32                                       bool ignoreMissingValue, bool firstPass) 
    3333{ 
    3434  int nbLocalIndex = localIndex.size(); 
  • XIOS/dev/branch_openmp/src/transformation/Functions/extract.hpp

    r1076 r1328  
    2727                     CArray<double,1>& dataOut, 
    2828                     std::vector<bool>& flagInitial, 
    29                      bool ignoreMissingValue); 
     29                     bool ignoreMissingValue, bool firstPass); 
    3030 
    3131  virtual ~CExtractReductionAlgorithm() {} 
  • XIOS/dev/branch_openmp/src/transformation/Functions/max_reduction.cpp

    r1205 r1328  
    3131                                   CArray<double,1>& dataOut, 
    3232                                   std::vector<bool>& flagInitial, 
    33                                    bool ignoreMissingValue) 
     33                                   bool ignoreMissingValue, bool firstPass) 
    3434{  
    3535  if (ignoreMissingValue) 
    3636  { 
    3737    int nbLocalIndex = localIndex.size(); 
    38     int currentlocalIndex = 0;     
     38    int currentlocalIndex = 0; 
     39    if (firstPass) dataOut=std::numeric_limits<double>::quiet_NaN();     
    3940    for (int idx = 0; idx < nbLocalIndex; ++idx) 
    4041    { 
     
    5152          dataOut(currentlocalIndex) = std::max(*(dataInput + idx), dataOut(currentlocalIndex)); 
    5253        } 
    53       } 
    54       else 
    55       { 
    56         if (flagInitial[currentlocalIndex])  
    57           dataOut(currentlocalIndex) = std::numeric_limits<double>::quiet_NaN(); 
    5854      } 
    5955    } 
  • XIOS/dev/branch_openmp/src/transformation/Functions/max_reduction.hpp

    r1076 r1328  
    2727                     CArray<double,1>& dataOut, 
    2828                     std::vector<bool>& flagInitial, 
    29                      bool ignoreMissingValue); 
     29                     bool ignoreMissingValue, bool firstPass); 
    3030 
    3131  virtual ~CMaxReductionAlgorithm() {} 
  • XIOS/dev/branch_openmp/src/transformation/Functions/min_reduction.cpp

    r1205 r1328  
    3131                                   CArray<double,1>& dataOut, 
    3232                                   std::vector<bool>& flagInitial, 
    33                                    bool ignoreMissingValue) 
     33                                   bool ignoreMissingValue, bool firstPass) 
    3434{ 
    3535  if (ignoreMissingValue) 
    3636  { 
    3737    int nbLocalIndex = localIndex.size(); 
    38     int currentlocalIndex = 0;     
     38    int currentlocalIndex = 0; 
     39    if (firstPass) dataOut=std::numeric_limits<double>::quiet_NaN(); 
    3940    for (int idx = 0; idx < nbLocalIndex; ++idx) 
    4041    { 
     
    5152          dataOut(currentlocalIndex) = std::min(*(dataInput + idx), dataOut(currentlocalIndex)); 
    5253        } 
    53       } 
    54       else 
    55       { 
    56         if (flagInitial[currentlocalIndex])  
    57           dataOut(currentlocalIndex) = std::numeric_limits<double>::quiet_NaN(); 
    5854      } 
    5955    } 
  • XIOS/dev/branch_openmp/src/transformation/Functions/min_reduction.hpp

    r1076 r1328  
    2727                     CArray<double,1>& dataOut, 
    2828                     std::vector<bool>& flagInitial,                      
    29                      bool ignoreMissingValue); 
     29                     bool ignoreMissingValue, bool firstPass); 
    3030 
    3131  virtual ~CMinReductionAlgorithm() {} 
  • XIOS/dev/branch_openmp/src/transformation/Functions/reduction.cpp

    r1155 r1328  
    1010CReductionAlgorithm::CallBackMap* CReductionAlgorithm::reductionCreationCallBacks_ = 0; 
    1111//std::map<StdString,EReductionType> CReductionAlgorithm::ReductionOperations = std::map<StdString,EReductionType>(); 
    12 std::map<StdString,EReductionType> *CReductionAlgorithm::ReductionOperations_ptr = 0;  
    13 //#pragma omp threadprivate(CReductionAlgorithm::ReductionOperations_ptr) 
     12std::map<StdString,EReductionType> *CReductionAlgorithm::ReductionOperations_ptr = 0; 
    1413 
     14bool CReductionAlgorithm::initReductionOperation(std::map<StdString,EReductionType>& m) 
     15{ 
     16  // So so stupid way to intialize operation but it works ... 
     17  m["sum"] = TRANS_REDUCE_SUM; 
     18  CSumReductionAlgorithm::registerTrans(); 
     19 
     20  m["min"] = TRANS_REDUCE_MIN; 
     21  CMinReductionAlgorithm::registerTrans(); 
     22 
     23  m["max"] = TRANS_REDUCE_MAX; 
     24  CMaxReductionAlgorithm::registerTrans(); 
     25 
     26  m["extract"] = TRANS_REDUCE_EXTRACT; 
     27  CExtractReductionAlgorithm::registerTrans(); 
     28 
     29  m["average"] = TRANS_REDUCE_AVERAGE; 
     30  CAverageReductionAlgorithm::registerTrans(); 
     31} 
    1532 
    1633bool CReductionAlgorithm::initReductionOperation() 
     
    3552 
    3653//bool CReductionAlgorithm::_dummyInit = CReductionAlgorithm::initReductionOperation(CReductionAlgorithm::ReductionOperations); 
    37 //bool CReductionAlgorithm::_dummyInit = CReductionAlgorithm::initReductionOperation(); 
     54bool CReductionAlgorithm::_dummyInit = CReductionAlgorithm::initReductionOperation(); 
    3855 
    3956CReductionAlgorithm* CReductionAlgorithm::createOperation(EReductionType reduceType) 
    4057{ 
    4158  int reduceTypeInt = reduceType; 
    42  
    4359  CallBackMap::const_iterator it = (*reductionCreationCallBacks_).find(reduceType); 
    4460  if ((*reductionCreationCallBacks_).end() == it) 
  • XIOS/dev/branch_openmp/src/transformation/Functions/reduction.hpp

    r1155 r1328  
    2525  //static std::map<StdString,EReductionType> ReductionOperations; 
    2626  static std::map<StdString,EReductionType> *ReductionOperations_ptr; 
    27   #pragma omp threadprivate(ReductionOperations_ptr) 
    2827 
    2928public: 
    30   CReductionAlgorithm() { } 
     29  CReductionAlgorithm() {} 
    3130 
    3231  /*! 
     
    4342    \param [in/out] dataOut Array contains local data 
    4443    \param [in/out] flagInitial vector of boolean to mark the local index already initialized. True means there is a need for initialization 
     44    \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  
    4545  */ 
    4646  virtual void apply(const std::vector<std::pair<int,double> >& localIndex, 
     
    4848                     CArray<double,1>& dataOut, 
    4949                     std::vector<bool>& flagInitial,                      
    50                      bool ignoreMissingValue) = 0; 
     50                     bool ignoreMissingValue, bool firstPass) = 0; 
    5151  /*! 
    5252    Update local data  
     
    6262  typedef std::map<EReductionType, CreateOperationCallBack> CallBackMap; 
    6363  static CallBackMap* reductionCreationCallBacks_; 
    64   #pragma omp threadprivate(reductionCreationCallBacks_) 
    6564 
    6665  static bool registerOperation(EReductionType reduceType, CreateOperationCallBack createFn); 
     
    7170  static bool initReductionOperation(); 
    7271  static bool _dummyInit; 
    73   #pragma omp threadprivate(_dummyInit) 
    7472}; 
    7573 
  • XIOS/dev/branch_openmp/src/transformation/Functions/sum_reduction.cpp

    r1205 r1328  
    3131                                   CArray<double,1>& dataOut, 
    3232                                   std::vector<bool>& flagInitial, 
    33                                    bool ignoreMissingValue) 
     33                                   bool ignoreMissingValue, bool firstPass) 
    3434{ 
    3535  if (ignoreMissingValue) 
    3636  { 
    3737    int nbLocalIndex = localIndex.size(); 
    38     int currentlocalIndex = 0;     
     38    int currentlocalIndex = 0; 
     39 
     40    if (firstPass) dataOut=std::numeric_limits<double>::quiet_NaN(); 
    3941   
    4042    for (int idx = 0; idx < nbLocalIndex; ++idx) 
     
    5254          dataOut(currentlocalIndex) += *(dataInput + idx); 
    5355        } 
    54       } 
    55       else 
    56       { 
    57         if (flagInitial[currentlocalIndex])  
    58           dataOut(currentlocalIndex) = std::numeric_limits<double>::quiet_NaN(); 
    5956      } 
    6057    }     
  • XIOS/dev/branch_openmp/src/transformation/Functions/sum_reduction.hpp

    r1076 r1328  
    2727                     CArray<double,1>& dataOut, 
    2828                     std::vector<bool>& flagInitial, 
    29                      bool ignoreMissingValue); 
     29                     bool ignoreMissingValue, bool firstPass); 
    3030 
    3131  virtual ~CSumReductionAlgorithm() {} 
  • XIOS/dev/branch_openmp/src/transformation/axis_algorithm_extract_domain.cpp

    r1155 r1328  
    1313#include "grid.hpp" 
    1414#include "grid_transformation_factory_impl.hpp" 
     15#include "reduction.hpp" 
    1516 
    1617namespace xios { 
     
    6162 
    6263  pos_ = algo->position; 
    63  
    64   if(CReductionAlgorithm::ReductionOperations_ptr == 0)  
    65     CReductionAlgorithm::initReductionOperation(); 
    66  
    67   reduction_ = CReductionAlgorithm::createOperation((*CReductionAlgorithm::ReductionOperations_ptr)[op]); 
     64  //reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 
     65  reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations_ptr->at(op)); 
    6866} 
    6967 
     
    7270                                        CArray<double,1>& dataOut, 
    7371                                        std::vector<bool>& flagInitial,                      
    74                                         bool ignoreMissingValue) 
     72                                        bool ignoreMissingValue, bool firstPass) 
    7573{ 
    76   reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue); 
     74  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 
    7775} 
    7876 
  • XIOS/dev/branch_openmp/src/transformation/axis_algorithm_extract_domain.hpp

    r1155 r1328  
    1212#include "axis_algorithm_transformation.hpp" 
    1313#include "transformation.hpp" 
    14 #include "reduction.hpp" 
    1514 
    1615namespace xios { 
     
    2625  Extract a domain to an axis 
    2726*/ 
    28 class CAxisAlgorithmExtractDomain : public CAxisAlgorithmTransformation, public CReductionAlgorithm 
     27class CAxisAlgorithmExtractDomain : public CAxisAlgorithmTransformation 
    2928{ 
    3029public: 
     
    3534                     CArray<double,1>& dataOut, 
    3635                     std::vector<bool>& flagInitial,                      
    37                      bool ignoreMissingValue); 
     36                     bool ignoreMissingValue, bool firstPass); 
    3837 
    3938  virtual ~CAxisAlgorithmExtractDomain(); 
  • XIOS/dev/branch_openmp/src/transformation/axis_algorithm_inverse.cpp

    r1134 r1328  
    1515#include "inverse_axis.hpp" 
    1616#include "client_client_dht_template.hpp" 
     17using namespace ep_lib; 
    1718 
    1819namespace xios { 
     
    173174 
    174175  // Sending global index of grid source to corresponding process as well as the corresponding mask 
    175   std::vector<ep_lib::MPI_Request> requests; 
    176   std::vector<ep_lib::MPI_Status> status; 
     176  std::vector<MPI_Request> requests; 
     177  std::vector<MPI_Status> status; 
    177178  boost::unordered_map<int, unsigned long* > recvGlobalIndexSrc; 
    178179  boost::unordered_map<int, double* > sendValueToDest; 
     
    184185    sendValueToDest[recvRank] = new double [recvSize]; 
    185186 
    186     requests.push_back(ep_lib::MPI_Request()); 
     187    requests.push_back(MPI_Request()); 
    187188    MPI_Irecv(recvGlobalIndexSrc[recvRank], recvSize, MPI_UNSIGNED_LONG, recvRank, 46, client->intraComm, &requests.back()); 
    188189  } 
     
    206207 
    207208    // Send global index source and mask 
    208     requests.push_back(ep_lib::MPI_Request()); 
     209    requests.push_back(MPI_Request()); 
    209210    MPI_Isend(sendGlobalIndexSrc[sendRank], sendSize, MPI_UNSIGNED_LONG, sendRank, 46, client->intraComm, &requests.back()); 
    210211  } 
     
    213214  MPI_Waitall(requests.size(), &requests[0], &status[0]); 
    214215 
    215   std::vector<ep_lib::MPI_Request>().swap(requests); 
    216   std::vector<ep_lib::MPI_Status>().swap(status); 
     216 
     217  std::vector<MPI_Request>().swap(requests); 
     218  std::vector<MPI_Status>().swap(status); 
    217219 
    218220  // Okie, on destination side, we will wait for information of masked index of source 
     
    222224    int recvSize = itSend->second; 
    223225 
    224     requests.push_back(ep_lib::MPI_Request()); 
     226    requests.push_back(MPI_Request()); 
    225227    MPI_Irecv(recvValueFromSrc[recvRank], recvSize, MPI_DOUBLE, recvRank, 48, client->intraComm, &requests.back()); 
    226228  } 
     
    240242    } 
    241243    // Okie, now inform the destination which source index are masked 
    242     requests.push_back(ep_lib::MPI_Request()); 
     244    requests.push_back(MPI_Request()); 
    243245    MPI_Isend(sendValueToDest[recvRank], recvSize, MPI_DOUBLE, recvRank, 48, client->intraComm, &requests.back()); 
    244246  } 
    245247  status.resize(requests.size()); 
    246248  MPI_Waitall(requests.size(), &requests[0], &status[0]); 
     249 
    247250 
    248251  size_t nGloAxisDest = axisDest_->n_glo.getValue() - 1; 
  • XIOS/dev/branch_openmp/src/transformation/axis_algorithm_inverse.hpp

    r1134 r1328  
    1212#include "axis_algorithm_transformation.hpp" 
    1313#include "transformation.hpp" 
    14 #ifdef _usingEP 
    15 #include "ep_declaration.hpp" 
    16 #endif 
    17     
     14 
    1815namespace xios { 
    1916 
  • XIOS/dev/branch_openmp/src/transformation/axis_algorithm_reduce_domain.cpp

    r1155 r1328  
    1313#include "grid.hpp" 
    1414#include "grid_transformation_factory_impl.hpp" 
     15#include "reduction.hpp" 
    1516 
    1617namespace xios { 
     
    6970 
    7071  dir_ = (CReduceDomainToAxis::direction_attr::iDir == algo->direction)  ? iDir : jDir; 
    71  
    72   if(CReductionAlgorithm::ReductionOperations_ptr == 0)  
    73     CReductionAlgorithm::initReductionOperation(); 
    74  
    75   reduction_ = CReductionAlgorithm::createOperation((*CReductionAlgorithm::ReductionOperations_ptr)[op]); 
     72  //reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 
     73  reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations_ptr->at(op)); 
    7674} 
    7775 
     
    8078                                       CArray<double,1>& dataOut, 
    8179                                       std::vector<bool>& flagInitial,                      
    82                                        bool ignoreMissingValue) 
     80                                       bool ignoreMissingValue, bool firstPass) 
    8381{ 
    84   reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue); 
     82  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 
    8583} 
    8684 
     
    105103  CArray<int,1>& axisDstIndex = axisDest_->index; 
    106104  int ni_glo = domainSrc_->ni_glo, nj_glo = domainSrc_->nj_glo; 
    107   if (jDir == dir_) 
     105  if (iDir == dir_) 
    108106  { 
    109107    int nbAxisIdx = axisDstIndex.numElements(); 
     
    120118    } 
    121119  } 
    122   else if (iDir == dir_) 
     120  else if (jDir == dir_) 
    123121  { 
    124122    int nbAxisIdx = axisDstIndex.numElements(); 
  • XIOS/dev/branch_openmp/src/transformation/axis_algorithm_reduce_domain.hpp

    r1155 r1328  
    1212#include "axis_algorithm_transformation.hpp" 
    1313#include "transformation.hpp" 
    14 #include "reduction.hpp" 
    1514 
    1615namespace xios { 
     
    2524  Reduce a domain to an axis 
    2625*/ 
    27 class CAxisAlgorithmReduceDomain : public CAxisAlgorithmTransformation, public CReductionAlgorithm 
     26class CAxisAlgorithmReduceDomain : public CAxisAlgorithmTransformation 
    2827{ 
    2928public: 
     
    3433                     CArray<double,1>& dataOut, 
    3534                     std::vector<bool>& flagInitial,                      
    36                      bool ignoreMissingValue); 
     35                     bool ignoreMissingValue, bool firstPass); 
    3736 
    3837  virtual void updateData(CArray<double,1>& dataOut); 
  • XIOS/dev/branch_openmp/src/transformation/axis_algorithm_zoom.cpp

    r1205 r1328  
    4444  zoomBegin_ = zoomAxis->begin.getValue(); 
    4545  zoomSize_  = zoomAxis->n.getValue(); 
    46   zoomEnd_   = zoomBegin_ + zoomSize_ - 1; 
     46  zoomEnd_   = zoomBegin_ + zoomSize_ - 1;   
    4747 
    4848  if (zoomSize_ > axisSource->n_glo.getValue()) 
  • XIOS/dev/branch_openmp/src/transformation/domain_algorithm_interpolate.cpp

    r1205 r1328  
    2020#include "interpolate_domain.hpp" 
    2121#include "grid.hpp" 
     22using namespace ep_lib; 
    2223 
    2324namespace xios { 
     
    113114  nVertexSrc = nVertexDest = constNVertex; 
    114115 
     116 
     117 
    115118  // First of all, try to retrieve the boundary values of domain source and domain destination 
    116119  int localDomainSrcSize = domainSrc_->i_index.numElements(); 
     
    281284  } 
    282285 
     286 
    283287  for (int idx = 0; idx < nDstLocal; ++idx) 
    284288  { 
     
    404408  CContext* context = CContext::getCurrent(); 
    405409  CContextClient* client=context->client; 
    406   int split_key; 
    407   ep_lib::MPI_Comm_rank(client->intraComm, &split_key); 
    408  
    409   ep_lib::MPI_Comm poleComme(MPI_COMM_NULL); 
    410   ep_lib::MPI_Comm_split(client->intraComm, interMapValuePole.empty() ? 9 : 1, split_key, &poleComme); 
    411   if (MPI_COMM_NULL != poleComme) 
     410 
     411  ep_lib::MPI_Comm poleComme; 
     412  ep_lib::MPI_Comm_split(client->intraComm, interMapValuePole.empty() ? 0 : 1, 0, &poleComme); 
     413  if (!poleComme.is_null()) 
    412414  { 
    413415    int nbClientPole; 
     
    428430    for(int n=1;n<nbClientPole;++n) displ[n]=displ[n-1]+recvCount[n-1] ; 
    429431    int recvSize=displ[nbClientPole-1]+recvCount[nbClientPole-1] ; 
    430      
    431432 
    432433    std::vector<int> sendSourceIndexBuff(nbWeight); 
     
    601602  double* sendWeightBuff = new double [sendBuffSize]; 
    602603 
    603   std::vector<ep_lib::MPI_Request> sendRequest; 
     604  std::vector<ep_lib::MPI_Request> sendRequest(3*globalIndexInterpSendToClient.size()); 
    604605 
    605606  int sendOffSet = 0, l = 0; 
     607  int position = 0; 
    606608  for (itMap = itbMap; itMap != iteMap; ++itMap) 
    607609  { 
     
    622624    } 
    623625 
    624     sendRequest.push_back(ep_lib::MPI_Request()); 
    625626    ep_lib::MPI_Isend(sendIndexDestBuff + sendOffSet, 
    626627             k, 
     
    629630             MPI_DOMAIN_INTERPOLATION_DEST_INDEX, 
    630631             client->intraComm, 
    631              &sendRequest.back()); 
    632     sendRequest.push_back(ep_lib::MPI_Request()); 
     632             &sendRequest[position++]); 
    633633    ep_lib::MPI_Isend(sendIndexSrcBuff + sendOffSet, 
    634634             k, 
     
    637637             MPI_DOMAIN_INTERPOLATION_SRC_INDEX, 
    638638             client->intraComm, 
    639              &sendRequest.back()); 
    640     sendRequest.push_back(ep_lib::MPI_Request()); 
     639             &sendRequest[position++]); 
    641640    ep_lib::MPI_Isend(sendWeightBuff + sendOffSet, 
    642641             k, 
     
    645644             MPI_DOMAIN_INTERPOLATION_WEIGHT, 
    646645             client->intraComm, 
    647              &sendRequest.back()); 
     646             &sendRequest[position++]); 
    648647    sendOffSet += k; 
    649648  } 
     
    661660             recvBuffSize, 
    662661             MPI_INT, 
    663              MPI_ANY_SOURCE, 
     662             -2, 
    664663             MPI_DOMAIN_INTERPOLATION_DEST_INDEX, 
    665664             client->intraComm, 
     
    673672    clientSrcRank = recvStatus.ep_src; 
    674673    #endif 
     674 
    675675    ep_lib::MPI_Recv((recvIndexSrcBuff + receivedSize), 
    676676             recvBuffSize, 
     
    698698 
    699699  std::vector<ep_lib::MPI_Status> requestStatus(sendRequest.size()); 
    700   ep_lib::MPI_Status stat_ignore; 
    701   ep_lib::MPI_Waitall(sendRequest.size(), &sendRequest[0], &stat_ignore); 
     700  ep_lib::MPI_Waitall(sendRequest.size(), &sendRequest[0], &requestStatus[0]); 
    702701 
    703702  delete [] sendIndexDestBuff; 
     
    712711  
    713712/*! Redefined some functions of CONetCDF4 to make use of them */ 
    714 CDomainAlgorithmInterpolate::WriteNetCdf::WriteNetCdf(const StdString& filename, const MPI_Comm comm) 
     713CDomainAlgorithmInterpolate::WriteNetCdf::WriteNetCdf(const StdString& filename, const ep_lib::MPI_Comm comm) 
    715714  : CNc4DataOutput(NULL, filename, false, false, true, comm, false, true) {} 
    716715int CDomainAlgorithmInterpolate::WriteNetCdf::addDimensionWrite(const StdString& name,  
     
    803802  std::vector<StdSize> start(1, startIndex - localNbWeight); 
    804803  std::vector<StdSize> count(1, localNbWeight); 
    805  
    806   WriteNetCdf netCdfWriter(filename, static_cast<MPI_Comm>(client->intraComm.mpi_comm)); 
     804   
     805  WriteNetCdf netCdfWriter(filename, client->intraComm);   
    807806 
    808807  // Define some dimensions 
  • XIOS/dev/branch_openmp/src/transformation/domain_algorithm_interpolate.hpp

    r1205 r1328  
    99#ifndef __XIOS_DOMAIN_ALGORITHM_INTERPOLATE_HPP__ 
    1010#define __XIOS_DOMAIN_ALGORITHM_INTERPOLATE_HPP__ 
    11  
     11#include "mpi_std.hpp" 
    1212#include "domain_algorithm_transformation.hpp" 
    1313#include "transformation.hpp" 
    1414#include "nc4_data_output.hpp" 
    15 #ifdef _usingEP 
    16 #include "ep_declaration.hpp" 
    17 #endif 
    1815 
    1916namespace xios { 
     
    5956  { 
    6057  public: 
    61     WriteNetCdf(const StdString& filename, const MPI_Comm comm); 
     58    WriteNetCdf(const StdString& filename, const ep_lib::MPI_Comm comm); 
    6259    int addDimensionWrite(const StdString& name, const StdSize size = UNLIMITED_DIM); 
    6360    int addVariableWrite(const StdString& name, nc_type type, 
  • XIOS/dev/branch_openmp/src/transformation/generic_algorithm_transformation.cpp

    r1205 r1328  
    3030                                            CArray<double,1>& dataOut, 
    3131                                            std::vector<bool>& flagInitial, 
    32                                             bool ignoreMissingValue) 
     32                                            bool ignoreMissingValue, bool firstPass  ) 
    3333{ 
    3434  int nbLocalIndex = localIndex.size();    
  • XIOS/dev/branch_openmp/src/transformation/generic_algorithm_transformation.hpp

    r1076 r1328  
    6464    \param [in/out] flagInitial vector of boolean to mark the local index already initialized. True means there is a need for initalization 
    6565    \param [in] ignoreMissingValue don't count missing value in operation if this flag is true 
     66    \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  
    6667  */ 
    6768  virtual void apply(const std::vector<std::pair<int,double> >& localIndex, 
     
    6970                     CArray<double,1>& dataOut, 
    7071                     std::vector<bool>& flagInitial,                      
    71                      bool ignoreMissingValue); 
     72                     bool ignoreMissingValue, bool firstPass); 
    7273 
    7374  /*! 
  • XIOS/dev/branch_openmp/src/transformation/grid_transformation.cpp

    r1203 r1328  
    453453    sendRankSizeMap[itIndex->first] = sendSize; 
    454454  } 
    455   MPI_Allgather(&connectedClient,1,MPI_INT,recvCount,1,MPI_INT,client->intraComm); 
     455  ep_lib::MPI_Allgather(&connectedClient,1,MPI_INT,recvCount,1,MPI_INT,client->intraComm); 
    456456 
    457457  displ[0]=0 ; 
     
    460460  int* recvRankBuff=new int[recvSize]; 
    461461  int* recvSizeBuff=new int[recvSize]; 
    462   MPI_Allgatherv(sendRankBuff,connectedClient,MPI_INT,recvRankBuff,recvCount,displ,MPI_INT,client->intraComm); 
    463   MPI_Allgatherv(sendSizeBuff,connectedClient,MPI_INT,recvSizeBuff,recvCount,displ,MPI_INT,client->intraComm); 
     462  ep_lib::MPI_Allgatherv(sendRankBuff,connectedClient,MPI_INT,recvRankBuff,recvCount,displ,MPI_INT,client->intraComm); 
     463  ep_lib::MPI_Allgatherv(sendSizeBuff,connectedClient,MPI_INT,recvSizeBuff,recvCount,displ,MPI_INT,client->intraComm); 
    464464  for (int i = 0; i < nbClient; ++i) 
    465465  { 
     
    473473 
    474474  // Sending global index of grid source to corresponding process as well as the corresponding mask 
    475   std::vector<ep_lib::MPI_Request> requests(2*recvRankSizeMap.size()+2*globaIndexWeightFromSrcToDst.size()); 
     475  std::vector<ep_lib::MPI_Request> requests(recvRankSizeMap.size()*2 + globaIndexWeightFromSrcToDst.size()*2); 
    476476  std::vector<ep_lib::MPI_Status> status; 
    477477  boost::unordered_map<int, unsigned char* > recvMaskDst; 
    478478  boost::unordered_map<int, unsigned long* > recvGlobalIndexSrc; 
    479   int position = 0; 
     479  int requests_position = 0; 
    480480  for (std::map<int,int>::const_iterator itRecv = recvRankSizeMap.begin(); itRecv != recvRankSizeMap.end(); ++itRecv) 
    481481  { 
     
    485485    recvGlobalIndexSrc[recvRank] = new unsigned long [recvSize]; 
    486486 
    487  
    488     MPI_Irecv(recvGlobalIndexSrc[recvRank], recvSize, MPI_UNSIGNED_LONG, recvRank, 46, client->intraComm, &requests[position]); 
    489     position++; 
    490  
    491     MPI_Irecv(recvMaskDst[recvRank], recvSize, MPI_UNSIGNED_CHAR, recvRank, 47, client->intraComm, &requests[position]); 
    492     position++; 
     487    ep_lib::MPI_Irecv(recvGlobalIndexSrc[recvRank], recvSize, MPI_UNSIGNED_LONG, recvRank, 46, client->intraComm, &requests[requests_position++]); 
     488    ep_lib::MPI_Irecv(recvMaskDst[recvRank], recvSize, MPI_UNSIGNED_CHAR, recvRank, 47, client->intraComm, &requests[requests_position++]); 
    493489  } 
    494490 
     
    525521 
    526522    // Send global index source and mask 
    527  
    528     MPI_Isend(sendGlobalIndexSrc[sendRank], sendSize, MPI_UNSIGNED_LONG, sendRank, 46, client->intraComm, &requests[position]); 
    529     position++; 
    530  
    531     MPI_Isend(sendMaskDst[sendRank], sendSize, MPI_UNSIGNED_CHAR, sendRank, 47, client->intraComm, &requests[position]); 
    532     position++; 
     523    ep_lib::MPI_Isend(sendGlobalIndexSrc[sendRank], sendSize, MPI_UNSIGNED_LONG, sendRank, 46, client->intraComm, &requests[requests_position++]); 
     524    ep_lib::MPI_Isend(sendMaskDst[sendRank], sendSize, MPI_UNSIGNED_CHAR, sendRank, 47, client->intraComm, &requests[requests_position++]); 
    533525  } 
    534526 
    535527  status.resize(requests.size()); 
    536   MPI_Waitall(requests.size(), &requests[0], &status[0]); 
     528  ep_lib::MPI_Waitall(requests.size(), &requests[0], &status[0]); 
    537529 
    538530  // Okie, now use the mask to identify which index source we need to send, then also signal the destination which masked index we will return 
    539   //std::vector<ep_lib::MPI_Request>().swap(requests); 
    540   //std::vector<ep_lib::MPI_Status>().swap(status); 
    541   requests.resize(sendRankSizeMap.size()+recvRankSizeMap.size()); 
    542   position = 0; 
     531  requests.resize(sendRankSizeMap.size() + recvRankSizeMap.size()); 
     532  requests_position = 0; 
     533  std::vector<ep_lib::MPI_Status>().swap(status); 
    543534  // Okie, on destination side, we will wait for information of masked index of source 
    544535  for (std::map<int,int>::const_iterator itSend = sendRankSizeMap.begin(); itSend != sendRankSizeMap.end(); ++itSend) 
     
    547538    int recvSize = itSend->second; 
    548539 
    549     MPI_Irecv(sendMaskDst[recvRank], recvSize, MPI_UNSIGNED_CHAR, recvRank, 48, client->intraComm, &requests[position]); 
    550     position++; 
     540    ep_lib::MPI_Irecv(sendMaskDst[recvRank], recvSize, MPI_UNSIGNED_CHAR, recvRank, 48, client->intraComm, &requests[requests_position++]); 
    551541  } 
    552542 
     
    584574 
    585575    // Okie, now inform the destination which source index are masked 
    586     MPI_Isend(recvMaskDst[recvRank], recvSize, MPI_UNSIGNED_CHAR, recvRank, 48, client->intraComm, &requests[position]); 
    587     position++; 
     576    ep_lib::MPI_Isend(recvMaskDst[recvRank], recvSize, MPI_UNSIGNED_CHAR, recvRank, 48, client->intraComm, &requests[requests_position++]); 
    588577  } 
    589578  status.resize(requests.size()); 
    590   MPI_Waitall(requests.size(), &requests[0], &status[0]); 
     579  ep_lib::MPI_Waitall(requests.size(), &requests[0], &status[0]); 
    591580 
    592581  // Cool, now we can fill in local index of grid destination (counted for masked index) 
  • XIOS/dev/branch_openmp/src/transformation/grid_transformation.hpp

    r978 r1328  
    1212#include <map> 
    1313#include <vector> 
     14#include "mpi_std.hpp" 
    1415#include "generic_algorithm_transformation.hpp" 
    1516#include "transformation_enum.hpp" 
  • XIOS/dev/branch_openmp/src/transformation/grid_transformation_factory_impl.hpp

    r1134 r1328  
    5757  typedef std::map<ETranformationType, CreateTransformationCallBack> CallBackMap; 
    5858  static CallBackMap* transformationCreationCallBacks_; 
    59   #pragma omp threadprivate(transformationCreationCallBacks_) 
    60    
    6159  static bool registerTransformation(ETranformationType transType, CreateTransformationCallBack createFn); 
    6260  static bool unregisterTransformation(ETranformationType transType); 
    6361  static bool initializeTransformation_; 
    64   #pragma omp threadprivate(initializeTransformation_) 
    6562}; 
    6663 
     
    8279                                                                               std::map<int, int>& elementPositionInGridDst2DomainPosition) 
    8380{ 
    84   if (0 == transformationCreationCallBacks_) 
    85     transformationCreationCallBacks_ = new CallBackMap(); 
    8681  typename CallBackMap::const_iterator it = (*transformationCreationCallBacks_).find(transType); 
    8782  if ((*transformationCreationCallBacks_).end() == it) 
  • XIOS/dev/branch_openmp/src/transformation/grid_transformation_selector.cpp

    r1106 r1328  
    1010#include "grid.hpp" 
    1111#include "algo_types.hpp" 
     12using namespace ep_lib; 
    1213 
    1314namespace xios { 
  • XIOS/dev/branch_openmp/src/transformation/grid_transformation_selector.hpp

    r978 r1328  
    1212#include <map> 
    1313#include <vector> 
     14#include "mpi_std.hpp" 
    1415#include "generic_algorithm_transformation.hpp" 
    1516#include "transformation_enum.hpp" 
  • XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_extract_axis.cpp

    r1155 r1328  
    1414#include "grid_transformation_factory_impl.hpp" 
    1515 
    16  
     16#include "reduction.hpp" 
    1717 
    1818namespace xios { 
     
    4949  StdString op = "extract"; 
    5050  pos_ = algo->position; 
    51    
    52   if(CReductionAlgorithm::ReductionOperations_ptr == 0)  
    53     CReductionAlgorithm::initReductionOperation(); 
    54    
    55   reduction_ = CReductionAlgorithm::createOperation((*CReductionAlgorithm::ReductionOperations_ptr)[op]); 
     51  //reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 
     52  reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations_ptr->at(op)); 
    5653} 
    5754 
     
    6057                                         CArray<double,1>& dataOut, 
    6158                                         std::vector<bool>& flagInitial,                      
    62                                          bool ignoreMissingValue) 
     59                                         bool ignoreMissingValue, bool firstPass) 
    6360{ 
    64   reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue); 
     61  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 
    6562} 
    6663 
  • XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_extract_axis.hpp

    r1155 r1328  
    1212#include "scalar_algorithm_transformation.hpp" 
    1313#include "transformation.hpp" 
    14 #include "reduction.hpp" 
    1514 
    1615namespace xios { 
     
    2524  Extract a scalar from an axis 
    2625*/ 
    27 class CScalarAlgorithmExtractAxis : public CScalarAlgorithmTransformation, public CReductionAlgorithm 
     26class CScalarAlgorithmExtractAxis : public CScalarAlgorithmTransformation 
    2827{ 
    2928public: 
     
    3433                     CArray<double,1>& dataOut, 
    3534                     std::vector<bool>& flagInitial,                      
    36                      bool ignoreMissingValue); 
     35                     bool ignoreMissingValue, bool firstPass); 
    3736 
    3837  virtual ~CScalarAlgorithmExtractAxis(); 
  • XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_reduce_axis.cpp

    r1155 r1328  
    1313#include "grid.hpp" 
    1414#include "grid_transformation_factory_impl.hpp" 
     15#include "reduction.hpp" 
     16 
     17#include "reduction.hpp" 
    1518 
    1619namespace xios { 
    17  
    18 //extern std::map<StdString,EReductionType> *CReductionAlgorithm::ReductionOperations_ptr;  
    19 //#pragma omp threadprivate(CReductionAlgorithm::ReductionOperations_ptr) 
    20  
    2120CGenericAlgorithmTransformation* CScalarAlgorithmReduceAxis::create(CGrid* gridDst, CGrid* gridSrc, 
    2221                                                                     CTransformation<CScalar>* transformation, 
     
    7675  } 
    7776   
    78   if(CReductionAlgorithm::ReductionOperations_ptr == 0)  
    79     CReductionAlgorithm::initReductionOperation(); 
    80    
    81   if ((*CReductionAlgorithm::ReductionOperations_ptr).end() == (*CReductionAlgorithm::ReductionOperations_ptr).find(op)) 
     77  //if (CReductionAlgorithm::ReductionOperations.end() == CReductionAlgorithm::ReductionOperations.find(op)) 
     78  if (CReductionAlgorithm::ReductionOperations_ptr->end() == CReductionAlgorithm::ReductionOperations_ptr->find(op)) 
    8279    ERROR("CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(CAxis* axisDestination, CAxis* axisSource, CReduceAxisToScalar* algo)", 
    8380       << "Operation '" << op << "' not found. Please make sure to use a supported one" 
     
    8582       << "Scalar destination " << scalarDestination->getId()); 
    8683 
    87   reduction_ = CReductionAlgorithm::createOperation((*CReductionAlgorithm::ReductionOperations_ptr)[op]); 
     84  //reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 
     85  reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations_ptr->at(op)); 
    8886} 
    8987 
    90 void CScalarAlgorithmReduceAxis::apply(const std::vector<std::pair<int,double> >& localIndex, 
    91                                          const double* dataInput, 
    92                                          CArray<double,1>& dataOut, 
    93                                          std::vector<bool>& flagInitial, 
    94                                        bool ignoreMissingValue) 
     88void CScalarAlgorithmReduceAxis::apply(const std::vector<std::pair<int,double> >& localIndex, const double* dataInput, CArray<double,1>& dataOut, 
     89                                         std::vector<bool>& flagInitial, bool ignoreMissingValue, bool firstPass) 
    9590{ 
    96   reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue); 
     91  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 
    9792} 
    9893 
     
    115110  TransformationWeightMap& transWeight = this->transformationWeight_[0]; 
    116111 
    117   CArray<int,1>& axisSrcIndex = axisSrc_->index; 
    118   int globalIndexSize = axisSrcIndex.numElements(); 
     112  int globalIndexSize = axisSrc_-> n_glo; 
    119113 
    120114  for (int idx = 0; idx < globalIndexSize; ++idx) 
    121115  { 
    122     transMap[0].push_back(axisSrcIndex(idx)); 
     116    transMap[0].push_back(idx); 
    123117    transWeight[0].push_back(1.0); 
    124118  } 
  • XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_reduce_axis.hpp

    r1155 r1328  
    1212#include "scalar_algorithm_transformation.hpp" 
    1313#include "transformation.hpp" 
    14 #include "reduction.hpp" 
    1514 
    1615namespace xios { 
     
    2524  Reducing an axis to a scalar 
    2625*/ 
    27 class CScalarAlgorithmReduceAxis : public CScalarAlgorithmTransformation, public CReductionAlgorithm 
     26class CScalarAlgorithmReduceAxis : public CScalarAlgorithmTransformation 
    2827{ 
    2928public: 
     
    3433                     CArray<double,1>& dataOut, 
    3534                     std::vector<bool>& flagInitial, 
    36                      bool ignoreMissingValue); 
     35                     bool ignoreMissingValue, bool firstPass); 
    3736 
    3837  virtual void updateData(CArray<double,1>& dataOut); 
  • XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_reduce_domain.cpp

    r1155 r1328  
    1414#include "grid_transformation_factory_impl.hpp" 
    1515 
    16  
     16#include "reduction.hpp" 
    1717 
    1818namespace xios { 
     
    6868 
    6969  } 
     70   
     71  // if(CReductionAlgorithm::ReductionOperations_ptr == 0)  
     72  //   CReductionAlgorithm::initReductionOperation(); 
    7073 
    71   if(CReductionAlgorithm::ReductionOperations_ptr == 0)  
    72     CReductionAlgorithm::initReductionOperation(); 
    73  
    74   if ((*CReductionAlgorithm::ReductionOperations_ptr).end() == (*CReductionAlgorithm::ReductionOperations_ptr).find(op)) 
     74  //if (CReductionAlgorithm::ReductionOperations.end() == CReductionAlgorithm::ReductionOperations.find(op)) 
     75  if (CReductionAlgorithm::ReductionOperations_ptr->end() == CReductionAlgorithm::ReductionOperations_ptr->find(op)) 
    7576    ERROR("CScalarAlgorithmReduceDomain::CScalarAlgorithmReduceDomain(CDomain* domainDestination, CDomain* domainSource, CReduceDomainToScalar* algo)", 
    7677       << "Operation '" << op << "' not found. Please make sure to use a supported one" 
     
    7879       << "Scalar destination " << scalarDestination->getId()); 
    7980 
    80   reduction_ = CReductionAlgorithm::createOperation((*CReductionAlgorithm::ReductionOperations_ptr)[op]); 
     81  //reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 
     82  reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations_ptr->at(op)); 
    8183} 
    8284 
     
    8587                                         CArray<double,1>& dataOut, 
    8688                                         std::vector<bool>& flagInitial,                      
    87                                          bool ignoreMissingValue) 
     89                                         bool ignoreMissingValue, bool firstPass) 
    8890{ 
    89   reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue); 
     91  reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 
    9092} 
    9193 
  • XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_reduce_domain.hpp

    r1155 r1328  
    1212#include "scalar_algorithm_transformation.hpp" 
    1313#include "transformation.hpp" 
    14 #include "reduction.hpp" 
    1514 
    1615namespace xios { 
     
    2524  Reducing an DOMAIN to a scalar 
    2625*/ 
    27 class CScalarAlgorithmReduceDomain : public CScalarAlgorithmTransformation, public CReductionAlgorithm 
     26class CScalarAlgorithmReduceDomain : public CScalarAlgorithmTransformation 
    2827{ 
    2928public: 
     
    3433                     CArray<double,1>& dataOut, 
    3534                     std::vector<bool>& flagInitial,                      
    36                      bool ignoreMissingValue); 
     35                     bool ignoreMissingValue, bool firstPass); 
    3736 
    3837  virtual void updateData(CArray<double,1>& dataOut); 
Note: See TracChangeset for help on using the changeset viewer.