Changeset 1236
- Timestamp:
- 08/04/17 16:03:34 (7 years ago)
- Location:
- XIOS/dev/XIOS_DEV_CMIP6/src/node
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.cpp
r1235 r1236 137 137 * \return A map associating the server rank with its minimum buffer size. 138 138 */ 139 std::map<int, StdSize> CAxis::getAttributesBufferSize( )139 std::map<int, StdSize> CAxis::getAttributesBufferSize(CContextClient* client) 140 140 { 141 141 // For now the assumption is that secondary server pools consist of the same number of procs. 142 142 // CHANGE the line below if the assumption changes. 143 CContext* context = CContext::getCurrent();144 CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[0] : context->client;143 // CContext* context = CContext::getCurrent(); 144 // CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[0] : context->client; 145 145 146 146 std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes(); 147 147 148 bool isNonDistributed = (n = = n_glo);148 bool isNonDistributed = (n = n_glo); 149 149 150 150 if (client->isServerLeader()) … … 168 168 { 169 169 // size estimation for sendDistributedValue 170 boost::unordered_map<int, vector<size_t> >::const_iterator it, ite = indSrv_ .end();171 for (it = indSrv_ .begin(); it != ite; ++it)170 boost::unordered_map<int, vector<size_t> >::const_iterator it, ite = indSrv_[client].end(); 171 for (it = indSrv_[client].begin(); it != ite; ++it) 172 172 { 173 173 size_t sizeIndexEvent = CArray<int,1>::size(it->second.size()); 174 if (isCompressible_)175 sizeIndexEvent += CArray<int,1>::size(indWrittenSrv_[it->first].size());174 // if (isCompressible_) 175 // sizeIndexEvent += CArray<int,1>::size(indWrittenSrv_[it->first].size()); 176 176 177 177 size_t sizeValEvent = CArray<double,1>::size(it->second.size()); … … 505 505 506 506 int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; 507 508 connectedServerRank_.clear(); 509 nbSenders.clear(); 510 507 511 for (int p = 0; p < nbSrvPools; ++p) 508 512 { … … 589 593 590 594 591 indSrv_ .swap(globalIndexAxisOnServer);592 CClientServerMapping::GlobalIndexMap::const_iterator it = indSrv_ .begin(),593 ite = indSrv_ .end();594 connectedServerRank_.clear();595 for (it = indSrv_ .begin(); it != ite; ++it) {596 connectedServerRank_ .push_back(it->first);595 indSrv_[client].swap(globalIndexAxisOnServer); 596 CClientServerMapping::GlobalIndexMap::const_iterator it = indSrv_[client].begin(), 597 ite = indSrv_[client].end(); 598 599 for (it = indSrv_[client].begin(); it != ite; ++it) { 600 connectedServerRank_[client].push_back(it->first); 597 601 } 598 602 599 603 for (std::list<int>::const_iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it) 600 connectedServerRank_ .push_back(*it);604 connectedServerRank_[client].push_back(*it); 601 605 602 606 // Even if a client has no index, it must connect to at least one server and 603 607 // send an "empty" data to this server 604 if (connectedServerRank_ .empty())605 connectedServerRank_ .push_back(client->clientRank % client->serverSize);606 607 nb ConnectedClients_ = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_);608 if (connectedServerRank_[client].empty()) 609 connectedServerRank_[client].push_back(client->clientRank % client->serverSize); 610 611 nbSenders[client] = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[client]); 608 612 609 613 delete clientServerMap; … … 1019 1023 1020 1024 boost::unordered_map<int, std::vector<size_t> >::const_iterator it, iteMap; 1021 iteMap = indSrv_ .end();1022 for (int k = 0; k < connectedServerRank_ .size(); ++k)1025 iteMap = indSrv_[client].end(); 1026 for (int k = 0; k < connectedServerRank_[client].size(); ++k) 1023 1027 { 1024 1028 int nbData = 0; 1025 int rank = connectedServerRank_[ k];1026 it = indSrv_ .find(rank);1029 int rank = connectedServerRank_[client][k]; 1030 it = indSrv_[client].find(rank); 1027 1031 if (iteMap != it) 1028 1032 nbData = it->second.size(); … … 1090 1094 listData.back() << list_label.back(); 1091 1095 1092 eventData.push(rank, nb ConnectedClients_[rank], listData.back());1096 eventData.push(rank, nbSenders[client][rank], listData.back()); 1093 1097 } 1094 1098 -
XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.hpp
r1235 r1236 73 73 int getOffsetWrittenIndexes() const; 74 74 75 std::map<int, StdSize> getAttributesBufferSize( );75 std::map<int, StdSize> getAttributesBufferSize(CContextClient* client); 76 76 77 77 /// Test /// … … 156 156 //! True if and only if the data defined on the axis can be outputted in a compressed way 157 157 bool isCompressible_; 158 std::map< int,int> nbConnectedClients_; // Mapping of number of communicating client to a server159 boost::unordered_map<int, vector<size_t> > indSrv_; // Global index of each client sent to server160 std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server158 std::map<CContextClient*, map<int,int> > nbSenders; // Mapping of number of communicating client to a server 159 std::map<CContextClient*, boost::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server 160 // std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server 161 161 boost::unordered_map<size_t,size_t> globalLocalIndexMap_; 162 162 std::vector<int> indexesToWrite; 163 163 int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; 164 std:: vector<int> connectedServerRank_;164 std::map<CContextClient*, std::vector<int> > connectedServerRank_; 165 165 bool hasBounds; 166 166 bool hasLabel; -
XIOS/dev/XIOS_DEV_CMIP6/src/node/context.cpp
r1232 r1236 1320 1320 { 1321 1321 CFile* file = this->enabledWriteModeFiles[i]; 1322 //if (file->getContextClient() == contextClient)1322 // if (file->getContextClient() == contextClient) 1323 1323 { 1324 1324 std::vector<CField*> enabledFields = file->getEnabledFields(); … … 1326 1326 for (size_t j = 0; j < numEnabledFields; ++j) 1327 1327 { 1328 const std::map<int, StdSize> mapSize = enabledFields[j]->getGridAttributesBufferSize( );1328 const std::map<int, StdSize> mapSize = enabledFields[j]->getGridAttributesBufferSize(contextClient); 1329 1329 std::map<int, StdSize>::const_iterator it = mapSize.begin(), itE = mapSize.end(); 1330 1330 for (; it != itE; ++it) … … 1354 1354 for (size_t j = 0; j < numEnabledFields; ++j) 1355 1355 { 1356 const std::map<int, StdSize> mapSize = enabledFields[j]->getGridAttributesBufferSize( );1356 const std::map<int, StdSize> mapSize = enabledFields[j]->getGridAttributesBufferSize(contextClient); 1357 1357 std::map<int, StdSize>::const_iterator it = mapSize.begin(), itE = mapSize.end(); 1358 1358 for (; it != itE; ++it) … … 1401 1401 for (size_t j = 0; j < numEnabledFields; ++j) 1402 1402 { 1403 const std::vector<std::map<int, StdSize> > mapSize = enabledFields[j]->getGridDataBufferSize(); 1404 for (size_t c = 0; c < mapSize.size(); ++c) 1405 { 1406 std::map<int, StdSize>::const_iterator it = mapSize[c].begin(), itE = mapSize[c].end(); 1403 // const std::vector<std::map<int, StdSize> > mapSize = enabledFields[j]->getGridDataBufferSize(contextClient); 1404 const std::map<int, StdSize> mapSize = enabledFields[j]->getGridDataBufferSize(contextClient); 1405 // for (size_t c = 0; c < mapSize.size(); ++c) 1406 // { 1407 std::map<int, StdSize>::const_iterator it = mapSize.begin(), itE = mapSize.end(); 1407 1408 for (; it != itE; ++it) 1408 1409 { … … 1417 1418 maxEventSize[it->first] = it->second; 1418 1419 } 1419 }1420 // } 1420 1421 } 1421 1422 } -
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 -
XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.hpp
r1215 r1236 50 50 EVENT_ID_INDEX, EVENT_ID_LON, EVENT_ID_LAT, 51 51 EVENT_ID_AREA, EVENT_ID_MASK, 52 EVENT_ID_DATA_INDEX, EVENT_ID_SERVER_ATTRIBUT, 53 EVENT_ID_INDEX_ZOOM 52 EVENT_ID_DATA_INDEX, EVENT_ID_SERVER_ATTRIBUT 54 53 } ; 55 56 57 54 58 55 public: … … 99 96 int getOffsetWrittenIndexes() const; 100 97 101 std::map<int, StdSize> getAttributesBufferSize(); 102 CArray<size_t,1> localIndexToWriteOnServer; 103 CArray<int, 1> compressedIndexToWriteOnServer; 98 std::map<int, StdSize> getAttributesBufferSize(CContextClient* client); 104 99 105 100 bool isEmpty(void) const; … … 107 102 bool isCompressible(void) const; 108 103 104 std::vector<int> getNbGlob(); 105 bool isEqual(CDomain* domain); 106 107 static bool dispatchEvent(CEventServer& event); 108 109 public: 110 /// Mutateur /// 111 void addRelFile(const StdString & filename); 112 void addRelFileCompressed(const StdString& filename); 113 114 void computeWrittenIndex(); 115 116 void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat, 117 CArray<double,1>& lon_g, CArray<double,1>& lat_g); 118 119 void fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat, 120 CArray<double,2>& boundsLon, CArray<double,2>& boundsLat); 121 122 void fillInLonLat(); 123 bool distributionAttributesHaveValue() const; 124 125 size_t getGlobalWrittenSize() ; 126 /// Destructeur /// 127 virtual ~CDomain(void); 128 129 /// Accesseurs statiques /// 130 static StdString GetName(void); 131 static StdString GetDefName(void); 132 133 static ENodeType GetType(void); 134 135 public: 109 136 CArray<double, 1> lonvalue, latvalue; 110 137 CArray<double, 2> bounds_lonvalue, bounds_latvalue; 111 138 CArray<double, 1> areavalue; 112 139 113 vector<int> connectedServer ; // list of connected server 114 vector<int> nbSenders ; // for each communication with a server, number of communicating client 115 vector<int> nbDataSrv ; // size of data to send to each server 116 vector< vector<int> > i_indSrv ; // for each server, i global index to send 117 vector< vector<int> > j_indSrv ; // for each server, j global index to send 118 std::vector<int> getNbGlob(); 119 bool isEqual(CDomain* domain); 120 public: 121 /// Mutateur /// 122 void addRelFile(const StdString & filename); 123 void addRelFileCompressed(const StdString& filename); 124 void completeLonLatClient(void); 125 void computeConnectedClients(); 126 void computeWrittenIndex(); 127 128 void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat, 129 CArray<double,1>& lon_g, CArray<double,1>& lat_g); 130 131 void fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat, 132 CArray<double,2>& boundsLon, CArray<double,2>& boundsLat); 133 134 void fillInLonLat(); 135 bool distributionAttributesHaveValue() const; 136 137 static bool dispatchEvent(CEventServer& event); 138 static void recvDistributionAttributes(CEventServer& event); 139 static void recvIndex(CEventServer& event); 140 static void recvIndexZoom(CEventServer& event); 141 static void recvMask(CEventServer& event); 142 static void recvZoom(CEventServer& event); 143 static void recvLon(CEventServer& event); 144 static void recvLat(CEventServer& event); 145 static void recvArea(CEventServer& event); 146 static void recvDataIndex(CEventServer& event); 147 void recvDistributionAttributes(CBufferIn& buffer); 148 void recvIndex(std::map<int, CBufferIn*>& rankBuffers); 149 void recvIndexZoom(std::map<int, CBufferIn*>& rankBuffers); 150 void recvMask(std::map<int, CBufferIn*>& rankBuffers); 151 void recvLon(std::map<int, CBufferIn*>& rankBuffers); 152 void recvLat(std::map<int, CBufferIn*>& rankBuffers); 153 void recvArea(std::map<int, CBufferIn*>& rankBuffers); 154 void recvDataIndex(std::map<int, CBufferIn*>& rankBuffers); 155 size_t getGlobalWrittenSize() ; 156 /// Destructeur /// 157 virtual ~CDomain(void); 158 159 /// Accesseurs statiques /// 160 static StdString GetName(void); 161 static StdString GetDefName(void); 162 163 static ENodeType GetType(void); 164 const std::map<int, vector<size_t> >& getIndexServer() const; 140 CArray<size_t,1> localIndexToWriteOnServer; 141 CArray<int, 1> compressedIndexToWriteOnServer; 142 165 143 CArray<bool, 1> localMask; 166 144 bool isCurvilinear ; … … 192 170 void sendMask(); 193 171 void sendArea(); 194 void sendLonLat(); 195 void sendIndexZoom(); 172 void sendLonLat(); 196 173 void sendDataIndex(); 197 174 void convertLonLatValue(); … … 199 176 void fillInCurvilinearLonLat(); 200 177 void fillInUnstructuredLonLat(); 178 179 static void recvDistributionAttributes(CEventServer& event); 180 static void recvIndex(CEventServer& event); 181 static void recvIndexZoom(CEventServer& event); 182 static void recvMask(CEventServer& event); 183 static void recvLon(CEventServer& event); 184 static void recvLat(CEventServer& event); 185 static void recvArea(CEventServer& event); 186 static void recvDataIndex(CEventServer& event); 187 void recvDistributionAttributes(CBufferIn& buffer); 188 void recvIndex(std::map<int, CBufferIn*>& rankBuffers); 189 void recvMask(std::map<int, CBufferIn*>& rankBuffers); 190 void recvLon(std::map<int, CBufferIn*>& rankBuffers); 191 void recvLat(std::map<int, CBufferIn*>& rankBuffers); 192 void recvArea(std::map<int, CBufferIn*>& rankBuffers); 193 void recvDataIndex(std::map<int, CBufferIn*>& rankBuffers); 194 195 void completeLonLatClient(void); 196 void computeConnectedClients(); 197 201 198 private: 202 199 bool doZoomByIndex_; … … 205 202 bool isClientChecked; // Verify whether all attributes of domain on the client side are good 206 203 bool isClientAfterTransformationChecked; 207 std::map<int, CArray<int,1> > indiSrv, indjSrv, indGlob_, indGlobZoom_; 208 std::map<int,int> nbConnectedClients_, nbConnectedClientsZoom_; // Mapping of number of communicating client to a server 209 210 boost::unordered_map<int, vector<size_t> > indSrv_; // Global index of each client sent to server 211 boost::unordered_map<int, vector<size_t> > indZoomSrv_; // Global index of each client sent to server 212 std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server 204 std::map<int, CArray<int,1> > indGlob_; 205 std::map<CContextClient*, map<int,int> > nbSenders; // Mapping of number of communicating client to a server 206 207 std::map<CContextClient*, boost::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server 208 // std::map<CContextClient*, std::map<int, vector<int> > > indWrittenSrv_; // Global written index of each client sent to server 213 209 std::vector<int> indexesToWrite; 214 std::vector<int> recvClientRanks_, recvClientZoomRanks_; 215 int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; 216 std::vector<int> connectedServerRank_, connectedServerZoomRank_; 210 std::vector<int> recvClientRanks_; 211 int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; 212 std::map<CContextClient*, std::map<int,size_t> > connectedDataSize_; 213 std::map<CContextClient*, std::vector<int> > connectedServerRank_; 214 217 215 //! True if and only if the data defined on the domain can be outputted in a compressed way 218 216 bool isCompressible_; … … 220 218 TransMapTypes transformationMap_; 221 219 bool isUnstructed_; 222 boost::unordered_map<size_t,size_t> globalLocalIndexMap_ , globalLocalIndexZoomMap_;220 boost::unordered_map<size_t,size_t> globalLocalIndexMap_; 223 221 224 222 private: -
XIOS/dev/XIOS_DEV_CMIP6/src/node/field.cpp
r1235 r1236 143 143 if (client->isServerLeader()) 144 144 { 145 for (it = grid->storeIndex_toSrv .begin(); it != grid->storeIndex_toSrv.end(); it++)145 for (it = grid->storeIndex_toSrv[client].begin(); it != grid->storeIndex_toSrv[client].end(); it++) 146 146 { 147 147 int rank = it->first; … … 163 163 else 164 164 { 165 for (it = grid->storeIndex_toSrv .begin(); it != grid->storeIndex_toSrv.end(); it++)165 for (it = grid->storeIndex_toSrv[client].begin(); it != grid->storeIndex_toSrv[client].end(); it++) 166 166 { 167 167 int rank = it->first; … … 175 175 176 176 list_msg.back() << getId() << data_tmp; 177 event.push(rank, grid->nbSenders[ 0][rank], list_msg.back());177 event.push(rank, grid->nbSenders[client][rank], list_msg.back()); 178 178 } 179 179 client->sendEvent(event); … … 423 423 } 424 424 425 event.push(it->first, grid->nbReadSenders[ 0][it->first], msg);425 event.push(it->first, grid->nbReadSenders[client][it->first], msg); 426 426 } 427 427 client->sendEvent(event); … … 860 860 } 861 861 862 std::map<int, StdSize> CField::getGridAttributesBufferSize( )863 { 864 return grid->getAttributesBufferSize( );865 } 866 867 std:: vector<std::map<int, StdSize> > CField::getGridDataBufferSize()868 { 869 return grid->getDataBufferSize( getId());862 std::map<int, StdSize> CField::getGridAttributesBufferSize(CContextClient* client) 863 { 864 return grid->getAttributesBufferSize(client); 865 } 866 867 std::map<int, StdSize> CField::getGridDataBufferSize(CContextClient* client) 868 { 869 return grid->getDataBufferSize(client, getId()); 870 870 } 871 871 -
XIOS/dev/XIOS_DEV_CMIP6/src/node/field.hpp
r1232 r1236 100 100 void resetNStepMax(); 101 101 102 std::map<int, StdSize> getGridAttributesBufferSize( );103 std:: vector<std::map<int, StdSize> > getGridDataBufferSize(); // Grid data buffer size for each connection of contextclient102 std::map<int, StdSize> getGridAttributesBufferSize(CContextClient* client); 103 std::map<int, StdSize> getGridDataBufferSize(CContextClient* client); // Grid data buffer size for each connection of contextclient 104 104 105 105 public: -
XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.cpp
r1235 r1236 100 100 * TODO: Refactor code 101 101 */ 102 std::map<int, StdSize> CGrid::getAttributesBufferSize( )102 std::map<int, StdSize> CGrid::getAttributesBufferSize(CContextClient* client) 103 103 { 104 104 std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes(); 105 105 106 106 // The grid indexes require a similar size as the actual data 107 std:: vector<std::map<int, StdSize> > dataSizes = getDataBufferSize();108 for (size_t i = 0; i < dataSizes.size(); ++i)109 {110 std::map<int, StdSize>::iterator it, itE = dataSizes [i].end();111 for (it = dataSizes [i].begin(); it != itE; ++it)107 std::map<int, StdSize> dataSizes = getDataBufferSize(client); 108 // for (size_t i = 0; i < dataSizes.size(); ++i) 109 // { 110 std::map<int, StdSize>::iterator it, itE = dataSizes.end(); 111 for (it = dataSizes.begin(); it != itE; ++it) 112 112 { 113 113 it->second += 2 * sizeof(bool); … … 115 115 attributesSizes[it->first] = it->second; 116 116 } 117 }118 119 std::map<int, StdSize>::iterator it, itE;117 // } 118 119 120 120 // Account for the axis attributes 121 121 std::vector<CAxis*> axisList = getAxis(); 122 122 for (size_t i = 0; i < axisList.size(); ++i) 123 123 { 124 std::map<int, StdSize> axisAttBuffSize = axisList[i]->getAttributesBufferSize( );124 std::map<int, StdSize> axisAttBuffSize = axisList[i]->getAttributesBufferSize(client); 125 125 for (it = axisAttBuffSize.begin(), itE = axisAttBuffSize.end(); it != itE; ++it) 126 126 { … … 134 134 for (size_t i = 0; i < domList.size(); ++i) 135 135 { 136 std::map<int, StdSize> domAttBuffSize = domList[i]->getAttributesBufferSize( );136 std::map<int, StdSize> domAttBuffSize = domList[i]->getAttributesBufferSize(client); 137 137 for (it = domAttBuffSize.begin(), itE = domAttBuffSize.end(); it != itE; ++it) 138 138 { … … 143 143 144 144 return attributesSizes; 145 145 } 146 146 147 147 /*! … … 151 151 * \return A map associating the server rank with its minimum buffer size. 152 152 */ 153 std:: vector<std::map<int, StdSize> > CGrid::getDataBufferSize(const std::string& id /*= ""*/)153 std::map<int, StdSize> CGrid::getDataBufferSize(CContextClient* client, const std::string& id /*= ""*/) 154 154 { 155 155 // The record index is sometimes sent along with the data but we always … … 158 158 + 2 * sizeof(size_t) 159 159 + sizeof(size_t); 160 CContext* context = CContext::getCurrent(); 161 int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 162 std::vector<std::map<int, StdSize> > dataSizes(nbSrvPools); 163 for (int p = 0; p < nbSrvPools; ++p) 160 // CContext* context = CContext::getCurrent(); 161 // int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 162 // std::vector<std::map<int, StdSize> > dataSizes(nbSrvPools); 163 // for (int p = 0; p < nbSrvPools; ++p) 164 // { 165 // std::map<int, size_t>::const_iterator itEnd = connectedDataSize_[client].end(); 166 // for (size_t k = 0; k < connectedServerRank_[p].size(); ++k) 167 // { 168 // int rank = connectedServerRank_[p][k]; 169 // std::map<int, size_t>::const_iterator it = connectedDataSize_[client].find(rank); 170 // size_t count = (it != itEnd) ? it->second : 0; 171 172 // dataSizes[p].insert(std::make_pair(rank, extraSize + CArray<double,1>::size(count))); 173 // } 174 175 // } 176 177 std::map<int, StdSize> dataSizes; 178 std::map<int, size_t>::const_iterator itEnd = connectedDataSize_[client].end(); 179 for (size_t k = 0; k < connectedServerRank_[client].size(); ++k) 164 180 { 165 std::map<int, size_t>::const_iterator itEnd = connectedDataSize_[p].end(); 166 for (size_t k = 0; k < connectedServerRank_[p].size(); ++k) 167 { 168 int rank = connectedServerRank_[p][k]; 169 std::map<int, size_t>::const_iterator it = connectedDataSize_[p].find(rank); 170 size_t count = (it != itEnd) ? it->second : 0; 171 172 dataSizes[p].insert(std::make_pair(rank, extraSize + CArray<double,1>::size(count))); 173 } 174 181 int rank = connectedServerRank_[client][k]; 182 std::map<int, size_t>::const_iterator it = connectedDataSize_[client].find(rank); 183 size_t count = (it != itEnd) ? it->second : 0; 184 185 dataSizes.insert(std::make_pair(rank, extraSize + CArray<double,1>::size(count))); 175 186 } 176 187 … … 251 262 252 263 //--------------------------------------------------------------- 253 264 /* 265 Find all reference of grid's components and inherite attributes if necessary 266 */ 254 267 void CGrid::solveDomainAxisRef(bool areAttributesChecked) 255 268 { … … 262 275 } 263 276 277 /* 278 Go up hierachy reference and fill in the base reference with attributes of the children 279 This function should be only used after reading component's attributes from file 280 */ 264 281 void CGrid::solveDomainAxisBaseRef() 265 282 { … … 332 349 } 333 350 351 /* 352 Create mask of grid from mask of its components 353 */ 334 354 void CGrid::createMask(void) 335 355 { … … 371 391 } 372 392 393 /* 394 Check validity of grid's mask by using the masks of its components 395 */ 373 396 void CGrid::checkMask(void) 374 397 { … … 410 433 } 411 434 435 /* 436 Modify value of mask in a certain index 437 This function can be used to correct the mask of grid after being constructed with createMask 438 \param [in] indexToModify 439 \param [in] modifyValue 440 */ 412 441 void CGrid::modifyMask(const CArray<int,1>& indexToModify, bool modifyValue) 413 442 { … … 444 473 } 445 474 475 /* 476 Change the mask size. This function is used on reconstructing mask in server side 477 \param [in] newDimensionSize 478 \param [in] newValue 479 */ 446 480 void CGrid::modifyMaskSize(const std::vector<int>& newDimensionSize, bool newValue) 447 481 { … … 539 573 } 540 574 } 541 }542 std::vector<int> CGrid::getAxisPositionInGrid() const543 {544 return axisPositionInGrid_;545 575 } 546 576 … … 612 642 //--------------------------------------------------------------- 613 643 644 /* 645 Compute the global index and its local index on taking account of mask, data index. 646 These global index then will be used to compute the connection of this client to other clients in the different group 647 (via function computeConnectedClient) 648 These global index also corresponding to data sent to other clients (if any) 649 */ 614 650 void CGrid::computeClientIndex() 615 651 { 616 652 CContext* context = CContext::getCurrent(); 617 653 618 // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;619 // int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1;620 654 // This needs to change one day 621 // It works only for the same number of procs on secondary pools622 655 int nbSrvPools = 1; 623 656 for (int p = 0; p < nbSrvPools; ++p) … … 682 715 Compute the connected clients and index to send to these clients. 683 716 Each client can connect to a pool of other clients, each of which can have a piece of information of a grid 684 685 717 */ 686 718 void CGrid::computeConnectedClients() … … 688 720 CContext* context = CContext::getCurrent(); 689 721 int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; 690 connectedServerRank_.resize(nbSrvPools); 691 connectedDataSize_.resize(nbSrvPools); 692 nbSenders.resize(nbSrvPools); 722 connectedServerRank_.clear(); 723 connectedDataSize_.clear(); 724 globalIndexOnServer_.clear(); 725 nbSenders.clear(); 693 726 694 727 for (int p = 0; p < nbSrvPools; ++p) … … 696 729 CContextClient* client = (context->hasServer) ? context->clientPrimServer[p] : context->client; 697 730 698 connectedServerRank_[ p].clear();731 connectedServerRank_[client].clear(); 699 732 700 733 if (!doGridHaveDataDistributed(client)) … … 706 739 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 707 740 { 708 connectedServerRank_[ p].push_back(*itRank);709 connectedDataSize_[ p][*itRank] = ssize;741 connectedServerRank_[client].push_back(*itRank); 742 connectedDataSize_[client][*itRank] = ssize; 710 743 } 711 744 } … … 730 763 *it = serverZeroIndex[*it]; 731 764 732 computeIndexByElement(indexServerOnElement, globalIndexOnServer_ );765 computeIndexByElement(indexServerOnElement, globalIndexOnServer_[client]); 733 766 734 767 const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = clientDistribution_->getGlobalLocalDataSendToServer(); 735 768 CDistributionClient::GlobalLocalDataMap::const_iterator iteGlobalLocalIndexMap = globalLocalIndexSendToServer.end(), itGlobalLocalIndexMap; 736 769 CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itbGlobalMap, itGlobalMap; 737 itbGlobalMap = globalIndexOnServer_ .begin();738 iteGlobalMap = globalIndexOnServer_ .end();770 itbGlobalMap = globalIndexOnServer_[client].begin(); 771 iteGlobalMap = globalIndexOnServer_[client].end(); 739 772 740 773 for (itGlobalMap = itbGlobalMap; itGlobalMap != iteGlobalMap; ++itGlobalMap) … … 748 781 if (iteGlobalLocalIndexMap != itGlobalLocalIndexMap) 749 782 { 750 if (connectedDataSize_[ p].end() == connectedDataSize_[p].find(serverRank))751 connectedDataSize_[ p][serverRank] = 1;783 if (connectedDataSize_[client].end() == connectedDataSize_[client].find(serverRank)) 784 connectedDataSize_[client][serverRank] = 1; 752 785 else 753 ++connectedDataSize_[ p][serverRank];786 ++connectedDataSize_[client][serverRank]; 754 787 } 755 788 } … … 758 791 // Connected servers which really have index 759 792 for (itGlobalMap = itbGlobalMap; itGlobalMap != iteGlobalMap; ++itGlobalMap) { 760 connectedServerRank_[ p].push_back(itGlobalMap->first);793 connectedServerRank_[client].push_back(itGlobalMap->first); 761 794 } 762 795 763 796 // Connected servers which have no index at all 764 797 for (std::list<int>::iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it) 765 connectedServerRank_[ p].push_back(*it);798 connectedServerRank_[client].push_back(*it); 766 799 767 800 // Even if a client has no index, it must connect to at least one server and 768 801 // send an "empty" data to this server 769 if (connectedServerRank_[ p].empty())770 connectedServerRank_[ p].push_back(client->clientRank % client->serverSize);771 772 nbSenders[ p] = clientServerMap_->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[p]);802 if (connectedServerRank_[client].empty()) 803 connectedServerRank_[client].push_back(client->clientRank % client->serverSize); 804 805 nbSenders[client] = clientServerMap_->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[client]); 773 806 } 774 807 } … … 1258 1291 CContext* context = CContext::getCurrent(); 1259 1292 int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; 1260 connectedServerRank_. resize(nbSrvPools);1261 connectedDataSize_. resize(nbSrvPools);1262 nbSenders. resize(nbSrvPools);1293 connectedServerRank_.clear(); 1294 connectedDataSize_.clear(); 1295 nbSenders.clear(); 1263 1296 1264 1297 for (int p = 0; p < nbSrvPools; ++p) … … 1267 1300 : context->client; 1268 1301 1269 connectedServerRank_[ p].clear();1302 connectedServerRank_[client].clear(); 1270 1303 1271 1304 if (client->isServerLeader()) … … 1276 1309 int rank = *itRank; 1277 1310 int nb = 1; 1278 connectedServerRank_[ p].push_back(rank);1279 connectedDataSize_[ p][rank] = nb;1280 nbSenders[ p][rank] = nb;1311 connectedServerRank_[client].push_back(rank); 1312 connectedDataSize_[client][rank] = nb; 1313 nbSenders[client][rank] = nb; 1281 1314 } 1282 1315 } … … 1288 1321 int rank = *itRank; 1289 1322 int nb = 1; 1290 connectedServerRank_[ p].push_back(rank);1291 connectedDataSize_[ p][rank] = nb;1292 nbSenders[ p][rank] = nb;1323 connectedServerRank_[client].push_back(rank); 1324 connectedDataSize_[client][rank] = nb; 1325 nbSenders[client][rank] = nb; 1293 1326 } 1294 1327 } … … 1302 1335 CContext* context = CContext::getCurrent(); 1303 1336 int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 1337 storeIndex_toSrv.clear(); 1338 1304 1339 for (int p = 0; p < nbSrvPools; ++p) 1305 1340 { … … 1317 1352 int rank = *itRank; 1318 1353 int nb = 1; 1319 storeIndex_toSrv .insert(std::make_pair(rank, CArray<int,1>(nb)));1354 storeIndex_toSrv[client].insert(std::make_pair(rank, CArray<int,1>(nb))); 1320 1355 listOutIndex.push_back(CArray<size_t,1>(nb)); 1321 1356 1322 CArray<int, 1>& outLocalIndexToServer = storeIndex_toSrv[ rank];1357 CArray<int, 1>& outLocalIndexToServer = storeIndex_toSrv[client][rank]; 1323 1358 CArray<size_t, 1>& outGlobalIndexOnServer = listOutIndex.back(); 1324 1359 … … 1329 1364 } 1330 1365 1331 storeIndex_fromSrv.insert(std::make_pair(rank, CArray<int,1>(outLocalIndexToServer))); 1366 if (context->hasClient && !context->hasServer) 1367 storeIndex_fromSrv.insert(std::make_pair(rank, CArray<int,1>(outLocalIndexToServer))); 1368 1332 1369 listMsg.push_back(CMessage()); 1333 1370 listMsg.back() << getId( )<< isDataDistributed_ << isCompressible_ << listOutIndex.back(); … … 1343 1380 { 1344 1381 int rank = *itRank; 1345 int nb = 1; 1346 storeIndex_fromSrv.insert(std::make_pair(rank, CArray<int,1>(nb))); 1347 CArray<int, 1>& outLocalIndexToServer = storeIndex_fromSrv[rank]; 1382 int nb = 1; 1383 CArray<int, 1> outLocalIndexToServer; 1348 1384 for (int k = 0; k < nb; ++k) 1349 1385 { 1350 1386 outLocalIndexToServer(k) = 0; 1351 1387 } 1388 1389 if (context->hasClient && !context->hasServer) 1390 storeIndex_fromSrv.insert(std::make_pair(rank, CArray<int,1>(outLocalIndexToServer))); 1352 1391 } 1353 1392 client->sendEvent(event); … … 1360 1399 CContext* context = CContext::getCurrent(); 1361 1400 int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; 1401 storeIndex_toSrv.clear(); 1362 1402 for (int p = 0; p < nbSrvPools; ++p) 1363 1403 { … … 1389 1429 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 1390 1430 { 1391 storeIndex_toSrv.insert(std::make_pair(*itRank, CArray<int,1>(outLocalIndexToServer))); 1392 storeIndex_fromSrv.insert(std::make_pair(*itRank, CArray<int,1>(outLocalIndexToServer))); 1431 storeIndex_toSrv[client].insert(std::make_pair(*itRank, CArray<int,1>(outLocalIndexToServer))); 1432 if (context->hasClient && !context->hasServer) 1433 storeIndex_fromSrv.insert(std::make_pair(*itRank, CArray<int,1>(outLocalIndexToServer))); 1434 1393 1435 listOutIndex.push_back(CArray<size_t,1>(outGlobalIndexOnServer)); 1394 1436 … … 1420 1462 { 1421 1463 CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itGlobalMap; 1422 itGlobalMap = globalIndexOnServer_ .begin();1423 iteGlobalMap = globalIndexOnServer_ .end();1464 itGlobalMap = globalIndexOnServer_[client].begin(); 1465 iteGlobalMap = globalIndexOnServer_[client].end(); 1424 1466 1425 1467 std::map<int,std::vector<int> >localIndexTmp; … … 1441 1483 } 1442 1484 1443 for (int ns = 0; ns < connectedServerRank_[ p].size(); ++ns)1444 { 1445 rank = connectedServerRank_[ p][ns];1485 for (int ns = 0; ns < connectedServerRank_[client].size(); ++ns) 1486 { 1487 rank = connectedServerRank_[client][ns]; 1446 1488 int nb = 0; 1447 1489 if (globalIndexTmp.end() != globalIndexTmp.find(rank)) 1448 1490 nb = globalIndexTmp[rank].size(); 1449 1491 1450 storeIndex_toSrv .insert(make_pair(rank, CArray<int,1>(nb)));1492 storeIndex_toSrv[client].insert(make_pair(rank, CArray<int,1>(nb))); 1451 1493 listOutIndex.push_back(CArray<size_t,1>(nb)); 1452 1494 1453 CArray<int, 1>& outLocalIndexToServer = storeIndex_toSrv[ rank];1495 CArray<int, 1>& outLocalIndexToServer = storeIndex_toSrv[client][rank]; 1454 1496 CArray<size_t, 1>& outGlobalIndexOnServer = listOutIndex.back(); 1455 1497 … … 1464 1506 listMsg.back() << getId() << isDataDistributed_ << isCompressible_ << listOutIndex.back(); 1465 1507 1466 event.push(rank, nbSenders[ p][rank], listMsg.back());1508 event.push(rank, nbSenders[client][rank], listMsg.back()); 1467 1509 } 1468 1510 … … 1495 1537 int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; 1496 1538 nbSrvPools = 1; 1497 nbReadSenders. resize(nbSrvPools);1539 nbReadSenders.clear(); 1498 1540 for (int p = 0; p < nbSrvPools; ++p) 1499 1541 { … … 1688 1730 if (isScalarGrid()) return; 1689 1731 1690 nbReadSenders[ p] = CClientServerMappingDistributed::computeConnectedClients(context->client->serverSize, context->client->clientSize, context->client->intraComm, ranks);1732 nbReadSenders[client] = CClientServerMappingDistributed::computeConnectedClients(context->client->serverSize, context->client->clientSize, context->client->intraComm, ranks); 1691 1733 } 1692 1734 } -
XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.hpp
r1235 r1236 162 162 void computeDomConServer(); 163 163 std::map<int, int> getDomConServerSide(); 164 std::map<int, StdSize> getAttributesBufferSize( );165 std:: vector<std::map<int, StdSize> > getDataBufferSize(const std::string& id = "");164 std::map<int, StdSize> getAttributesBufferSize(CContextClient* client); 165 std::map<int, StdSize> getDataBufferSize(CContextClient* client, const std::string& id = ""); 166 166 std::vector<StdString> getDomainList(); 167 167 std::vector<StdString> getAxisList(); … … 175 175 std::vector<int> getAxisOrder(); 176 176 std::vector<int> getGlobalDimension(); 177 bool isScalarGrid() const; 178 std::vector<int> getAxisPositionInGrid() const; 177 bool isScalarGrid() const; 179 178 180 179 bool doGridHaveDataToWrite(); … … 200 199 bool hasTransform(); 201 200 size_t getGlobalWrittenSize(void) ; 201 202 202 public: 203 204 /// Propriétés privées ///205 bool isChecked;206 bool isDomainAxisChecked;207 bool isIndexSent;208 209 203 CArray<int, 1> storeIndex_client; 210 204 211 map<int, CArray<int, 1> > storeIndex_toSrv;212 map<int, CArray<int, 1> > storeIndex_fromSrv; 213 std:: vector<map<int,int> > nbSenders, nbReadSenders;205 std::map<CContextClient*, map<int, CArray<int, 1> > > storeIndex_toSrv; // Same grid but can be sent to several pools 206 map<int, CArray<int, 1> > storeIndex_fromSrv; // Support, for now, reading with level-1 server 207 std::map<CContextClient*, std::map<int,int> > nbSenders, nbReadSenders; 214 208 215 209 map<int, CArray<size_t, 1> > outIndexFromClient, compressedOutIndexFromClient, outGlobalIndexFromClient; … … 282 276 283 277 private: 278 bool isChecked; 279 bool isDomainAxisChecked; 280 bool isIndexSent; 281 284 282 CDomainGroup* vDomainGroup_; 285 283 CAxisGroup* vAxisGroup_; … … 293 291 size_t writtenDataSize_; 294 292 int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; 295 std:: vector<std::map<int,size_t> > connectedDataSize_;296 std:: vector<std::vector<int> > connectedServerRank_;293 std::map<CContextClient*, std::map<int,size_t> > connectedDataSize_; 294 std::map<CContextClient*, std::vector<int> > connectedServerRank_; 297 295 bool isDataDistributed_; 298 296 //! True if and only if the data defined on the grid can be outputted in a compressed way … … 307 305 std::map<CGrid*, std::pair<bool,StdString> > gridSrc_; 308 306 bool hasTransform_; 309 CClientServerMapping::GlobalIndexMapglobalIndexOnServer_;307 std::map<CContextClient*, CClientServerMapping::GlobalIndexMap> globalIndexOnServer_; 310 308 // List order of axis and domain in a grid, if there is a domain, it will take value 1 (true), axis 0 (false) 311 309 std::vector<int> order_;
Note: See TracChangeset
for help on using the changeset viewer.