Changeset 829 for XIOS/trunk/src/client_client_dht_template_impl.hpp
- Timestamp:
- 03/23/16 16:11:01 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/client_client_dht_template_impl.hpp
r721 r829 49 49 for (size_t idx = 0; idx < size; ++idx) 50 50 { 51 int serverIdx = indexToInfoMappingLevel_[indices(idx)]; 52 indexGlobalOnServer_[serverIdx].push_back(indices(idx)); 51 T& info = indexToInfoMappingLevel_[indices(idx)]; 52 // infoIndexMapping_[info].push_back(indices(idx)); 53 infoIndexMapping_[indices(idx)] = info; 53 54 } 54 55 } … … 125 126 126 127 // Buffer to receive respond from other clients, it can be allocated or not depending whether it demands other clients 127 InfoType* recvBuffInfo = 0; 128 // InfoType* recvBuffInfo = 0; 129 unsigned char* recvBuffInfo = 0; 128 130 int nbIndexReceivedFromOthers = nbIndexToSend; 129 131 if (0 != nbIndexReceivedFromOthers) 130 recvBuffInfo = new InfoType[nbIndexReceivedFromOthers];132 recvBuffInfo = new unsigned char[nbIndexReceivedFromOthers*infoTypeSize]; 131 133 132 134 std::map<int, MPI_Request>::iterator itRequest; … … 212 214 213 215 // Mapping client rank and the begining position of receiving buffer for message of server index from this client 214 std::map<int, InfoType*> infoBuffBegin;216 std::map<int, unsigned char*> infoBuffBegin; 215 217 216 218 while ((!sendInfoRequest.empty()) || (nbSendBuffInfoReceived < nbIndexReceivedFromOthers)) … … 233 235 if (true == flagInfo) 234 236 { 235 MPI_Get_count(&statusInfo, MPI_INT, &count); 237 MPI_Get_count(&statusInfo, MPI_CHAR, &count); 238 int actualCountInfo = count/infoTypeSize; 236 239 int clientSourceRank = statusInfo.MPI_SOURCE; 237 InfoType* beginBuff = infoBuffBegin[clientSourceRank];240 unsigned char* beginBuff = infoBuffBegin[clientSourceRank]; 238 241 std::vector<size_t>& indexTmp = client2ClientIndex[clientSourceRank]; 239 for (int i = 0; i < count; ++i) 242 TypeToBytes<InfoType> u; 243 for (int i = 0; i < actualCountInfo; ++i) 240 244 { 241 indexToInfoMapping[indexTmp[i]] = *(beginBuff+i); 245 unsigned char* tmpBeginBuff = beginBuff+i*infoTypeSize; 246 for (size_t idx = 0; idx < infoTypeSize; ++idx) u.bytes[idx] = *(tmpBeginBuff+idx); 247 indexToInfoMapping[indexTmp[i]] = u.value; 242 248 } 243 nbSendBuffInfoReceived += count;249 nbSendBuffInfoReceived += actualCountInfo; 244 250 repondAlreadyReceived.push_back(clientSourceRank); 245 251 } … … 251 257 } 252 258 253 indexToInfoMappingLevel_ = indexToInfoMapping;259 indexToInfoMappingLevel_.swap(indexToInfoMapping); 254 260 if (0 != maxNbIndexDemandedFromOthers) delete [] recvBuffIndex; 255 261 if (0 != nbIndexReceivedFromOthers) delete [] recvBuffInfo; … … 289 295 template<typename T, typename H> 290 296 void CClientClientDHTTemplate<T,H>::computeDistributedIndex(const boost::unordered_map<size_t,T>& indexInfoMap, 291 const MPI_Comm& commLevel,292 int level)297 const MPI_Comm& commLevel, 298 int level) 293 299 { 294 300 int nbClient, clientRank; … … 340 346 int recvNbIndexCount = recvNbIndexBuff[clientRank]; 341 347 unsigned long* recvIndexBuff = new unsigned long[recvNbIndexCount]; 342 InfoType* recvInfoBuff = new InfoType[recvNbIndexCount];348 unsigned char* recvInfoBuff = new unsigned char[recvNbIndexCount*infoTypeSize]; 343 349 344 350 // If a client holds information about index and the corresponding which don't belong to it, … … 374 380 375 381 // Mapping client rank and the begining position of receiving buffer for message of server index from this client 376 std::map<int, int*> infoBuffBegin;382 std::map<int, unsigned char*> infoBuffBegin; 377 383 378 384 boost::unordered_map<size_t,InfoType> indexToInfoMapping; … … 418 424 { 419 425 int count = it->second; 426 TypeToBytes<InfoType> u; 420 427 for (int i = 0; i < count; ++i) 421 indexToInfoMapping.insert(std::make_pair<size_t,InfoType>(*(indexBuffBegin[rank]+i),*(infoBuffBegin[rank]+i))); 428 { 429 unsigned char* tmpBeginBuff = infoBuffBegin[rank]+i*infoTypeSize; 430 for (size_t idx = 0; idx < infoTypeSize; ++idx) u.bytes[idx] = *(tmpBeginBuff+idx); 431 indexToInfoMapping.insert(std::make_pair<size_t,InfoType>(*(indexBuffBegin[rank]+i),u.value)); 432 } 433 422 434 processedList.push_back(rank); 423 435 --recvNbClient; … … 466 478 template<typename T, typename H> 467 479 void CClientClientDHTTemplate<T,H>::probeIndexMessageFromClients(unsigned long* recvIndexBuff, 468 const int recvNbIndexCount,469 int& countIndex,470 std::map<int, unsigned long*>& indexBuffBegin,471 std::map<int, MPI_Request>& requestRecvIndex,472 const MPI_Comm& intraComm)480 const int recvNbIndexCount, 481 int& countIndex, 482 std::map<int, unsigned long*>& indexBuffBegin, 483 std::map<int, MPI_Request>& requestRecvIndex, 484 const MPI_Comm& intraComm) 473 485 { 474 486 MPI_Status statusIndexGlobal; … … 500 512 */ 501 513 template<typename T, typename H> 502 void CClientClientDHTTemplate<T,H>::probeInfoMessageFromClients( T* recvInfoBuff,503 const int recvNbIndexCount,504 int& countInfo,505 std::map<int, T*>& infoBuffBegin,506 std::map<int, MPI_Request>& requestRecvInfo,507 const MPI_Comm& intraComm)514 void CClientClientDHTTemplate<T,H>::probeInfoMessageFromClients(unsigned char* recvInfoBuff, 515 const int recvNbIndexCount, 516 int& countInfo, 517 std::map<int, unsigned char*>& infoBuffBegin, 518 std::map<int, MPI_Request>& requestRecvInfo, 519 const MPI_Comm& intraComm) 508 520 { 509 521 MPI_Status statusInfo; … … 515 527 { 516 528 MPI_Get_count(&statusInfo, MPI_CHAR, &count); 517 infoBuffBegin.insert(std::make_pair<int, T*>(statusInfo.MPI_SOURCE, recvInfoBuff+countInfo)); 518 MPI_Irecv(recvInfoBuff+countInfo, count, MPI_CHAR, 529 unsigned char* beginInfoBuff = recvInfoBuff+countInfo*infoTypeSize; 530 infoBuffBegin.insert(std::make_pair<int, unsigned char*>(statusInfo.MPI_SOURCE, beginInfoBuff)); 531 MPI_Irecv(beginInfoBuff, count, MPI_CHAR, 519 532 statusInfo.MPI_SOURCE, MPI_DHT_INFO, intraComm, 520 533 &requestRecvInfo[statusInfo.MPI_SOURCE]); … … 533 546 template<typename T, typename H> 534 547 void CClientClientDHTTemplate<T,H>::sendIndexToClients(int clientDestRank, std::vector<size_t>& indices, 535 const MPI_Comm& clientIntraComm,536 std::list<MPI_Request>& requestSendIndex)548 const MPI_Comm& clientIntraComm, 549 std::list<MPI_Request>& requestSendIndex) 537 550 { 538 551 MPI_Request request; … … 551 564 template<typename T, typename H> 552 565 void CClientClientDHTTemplate<T,H>::sendInfoToClients(int clientDestRank, std::vector<T>& info, 553 const MPI_Comm& clientIntraComm,554 std::list<MPI_Request>& requestSendInfo)566 const MPI_Comm& clientIntraComm, 567 std::list<MPI_Request>& requestSendInfo) 555 568 { 556 569 MPI_Request request;
Note: See TracChangeset
for help on using the changeset viewer.