Changeset 1236 for XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.cpp
- Timestamp:
- 08/04/17 16:03:34 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.cpp
r1232 r1236 18 18 #include "server_distribution_description.hpp" 19 19 #include "client_server_mapping_distributed.hpp" 20 #include "zoom_domain.hpp"21 #include "interpolate_domain.hpp"22 #include "generate_rectilinear_domain.hpp"23 20 24 21 #include <algorithm> … … 30 27 CDomain::CDomain(void) 31 28 : CObjectTemplate<CDomain>(), CDomainAttributes() 32 , isChecked(false), relFiles(), isClientChecked(false), nb ConnectedClients_(), indSrv_(), connectedServerRank_(), connectedServerZoomRank_()29 , isChecked(false), relFiles(), isClientChecked(false), nbSenders(), indSrv_(), connectedServerRank_() 33 30 , hasBounds(false), hasArea(false), isCompressible_(false), isUnstructed_(false) 34 31 , isClientAfterTransformationChecked(false), hasLonLat(false) … … 41 38 CDomain::CDomain(const StdString & id) 42 39 : CObjectTemplate<CDomain>(id), CDomainAttributes() 43 , isChecked(false), relFiles(), isClientChecked(false), nb ConnectedClients_(), indSrv_(), connectedServerRank_(), connectedServerZoomRank_()40 , isChecked(false), relFiles(), isClientChecked(false), nbSenders(), indSrv_(), connectedServerRank_() 44 41 , hasBounds(false), hasArea(false), isCompressible_(false), isUnstructed_(false) 45 42 , isClientAfterTransformationChecked(false), hasLonLat(false) … … 119 116 * \return A map associating the server rank with its minimum buffer size. 120 117 */ 121 std::map<int, StdSize> CDomain::getAttributesBufferSize( )118 std::map<int, StdSize> CDomain::getAttributesBufferSize(CContextClient* client) 122 119 { 123 120 CContext* context = CContext::getCurrent(); 124 121 // For now the assumption is that secondary server pools consist of the same number of procs. 125 122 // CHANGE the line below if the assumption changes. 126 CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[0] : context->client;123 // CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[0] : context->client; 127 124 128 125 std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes(); … … 141 138 } 142 139 143 boost::unordered_map<int, vector<size_t> >::const_iterator itIndexEnd = indSrv_ .end();144 std::map<int, std::vector<int> >::const_iterator itWrittenIndexEnd = indWrittenSrv_.end();145 for (size_t k = 0; k < connectedServerRank_ .size(); ++k)146 { 147 int rank = connectedServerRank_[ k];148 boost::unordered_map<int, std::vector<size_t> >::const_iterator it = indSrv_ .find(rank);140 boost::unordered_map<int, vector<size_t> >::const_iterator itIndexEnd = indSrv_[client].end(); 141 // std::map<int, std::vector<int> >::const_iterator itWrittenIndexEnd = indWrittenSrv_.end(); 142 for (size_t k = 0; k < connectedServerRank_[client].size(); ++k) 143 { 144 int rank = connectedServerRank_[client][k]; 145 boost::unordered_map<int, std::vector<size_t> >::const_iterator it = indSrv_[client].find(rank); 149 146 size_t idxCount = (it != itIndexEnd) ? it->second.size() : 0; 150 147 151 148 // size estimation for sendIndex (and sendArea which is always smaller or equal) 152 149 size_t sizeIndexEvent = 2 * sizeof(size_t) + 2 * CArray<int,1>::size(idxCount); 153 if (isCompressible_)154 {155 std::map<int, std::vector<int> >::const_iterator itWritten = indWrittenSrv_.find(rank);156 size_t writtenIdxCount = (itWritten != itWrittenIndexEnd) ? itWritten->second.size() : 0;157 sizeIndexEvent += CArray<int,1>::size(writtenIdxCount);158 }150 // if (isCompressible_) 151 // { 152 // std::map<int, std::vector<int> >::const_iterator itWritten = indWrittenSrv_.find(rank); 153 // size_t writtenIdxCount = (itWritten != itWrittenIndexEnd) ? itWritten->second.size() : 0; 154 // sizeIndexEvent += CArray<int,1>::size(writtenIdxCount); 155 // } 159 156 160 157 // size estimation for sendLonLat … … 761 758 } 762 759 760 /* 761 General check of the domain to verify its mandatory attributes 762 */ 763 763 void CDomain::checkDomain(void) 764 764 { … … 1686 1686 { 1687 1687 CContext* context=CContext::getCurrent() ; 1688 1689 // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;1688 1689 // This line should be changed soon. 1690 1690 int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 1691 1692 nbSenders.clear(); 1693 connectedServerRank_.clear(); 1694 1691 1695 for (int p = 0; p < nbSrvPools; ++p) 1692 1696 { … … 1830 1834 CClientServerMapping::GlobalIndexMap::const_iterator it = globalIndexDomainOnServer.begin(), 1831 1835 ite = globalIndexDomainOnServer.end(); 1832 indSrv_ .swap(globalIndexDomainOnServer);1833 connectedServerRank_ .clear();1834 for (it = indSrv_ .begin(); it != ite; ++it)1835 connectedServerRank_ .push_back(it->first);1836 indSrv_[client].swap(globalIndexDomainOnServer); 1837 connectedServerRank_[client].clear(); 1838 for (it = indSrv_[client].begin(); it != ite; ++it) 1839 connectedServerRank_[client].push_back(it->first); 1836 1840 1837 1841 for (std::list<int>::const_iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it) 1838 connectedServerRank_ .push_back(*it);1842 connectedServerRank_[client].push_back(*it); 1839 1843 1840 1844 // Even if a client has no index, it must connect to at least one server and 1841 1845 // send an "empty" data to this server 1842 if (connectedServerRank_.empty()) 1843 connectedServerRank_.push_back(client->clientRank % client->serverSize); 1844 1845 nbConnectedClients_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 1846 1847 // clientServerMap->computeServerIndexMapping(globalIndexDomainZoom); 1848 // CClientServerMapping::GlobalIndexMap& globalIndexDomainZoomOnServer = clientServerMap->getGlobalIndexOnServer(); 1849 // indZoomSrv_.swap(globalIndexDomainZoomOnServer); 1850 1851 // for (it = indZoomSrv_.begin(); it != indZoomSrv_.end(); ++it) 1852 // connectedServerZoomRank_.push_back(it->first); 1853 1854 // nbConnectedClientsZoom_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerZoomRank_); 1846 if (connectedServerRank_[client].empty()) 1847 connectedServerRank_[client].push_back(client->clientRank % client->serverSize); 1848 1849 nbSenders[client] = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[client]); 1855 1850 1856 1851 delete clientServerMap; … … 1960 1955 { 1961 1956 sendDistributionAttributes(); 1962 sendIndex(); 1963 // sendIndexZoom(); 1957 sendIndex(); 1964 1958 sendMask(); 1965 1959 sendLonLat(); … … 1989 1983 1990 1984 boost::unordered_map<int, vector<size_t> >::const_iterator itIndex, iteIndex; 1991 iteIndex = indSrv_ .end();1992 for (int k = 0; k < connectedServerRank_ .size(); ++k)1985 iteIndex = indSrv_[client].end(); 1986 for (int k = 0; k < connectedServerRank_[client].size(); ++k) 1993 1987 { 1994 1988 int nbIndGlob = 0; 1995 int rank = connectedServerRank_[ k];1996 itIndex = indSrv_ .find(rank);1989 int rank = connectedServerRank_[client][k]; 1990 itIndex = indSrv_[client].find(rank); 1997 1991 if (iteIndex != itIndex) 1998 1992 nbIndGlob = itIndex->second.size(); … … 2011 2005 list_msgsIndex.back() << list_indGlob.back(); //list_indi.back() << list_indj.back(); 2012 2006 2013 eventIndex.push(rank, nb ConnectedClients_[rank], list_msgsIndex.back());2007 eventIndex.push(rank, nbSenders[client][rank], list_msgsIndex.back()); 2014 2008 } 2015 2009 … … 2017 2011 } 2018 2012 } 2019 2020 /*!2021 Send global index and zoom index from client to connected client(s)2022 zoom index can be smaller than global index.2023 This function can be used in the future???2024 */2025 // void CDomain::sendIndexZoom()2026 // {2027 // int ns, n, i, j, ind, nv, idx;2028 // CContext* context = CContext::getCurrent();2029 2030 // // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;2031 // int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1;2032 // for (int p = 0; p < nbSrvPools; ++p)2033 // {2034 // CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[p] : context->client;2035 // CEventClient eventIndexZoom(getType(), EVENT_ID_INDEX_ZOOM);2036 2037 // list<CMessage> list_msgsIndex;2038 // list<CArray<int,1> > list_indZoom;2039 2040 // boost::unordered_map<int, vector<size_t> >::const_iterator itZoom, iteZoom;2041 // iteZoom = indZoomSrv_.end();2042 // for (int k = 0; k < connectedServerZoomRank_.size(); ++k)2043 // {2044 // int nbIndGlob = 0;2045 // int rank = connectedServerZoomRank_[k];2046 // int nbIndZoom = 0;2047 // itZoom = indZoomSrv_.find(rank);2048 // if (iteZoom != itZoom)2049 // nbIndZoom = itZoom->second.size();2050 2051 // list_indZoom.push_back(CArray<int,1>(nbIndZoom));2052 // CArray<int,1>& indZoom = list_indZoom.back();2053 // for (n = 0; n < nbIndZoom; ++n)2054 // {2055 // indZoom(n) = static_cast<int>(itZoom->second[n]);2056 // }2057 2058 // list_msgsIndex.push_back(CMessage());2059 // list_msgsIndex.back() << this->getId(); // enum ne fonctionne pour les message => ToFix2060 // list_msgsIndex.back() << list_indZoom.back() << doZoomByIndex_; //list_indi.back() << list_indj.back2061 2062 // eventIndexZoom.push(rank, nbConnectedClientsZoom_[rank], list_msgsIndex.back());2063 // }2064 2065 // client->sendEvent(eventIndexZoom);2066 // }2067 // }2068 2013 2069 2014 /*! … … 2144 2089 2145 2090 boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 2146 iteMap = indSrv_ .end();2147 for (int k = 0; k < connectedServerRank_ .size(); ++k)2091 iteMap = indSrv_[client].end(); 2092 for (int k = 0; k < connectedServerRank_[client].size(); ++k) 2148 2093 { 2149 2094 int nbData = 0; 2150 int rank = connectedServerRank_[ k];2151 it = indSrv_ .find(rank);2095 int rank = connectedServerRank_[client][k]; 2096 it = indSrv_[client].find(rank); 2152 2097 if (iteMap != it) 2153 2098 nbData = it->second.size(); … … 2163 2108 list_msgsMask.push_back(CMessage()); 2164 2109 list_msgsMask.back() << this->getId() << list_mask.back(); 2165 eventMask.push(rank, nb ConnectedClients_[rank], list_msgsMask.back());2110 eventMask.push(rank, nbSenders[client][rank], list_msgsMask.back()); 2166 2111 } 2167 2112 client->sendEvent(eventMask); … … 2192 2137 2193 2138 boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 2194 iteMap = indSrv_ .end();2195 for (int k = 0; k < connectedServerRank_ .size(); ++k)2139 iteMap = indSrv_[client].end(); 2140 for (int k = 0; k < connectedServerRank_[client].size(); ++k) 2196 2141 { 2197 2142 int nbData = 0; 2198 int rank = connectedServerRank_[ k];2199 it = indSrv_ .find(rank);2143 int rank = connectedServerRank_[client][k]; 2144 it = indSrv_[client].find(rank); 2200 2145 if (iteMap != it) 2201 2146 nbData = it->second.size(); … … 2212 2157 list_msgsArea.back() << this->getId() << hasArea; 2213 2158 list_msgsArea.back() << list_area.back(); 2214 eventArea.push(rank, nb ConnectedClients_[rank], list_msgsArea.back());2159 eventArea.push(rank, nbSenders[client][rank], list_msgsArea.back()); 2215 2160 } 2216 2161 client->sendEvent(eventArea); … … 2245 2190 2246 2191 boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 2247 iteMap = indSrv_ .end();2248 for (int k = 0; k < connectedServerRank_ .size(); ++k)2192 iteMap = indSrv_[client].end(); 2193 for (int k = 0; k < connectedServerRank_[client].size(); ++k) 2249 2194 { 2250 2195 int nbData = 0; 2251 int rank = connectedServerRank_[ k];2252 it = indSrv_ .find(rank);2196 int rank = connectedServerRank_[client][k]; 2197 it = indSrv_[client].find(rank); 2253 2198 if (iteMap != it) 2254 2199 nbData = it->second.size(); … … 2307 2252 } 2308 2253 2309 eventLon.push(rank, nb ConnectedClients_[rank], list_msgsLon.back());2310 eventLat.push(rank, nb ConnectedClients_[rank], list_msgsLat.back());2254 eventLon.push(rank, nbSenders[client][rank], list_msgsLon.back()); 2255 eventLat.push(rank, nbSenders[client][rank], list_msgsLat.back()); 2311 2256 } 2312 2257 client->sendEvent(eventLon); … … 2363 2308 2364 2309 boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 2365 iteMap = indSrv_ .end();2366 for (int k = 0; k < connectedServerRank_ .size(); ++k)2310 iteMap = indSrv_[client].end(); 2311 for (int k = 0; k < connectedServerRank_[client].size(); ++k) 2367 2312 { 2368 2313 int nbData = 0; 2369 int rank = connectedServerRank_[ k];2370 it = indSrv_ .find(rank);2314 int rank = connectedServerRank_[client][k]; 2315 it = indSrv_[client].find(rank); 2371 2316 if (iteMap != it) 2372 2317 nbData = it->second.size(); … … 2386 2331 list_msgsDataIndex.back() << this->getId(); 2387 2332 list_msgsDataIndex.back() << list_data_i_index.back() << list_data_j_index.back(); 2388 eventDataIndex.push(rank, nb ConnectedClients_[rank], list_msgsDataIndex.back());2333 eventDataIndex.push(rank, nbSenders[client][rank], list_msgsDataIndex.back()); 2389 2334 } 2390 2335 client->sendEvent(eventDataIndex); … … 2405 2350 case EVENT_ID_INDEX: 2406 2351 recvIndex(event); 2407 return true;2408 break;2409 case EVENT_ID_INDEX_ZOOM:2410 recvIndexZoom(event);2411 2352 return true; 2412 2353 break; … … 2508 2449 2509 2450 /*! 2510 Receive index event from clients(s)2511 \param[in] event event contain info about rank and associated index2512 */2513 void CDomain::recvIndexZoom(CEventServer& event)2514 {2515 string domainId;2516 std::map<int, CBufferIn*> rankBuffers;2517 2518 list<CEventServer::SSubEvent>::iterator it;2519 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it)2520 {2521 CBufferIn* buffer = it->buffer;2522 *buffer >> domainId;2523 rankBuffers[it->rank] = buffer;2524 }2525 get(domainId)->recvIndexZoom(rankBuffers);2526 }2527 2528 /*!2529 Receive index information from client(s)2530 \param[in] rankBuffers rank of sending client and the corresponding receive buffer2531 */2532 void CDomain::recvIndexZoom(std::map<int, CBufferIn*>& rankBuffers)2533 {2534 int nbReceived = rankBuffers.size(), i, ind, index, type_int;2535 recvClientZoomRanks_.resize(nbReceived);2536 int ni_zoom_tmp, ibegin_zoom_tmp, nj_zoom_tmp, jbegin_zoom_tmp;2537 2538 std::map<int, CBufferIn*>::iterator it = rankBuffers.begin(), ite = rankBuffers.end();2539 ind = 0;2540 for (ind = 0; it != ite; ++it, ++ind)2541 {2542 recvClientZoomRanks_[ind] = it->first;2543 CBufferIn& buffer = *(it->second);2544 buffer >> indGlobZoom_[it->first] >> doZoomByIndex_;2545 }2546 2547 int nbZoomInd = 0;2548 for (i = 0; i < nbReceived; ++i)2549 {2550 nbZoomInd += indGlobZoom_[recvClientZoomRanks_[i]].numElements();2551 }2552 2553 if (doZoomByIndex_)2554 {2555 zoom_i_index.resize(nbZoomInd);2556 zoom_j_index.resize(nbZoomInd);2557 2558 nbZoomInd = 0;2559 for (i = 0; i < nbReceived; ++i)2560 {2561 CArray<int,1>& tmp = indGlobZoom_[recvClientRanks_[i]];2562 for (ind = 0; ind < tmp.numElements(); ++ind)2563 {2564 index = tmp(ind);2565 zoom_i_index(nbZoomInd) = index % ni_glo;2566 zoom_j_index(nbZoomInd) = index / ni_glo;2567 ++nbZoomInd;2568 }2569 }2570 }2571 else2572 {2573 }2574 }2575 2576 /*!2577 2451 Receive attributes event from clients(s) 2578 2452 \param[in] event event contain info about rank and associated attributes
Note: See TracChangeset
for help on using the changeset viewer.