Changeset 867
- Timestamp:
- 06/09/16 11:33:19 (9 years ago)
- Location:
- XIOS/trunk/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/client_client_dht_template.hpp
r860 r867 34 34 typedef T InfoType; 35 35 static const int infoTypeSize = sizeof(InfoType); 36 typedef typename boost::unordered_map<InfoType, std::vector<size_t> > InfoType2IndexMap;36 // typedef typename boost::unordered_map<InfoType, std::vector<size_t> > InfoType2IndexMap; 37 37 typedef typename boost::unordered_map<size_t,InfoType> Index2InfoTypeMap; 38 38 typedef typename boost::unordered_map<size_t,std::vector<InfoType> > Index2VectorInfoTypeMap; … … 47 47 void computeIndexInfoMapping(const CArray<size_t,1>& indices); 48 48 49 // const Index2InfoTypeMap& getInfoIndexMap() const {return indexToInfoMappingLevel_; }50 49 const Index2VectorInfoTypeMap& getInfoIndexMap() const {return indexToInfoMappingLevel_; } 51 52 50 int getNbClient() { return nbClient_; } 53 51 … … 102 100 protected: 103 101 //! Mapping of global index to the corresponding client 104 // Index2InfoTypeMap index2InfoMapping_;105 102 Index2VectorInfoTypeMap index2InfoMapping_; 106 103 107 104 //! A mapping of index to the corresponding information in each level of hierarchy 108 // Index2InfoTypeMap indexToInfoMappingLevel_;109 105 Index2VectorInfoTypeMap indexToInfoMappingLevel_; 110 106 107 //! Rank of client to send on each DHT level 111 108 std::vector<std::vector<int> > sendRank_; 112 109 110 //! Rank of client to receive on each DHT level 113 111 std::vector<std::vector<int> > recvRank_; 114 112 -
XIOS/trunk/src/client_client_dht_template_impl.hpp
r863 r867 205 205 if (iteIndexToInfoMap != itIndexToInfoMap) 206 206 sendNbIndexOnReturn[idx] += itIndexToInfoMap->second.size(); 207 // ++sendNbIndexOnReturn[idx];208 207 } 209 208 currentIndex += recvNbIndexClientCount[idx]; … … 294 293 ProcessDHTElement<InfoType>::unpackElement(unpackedInfo, recvInfoBuffOnReturn, infoIndex); 295 294 indexToInfoMapping[recvIndexBuffOnReturn[idx]].push_back(unpackedInfo); 296 // ProcessDHTElement<InfoType>::unpackElement(indexToInfoMapping[recvIndexBuffOnReturn[idx]], recvInfoBuffOnReturn, infoIndex); 297 } 298 299 indexToInfoMappingLevel_.swap(indexToInfoMapping); //indexToInfoMappingLevel_ = (indexToInfoMapping); 295 } 296 297 indexToInfoMappingLevel_.swap(indexToInfoMapping); 300 298 if (0 != recvNbIndexCount) delete [] recvIndexBuff; 301 299 for (boost::unordered_map<int,size_t*>::const_iterator it = client2ClientIndex.begin(); … … 318 316 delete [] it->second; 319 317 } 320 321 ///*!322 // Compute mapping between indices and information corresponding to these indices323 //for each level of hierarchical DHT. Recursive function324 // \param [in] indices indices a proc has325 // \param [in] commLevel communicator of current level326 // \param [in] level current level327 //*/328 //template<typename T, typename H>329 //void CClientClientDHTTemplate<T,H>::computeIndexInfoMappingLevel(const CArray<size_t,1>& indices,330 // const MPI_Comm& commLevel,331 // int level)332 //{333 // int clientRank;334 // MPI_Comm_rank(commLevel,&clientRank);335 // int groupRankBegin = this->getGroupBegin()[level];336 // int nbClient = this->getNbInGroup()[level];337 // std::vector<size_t> hashedIndex;338 // computeHashIndex(hashedIndex, nbClient);339 //340 // size_t ssize = indices.numElements(), hashedVal;341 //342 // std::vector<size_t>::const_iterator itbClientHash = hashedIndex.begin(), itClientHash,343 // iteClientHash = hashedIndex.end();344 // std::vector<int> sendBuff(nbClient,0);345 // std::vector<int> sendNbIndexBuff(nbClient,0);346 //347 // // Number of global index whose mapping server are on other clients348 // int nbIndexToSend = 0;349 // size_t index;350 // HashXIOS<size_t> hashGlobalIndex;351 // for (int i = 0; i < ssize; ++i)352 // {353 // index = indices(i);354 // hashedVal = hashGlobalIndex(index);355 // itClientHash = std::upper_bound(itbClientHash, iteClientHash, hashedVal);356 // int indexClient = std::distance(itbClientHash, itClientHash)-1;357 // ++sendNbIndexBuff[indexClient];358 // }359 //360 // boost::unordered_map<int, size_t* > client2ClientIndex;361 // for (int idx = 0; idx < nbClient; ++idx)362 // {363 // if (0 != sendNbIndexBuff[idx])364 // {365 // client2ClientIndex[idx+groupRankBegin] = new unsigned long [sendNbIndexBuff[idx]];366 // nbIndexToSend += sendNbIndexBuff[idx];367 // sendBuff[idx] = 1;368 // sendNbIndexBuff[idx] = 0;369 // }370 // }371 //372 // for (int i = 0; i < ssize; ++i)373 // {374 // index = indices(i);375 // hashedVal = hashGlobalIndex(index);376 // itClientHash = std::upper_bound(itbClientHash, iteClientHash, hashedVal);377 // {378 // int indexClient = std::distance(itbClientHash, itClientHash)-1;379 // {380 // client2ClientIndex[indexClient+groupRankBegin][sendNbIndexBuff[indexClient]] = index;381 // ++sendNbIndexBuff[indexClient];382 // }383 // }384 // }385 //386 // std::vector<int> recvRankClient, recvNbIndexClientCount;387 // sendRecvRank(level, sendBuff, sendNbIndexBuff,388 // recvRankClient, recvNbIndexClientCount);389 //390 // int recvNbIndexCount = 0;391 // for (int idx = 0; idx < recvNbIndexClientCount.size(); ++idx)392 // recvNbIndexCount += recvNbIndexClientCount[idx];393 //394 // unsigned long* recvIndexBuff;395 // if (0 != recvNbIndexCount)396 // recvIndexBuff = new unsigned long[recvNbIndexCount];397 //398 // std::vector<MPI_Request> request;399 // std::vector<int>::iterator itbRecvIndex = recvRankClient.begin(), itRecvIndex,400 // iteRecvIndex = recvRankClient.end(),401 // itbRecvNbIndex = recvNbIndexClientCount.begin(),402 // itRecvNbIndex;403 // int currentIndex = 0;404 // int nbRecvClient = recvRankClient.size();405 // for (int idx = 0; idx < nbRecvClient; ++idx)406 // {407 // if (0 != recvNbIndexClientCount[idx])408 // recvIndexFromClients(recvRankClient[idx], recvIndexBuff+currentIndex, recvNbIndexClientCount[idx], commLevel, request);409 // currentIndex += recvNbIndexClientCount[idx];410 // }411 //412 // boost::unordered_map<int, size_t* >::iterator itbIndex = client2ClientIndex.begin(), itIndex,413 // iteIndex = client2ClientIndex.end();414 // for (itIndex = itbIndex; itIndex != iteIndex; ++itIndex)415 // sendIndexToClients(itIndex->first, (itIndex->second), sendNbIndexBuff[itIndex->first-groupRankBegin], commLevel, request);416 //417 // std::vector<MPI_Status> status(request.size());418 // MPI_Waitall(request.size(), &request[0], &status[0]);419 //420 // CArray<size_t,1>* tmpGlobalIndex;421 // if (0 != recvNbIndexCount)422 // tmpGlobalIndex = new CArray<size_t,1>(recvIndexBuff, shape(recvNbIndexCount), neverDeleteData);423 // else424 // tmpGlobalIndex = new CArray<size_t,1>();425 //426 // // OK, we go to the next level and do something recursive427 // if (0 < level)428 // {429 // --level;430 // computeIndexInfoMappingLevel(*tmpGlobalIndex, this->internalComm_, level);431 // }432 // else // Now, we are in the last level where necessary mappings are.433 // indexToInfoMappingLevel_= (index2InfoMapping_);434 //435 // typename Index2InfoTypeMap::const_iterator iteIndexToInfoMap = indexToInfoMappingLevel_.end(), itIndexToInfoMap;436 // std::vector<int> sendNbIndexOnReturn(nbRecvClient,0);437 // currentIndex = 0;438 // for (int idx = 0; idx < nbRecvClient; ++idx)439 // {440 // for (int i = 0; i < recvNbIndexClientCount[idx]; ++i)441 // {442 // itIndexToInfoMap = indexToInfoMappingLevel_.find(*(recvIndexBuff+currentIndex+i));443 // if (iteIndexToInfoMap != itIndexToInfoMap) ++sendNbIndexOnReturn[idx];444 // }445 // currentIndex += recvNbIndexClientCount[idx];446 // }447 //448 // std::vector<int> recvRankOnReturn(client2ClientIndex.size());449 // std::vector<int> recvNbIndexOnReturn(client2ClientIndex.size(),0);450 // int indexIndex = 0;451 // for (itIndex = itbIndex; itIndex != iteIndex; ++itIndex, ++indexIndex)452 // {453 // recvRankOnReturn[indexIndex] = itIndex->first;454 // }455 // sendRecvOnReturn(recvRankClient, sendNbIndexOnReturn,456 // recvRankOnReturn, recvNbIndexOnReturn);457 //458 // int recvNbIndexCountOnReturn = 0;459 // for (int idx = 0; idx < recvRankOnReturn.size(); ++idx)460 // recvNbIndexCountOnReturn += recvNbIndexOnReturn[idx];461 //462 // unsigned long* recvIndexBuffOnReturn;463 // unsigned char* recvInfoBuffOnReturn;464 // if (0 != recvNbIndexCountOnReturn)465 // {466 // recvIndexBuffOnReturn = new unsigned long[recvNbIndexCountOnReturn];467 // recvInfoBuffOnReturn = new unsigned char[recvNbIndexCountOnReturn*ProcessDHTElement<InfoType>::typeSize()];468 // }469 //470 // std::vector<MPI_Request> requestOnReturn;471 // currentIndex = 0;472 // for (int idx = 0; idx < recvRankOnReturn.size(); ++idx)473 // {474 // if (0 != recvNbIndexOnReturn[idx])475 // {476 // recvIndexFromClients(recvRankOnReturn[idx], recvIndexBuffOnReturn+currentIndex, recvNbIndexOnReturn[idx], commLevel, requestOnReturn);477 // recvInfoFromClients(recvRankOnReturn[idx],478 // recvInfoBuffOnReturn+currentIndex*ProcessDHTElement<InfoType>::typeSize(),479 // recvNbIndexOnReturn[idx]*ProcessDHTElement<InfoType>::typeSize(),480 // commLevel, requestOnReturn);481 // }482 // currentIndex += recvNbIndexOnReturn[idx];483 // }484 //485 // boost::unordered_map<int,unsigned char*> client2ClientInfoOnReturn;486 // boost::unordered_map<int,size_t*> client2ClientIndexOnReturn;487 // currentIndex = 0;488 // for (int idx = 0; idx < nbRecvClient; ++idx)489 // {490 // if (0 != sendNbIndexOnReturn[idx])491 // {492 // int rank = recvRankClient[idx];493 // client2ClientIndexOnReturn[rank] = new unsigned long [sendNbIndexOnReturn[idx]];494 // client2ClientInfoOnReturn[rank] = new unsigned char [sendNbIndexOnReturn[idx]*ProcessDHTElement<InfoType>::typeSize()];495 // unsigned char* tmpInfoPtr = client2ClientInfoOnReturn[rank];496 // int infoIndex = 0;497 // int nb = 0;498 // for (int i = 0; i < recvNbIndexClientCount[idx]; ++i)499 // {500 // itIndexToInfoMap = indexToInfoMappingLevel_.find(*(recvIndexBuff+currentIndex+i));501 // if (iteIndexToInfoMap != itIndexToInfoMap)502 // {503 // client2ClientIndexOnReturn[rank][nb] = itIndexToInfoMap->first;504 // ProcessDHTElement<InfoType>::packElement(itIndexToInfoMap->second, tmpInfoPtr, infoIndex);505 // ++nb;506 // }507 // }508 //509 // sendIndexToClients(rank, client2ClientIndexOnReturn[rank],510 // sendNbIndexOnReturn[idx], commLevel, requestOnReturn);511 // sendInfoToClients(rank, client2ClientInfoOnReturn[rank],512 // sendNbIndexOnReturn[idx]*ProcessDHTElement<InfoType>::typeSize(), commLevel, requestOnReturn);513 // }514 // currentIndex += recvNbIndexClientCount[idx];515 // }516 //517 // std::vector<MPI_Status> statusOnReturn(requestOnReturn.size());518 // MPI_Waitall(requestOnReturn.size(), &requestOnReturn[0], &statusOnReturn[0]);519 //520 // boost::unordered_map<size_t,InfoType> indexToInfoMapping;521 // indexToInfoMapping.rehash(std::ceil(recvNbIndexCountOnReturn/indexToInfoMapping.max_load_factor()));522 // int infoIndex = 0;523 // for (int idx = 0; idx < recvNbIndexCountOnReturn; ++idx)524 // {525 // ProcessDHTElement<InfoType>::unpackElement(indexToInfoMapping[recvIndexBuffOnReturn[idx]], recvInfoBuffOnReturn, infoIndex);526 // }527 //528 // indexToInfoMappingLevel_.swap(indexToInfoMapping); //indexToInfoMappingLevel_ = (indexToInfoMapping);529 // if (0 != recvNbIndexCount) delete [] recvIndexBuff;530 // for (boost::unordered_map<int,size_t*>::const_iterator it = client2ClientIndex.begin();531 // it != client2ClientIndex.end(); ++it)532 // delete [] it->second;533 // delete tmpGlobalIndex;534 //535 // if (0 != recvNbIndexCountOnReturn)536 // {537 // delete [] recvIndexBuffOnReturn;538 // delete [] recvInfoBuffOnReturn;539 // }540 //541 // for (boost::unordered_map<int,unsigned char*>::const_iterator it = client2ClientInfoOnReturn.begin();542 // it != client2ClientInfoOnReturn.end(); ++it)543 // delete [] it->second;544 //545 // for (boost::unordered_map<int,size_t*>::const_iterator it = client2ClientIndexOnReturn.begin();546 // it != client2ClientIndexOnReturn.end(); ++it)547 // delete [] it->second;548 //}549 318 550 319 /*! … … 689 458 Index2VectorInfoTypeMap indexToInfoMapping; 690 459 indexToInfoMapping.rehash(std::ceil(currentIndex/indexToInfoMapping.max_load_factor())); 691 // boost::unordered_map<size_t,int> tmpInfoSize;692 // tmpInfoSize.rehash(std::ceil(currentIndex/tmpInfoSize.max_load_factor()));693 // currentIndex = 0;694 // for (int idx = 0; idx < nbRecvClient; ++idx)695 // {696 // int count = recvNbIndexClientCount[idx];697 // for (int i = 0; i < count; ++i)698 // {699 // ++tmpInfoSize[*(recvIndexBuff+currentIndex+i)];700 // }701 // currentIndex += count;702 // }703 //704 // for (boost::unordered_map<size_t,int>::iterator it=tmpInfoSize.begin(); it != tmpInfoSize.end(); ++it)705 // {706 // indexToInfoMapping[it->first].resize(it->second);707 // it->second = 0;708 // }709 710 460 currentIndex = 0; 711 461 InfoType infoValue; … … 714 464 for (int idx = 0; idx < nbRecvClient; ++idx) 715 465 { 716 //size_t index;466 size_t index; 717 467 int count = recvNbIndexClientCount[idx]; 718 468 for (int i = 0; i < count; ++i) 719 469 { 720 // index = *(recvIndexBuff+currentIndex+i);721 470 ProcessDHTElement<InfoType>::unpackElement(infoValue, infoBuff, infoIndex); 722 // ProcessDHTElement<InfoType>::unpackElement(indexToInfoMapping[index][tmpInfoSize[index]], infoBuff, infoIndex);723 // ++tmpInfoSize[index];724 471 indexToInfoMapping[*(recvIndexBuff+currentIndex+i)].push_back(infoValue); 725 472 } … … 749 496 index2InfoMapping_.swap(indexToInfoMapping); 750 497 } 751 752 ///*!753 // Compute distribution of global index for servers754 // Each client already holds a piece of information and its associated index.755 //This information will be redistributed among processes by projecting indices into size_t space,756 //the corresponding information will be also distributed on size_t space.757 //After the redistribution, each client holds rearranged index and its corresponding information.758 // \param [in] indexInfoMap index and its corresponding info (usually server index)759 // \param [in] commLevel communicator of current level760 // \param [in] level current level761 //*/762 //template<typename T, typename H>763 //void CClientClientDHTTemplate<T,H>::computeDistributedIndex(const boost::unordered_map<size_t,T>& indexInfoMap,764 // const MPI_Comm& commLevel,765 // int level)766 //{767 // int clientRank;768 // MPI_Comm_rank(commLevel,&clientRank);769 // computeSendRecvRank(level, clientRank);770 //771 // int groupRankBegin = this->getGroupBegin()[level];772 // int nbClient = this->getNbInGroup()[level];773 // std::vector<size_t> hashedIndex;774 // computeHashIndex(hashedIndex, nbClient);775 //776 // std::vector<int> sendBuff(nbClient,0);777 // std::vector<int> sendNbIndexBuff(nbClient,0);778 // std::vector<size_t>::const_iterator itbClientHash = hashedIndex.begin(), itClientHash,779 // iteClientHash = hashedIndex.end();780 // typename boost::unordered_map<size_t,InfoType>::const_iterator itb = indexInfoMap.begin(),it,781 // ite = indexInfoMap.end();782 // HashXIOS<size_t> hashGlobalIndex;783 //784 // // Compute size of sending and receving buffer785 // for (it = itb; it != ite; ++it)786 // {787 // size_t hashIndex = hashGlobalIndex(it->first);788 // itClientHash = std::upper_bound(itbClientHash, iteClientHash, hashIndex);789 // {790 // int indexClient = std::distance(itbClientHash, itClientHash)-1;791 // {792 // ++sendNbIndexBuff[indexClient];793 // }794 // }795 // }796 //797 // boost::unordered_map<int, size_t*> client2ClientIndex;798 // boost::unordered_map<int, unsigned char*> client2ClientInfo;799 // for (int idx = 0; idx < nbClient; ++idx)800 // {801 // if (0 != sendNbIndexBuff[idx])802 // {803 // client2ClientIndex[idx+groupRankBegin] = new unsigned long [sendNbIndexBuff[idx]];804 // client2ClientInfo[idx+groupRankBegin] = new unsigned char [sendNbIndexBuff[idx]*ProcessDHTElement<InfoType>::typeSize()];805 // sendNbIndexBuff[idx] = 0;806 // sendBuff[idx] = 1;807 // }808 // }809 //810 // std::vector<int> sendNbInfo(nbClient,0);811 // for (it = itb; it != ite; ++it)812 // {813 // size_t hashIndex = hashGlobalIndex(it->first);814 // itClientHash = std::upper_bound(itbClientHash, iteClientHash, hashIndex);815 // {816 // int indexClient = std::distance(itbClientHash, itClientHash)-1;817 // {818 // client2ClientIndex[indexClient + groupRankBegin][sendNbIndexBuff[indexClient]] = it->first;;819 // ProcessDHTElement<InfoType>::packElement(it->second, client2ClientInfo[indexClient + groupRankBegin], sendNbInfo[indexClient]);820 // ++sendNbIndexBuff[indexClient];821 // }822 // }823 // }824 //825 // // Calculate from how many clients each client receive message.826 // // Calculate size of buffer for receiving message827 // std::vector<int> recvRankClient, recvNbIndexClientCount;828 // sendRecvRank(level, sendBuff, sendNbIndexBuff,829 // recvRankClient, recvNbIndexClientCount);830 //831 // int recvNbIndexCount = 0;832 // for (int idx = 0; idx < recvNbIndexClientCount.size(); ++idx)833 // recvNbIndexCount += recvNbIndexClientCount[idx];834 //835 // unsigned long* recvIndexBuff;836 // unsigned char* recvInfoBuff;837 // if (0 != recvNbIndexCount)838 // {839 // recvIndexBuff = new unsigned long[recvNbIndexCount];840 // recvInfoBuff = new unsigned char[recvNbIndexCount*ProcessDHTElement<InfoType>::typeSize()];841 // }842 //843 // // If a client holds information about index and the corresponding which don't belong to it,844 // // it will send a message to the correct clients.845 // // Contents of the message are index and its corresponding informatioin846 // std::vector<MPI_Request> request;847 // int currentIndex = 0;848 // int nbRecvClient = recvRankClient.size();849 // for (int idx = 0; idx < nbRecvClient; ++idx)850 // {851 // if (0 != recvNbIndexClientCount[idx])852 // {853 // recvIndexFromClients(recvRankClient[idx], recvIndexBuff+currentIndex, recvNbIndexClientCount[idx], commLevel, request);854 // recvInfoFromClients(recvRankClient[idx],855 // recvInfoBuff+currentIndex*ProcessDHTElement<InfoType>::typeSize(),856 // recvNbIndexClientCount[idx]*ProcessDHTElement<InfoType>::typeSize(),857 // commLevel, request);858 // }859 // currentIndex += recvNbIndexClientCount[idx];860 // }861 //862 // boost::unordered_map<int, size_t* >::iterator itbIndex = client2ClientIndex.begin(), itIndex,863 // iteIndex = client2ClientIndex.end();864 // for (itIndex = itbIndex; itIndex != iteIndex; ++itIndex)865 // sendIndexToClients(itIndex->first, itIndex->second, sendNbIndexBuff[itIndex->first-groupRankBegin], commLevel, request);866 // boost::unordered_map<int, unsigned char*>::iterator itbInfo = client2ClientInfo.begin(), itInfo,867 // iteInfo = client2ClientInfo.end();868 // for (itInfo = itbInfo; itInfo != iteInfo; ++itInfo)869 // sendInfoToClients(itInfo->first, itInfo->second, sendNbInfo[itInfo->first-groupRankBegin], commLevel, request);870 //871 // std::vector<MPI_Status> status(request.size());872 // MPI_Waitall(request.size(), &request[0], &status[0]);873 //874 // boost::unordered_map<size_t,InfoType> indexToInfoMapping;875 // indexToInfoMapping.rehash(std::ceil(currentIndex/indexToInfoMapping.max_load_factor()));876 // currentIndex = 0;877 // InfoType infoValue;878 // int infoIndex = 0;879 // unsigned char* infoBuff = recvInfoBuff;880 // for (int idx = 0; idx < nbRecvClient; ++idx)881 // {882 // int count = recvNbIndexClientCount[idx];883 // for (int i = 0; i < count; ++i)884 // {885 // ProcessDHTElement<InfoType>::unpackElement(infoValue, infoBuff, infoIndex);886 // indexToInfoMapping[*(recvIndexBuff+currentIndex+i)] = infoValue;887 // }888 // currentIndex += count;889 // }890 //891 // if (0 != recvNbIndexCount)892 // {893 // delete [] recvIndexBuff;894 // delete [] recvInfoBuff;895 // }896 // for (boost::unordered_map<int,unsigned char*>::const_iterator it = client2ClientInfo.begin();897 // it != client2ClientInfo.end(); ++it)898 // delete [] it->second;899 //900 // for (boost::unordered_map<int,size_t*>::const_iterator it = client2ClientIndex.begin();901 // it != client2ClientIndex.end(); ++it)902 // delete [] it->second;903 //904 // // Ok, now do something recursive905 // if (0 < level)906 // {907 // --level;908 // computeDistributedIndex(indexToInfoMapping, this->internalComm_, level);909 // }910 // else911 // index2InfoMapping_.swap(indexToInfoMapping); //index2InfoMapping_ = (indexToInfoMapping);912 //}913 498 914 499 /*! … … 1107 692 { 1108 693 MPI_Irecv(&recvBuff[0]+2*idx, 2, MPI_INT, 1109 recvRank[idx], MPI_DHT_INDEX_ 1, this->internalComm_, &request[nRequest]);694 recvRank[idx], MPI_DHT_INDEX_0, this->internalComm_, &request[nRequest]); 1110 695 ++nRequest; 1111 696 } … … 1121 706 { 1122 707 MPI_Isend(&sendBuff[idx*2], 2, MPI_INT, 1123 sendRank[idx], MPI_DHT_INDEX_ 1, this->internalComm_, &request[nRequest]);708 sendRank[idx], MPI_DHT_INDEX_0, this->internalComm_, &request[nRequest]); 1124 709 ++nRequest; 1125 710 } -
XIOS/trunk/src/transformation/axis_algorithm_interpolate.cpp
r862 r867 274 274 transPosition_[idx].resize(1); 275 275 transPosition_[idx][0] = (dom->i_index)(idx) + niGlobDom * (dom->j_index)(idx); 276 // transPosition_[idx][0] = (dom->i_index)(idx);277 // transPosition_[idx][1] = (dom->j_index)(idx);278 276 } 279 277 } -
XIOS/trunk/src/transformation/axis_algorithm_transformation.cpp
r866 r867 14 14 #include "context_client.hpp" 15 15 #include "client_client_dht_template.hpp" 16 #include "axis.hpp" 16 17 17 18 namespace xios { … … 32 33 } 33 34 35 void CAxisAlgorithmTransformation::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 36 { 37 } 38 39 /*! 40 Compute global index of axis on different processes 41 \param [in] globalAxisIndex global index of axis source 42 \param [out] globalAxisIndexOnProc processes which contain the corresponding global index of axis source 43 */ 34 44 void CAxisAlgorithmTransformation::computeExchangeGlobalIndex(const CArray<size_t,1>& globalAxisIndex, 35 45 CClientClientDHTInt::Index2VectorInfoTypeMap& globalAxisIndexOnProc) … … 49 59 globalIndex2ProcRank[globalIndex].resize(1); 50 60 globalIndex2ProcRank[globalIndex][0] = clientRank; 51 // globalIndex2ProcRank[globalIndex].push_back(clientRank);52 61 } 53 62 … … 55 64 dhtIndexProcRank.computeIndexInfoMapping(globalAxisIndex); 56 65 57 // std::vector<int> countIndex(clientSize,0);58 // const CClientClientDHTInt::Index2VectorInfoTypeMap& computedGlobalIndexOnProc = dhtIndexProcRank.getInfoIndexMap();59 66 globalAxisIndexOnProc = dhtIndexProcRank.getInfoIndexMap(); 60 //61 // CClientClientDHTInt::Index2VectorInfoTypeMap::const_iterator itb = computedGlobalIndexOnProc.begin(), it,62 // ite = computedGlobalIndexOnProc.end();63 // for (it = itb; it != ite; ++it)64 // {65 // const std::vector<int>& procList = it->second;66 // for (int idx = 0; idx < procList.size(); ++idx) ++countIndex[procList[idx]];67 // }68 //69 // globalAxisIndexOnProc.rehash(std::ceil(clientSize/globalAxisIndexOnProc.max_load_factor()));70 // for (int idx = 0; idx < clientSize; ++idx)71 // {72 // if (0 != countIndex[idx])73 // {74 // globalAxisIndexOnProc[idx].resize(countIndex[idx]);75 // countIndex[idx] = 0;76 // }77 // }78 //79 // for (it = itb; it != ite; ++it)80 // {81 // const std::vector<int>& procList = it->second;82 // for (int idx = 0; idx < procList.size(); ++idx)83 // {84 // globalAxisIndexOnProc[procList[idx]][countIndex[procList[idx]]] = it->first;85 // ++countIndex[procList[idx]];86 // }87 // }88 67 } 89 68 90 void CAxisAlgorithmTransformation::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs)91 {92 69 } 93 94 /*!95 Compute an array of global index from a global index on a axis96 \param[in] axisDestGlobalIndex global index on an axis of destination grid97 \param[in] axisSrcGlobalIndex global index on an axis of source grid (which are needed by one index on axis destination)98 \param[in] axisPositionInGrid position of the axis in the grid99 \param[in] gridDestGlobalDim dimension size of destination grid (it should share the same size for all dimension, maybe except the axis on which transformation is performed)100 \param[in] globalIndexGridDestSendToServer global index of destination grid which are to be sent to server(s), this array is already acsending sorted101 \param[in/out] globalIndexDestGrid array of global index (for 2d grid, this array is a line, for 3d, this array represents a plan). It should be preallocated102 \param[in/out] globalIndexSrcGrid array of global index of source grid (for 2d grid, this array is a line, for 3d, this array represents a plan). It should be preallocated103 */104 void CAxisAlgorithmTransformation::computeGlobalGridIndexFromGlobalIndexElement(int axisDestGlobalIndex,105 const std::vector<int>& axisSrcGlobalIndex,106 const std::vector<int>& destGlobalIndexPositionInGrid,107 int axisPositionInGrid,108 const std::vector<int>& gridDestGlobalDim,109 const std::vector<int>& gridSrcGlobalDim,110 const GlobalLocalMap& globalLocalIndexDestSendToServerMap,111 std::vector<std::pair<size_t,int> >& globalLocalIndexDestMap,112 std::vector<std::vector<size_t> >& globalIndexSrcGrid)113 {114 bool hasDestGlobalIndexPos = !destGlobalIndexPositionInGrid.empty();115 int globalDim = gridDestGlobalDim.size();116 117 std::vector<size_t> currentIndex(globalDim);118 std::vector<int> gridAxisGlobalDim(globalDim);119 std::vector<int> idxLoop(globalDim, 0);120 121 size_t ssize = 1, idx = 0, realGlobalIndexSize = 0;122 for (int i = 0; i< globalDim; ++i)123 {124 if (axisPositionInGrid == i) gridAxisGlobalDim[i] = 1;125 else126 {127 if (!hasDestGlobalIndexPos) gridAxisGlobalDim[i] = gridDestGlobalDim[i];128 else gridAxisGlobalDim[i] = 1;129 }130 ssize *= gridAxisGlobalDim[i];131 }132 133 GlobalLocalMap::const_iterator iteArr = globalLocalIndexDestSendToServerMap.end(), it;134 135 while (idx < ssize)136 {137 for (int i = 0; i < globalDim-1; ++i)138 {139 if (idxLoop[i] == gridAxisGlobalDim[i])140 {141 idxLoop[i] = 0;142 ++idxLoop[i+1];143 }144 }145 146 int j = 0;147 for (int i = 0; i < globalDim; ++i)148 {149 if (!hasDestGlobalIndexPos) currentIndex[i] = idxLoop[i];150 else151 {152 if (axisPositionInGrid == i) currentIndex[i] = axisDestGlobalIndex;153 else154 {155 currentIndex[i] = destGlobalIndexPositionInGrid[j];156 ++j;157 }158 }159 }160 161 currentIndex[axisPositionInGrid] = axisDestGlobalIndex;162 163 size_t globIndex = currentIndex[0];164 size_t mulDim = 1;165 for (int k = 1; k < globalDim; ++k)166 {167 mulDim *= gridDestGlobalDim[k-1];168 globIndex += (currentIndex[k])*mulDim;169 }170 171 if (iteArr != globalLocalIndexDestSendToServerMap.find(globIndex)) ++realGlobalIndexSize;172 ++idxLoop[0];173 ++idx;174 }175 176 if (globalLocalIndexDestMap.size() != realGlobalIndexSize)177 globalLocalIndexDestMap.resize(realGlobalIndexSize);178 179 if (realGlobalIndexSize != globalIndexSrcGrid.size()) globalIndexSrcGrid.resize(realGlobalIndexSize);180 for (int i = 0; i < globalIndexSrcGrid.size(); ++i)181 if (globalIndexSrcGrid[i].size() != axisSrcGlobalIndex.size())182 globalIndexSrcGrid[i].resize(axisSrcGlobalIndex.size());183 184 size_t realGlobalIndex = 0;185 idx = 0;186 idxLoop.assign(globalDim, 0);187 while (idx < ssize)188 {189 for (int i = 0; i < globalDim-1; ++i)190 {191 if (idxLoop[i] == gridAxisGlobalDim[i])192 {193 idxLoop[i] = 0;194 ++idxLoop[i+1];195 }196 }197 198 int j = 0;199 for (int i = 0; i < globalDim; ++i)200 {201 if (!hasDestGlobalIndexPos) currentIndex[i] = idxLoop[i];202 else203 {204 if (axisPositionInGrid == i) currentIndex[i] = axisDestGlobalIndex;205 else206 {207 currentIndex[i] = destGlobalIndexPositionInGrid[j];208 ++j;209 }210 }211 }212 currentIndex[axisPositionInGrid] = axisDestGlobalIndex;213 214 size_t globIndex = currentIndex[0];215 size_t mulDim = 1;216 for (int k = 1; k < globalDim; ++k)217 {218 mulDim *= gridDestGlobalDim[k-1];219 globIndex += (currentIndex[k])*mulDim;220 }221 222 it = globalLocalIndexDestSendToServerMap.find(globIndex);223 if (iteArr != it)224 {225 globalLocalIndexDestMap[realGlobalIndex] = (std::make_pair(it->first,it->second));226 for (int i = 0; i < globalIndexSrcGrid[realGlobalIndex].size(); ++i)227 {228 currentIndex[axisPositionInGrid] = axisSrcGlobalIndex[i];229 globIndex = currentIndex[0];230 mulDim = 1;231 for (int k = 1; k < globalDim; ++k)232 {233 mulDim *= gridDestGlobalDim[k-1];234 globIndex += (currentIndex[k])*mulDim;235 }236 (globalIndexSrcGrid[realGlobalIndex])[i] = globIndex;237 }238 ++realGlobalIndex;239 }240 241 ++idxLoop[0];242 ++idx;243 }244 }245 } -
XIOS/trunk/src/transformation/axis_algorithm_transformation.hpp
r866 r867 11 11 12 12 #include "generic_algorithm_transformation.hpp" 13 #include "axis.hpp"14 13 15 14 namespace xios { 16 15 16 class CAxis; 17 17 /*! 18 18 \class CAxisAlgorithmTransformation … … 27 27 28 28 protected: 29 virtual void computeGlobalGridIndexFromGlobalIndexElement(int axisDestGlobalIndex,30 const std::vector<int>& axisSrcGlobalIndex,31 const std::vector<int>& destGlobalIndexPositionInGrid,32 int axisPositionInGrid,33 const std::vector<int>& gridDestGlobalDim,34 const std::vector<int>& gridSrcGlobalDim,35 const GlobalLocalMap& globalLocalIndexDestSendToServerMap,36 std::vector<std::pair<size_t,int> >& globalLocalIndexDestMap,37 std::vector<std::vector<size_t> >& globalIndexSrcGrid);38 39 29 void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs); 40 30 41 v oid computeExchangeGlobalIndex(const CArray<size_t,1>& globalAxisIndex,42 CClientClientDHTInt::Index2VectorInfoTypeMap& globalDomainIndexOnProc);31 virtual void computeExchangeGlobalIndex(const CArray<size_t,1>& globalAxisIndex, 32 CClientClientDHTInt::Index2VectorInfoTypeMap& globalDomainIndexOnProc); 43 33 44 34 protected: -
XIOS/trunk/src/transformation/domain_algorithm_transformation.cpp
r866 r867 28 28 } 29 29 30 /*! 31 Compute global index of domain on different processes 32 \param [in] globalDomainIndex global index of domain source 33 \param [out] globalDomainIndexOnProc processes which contain the corresponding global index of domain source 34 */ 30 35 void CDomainAlgorithmTransformation::computeExchangeGlobalIndex(const CArray<size_t,1>& globalDomainIndex, 31 36 CClientClientDHTInt::Index2VectorInfoTypeMap& globalDomainIndexOnProc) … … 54 59 dhtIndexProcRank.computeIndexInfoMapping(globalDomainIndex); 55 60 globalDomainIndexOnProc = dhtIndexProcRank.getInfoIndexMap(); 56 57 58 // std::vector<int> countIndex(clientSize,0);59 // const CClientClientDHTInt::Index2VectorInfoTypeMap& computedGlobalIndexOnProc = dhtIndexProcRank.getInfoIndexMap();60 // CClientClientDHTInt::Index2VectorInfoTypeMap::const_iterator itb = computedGlobalIndexOnProc.begin(), it,61 // ite = computedGlobalIndexOnProc.end();62 // for (it = itb; it != ite; ++it)63 // {64 // const std::vector<int>& procList = it->second;65 // for (int idx = 0; idx < procList.size(); ++idx) ++countIndex[procList[idx]];66 // }67 //68 // globalDomainIndexOnProc.rehash(std::ceil(clientSize/globalDomainIndexOnProc.max_load_factor()));69 // for (int idx = 0; idx < clientSize; ++idx)70 // {71 // if (0 != countIndex[idx])72 // {73 // globalDomainIndexOnProc[idx].resize(countIndex[idx]);74 // countIndex[idx] = 0;75 // }76 // }77 //78 // for (it = itb; it != ite; ++it)79 // {80 // const std::vector<int>& procList = it->second;81 // for (int idx = 0; idx < procList.size(); ++idx)82 // {83 // globalDomainIndexOnProc[procList[idx]][countIndex[procList[idx]]] = it->first;84 // ++countIndex[procList[idx]];85 // }86 // }87 61 } 88 62 89 /*!90 Compute an array of global index from a global index on a domain91 \param[in] domainDestGlobalIndex global index on an domain of destination grid92 \param[in] domainSrcGlobalIndex global index on an domain of source grid (which are needed by one index on domain destination)93 \param[in] domainPositionInGrid position of the domain in the grid94 \param[in] gridDestGlobalDim dimension size of destination grid (it should share the same size for all dimension, maybe except the domain on which transformation is performed)95 \param[in] gridSrcGlobalDim dimension size of source grid (it should share the same size for all dimension, maybe except the domain on which transformation is performed)96 \param[in] globalIndexGridDestSendToServer global index of destination grid which are to be sent to server(s), this array is already acsending sorted97 \param[in/out] globalIndexDestGrid array of global index (for 2d grid, this array is a line, for 3d, this array represents a plan). It should be preallocated98 \param[in/out] globalIndexSrcGrid array of global index of source grid (for 2d grid, this array is a line, for 3d, this array represents a plan). It should be preallocated99 */100 void CDomainAlgorithmTransformation::computeGlobalGridIndexFromGlobalIndexElement(int domainDestGlobalIndex,101 const std::vector<int>& domainSrcGlobalIndex,102 const std::vector<int>& destGlobalIndexPositionInGrid,103 int domainPositionInGrid,104 const std::vector<int>& gridDestGlobalDim,105 const std::vector<int>& gridSrcGlobalDim,106 const GlobalLocalMap& globalLocalIndexDestSendToServerMap,107 std::vector<std::pair<size_t,int> >& globalLocalIndexDestMap,108 std::vector<std::vector<size_t> >& globalIndexSrcGrid)109 {110 int globalDim = gridDestGlobalDim.size();111 int numElement = globalDim - 1;112 int domainElementPosition = 0;113 std::vector<int> currentIndex(globalDim);114 std::vector<int> gridDomainGlobalDim(numElement), indexMap(numElement);115 std::vector<int> idxLoop(numElement, 0), domainSrcGlobalDim(2), domainDestGlobalDim(2);116 117 118 size_t ssize = 1, idx = 0, realGlobalIndexSize = 0;119 for (int i = 0; i< globalDim; ++i)120 {121 if (domainPositionInGrid == i) continue;122 if (domainPositionInGrid == (i+1))123 {124 domainDestGlobalDim[0] = gridDestGlobalDim[i];125 domainDestGlobalDim[1] = gridDestGlobalDim[i+1];126 domainSrcGlobalDim[0] = gridSrcGlobalDim[i];127 domainSrcGlobalDim[1] = gridSrcGlobalDim[i+1];128 gridDomainGlobalDim[idx] = 1;129 domainElementPosition = idx;130 }131 else132 {133 gridDomainGlobalDim[idx] = gridDestGlobalDim[i];134 }135 indexMap[idx] = i;136 ++idx;137 }138 int iIndex = domainDestGlobalIndex % domainDestGlobalDim[0];139 int jIndex = domainDestGlobalIndex / domainDestGlobalDim[0];140 141 for (int i = 0; i< numElement; ++i) ssize *= gridDomainGlobalDim[i];142 143 GlobalLocalMap::const_iterator iteArr = globalLocalIndexDestSendToServerMap.end(), it;144 145 idx = 0;146 while (idx < ssize)147 {148 for (int i = 0; i < numElement; ++i)149 {150 if (idxLoop[i] == gridDomainGlobalDim[i])151 {152 idxLoop[i] = 0;153 ++idxLoop[i+1];154 }155 }156 157 for (int i = 0; i < numElement; ++i)158 {159 if (domainElementPosition == i)160 {161 currentIndex[indexMap[i]] = iIndex;162 currentIndex[indexMap[i]+1] = jIndex;163 }164 else165 currentIndex[indexMap[i]] = idxLoop[i];166 }167 168 size_t globIndex = currentIndex[0];169 size_t mulDim = 1;170 for (int k = 1; k < globalDim; ++k)171 {172 mulDim *= gridDestGlobalDim[k-1];173 globIndex += (currentIndex[k])*mulDim;174 }175 176 if (iteArr != globalLocalIndexDestSendToServerMap.find(globIndex)) ++realGlobalIndexSize;177 ++idxLoop[0];178 ++idx;179 }180 181 if (globalLocalIndexDestMap.size() != realGlobalIndexSize)182 globalLocalIndexDestMap.resize(realGlobalIndexSize);183 184 if (realGlobalIndexSize != globalIndexSrcGrid.size()) globalIndexSrcGrid.resize(realGlobalIndexSize);185 for (int i = 0; i < globalIndexSrcGrid.size(); ++i)186 if (globalIndexSrcGrid[i].size() != domainSrcGlobalIndex.size())187 globalIndexSrcGrid[i].resize(domainSrcGlobalIndex.size());188 189 size_t realGlobalIndex = 0;190 idx = 0;191 idxLoop.assign(globalDim, 0);192 while (idx < ssize)193 {194 for (int i = 0; i < numElement; ++i)195 {196 if (idxLoop[i] == gridDomainGlobalDim[i])197 {198 idxLoop[i] = 0;199 ++idxLoop[i+1];200 }201 }202 203 for (int i = 0; i < numElement; ++i)204 {205 if (domainElementPosition == i)206 {207 currentIndex[indexMap[i]] = iIndex;208 currentIndex[indexMap[i]+1] = jIndex;209 }210 else211 currentIndex[indexMap[i]] = idxLoop[i];212 }213 214 size_t globIndex = currentIndex[0];215 size_t mulDim = 1;216 for (int k = 1; k < globalDim; ++k)217 {218 mulDim *= gridDestGlobalDim[k-1];219 globIndex += (currentIndex[k])*mulDim;220 }221 222 it = globalLocalIndexDestSendToServerMap.find(globIndex);223 if (iteArr != it)224 {225 globalLocalIndexDestMap[realGlobalIndex] = (std::make_pair(it->first,it->second));226 for (int i = 0; i < globalIndexSrcGrid[realGlobalIndex].size(); ++i)227 {228 domainGlobalIndex(domainSrcGlobalIndex[i], domainSrcGlobalDim[0], domainSrcGlobalDim[1],229 currentIndex[indexMap[domainElementPosition]],230 currentIndex[indexMap[domainElementPosition]+1]);231 232 globIndex = currentIndex[0];233 mulDim = 1;234 for (int k = 1; k < globalDim; ++k)235 {236 mulDim *= gridSrcGlobalDim[k-1];237 globIndex += (currentIndex[k])*mulDim;238 }239 (globalIndexSrcGrid[realGlobalIndex])[i] = globIndex;240 }241 ++realGlobalIndex;242 }243 244 ++idxLoop[0];245 ++idx;246 }247 63 } 248 249 void CDomainAlgorithmTransformation::domainGlobalIndex(const int& index, const int& niGlob, const int& njGlob,250 int& iIndex, int& jIndex)251 {252 iIndex = index % niGlob;253 jIndex = index / niGlob;254 }255 } -
XIOS/trunk/src/transformation/domain_algorithm_transformation.hpp
r866 r867 28 28 29 29 protected: 30 virtual void computeGlobalGridIndexFromGlobalIndexElement(int domainDestGlobalIndex,31 const std::vector<int>& domainSrcGlobalIndex,32 const std::vector<int>& destGlobalIndexPositionInGrid,33 int domainPositionInGrid,34 const std::vector<int>& gridDestGlobalDim,35 const std::vector<int>& gridSrcGlobalDim,36 const GlobalLocalMap& globalLocalIndexDestSendToServerMap,37 std::vector<std::pair<size_t,int> >& globalLocalIndexDestMap,38 std::vector<std::vector<size_t> >& globalIndexSrcGrid);39 40 30 void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >&); 41 31 42 v oid computeExchangeGlobalIndex(const CArray<size_t,1>& globalDomainIndex,32 virtual void computeExchangeGlobalIndex(const CArray<size_t,1>& globalDomainIndex, 43 33 CClientClientDHTInt::Index2VectorInfoTypeMap& globalDomainIndexOnProc); 44 protected:45 inline void domainGlobalIndex(const int& index, const int& niGlob, const int& njGlob,46 int& iIndex, int& jIndex);47 34 48 35 protected: -
XIOS/trunk/src/transformation/generic_algorithm_transformation.cpp
r866 r867 22 22 This function computes the global indexes of grid source, which the grid destination is in demand. 23 23 \param[in] elementPositionInGrid position of an element in a grid .E.g: if grid is composed of domain and axis (in order), 24 then position of axis in grid is 2 (since a domain is considered to contain 2 elements (axis)25 \param[in] gridDestGlobalDim global size of each dimension of grid source (all dimension must have the same size except of the one on which transformation is performed)26 \param[in] gridSrcGlobalDim dimension size of source grid (it should share the same size for all dimension, maybe except the domain on which transformation is performed)27 \param[in] globalLocalIndexGridDestSendToServer global and local index mapping of grid destination on the current client to send to server28 \param[in/out] globaIndexWeightFromDestToSource mapping between transformed global index of grid destination29 and the weighted value as well as global index from grid index source30 */31 //void CGenericAlgorithmTransformation::computeGlobalSourceIndex(int elementPositionInGrid,32 // const std::vector<int>& gridDestGlobalDim,33 // const std::vector<int>& gridSrcGlobalDim,34 // const GlobalLocalMap& globalLocalIndexGridDestSendToServer,35 // DestinationIndexMap& globaIndexWeightFromDestToSource)36 //{37 // bool isTransPosEmpty = transformationPosition_.empty();38 // for (size_t idxTrans = 0; idxTrans < transformationMapping_.size(); ++idxTrans)39 // {40 // TransformationIndexMap::const_iterator itbTransMap = transformationMapping_[idxTrans].begin(), itTransMap,41 // iteTransMap = transformationMapping_[idxTrans].end();42 // TransformationWeightMap::const_iterator itTransWeight = transformationWeight_[idxTrans].begin();43 //44 // // If transformation position exists45 // TransformationIndexMap::const_iterator itTransPos, iteTransPos;46 // if (!isTransPosEmpty)47 // {48 // itTransPos = transformationPosition_[idxTrans].begin(),49 // iteTransPos = transformationPosition_[idxTrans].end();50 // }51 // std::vector<int> emptyTransPos;52 //53 // std::vector<std::vector<size_t> > globalIndexSrcGrid;54 // std::vector<std::pair<size_t,int> > globalLocalIndexDest;55 // for (itTransMap = itbTransMap; itTransMap != iteTransMap; ++itTransMap, ++itTransWeight)56 // {57 // if (!isTransPosEmpty)58 // {59 // this->computeGlobalGridIndexFromGlobalIndexElement(itTransMap->first,60 // itTransMap->second,61 // itTransPos->second,62 // elementPositionInGrid,63 // gridDestGlobalDim,64 // gridSrcGlobalDim,65 // globalLocalIndexGridDestSendToServer,66 // globalLocalIndexDest,67 // globalIndexSrcGrid);68 // ++itTransPos;69 // }70 // else71 // {72 // this->computeGlobalGridIndexFromGlobalIndexElement(itTransMap->first,73 // itTransMap->second,74 // emptyTransPos,75 // elementPositionInGrid,76 // gridDestGlobalDim,77 // gridSrcGlobalDim,78 // globalLocalIndexGridDestSendToServer,79 // globalLocalIndexDest,80 // globalIndexSrcGrid);81 // }82 // std::vector<std::pair<size_t,int> >::const_iterator it = globalLocalIndexDest.begin(), ite = globalLocalIndexDest.end();83 // const std::vector<double>& currentVecWeight = itTransWeight->second;84 //85 // for (size_t idx = 0; it != ite; ++it, ++idx)86 // {87 // size_t srcGridSize = globalIndexSrcGrid[idx].size();88 //// globaIndexWeightFromDestToSource[(it->first)].resize(srcGridSize);89 // DestinationGlobalIndex& tmp = globaIndexWeightFromDestToSource[(it->first)];90 // tmp.resize(srcGridSize);91 // for (int i = 0; i < srcGridSize; ++i)92 // {93 // tmp[i].first = it->second;94 // tmp[i].second = make_pair(globalIndexSrcGrid[idx][i], currentVecWeight[i]);95 //// globaIndexWeightFromDestToSource[(it->first)][i] = (make_pair(it->second, make_pair(globalIndexSrcGrid[idx][i], currentVecWeight[i])));96 // }97 // }98 // }99 // }100 //}101 102 /*!103 This function computes the global indexes of grid source, which the grid destination is in demand.104 \param[in] elementPositionInGrid position of an element in a grid .E.g: if grid is composed of domain and axis (in order),105 24 then position of axis in grid is 1 and domain is positioned at 0. 106 25 \param[in] gridSrc Grid source 107 26 \param[in] gridDst Grid destination 108 \param[in ] globaIndexWeightFromSrcToDst mapping of each global index source and weight to index destination27 \param[in\out] globaIndexWeightFromSrcToDst mapping of each global index source and weight to index destination 109 28 */ 110 29 void CGenericAlgorithmTransformation::computeGlobalSourceIndex(int elementPositionInGrid, -
XIOS/trunk/src/transformation/generic_algorithm_transformation.hpp
r866 r867 47 47 virtual ~CGenericAlgorithmTransformation() {} 48 48 49 // void computeGlobalSourceIndex(int elementPositionInGrid,50 // const std::vector<int>& gridDestGlobalDim,51 // const std::vector<int>& gridSrcGlobalDim,52 // const GlobalLocalMap& globalLocalIndexGridDestSendToServer,53 // DestinationIndexMap& globaIndexWeightFromDestToSource);54 55 49 void computeGlobalSourceIndex(int elementPositionInGrid, 56 50 CGrid* gridSrc, … … 66 60 67 61 protected: 68 /*!69 Compute an array of global index from a global index on an element70 \param[in] destGlobalIndex global index on an element of destination grid71 \param[in] srcGlobalIndex global index(es) on an element of source grid (which are needed by one index on element destination)72 \param[in] elementPositionInGrid position of the element in the grid (for example: a grid with one domain and one axis, position of domain is 1, position of axis is 2)73 \param[in] gridDestGlobalDim dimension size of destination grid (it should share the same size for all dimension, maybe except the element on which transformation is performed)74 \param[in] globalLocalIndexDestSendToServerMap pair of global index and local index of destination grid which are to be sent to server(s), this array is already acsending sorted75 \param[in/out] globalLocalIndexDestMap array of global index (for 2d grid, this array maybe a line, for 3d, this array may represent a plan). It should be preallocated76 \param[in/out] globalIndexSrcGrid array of global index of source grid (for 2d grid, this array is a line, for 3d, this array represents a plan). It should be preallocated77 */78 virtual void computeGlobalGridIndexFromGlobalIndexElement(int destGlobalIndex,79 const std::vector<int>& srcGlobalIndex,80 const std::vector<int>& destGlobalIndexPositionInGrid,81 int elementPositionInGrid,82 const std::vector<int>& gridDestGlobalDim,83 const std::vector<int>& gridSrcGlobalDim,84 const GlobalLocalMap& globalLocalIndexDestSendToServerMap,85 std::vector<std::pair<size_t,int> >& globalLocalIndexDestMap,86 std::vector<std::vector<size_t> >& globalIndexSrcGrid) = 0;87 88 62 virtual void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >&) = 0; 89 63 64 /*! 65 Compute proc which contains global index of an element 66 \param[in] globalElementIndex demanding global index of an element of source grid 67 \param[out] globalElementIndexOnProc Proc contains the demanding global index 68 */ 90 69 virtual void computeExchangeGlobalIndex(const CArray<size_t,1>& globalElementIndex, 91 70 CClientClientDHTInt::Index2VectorInfoTypeMap& globalElementIndexOnProc) = 0; 92 71 72 protected: 93 73 void computeGlobalGridIndexMapping(int elementPositionInGrid, 94 74 const std::vector<int>& srcRank, … … 118 98 std::vector<TransformationPositionMap> transformationPosition_; 119 99 120 //! Id of auxillary inputs which help doing transformation dynamically100 //! Id of auxillary inputs which helps doing transformation dynamically 121 101 std::vector<StdString> idAuxInputs_; 122 102 }; -
XIOS/trunk/src/transformation/grid_transformation.cpp
- Property svn:executable set to *
r862 r867 15 15 #include "context.hpp" 16 16 #include "context_client.hpp" 17 #include "transformation_mapping.hpp"18 17 #include "axis_algorithm_transformation.hpp" 19 18 #include "distribution_client.hpp" 20 19 #include "mpi_tag.hpp" 20 #include "grid.hpp" 21 21 #include <boost/unordered_map.hpp> 22 22 … … 24 24 CGridTransformation::CGridTransformation(CGrid* destination, CGrid* source) 25 25 : gridSource_(source), gridDestination_(destination), originalGridSource_(source), 26 algoTypes_(), nbAlgos_(0), currentGridIndexToOriginalGridIndex_(),tempGrids_(),26 algoTypes_(), nbAlgos_(0), tempGrids_(), 27 27 auxInputs_(), dynamicalTransformation_(false), timeStamp_() 28 28 … … 45 45 } 46 46 47 initialize MappingOfOriginalGridSource();47 initializeTransformations(); 48 48 } 49 49 … … 54 54 for each transformation, we need to make sure that the current "temporary source" maps its global index correctly to the original one. 55 55 */ 56 void CGridTransformation::initialize MappingOfOriginalGridSource()56 void CGridTransformation::initializeTransformations() 57 57 { 58 58 CContext* context = CContext::getCurrent(); … … 95 95 { 96 96 axisPositionInGrid.push_back(i); 97 // axisPositionInGrid.push_back(idx);98 // ++idx;99 97 } 100 98 else 101 99 { 102 100 domPositionInGrid.push_back(i); 103 // ++idx;104 // domPositionInGrid.push_back(idx);105 // ++idx;106 101 } 107 102 } … … 123 118 { 124 119 initializeAxisAlgorithms(i); 125 // initializeAxisAlgorithms(idx);126 // ++idx;127 120 } 128 121 else 129 122 { 130 123 initializeDomainAlgorithms(i); 131 // ++idx;132 // initializeDomainAlgorithms(idx);133 // ++idx;134 124 } 135 125 } … … 357 347 -) Chose the correct algorithm by transformation type and position of element 358 348 -) Calculate the mapping of global index between the current grid source and grid destination 359 -) Calculate the mapping of global index between current grid DESTINATION and ORIGINALgrid SOURCE349 -) Calculate the mapping of global index between current grid DESTINATION and grid SOURCE 360 350 -) Make current grid destination become grid source in the next transformation 361 351 */ 362 //void CGridTransformation::computeAll(const std::vector<CArray<double,1>* >& dataAuxInputs, Time timeStamp)363 //{364 // if (nbAlgos_ < 1) return;365 // if (!auxInputs_.empty() && !dynamicalTransformation_) { dynamicalTransformation_ = true; return; }366 // if (dynamicalTransformation_)367 // {368 // if (timeStamp_.insert(timeStamp).second)369 // DestinationIndexMap().swap(currentGridIndexToOriginalGridIndex_); // Reset map370 // else371 // return;372 // }373 //374 // CContext* context = CContext::getCurrent();375 // CContextClient* client = context->client;376 //377 // ListAlgoType::const_iterator itb = listAlgos_.begin(),378 // ite = listAlgos_.end(), it;379 //380 // CGenericAlgorithmTransformation* algo = 0;381 // int nbAgloTransformation = 0; // Only count for executed transformation. Generate domain is a special one, not executed in the list382 // for (it = itb; it != ite; ++it)383 // {384 // int elementPositionInGrid = it->first;385 // ETranformationType transType = (it->second).first;386 // int transformationOrder = (it->second).second;387 // DestinationIndexMap globaIndexWeightFromDestToSource;388 //389 // // First of all, select an algorithm390 // if (!dynamicalTransformation_ || (algoTransformation_.size() < listAlgos_.size()))391 // {392 // selectAlgo(elementPositionInGrid, transType, transformationOrder, algoTypes_[std::distance(itb, it)]);393 // algo = algoTransformation_.back();394 // }395 // else396 // algo = algoTransformation_[std::distance(itb, it)];397 //398 // if (0 != algo) // Only registered transformation can be executed399 // {400 // algo->computeIndexSourceMapping(dataAuxInputs);401 //402 // // Recalculate the distribution of grid destination403 // CDistributionClient distributionClientDest(client->clientRank, gridDestination_);404 // const CDistributionClient::GlobalLocalDataMap& globalLocalIndexGridDestSendToServer = distributionClientDest.getGlobalLocalDataSendToServer();405 //406 // // ComputeTransformation of global index of each element407 // std::vector<int> gridDestinationDimensionSize = gridDestination_->getGlobalDimension();408 // std::vector<int> gridSrcDimensionSize = gridSource_->getGlobalDimension();409 // int elementPosition = it->first;410 // algo->computeGlobalSourceIndex(elementPosition,411 // gridDestinationDimensionSize,412 // gridSrcDimensionSize,413 // globalLocalIndexGridDestSendToServer,414 // globaIndexWeightFromDestToSource);415 //416 // // Compute transformation of global indexes among grids417 // computeTransformationMapping(globaIndexWeightFromDestToSource);418 //419 // // Update number of local index on each transformation420 // nbLocalIndexOnGridDest_.push_back(globalLocalIndexGridDestSendToServer.size());421 //422 // if (1 < nbAlgos_)423 // {424 // // Now grid destination becomes grid source in a new transformation425 // if (nbAgloTransformation != (nbAlgos_-1)) setUpGrid(elementPositionInGrid, transType, nbAgloTransformation);426 // }427 // ++nbAgloTransformation;428 // }429 // }430 //}431 432 352 void CGridTransformation::computeAll(const std::vector<CArray<double,1>* >& dataAuxInputs, Time timeStamp) 433 353 { … … 436 356 if (dynamicalTransformation_) 437 357 { 438 if (timeStamp_.insert(timeStamp).second) 439 { 440 DestinationIndexMap().swap(currentGridIndexToOriginalGridIndex_); // Reset map 441 std::list<size_t>().swap(nbLocalIndexOnGridDest_); 358 if (timeStamp_.insert(timeStamp).second) //Reset map 359 { 442 360 std::list<SendingIndexGridSourceMap>().swap(localIndexToSendFromGridSource_); 443 361 std::list<RecvIndexGridDestinationMap>().swap(localIndexToReceiveOnGridDest_); 444 } 362 std::list<size_t>().swap(nbLocalIndexOnGridDest_); 363 } 445 364 else 446 365 return; … … 555 474 } 556 475 557 558 559 476 // Sending global index of grid source to corresponding process as well as the corresponding mask 560 477 std::vector<MPI_Request> requests; … … 720 637 } 721 638 722 ///*!723 // Compute exchange index between grid source and grid destination724 // \param [in] globalIndexWeightFromDestToSource global index mapping between grid destination and grid source725 //*/726 //void CGridTransformation::computeTransformationMapping(const DestinationIndexMap& globalIndexWeightFromDestToSource)727 //{728 // CContext* context = CContext::getCurrent();729 // CContextClient* client = context->client;730 //731 // CTransformationMapping transformationMap(gridDestination_, gridSource_);732 //733 // transformationMap.computeTransformationMapping(globalIndexWeightFromDestToSource);734 //735 // const CTransformationMapping::ReceivedIndexMap& globalIndexToReceive = transformationMap.getGlobalIndexReceivedOnGridDestMapping();736 // CTransformationMapping::ReceivedIndexMap::const_iterator itbMapRecv, itMapRecv, iteMapRecv;737 // itbMapRecv = globalIndexToReceive.begin();738 // iteMapRecv = globalIndexToReceive.end();739 // localIndexToReceiveOnGridDest_.push_back(RecvIndexGridDestinationMap());740 // RecvIndexGridDestinationMap& recvTmp = localIndexToReceiveOnGridDest_.back();741 // for (itMapRecv = itbMapRecv; itMapRecv != iteMapRecv; ++itMapRecv)742 // {743 // int sourceRank = itMapRecv->first;744 // int numGlobalIndex = (itMapRecv->second).size();745 // recvTmp[sourceRank].resize(numGlobalIndex);746 // for (int i = 0; i < numGlobalIndex; ++i)747 // {748 // recvTmp[sourceRank][i] = make_pair((itMapRecv->second)[i].localIndex,(itMapRecv->second)[i].weight);749 // }750 // }751 //752 // // Find out local index on grid source (to send)753 // const CTransformationMapping::SentIndexMap& globalIndexToSend = transformationMap.getGlobalIndexSendToGridDestMapping();754 // CTransformationMapping::SentIndexMap::const_iterator itbMap, itMap, iteMap;755 // itbMap = globalIndexToSend.begin();756 // iteMap = globalIndexToSend.end();757 // localIndexToSendFromGridSource_.push_back(SendingIndexGridSourceMap());758 // SendingIndexGridSourceMap& tmpSend = localIndexToSendFromGridSource_.back();759 // for (itMap = itbMap; itMap != iteMap; ++itMap)760 // {761 // int destRank = itMap->first;762 // int vecSize = itMap->second.size();763 // tmpSend[destRank].resize(vecSize);764 // for (int idx = 0; idx < vecSize; ++idx)765 // {766 // tmpSend[destRank](idx) = itMap->second[idx].first;767 // }768 // }769 //}770 771 639 bool CGridTransformation::isSpecialTransformation(ETranformationType transType) 772 640 { -
XIOS/trunk/src/transformation/grid_transformation.hpp
r862 r867 12 12 #include <map> 13 13 #include <vector> 14 #include "grid.hpp"15 14 #include "generic_algorithm_transformation.hpp" 16 15 #include "transformation_enum.hpp" … … 25 24 This class is an interface for all transformations to interact with the rest of XIOS. 26 25 The class, firstly, tries to get all information relating to requested transformations by retrieving directly from grid. 27 Then with all these information, all necessary transformations will be created by generic class \class CGenericAlgorithmTransformation. 28 Because there are information exchange among clients to accomplish the transformations (e.g: some index need retrieving from other clients), 29 this class uses class \class CTransformationMapping to fulfill this demand. 26 Secondly, with all these information, all necessary transformations will be created by generic class \class CGenericAlgorithmTransformation. 27 Then this class accomplishes the transformations by exchanging information among clients (e.g: some index need retrieving index from other clients), 30 28 For each transformation, a new temporary grid source is created. 31 29 For a consequential transformations (e.g: inversing -> zoom -> inversing -> ...), … … 63 61 void initializeAxisAlgorithms(int axisPositionInGrid); 64 62 void initializeDomainAlgorithms(int domPositionInGrid); 65 void initialize MappingOfOriginalGridSource();63 void initializeTransformations(); 66 64 67 65 void selectAxisAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder); … … 69 67 void selectAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder, bool isDomainAlgo); 70 68 void setUpGrid(int elementPositionInGrid, ETranformationType transType, int nbTransformation); 71 // void computeFinalTransformationMapping();72 // void computeTransformationFromOriginalGridSource(const DestinationIndexMap& globaIndexMapFromDestToSource);73 69 void computeTransformationMapping(const SourceDestinationIndexMap& globalIndexWeightFromSrcToDest); 74 // void updateFinalGridDestination();75 70 bool isSpecialTransformation(ETranformationType transType); 76 71 … … 113 108 std::map<int, int> elementPosition2AxisPositionInGrid_, elementPosition2DomainPositionInGrid_; 114 109 115 //! (Grid) Global index of grid source116 DestinationIndexMap currentGridIndexToOriginalGridIndex_;117 118 110 std::vector<CGrid*> tempGrids_; 119 111 std::vector<StdString> auxInputs_;
Note: See TracChangeset
for help on using the changeset viewer.