Changeset 1144 for XIOS/dev/dev_olga/src/node/grid.cpp
- Timestamp:
- 05/23/17 16:32:26 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_olga/src/node/grid.cpp
r1143 r1144 536 536 } 537 537 538 std::vector<int> CGrid::getAxisPositionInGrid() const 539 { 540 return axisPositionInGrid_; 541 } 542 538 /*! 539 Compute the index to for write data into a file 540 */ 543 541 void CGrid::computeWrittenIndex() 544 542 { … … 561 559 localIndexToWriteOnClient.resize(nbWritten); 562 560 localIndexToWriteOnServer.resize(nbWritten); 563 564 // if (isCompressible()) 561 565 562 { 566 563 numberWrittenIndexes_ = nbWritten; … … 607 604 int rank = client->clientRank; 608 605 609 clientDistribution_ = new CDistributionClient(rank, this); 610 // Get local data index on client 611 storeIndex_client.resize(clientDistribution_->getLocalDataIndexOnClient().size()); 612 int nbStoreIndex = storeIndex_client.numElements(); 613 for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndex_client(idx) = (clientDistribution_->getLocalDataIndexOnClient())[idx]; 614 // } 606 clientDistribution_ = new CDistributionClient(rank, this); 607 // Get local data index on client 608 storeIndex_client.resize(clientDistribution_->getLocalDataIndexOnClient().size()); 609 int nbStoreIndex = storeIndex_client.numElements(); 610 for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndex_client(idx) = (clientDistribution_->getLocalDataIndexOnClient())[idx]; 615 611 616 612 if (0 == serverDistribution_) isDataDistributed_= clientDistribution_->isDataDistributed(); 617 613 else 618 { 619 614 { 620 615 // Mapping global index received from clients to the storeIndex_client 621 616 CDistributionClient::GlobalLocalDataMap& globalDataIndex = clientDistribution_->getGlobalDataIndexOnClient(); … … 858 853 } 859 854 860 // nbIndexOnServer = 0;861 // for (it = itb; it != ite; ++it)862 // {863 // const std::vector<int>& tmp = it->second;864 // nbIndexOnServerTmp = 0;865 // for (int i = 0; i < tmp.size(); ++i)866 // {867 // if (0 == nbIndexOnServerTmp(tmp[i]))868 // {869 // globalElementIndexOnServer[idx][tmp[i]][nbIndexOnServer(tmp[i])] = it->first;870 // ++nbIndexOnServerTmp(tmp[i]);871 // }872 // }873 // nbIndexOnServer += nbIndexOnServerTmp;874 // }875 // }876 877 855 nbIndexOnServer = 0; 878 856 for (size_t j = 0; j < globalIndexElementOnServerMap.size(); ++j) … … 1144 1122 } 1145 1123 1146 void CGrid::outputField(int rank, const CArray<double, 1>& stored, double* field)1147 {1148 const CArray<size_t,1>& out_i = outIndexFromClient[rank];1149 StdSize numElements = stored.numElements();1150 for (StdSize n = 0; n < numElements; ++n)1151 {1152 field[out_i(n)] = stored(n);1153 }1154 }1155 1156 void CGrid::inputField(int rank, const double* const field, CArray<double,1>& stored)1157 {1158 const CArray<size_t,1>& out_i = outIndexFromClient[rank];1159 StdSize numElements = stored.numElements();1160 for (StdSize n = 0; n < numElements; ++n)1161 {1162 stored(n) = field[out_i(n)];1163 }1164 }1165 1166 void CGrid::outputCompressedField(int rank, const CArray<double,1>& stored, double* field)1167 {1168 const CArray<size_t,1>& out_i = compressedOutIndexFromClient[rank];1169 StdSize numElements = stored.numElements();1170 for (StdSize n = 0; n < numElements; ++n)1171 {1172 field[out_i(n)] = stored(n);1173 }1174 }1175 1176 //----------------------------------------------------------------1177 1178 1124 void CGrid::storeField_arr(const double* const data, CArray<double, 1>& stored) const 1179 1125 { … … 1193 1139 void CGrid::computeIndexScalarGrid() 1194 1140 { 1195 CContext* context = CContext::getCurrent(); 1196 // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 1141 CContext* context = CContext::getCurrent(); 1197 1142 int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; 1198 1143 connectedServerRank_.resize(nbSrvPools); … … 1219 1164 } 1220 1165 isDataDistributed_ = false; 1221 }1222 }1223 1224 void CGrid::computeCompressedIndex()1225 {1226 compressedOutIndexFromClient = outIndexFromClient;1227 1228 std::map<size_t, size_t> indexes;1229 1230 {1231 std::map<int, CArray<size_t,1> >::const_iterator it = compressedOutIndexFromClient.begin();1232 std::map<int, CArray<size_t,1> >::const_iterator itEnd = compressedOutIndexFromClient.end();1233 for (; it != itEnd; ++it)1234 {1235 for (int i = 0; i < it->second.numElements(); ++i)1236 indexes.insert(std::make_pair(it->second(i), 0));1237 }1238 }1239 1240 {1241 std::map<size_t, size_t>::iterator it = indexes.begin();1242 std::map<size_t, size_t>::iterator itEnd = indexes.end();1243 for (size_t i = 0; it != itEnd; ++it, ++i)1244 it->second = i;1245 }1246 1247 {1248 std::map<int, CArray<size_t,1> >::iterator it = compressedOutIndexFromClient.begin();1249 std::map<int, CArray<size_t,1> >::iterator itEnd = compressedOutIndexFromClient.end();1250 for (; it != itEnd; ++it)1251 {1252 for (int i = 0; i < it->second.numElements(); ++i)1253 it->second(i) = indexes[it->second(i)];1254 }1255 1166 } 1256 1167 } … … 1378 1289 else 1379 1290 { 1380 // CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itGlobalMap, itbGlobalMap;1381 // itbGlobalMap = globalIndexOnServer_.begin(), itGlobalMap;1382 // iteGlobalMap = globalIndexOnServer_.end();1383 1384 // std::map<int,int > nbGlobalLocalTmp;1385 // for (itGlobalMap = itbGlobalMap; itGlobalMap != iteGlobalMap; ++itGlobalMap)1386 // {1387 // int serverRank = itGlobalMap->first;1388 // nbGlobalLocalTmp[serverRank] = 0;1389 // const std::vector<size_t>& indexVec = itGlobalMap->second;1390 // int indexSize = indexVec.size();1391 // for (int idx = 0; idx < indexSize; ++idx)1392 // {1393 // itIndex = globalLocalIndexSendToServer.find(indexVec[idx]);1394 // if (iteIndex != itIndex)1395 // {1396 // ++nbGlobalLocalTmp[serverRank];1397 // }1398 // }1399 // }1400 1401 // std::map<int,std::vector<int> >localIndexTmp;1402 // std::map<int,std::vector<size_t> > globalIndexTmp;1403 // for (std::map<int,int>::iterator it = nbGlobalLocalTmp.begin(); it != nbGlobalLocalTmp.end(); ++it)1404 // {1405 // localIndexTmp[it->first].resize(it->second);1406 // globalIndexTmp[it->first].resize(it->second);1407 // it->second = 0;1408 // }1409 1410 // for (itGlobalMap = itbGlobalMap; itGlobalMap != iteGlobalMap; ++itGlobalMap)1411 // {1412 // int serverRank = itGlobalMap->first;1413 // const std::vector<size_t>& indexVec = itGlobalMap->second;1414 // int indexSize = indexVec.size();1415 // int ind = 0;1416 // for (int idx = 0; idx < indexSize; ++idx)1417 // {1418 // itIndex = globalLocalIndexSendToServer.find(indexVec[idx]);1419 // if (iteIndex != itIndex)1420 // {1421 // ind = nbGlobalLocalTmp[serverRank];1422 // globalIndexTmp[serverRank][ind] = itIndex->first;1423 // localIndexTmp[serverRank][ind] = itIndex->second;1424 // ++nbGlobalLocalTmp[serverRank];1425 // }1426 // }1427 // }1428 1429 1291 CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itGlobalMap; 1430 1292 itGlobalMap = globalIndexOnServer_.begin(); … … 1502 1364 1503 1365 int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; 1504 nbSrvPools = 1; 1505 // connectedServerRank_.resize(nbSrvPools); 1366 nbSrvPools = 1; 1506 1367 nbReadSenders.resize(nbSrvPools); 1507 1368 for (int p = 0; p < nbSrvPools; ++p) … … 1510 1371 CContextClient* client = (!context->hasClient) ? context->client : context->clientPrimServer[p]; 1511 1372 1512 // CContextServer* server = (context->hasServer) ? context->server : context->serverPrimServer[p];1513 // CContextClient* client = (context->hasServer) ? context->client : context->clientPrimServer[p];1514 // numberWrittenIndexes_ = totalNumberWrittenIndexes_ = offsetWrittenIndexes_ = 0;1515 //connectedServerRank_[p] = ranks;1516 1517 1373 int idx = 0, numElement = axis_domain_order.numElements(); 1518 1374 int ssize = numElement; … … 1596 1452 else 1597 1453 { 1598 // dataSize = outIndex.numElements();1599 // for (int i = 0; i < outIndex.numElements(); ++i) outIndex(i) = i;1600 1454 // THE PROBLEM HERE IS THAT DATA CAN BE NONDISTRIBUTED ON CLIENT AND DISTRIBUTED ON SERVER 1601 1455 // BELOW IS THE TEMPORARY FIX only for a single type of element (domain, asix, scalar) 1602 1456 dataSize = serverDistribution_->getGridSize(); 1603 // dataSize = serverDistribution_->getGlobalIndexEachDimension()[0].numElements();1604 // outIndex.resize(dataSize);1605 // outIndex = serverDistribution_->getGlobalIndexEachDimension()[0];1606 1607 1457 } 1608 1458 writtenDataSize_ += dataSize; 1609 1610 // outIndexFromClient.insert(std::make_pair(rank, outIndex));1611 // connectedDataSize_[p][rank] = outIndex.numElements();1612 // numberWrittenIndexes_ += outIndex.numElements();1613 1459 } 1614 1460 … … 1686 1532 } 1687 1533 1688 // if (isScalarGrid()) return; 1689 1690 // if (isDataDistributed_) 1691 // { 1692 // MPI_Allreduce(&numberWrittenIndexes_, &totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 1693 // MPI_Scan(&numberWrittenIndexes_, &offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 1694 // offsetWrittenIndexes_ -= numberWrittenIndexes_; 1695 // } 1696 // else 1697 // totalNumberWrittenIndexes_ = numberWrittenIndexes_; 1534 if (isScalarGrid()) return; 1698 1535 1699 1536 nbReadSenders[p] = CClientServerMappingDistributed::computeConnectedClients(context->client->serverSize, context->client->clientSize, context->client->intraComm, ranks); … … 1910 1747 { 1911 1748 sendAddItem(id, (int)EVENT_ID_ADD_DOMAIN); 1912 // CContext* context=CContext::getCurrent();1913 1914 // if (! context->hasServer )1915 // {1916 // CContextClient* client=context->client;1917 1918 // CEventClient event(this->getType(),EVENT_ID_ADD_DOMAIN);1919 // if (client->isServerLeader())1920 // {1921 // CMessage msg;1922 // msg<<this->getId();1923 // msg<<id;1924 // const std::list<int>& ranks = client->getRanksServerLeader();1925 // for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)1926 // event.push(*itRank,1,msg);1927 // client->sendEvent(event);1928 // }1929 // else client->sendEvent(event);1930 // }1931 1749 } 1932 1750 … … 1938 1756 { 1939 1757 sendAddItem(id, (int)EVENT_ID_ADD_AXIS); 1940 // CContext* context=CContext::getCurrent();1941 1942 // if (! context->hasServer )1943 // {1944 // CContextClient* client=context->client;1945 1946 // CEventClient event(this->getType(),EVENT_ID_ADD_AXIS);1947 // if (client->isServerLeader())1948 // {1949 // CMessage msg;1950 // msg<<this->getId();1951 // msg<<id;1952 // const std::list<int>& ranks = client->getRanksServerLeader();1953 // for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)1954 // event.push(*itRank,1,msg);1955 // client->sendEvent(event);1956 // }1957 // else client->sendEvent(event);1958 // }1959 1758 } 1960 1759 … … 1966 1765 { 1967 1766 sendAddItem(id, (int)EVENT_ID_ADD_SCALAR); 1968 // CContext* context=CContext::getCurrent();1969 1970 // if (! context->hasServer )1971 // {1972 // CContextClient* client=context->client;1973 1974 // CEventClient event(this->getType(),EVENT_ID_ADD_SCALAR);1975 // if (client->isServerLeader())1976 // {1977 // CMessage msg;1978 // msg<<this->getId();1979 // msg<<id;1980 // const std::list<int>& ranks = client->getRanksServerLeader();1981 // for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)1982 // event.push(*itRank,1,msg);1983 // client->sendEvent(event);1984 // }1985 // else client->sendEvent(event);1986 // }1987 1767 } 1988 1768 … … 2075 1855 { 2076 1856 CDomain* pDom = CDomain::get(*it); 2077 if (context->hasClient && !context->hasServer) 2078 //if (context->hasClient) 1857 if (context->hasClient && !context->hasServer) 2079 1858 { 2080 1859 pDom->solveRefInheritance(apply); … … 2089 1868 CAxis* pAxis = CAxis::get(*it); 2090 1869 if (context->hasClient && !context->hasServer) 2091 // if (context->hasClient)2092 1870 { 2093 1871 pAxis->solveRefInheritance(apply); … … 2102 1880 CScalar* pScalar = CScalar::get(*it); 2103 1881 if (context->hasClient && !context->hasServer) 2104 // if (context->hasClient)2105 1882 { 2106 1883 pScalar->solveRefInheritance(apply);
Note: See TracChangeset
for help on using the changeset viewer.