Changeset 1328 for XIOS/dev/branch_openmp/src/transformation
- Timestamp:
- 11/15/17 12:14:34 (6 years ago)
- 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 31 31 CArray<double,1>& dataOut, 32 32 std::vector<bool>& flagInitial, 33 bool ignoreMissingValue )33 bool ignoreMissingValue, bool firstPass) 34 34 { 35 35 if (resetWeight_) { weights_.resize(flagInitial.size()); weights_ = 1.0; resetWeight_ = false; } … … 39 39 int nbLocalIndex = localIndex.size(); 40 40 int currentlocalIndex = 0; 41 double currentWeight = 0.0; 41 double currentWeight = 0.0; 42 43 if (firstPass) dataOut=std::numeric_limits<double>::quiet_NaN(); 42 44 43 45 for (int idx = 0; idx < nbLocalIndex; ++idx) … … 57 59 weights_(currentlocalIndex) += 1.0; 58 60 } 59 }60 else61 {62 if (flagInitial[currentlocalIndex])63 dataOut(currentlocalIndex) = std::numeric_limits<double>::quiet_NaN();64 61 } 65 62 } -
XIOS/dev/branch_openmp/src/transformation/Functions/average_reduction.hpp
r1076 r1328 27 27 CArray<double,1>& dataOut, 28 28 std::vector<bool>& flagInitial, 29 bool ignoreMissingValue );29 bool ignoreMissingValue, bool firstPass); 30 30 31 31 virtual void updateData(CArray<double,1>& dataOut); -
XIOS/dev/branch_openmp/src/transformation/Functions/extract.cpp
r1076 r1328 30 30 CArray<double,1>& dataOut, 31 31 std::vector<bool>& flagInitial, 32 bool ignoreMissingValue )32 bool ignoreMissingValue, bool firstPass) 33 33 { 34 34 int nbLocalIndex = localIndex.size(); -
XIOS/dev/branch_openmp/src/transformation/Functions/extract.hpp
r1076 r1328 27 27 CArray<double,1>& dataOut, 28 28 std::vector<bool>& flagInitial, 29 bool ignoreMissingValue );29 bool ignoreMissingValue, bool firstPass); 30 30 31 31 virtual ~CExtractReductionAlgorithm() {} -
XIOS/dev/branch_openmp/src/transformation/Functions/max_reduction.cpp
r1205 r1328 31 31 CArray<double,1>& dataOut, 32 32 std::vector<bool>& flagInitial, 33 bool ignoreMissingValue )33 bool ignoreMissingValue, bool firstPass) 34 34 { 35 35 if (ignoreMissingValue) 36 36 { 37 37 int nbLocalIndex = localIndex.size(); 38 int currentlocalIndex = 0; 38 int currentlocalIndex = 0; 39 if (firstPass) dataOut=std::numeric_limits<double>::quiet_NaN(); 39 40 for (int idx = 0; idx < nbLocalIndex; ++idx) 40 41 { … … 51 52 dataOut(currentlocalIndex) = std::max(*(dataInput + idx), dataOut(currentlocalIndex)); 52 53 } 53 }54 else55 {56 if (flagInitial[currentlocalIndex])57 dataOut(currentlocalIndex) = std::numeric_limits<double>::quiet_NaN();58 54 } 59 55 } -
XIOS/dev/branch_openmp/src/transformation/Functions/max_reduction.hpp
r1076 r1328 27 27 CArray<double,1>& dataOut, 28 28 std::vector<bool>& flagInitial, 29 bool ignoreMissingValue );29 bool ignoreMissingValue, bool firstPass); 30 30 31 31 virtual ~CMaxReductionAlgorithm() {} -
XIOS/dev/branch_openmp/src/transformation/Functions/min_reduction.cpp
r1205 r1328 31 31 CArray<double,1>& dataOut, 32 32 std::vector<bool>& flagInitial, 33 bool ignoreMissingValue )33 bool ignoreMissingValue, bool firstPass) 34 34 { 35 35 if (ignoreMissingValue) 36 36 { 37 37 int nbLocalIndex = localIndex.size(); 38 int currentlocalIndex = 0; 38 int currentlocalIndex = 0; 39 if (firstPass) dataOut=std::numeric_limits<double>::quiet_NaN(); 39 40 for (int idx = 0; idx < nbLocalIndex; ++idx) 40 41 { … … 51 52 dataOut(currentlocalIndex) = std::min(*(dataInput + idx), dataOut(currentlocalIndex)); 52 53 } 53 }54 else55 {56 if (flagInitial[currentlocalIndex])57 dataOut(currentlocalIndex) = std::numeric_limits<double>::quiet_NaN();58 54 } 59 55 } -
XIOS/dev/branch_openmp/src/transformation/Functions/min_reduction.hpp
r1076 r1328 27 27 CArray<double,1>& dataOut, 28 28 std::vector<bool>& flagInitial, 29 bool ignoreMissingValue );29 bool ignoreMissingValue, bool firstPass); 30 30 31 31 virtual ~CMinReductionAlgorithm() {} -
XIOS/dev/branch_openmp/src/transformation/Functions/reduction.cpp
r1155 r1328 10 10 CReductionAlgorithm::CallBackMap* CReductionAlgorithm::reductionCreationCallBacks_ = 0; 11 11 //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) 12 std::map<StdString,EReductionType> *CReductionAlgorithm::ReductionOperations_ptr = 0; 14 13 14 bool 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 } 15 32 16 33 bool CReductionAlgorithm::initReductionOperation() … … 35 52 36 53 //bool CReductionAlgorithm::_dummyInit = CReductionAlgorithm::initReductionOperation(CReductionAlgorithm::ReductionOperations); 37 //bool CReductionAlgorithm::_dummyInit = CReductionAlgorithm::initReductionOperation();54 bool CReductionAlgorithm::_dummyInit = CReductionAlgorithm::initReductionOperation(); 38 55 39 56 CReductionAlgorithm* CReductionAlgorithm::createOperation(EReductionType reduceType) 40 57 { 41 58 int reduceTypeInt = reduceType; 42 43 59 CallBackMap::const_iterator it = (*reductionCreationCallBacks_).find(reduceType); 44 60 if ((*reductionCreationCallBacks_).end() == it) -
XIOS/dev/branch_openmp/src/transformation/Functions/reduction.hpp
r1155 r1328 25 25 //static std::map<StdString,EReductionType> ReductionOperations; 26 26 static std::map<StdString,EReductionType> *ReductionOperations_ptr; 27 #pragma omp threadprivate(ReductionOperations_ptr)28 27 29 28 public: 30 CReductionAlgorithm() { 29 CReductionAlgorithm() {} 31 30 32 31 /*! … … 43 42 \param [in/out] dataOut Array contains local data 44 43 \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 45 45 */ 46 46 virtual void apply(const std::vector<std::pair<int,double> >& localIndex, … … 48 48 CArray<double,1>& dataOut, 49 49 std::vector<bool>& flagInitial, 50 bool ignoreMissingValue ) = 0;50 bool ignoreMissingValue, bool firstPass) = 0; 51 51 /*! 52 52 Update local data … … 62 62 typedef std::map<EReductionType, CreateOperationCallBack> CallBackMap; 63 63 static CallBackMap* reductionCreationCallBacks_; 64 #pragma omp threadprivate(reductionCreationCallBacks_)65 64 66 65 static bool registerOperation(EReductionType reduceType, CreateOperationCallBack createFn); … … 71 70 static bool initReductionOperation(); 72 71 static bool _dummyInit; 73 #pragma omp threadprivate(_dummyInit)74 72 }; 75 73 -
XIOS/dev/branch_openmp/src/transformation/Functions/sum_reduction.cpp
r1205 r1328 31 31 CArray<double,1>& dataOut, 32 32 std::vector<bool>& flagInitial, 33 bool ignoreMissingValue )33 bool ignoreMissingValue, bool firstPass) 34 34 { 35 35 if (ignoreMissingValue) 36 36 { 37 37 int nbLocalIndex = localIndex.size(); 38 int currentlocalIndex = 0; 38 int currentlocalIndex = 0; 39 40 if (firstPass) dataOut=std::numeric_limits<double>::quiet_NaN(); 39 41 40 42 for (int idx = 0; idx < nbLocalIndex; ++idx) … … 52 54 dataOut(currentlocalIndex) += *(dataInput + idx); 53 55 } 54 }55 else56 {57 if (flagInitial[currentlocalIndex])58 dataOut(currentlocalIndex) = std::numeric_limits<double>::quiet_NaN();59 56 } 60 57 } -
XIOS/dev/branch_openmp/src/transformation/Functions/sum_reduction.hpp
r1076 r1328 27 27 CArray<double,1>& dataOut, 28 28 std::vector<bool>& flagInitial, 29 bool ignoreMissingValue );29 bool ignoreMissingValue, bool firstPass); 30 30 31 31 virtual ~CSumReductionAlgorithm() {} -
XIOS/dev/branch_openmp/src/transformation/axis_algorithm_extract_domain.cpp
r1155 r1328 13 13 #include "grid.hpp" 14 14 #include "grid_transformation_factory_impl.hpp" 15 #include "reduction.hpp" 15 16 16 17 namespace xios { … … 61 62 62 63 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)); 68 66 } 69 67 … … 72 70 CArray<double,1>& dataOut, 73 71 std::vector<bool>& flagInitial, 74 bool ignoreMissingValue )72 bool ignoreMissingValue, bool firstPass) 75 73 { 76 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue );74 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 77 75 } 78 76 -
XIOS/dev/branch_openmp/src/transformation/axis_algorithm_extract_domain.hpp
r1155 r1328 12 12 #include "axis_algorithm_transformation.hpp" 13 13 #include "transformation.hpp" 14 #include "reduction.hpp"15 14 16 15 namespace xios { … … 26 25 Extract a domain to an axis 27 26 */ 28 class CAxisAlgorithmExtractDomain : public CAxisAlgorithmTransformation , public CReductionAlgorithm27 class CAxisAlgorithmExtractDomain : public CAxisAlgorithmTransformation 29 28 { 30 29 public: … … 35 34 CArray<double,1>& dataOut, 36 35 std::vector<bool>& flagInitial, 37 bool ignoreMissingValue );36 bool ignoreMissingValue, bool firstPass); 38 37 39 38 virtual ~CAxisAlgorithmExtractDomain(); -
XIOS/dev/branch_openmp/src/transformation/axis_algorithm_inverse.cpp
r1134 r1328 15 15 #include "inverse_axis.hpp" 16 16 #include "client_client_dht_template.hpp" 17 using namespace ep_lib; 17 18 18 19 namespace xios { … … 173 174 174 175 // 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; 177 178 boost::unordered_map<int, unsigned long* > recvGlobalIndexSrc; 178 179 boost::unordered_map<int, double* > sendValueToDest; … … 184 185 sendValueToDest[recvRank] = new double [recvSize]; 185 186 186 requests.push_back( ep_lib::MPI_Request());187 requests.push_back(MPI_Request()); 187 188 MPI_Irecv(recvGlobalIndexSrc[recvRank], recvSize, MPI_UNSIGNED_LONG, recvRank, 46, client->intraComm, &requests.back()); 188 189 } … … 206 207 207 208 // Send global index source and mask 208 requests.push_back( ep_lib::MPI_Request());209 requests.push_back(MPI_Request()); 209 210 MPI_Isend(sendGlobalIndexSrc[sendRank], sendSize, MPI_UNSIGNED_LONG, sendRank, 46, client->intraComm, &requests.back()); 210 211 } … … 213 214 MPI_Waitall(requests.size(), &requests[0], &status[0]); 214 215 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); 217 219 218 220 // Okie, on destination side, we will wait for information of masked index of source … … 222 224 int recvSize = itSend->second; 223 225 224 requests.push_back( ep_lib::MPI_Request());226 requests.push_back(MPI_Request()); 225 227 MPI_Irecv(recvValueFromSrc[recvRank], recvSize, MPI_DOUBLE, recvRank, 48, client->intraComm, &requests.back()); 226 228 } … … 240 242 } 241 243 // Okie, now inform the destination which source index are masked 242 requests.push_back( ep_lib::MPI_Request());244 requests.push_back(MPI_Request()); 243 245 MPI_Isend(sendValueToDest[recvRank], recvSize, MPI_DOUBLE, recvRank, 48, client->intraComm, &requests.back()); 244 246 } 245 247 status.resize(requests.size()); 246 248 MPI_Waitall(requests.size(), &requests[0], &status[0]); 249 247 250 248 251 size_t nGloAxisDest = axisDest_->n_glo.getValue() - 1; -
XIOS/dev/branch_openmp/src/transformation/axis_algorithm_inverse.hpp
r1134 r1328 12 12 #include "axis_algorithm_transformation.hpp" 13 13 #include "transformation.hpp" 14 #ifdef _usingEP 15 #include "ep_declaration.hpp" 16 #endif 17 14 18 15 namespace xios { 19 16 -
XIOS/dev/branch_openmp/src/transformation/axis_algorithm_reduce_domain.cpp
r1155 r1328 13 13 #include "grid.hpp" 14 14 #include "grid_transformation_factory_impl.hpp" 15 #include "reduction.hpp" 15 16 16 17 namespace xios { … … 69 70 70 71 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)); 76 74 } 77 75 … … 80 78 CArray<double,1>& dataOut, 81 79 std::vector<bool>& flagInitial, 82 bool ignoreMissingValue )80 bool ignoreMissingValue, bool firstPass) 83 81 { 84 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue );82 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 85 83 } 86 84 … … 105 103 CArray<int,1>& axisDstIndex = axisDest_->index; 106 104 int ni_glo = domainSrc_->ni_glo, nj_glo = domainSrc_->nj_glo; 107 if ( jDir == dir_)105 if (iDir == dir_) 108 106 { 109 107 int nbAxisIdx = axisDstIndex.numElements(); … … 120 118 } 121 119 } 122 else if ( iDir == dir_)120 else if (jDir == dir_) 123 121 { 124 122 int nbAxisIdx = axisDstIndex.numElements(); -
XIOS/dev/branch_openmp/src/transformation/axis_algorithm_reduce_domain.hpp
r1155 r1328 12 12 #include "axis_algorithm_transformation.hpp" 13 13 #include "transformation.hpp" 14 #include "reduction.hpp"15 14 16 15 namespace xios { … … 25 24 Reduce a domain to an axis 26 25 */ 27 class CAxisAlgorithmReduceDomain : public CAxisAlgorithmTransformation , public CReductionAlgorithm26 class CAxisAlgorithmReduceDomain : public CAxisAlgorithmTransformation 28 27 { 29 28 public: … … 34 33 CArray<double,1>& dataOut, 35 34 std::vector<bool>& flagInitial, 36 bool ignoreMissingValue );35 bool ignoreMissingValue, bool firstPass); 37 36 38 37 virtual void updateData(CArray<double,1>& dataOut); -
XIOS/dev/branch_openmp/src/transformation/axis_algorithm_zoom.cpp
r1205 r1328 44 44 zoomBegin_ = zoomAxis->begin.getValue(); 45 45 zoomSize_ = zoomAxis->n.getValue(); 46 zoomEnd_ = zoomBegin_ + zoomSize_ - 1; 46 zoomEnd_ = zoomBegin_ + zoomSize_ - 1; 47 47 48 48 if (zoomSize_ > axisSource->n_glo.getValue()) -
XIOS/dev/branch_openmp/src/transformation/domain_algorithm_interpolate.cpp
r1205 r1328 20 20 #include "interpolate_domain.hpp" 21 21 #include "grid.hpp" 22 using namespace ep_lib; 22 23 23 24 namespace xios { … … 113 114 nVertexSrc = nVertexDest = constNVertex; 114 115 116 117 115 118 // First of all, try to retrieve the boundary values of domain source and domain destination 116 119 int localDomainSrcSize = domainSrc_->i_index.numElements(); … … 281 284 } 282 285 286 283 287 for (int idx = 0; idx < nDstLocal; ++idx) 284 288 { … … 404 408 CContext* context = CContext::getCurrent(); 405 409 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()) 412 414 { 413 415 int nbClientPole; … … 428 430 for(int n=1;n<nbClientPole;++n) displ[n]=displ[n-1]+recvCount[n-1] ; 429 431 int recvSize=displ[nbClientPole-1]+recvCount[nbClientPole-1] ; 430 431 432 432 433 std::vector<int> sendSourceIndexBuff(nbWeight); … … 601 602 double* sendWeightBuff = new double [sendBuffSize]; 602 603 603 std::vector<ep_lib::MPI_Request> sendRequest ;604 std::vector<ep_lib::MPI_Request> sendRequest(3*globalIndexInterpSendToClient.size()); 604 605 605 606 int sendOffSet = 0, l = 0; 607 int position = 0; 606 608 for (itMap = itbMap; itMap != iteMap; ++itMap) 607 609 { … … 622 624 } 623 625 624 sendRequest.push_back(ep_lib::MPI_Request());625 626 ep_lib::MPI_Isend(sendIndexDestBuff + sendOffSet, 626 627 k, … … 629 630 MPI_DOMAIN_INTERPOLATION_DEST_INDEX, 630 631 client->intraComm, 631 &sendRequest.back()); 632 sendRequest.push_back(ep_lib::MPI_Request()); 632 &sendRequest[position++]); 633 633 ep_lib::MPI_Isend(sendIndexSrcBuff + sendOffSet, 634 634 k, … … 637 637 MPI_DOMAIN_INTERPOLATION_SRC_INDEX, 638 638 client->intraComm, 639 &sendRequest.back()); 640 sendRequest.push_back(ep_lib::MPI_Request()); 639 &sendRequest[position++]); 641 640 ep_lib::MPI_Isend(sendWeightBuff + sendOffSet, 642 641 k, … … 645 644 MPI_DOMAIN_INTERPOLATION_WEIGHT, 646 645 client->intraComm, 647 &sendRequest .back());646 &sendRequest[position++]); 648 647 sendOffSet += k; 649 648 } … … 661 660 recvBuffSize, 662 661 MPI_INT, 663 MPI_ANY_SOURCE,662 -2, 664 663 MPI_DOMAIN_INTERPOLATION_DEST_INDEX, 665 664 client->intraComm, … … 673 672 clientSrcRank = recvStatus.ep_src; 674 673 #endif 674 675 675 ep_lib::MPI_Recv((recvIndexSrcBuff + receivedSize), 676 676 recvBuffSize, … … 698 698 699 699 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]); 702 701 703 702 delete [] sendIndexDestBuff; … … 712 711 713 712 /*! Redefined some functions of CONetCDF4 to make use of them */ 714 CDomainAlgorithmInterpolate::WriteNetCdf::WriteNetCdf(const StdString& filename, const MPI_Comm comm)713 CDomainAlgorithmInterpolate::WriteNetCdf::WriteNetCdf(const StdString& filename, const ep_lib::MPI_Comm comm) 715 714 : CNc4DataOutput(NULL, filename, false, false, true, comm, false, true) {} 716 715 int CDomainAlgorithmInterpolate::WriteNetCdf::addDimensionWrite(const StdString& name, … … 803 802 std::vector<StdSize> start(1, startIndex - localNbWeight); 804 803 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); 807 806 808 807 // Define some dimensions -
XIOS/dev/branch_openmp/src/transformation/domain_algorithm_interpolate.hpp
r1205 r1328 9 9 #ifndef __XIOS_DOMAIN_ALGORITHM_INTERPOLATE_HPP__ 10 10 #define __XIOS_DOMAIN_ALGORITHM_INTERPOLATE_HPP__ 11 11 #include "mpi_std.hpp" 12 12 #include "domain_algorithm_transformation.hpp" 13 13 #include "transformation.hpp" 14 14 #include "nc4_data_output.hpp" 15 #ifdef _usingEP16 #include "ep_declaration.hpp"17 #endif18 15 19 16 namespace xios { … … 59 56 { 60 57 public: 61 WriteNetCdf(const StdString& filename, const MPI_Comm comm);58 WriteNetCdf(const StdString& filename, const ep_lib::MPI_Comm comm); 62 59 int addDimensionWrite(const StdString& name, const StdSize size = UNLIMITED_DIM); 63 60 int addVariableWrite(const StdString& name, nc_type type, -
XIOS/dev/branch_openmp/src/transformation/generic_algorithm_transformation.cpp
r1205 r1328 30 30 CArray<double,1>& dataOut, 31 31 std::vector<bool>& flagInitial, 32 bool ignoreMissingValue )32 bool ignoreMissingValue, bool firstPass ) 33 33 { 34 34 int nbLocalIndex = localIndex.size(); -
XIOS/dev/branch_openmp/src/transformation/generic_algorithm_transformation.hpp
r1076 r1328 64 64 \param [in/out] flagInitial vector of boolean to mark the local index already initialized. True means there is a need for initalization 65 65 \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 66 67 */ 67 68 virtual void apply(const std::vector<std::pair<int,double> >& localIndex, … … 69 70 CArray<double,1>& dataOut, 70 71 std::vector<bool>& flagInitial, 71 bool ignoreMissingValue );72 bool ignoreMissingValue, bool firstPass); 72 73 73 74 /*! -
XIOS/dev/branch_openmp/src/transformation/grid_transformation.cpp
r1203 r1328 453 453 sendRankSizeMap[itIndex->first] = sendSize; 454 454 } 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); 456 456 457 457 displ[0]=0 ; … … 460 460 int* recvRankBuff=new int[recvSize]; 461 461 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); 464 464 for (int i = 0; i < nbClient; ++i) 465 465 { … … 473 473 474 474 // 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); 476 476 std::vector<ep_lib::MPI_Status> status; 477 477 boost::unordered_map<int, unsigned char* > recvMaskDst; 478 478 boost::unordered_map<int, unsigned long* > recvGlobalIndexSrc; 479 int position = 0;479 int requests_position = 0; 480 480 for (std::map<int,int>::const_iterator itRecv = recvRankSizeMap.begin(); itRecv != recvRankSizeMap.end(); ++itRecv) 481 481 { … … 485 485 recvGlobalIndexSrc[recvRank] = new unsigned long [recvSize]; 486 486 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++]); 493 489 } 494 490 … … 525 521 526 522 // 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++]); 533 525 } 534 526 535 527 status.resize(requests.size()); 536 MPI_Waitall(requests.size(), &requests[0], &status[0]);528 ep_lib::MPI_Waitall(requests.size(), &requests[0], &status[0]); 537 529 538 530 // 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); 543 534 // Okie, on destination side, we will wait for information of masked index of source 544 535 for (std::map<int,int>::const_iterator itSend = sendRankSizeMap.begin(); itSend != sendRankSizeMap.end(); ++itSend) … … 547 538 int recvSize = itSend->second; 548 539 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++]); 551 541 } 552 542 … … 584 574 585 575 // 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++]); 588 577 } 589 578 status.resize(requests.size()); 590 MPI_Waitall(requests.size(), &requests[0], &status[0]);579 ep_lib::MPI_Waitall(requests.size(), &requests[0], &status[0]); 591 580 592 581 // 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 12 12 #include <map> 13 13 #include <vector> 14 #include "mpi_std.hpp" 14 15 #include "generic_algorithm_transformation.hpp" 15 16 #include "transformation_enum.hpp" -
XIOS/dev/branch_openmp/src/transformation/grid_transformation_factory_impl.hpp
r1134 r1328 57 57 typedef std::map<ETranformationType, CreateTransformationCallBack> CallBackMap; 58 58 static CallBackMap* transformationCreationCallBacks_; 59 #pragma omp threadprivate(transformationCreationCallBacks_)60 61 59 static bool registerTransformation(ETranformationType transType, CreateTransformationCallBack createFn); 62 60 static bool unregisterTransformation(ETranformationType transType); 63 61 static bool initializeTransformation_; 64 #pragma omp threadprivate(initializeTransformation_)65 62 }; 66 63 … … 82 79 std::map<int, int>& elementPositionInGridDst2DomainPosition) 83 80 { 84 if (0 == transformationCreationCallBacks_)85 transformationCreationCallBacks_ = new CallBackMap();86 81 typename CallBackMap::const_iterator it = (*transformationCreationCallBacks_).find(transType); 87 82 if ((*transformationCreationCallBacks_).end() == it) -
XIOS/dev/branch_openmp/src/transformation/grid_transformation_selector.cpp
r1106 r1328 10 10 #include "grid.hpp" 11 11 #include "algo_types.hpp" 12 using namespace ep_lib; 12 13 13 14 namespace xios { -
XIOS/dev/branch_openmp/src/transformation/grid_transformation_selector.hpp
r978 r1328 12 12 #include <map> 13 13 #include <vector> 14 #include "mpi_std.hpp" 14 15 #include "generic_algorithm_transformation.hpp" 15 16 #include "transformation_enum.hpp" -
XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_extract_axis.cpp
r1155 r1328 14 14 #include "grid_transformation_factory_impl.hpp" 15 15 16 16 #include "reduction.hpp" 17 17 18 18 namespace xios { … … 49 49 StdString op = "extract"; 50 50 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)); 56 53 } 57 54 … … 60 57 CArray<double,1>& dataOut, 61 58 std::vector<bool>& flagInitial, 62 bool ignoreMissingValue )59 bool ignoreMissingValue, bool firstPass) 63 60 { 64 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue );61 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 65 62 } 66 63 -
XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_extract_axis.hpp
r1155 r1328 12 12 #include "scalar_algorithm_transformation.hpp" 13 13 #include "transformation.hpp" 14 #include "reduction.hpp"15 14 16 15 namespace xios { … … 25 24 Extract a scalar from an axis 26 25 */ 27 class CScalarAlgorithmExtractAxis : public CScalarAlgorithmTransformation , public CReductionAlgorithm26 class CScalarAlgorithmExtractAxis : public CScalarAlgorithmTransformation 28 27 { 29 28 public: … … 34 33 CArray<double,1>& dataOut, 35 34 std::vector<bool>& flagInitial, 36 bool ignoreMissingValue );35 bool ignoreMissingValue, bool firstPass); 37 36 38 37 virtual ~CScalarAlgorithmExtractAxis(); -
XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_reduce_axis.cpp
r1155 r1328 13 13 #include "grid.hpp" 14 14 #include "grid_transformation_factory_impl.hpp" 15 #include "reduction.hpp" 16 17 #include "reduction.hpp" 15 18 16 19 namespace xios { 17 18 //extern std::map<StdString,EReductionType> *CReductionAlgorithm::ReductionOperations_ptr;19 //#pragma omp threadprivate(CReductionAlgorithm::ReductionOperations_ptr)20 21 20 CGenericAlgorithmTransformation* CScalarAlgorithmReduceAxis::create(CGrid* gridDst, CGrid* gridSrc, 22 21 CTransformation<CScalar>* transformation, … … 76 75 } 77 76 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)) 82 79 ERROR("CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(CAxis* axisDestination, CAxis* axisSource, CReduceAxisToScalar* algo)", 83 80 << "Operation '" << op << "' not found. Please make sure to use a supported one" … … 85 82 << "Scalar destination " << scalarDestination->getId()); 86 83 87 reduction_ = CReductionAlgorithm::createOperation((*CReductionAlgorithm::ReductionOperations_ptr)[op]); 84 //reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 85 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations_ptr->at(op)); 88 86 } 89 87 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) 88 void 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) 95 90 { 96 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue );91 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 97 92 } 98 93 … … 115 110 TransformationWeightMap& transWeight = this->transformationWeight_[0]; 116 111 117 CArray<int,1>& axisSrcIndex = axisSrc_->index; 118 int globalIndexSize = axisSrcIndex.numElements(); 112 int globalIndexSize = axisSrc_-> n_glo; 119 113 120 114 for (int idx = 0; idx < globalIndexSize; ++idx) 121 115 { 122 transMap[0].push_back( axisSrcIndex(idx));116 transMap[0].push_back(idx); 123 117 transWeight[0].push_back(1.0); 124 118 } -
XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_reduce_axis.hpp
r1155 r1328 12 12 #include "scalar_algorithm_transformation.hpp" 13 13 #include "transformation.hpp" 14 #include "reduction.hpp"15 14 16 15 namespace xios { … … 25 24 Reducing an axis to a scalar 26 25 */ 27 class CScalarAlgorithmReduceAxis : public CScalarAlgorithmTransformation , public CReductionAlgorithm26 class CScalarAlgorithmReduceAxis : public CScalarAlgorithmTransformation 28 27 { 29 28 public: … … 34 33 CArray<double,1>& dataOut, 35 34 std::vector<bool>& flagInitial, 36 bool ignoreMissingValue );35 bool ignoreMissingValue, bool firstPass); 37 36 38 37 virtual void updateData(CArray<double,1>& dataOut); -
XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_reduce_domain.cpp
r1155 r1328 14 14 #include "grid_transformation_factory_impl.hpp" 15 15 16 16 #include "reduction.hpp" 17 17 18 18 namespace xios { … … 68 68 69 69 } 70 71 // if(CReductionAlgorithm::ReductionOperations_ptr == 0) 72 // CReductionAlgorithm::initReductionOperation(); 70 73 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)) 75 76 ERROR("CScalarAlgorithmReduceDomain::CScalarAlgorithmReduceDomain(CDomain* domainDestination, CDomain* domainSource, CReduceDomainToScalar* algo)", 76 77 << "Operation '" << op << "' not found. Please make sure to use a supported one" … … 78 79 << "Scalar destination " << scalarDestination->getId()); 79 80 80 reduction_ = CReductionAlgorithm::createOperation((*CReductionAlgorithm::ReductionOperations_ptr)[op]); 81 //reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 82 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations_ptr->at(op)); 81 83 } 82 84 … … 85 87 CArray<double,1>& dataOut, 86 88 std::vector<bool>& flagInitial, 87 bool ignoreMissingValue )89 bool ignoreMissingValue, bool firstPass) 88 90 { 89 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue );91 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 90 92 } 91 93 -
XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_reduce_domain.hpp
r1155 r1328 12 12 #include "scalar_algorithm_transformation.hpp" 13 13 #include "transformation.hpp" 14 #include "reduction.hpp"15 14 16 15 namespace xios { … … 25 24 Reducing an DOMAIN to a scalar 26 25 */ 27 class CScalarAlgorithmReduceDomain : public CScalarAlgorithmTransformation , public CReductionAlgorithm26 class CScalarAlgorithmReduceDomain : public CScalarAlgorithmTransformation 28 27 { 29 28 public: … … 34 33 CArray<double,1>& dataOut, 35 34 std::vector<bool>& flagInitial, 36 bool ignoreMissingValue );35 bool ignoreMissingValue, bool firstPass); 37 36 38 37 virtual void updateData(CArray<double,1>& dataOut);
Note: See TracChangeset
for help on using the changeset viewer.