[591] | 1 | #include "xios_spl.hpp" |
---|
[300] | 2 | #include "context_client.hpp" |
---|
| 3 | #include "context_server.hpp" |
---|
| 4 | #include "event_client.hpp" |
---|
| 5 | #include "buffer_out.hpp" |
---|
| 6 | #include "buffer_client.hpp" |
---|
| 7 | #include "type.hpp" |
---|
| 8 | #include "event_client.hpp" |
---|
| 9 | #include "context.hpp" |
---|
[382] | 10 | #include "mpi.hpp" |
---|
[347] | 11 | #include "timer.hpp" |
---|
[401] | 12 | #include "cxios.hpp" |
---|
[1130] | 13 | #include "server.hpp" |
---|
[300] | 14 | |
---|
[335] | 15 | namespace xios |
---|
[300] | 16 | { |
---|
[512] | 17 | /*! |
---|
| 18 | \param [in] parent Pointer to context on client side |
---|
| 19 | \param [in] intraComm_ communicator of group client |
---|
| 20 | \param [in] interComm_ communicator of group server |
---|
[983] | 21 | \cxtSer [in] cxtSer Pointer to context of server side. (It is only used in case of attached mode). |
---|
[512] | 22 | */ |
---|
[595] | 23 | CContextClient::CContextClient(CContext* parent, MPI_Comm intraComm_, MPI_Comm interComm_, CContext* cxtSer) |
---|
[917] | 24 | : mapBufferSize_(), parentServer(cxtSer), maxBufferedEvents(4) |
---|
[300] | 25 | { |
---|
[595] | 26 | context = parent; |
---|
| 27 | intraComm = intraComm_; |
---|
| 28 | interComm = interComm_; |
---|
| 29 | MPI_Comm_rank(intraComm, &clientRank); |
---|
| 30 | MPI_Comm_size(intraComm, &clientSize); |
---|
[509] | 31 | |
---|
[595] | 32 | int flag; |
---|
| 33 | MPI_Comm_test_inter(interComm, &flag); |
---|
| 34 | if (flag) MPI_Comm_remote_size(interComm, &serverSize); |
---|
| 35 | else MPI_Comm_size(interComm, &serverSize); |
---|
[509] | 36 | |
---|
[1232] | 37 | computeLeader(clientRank, clientSize, serverSize, ranksServerLeader, ranksServerNotLeader); |
---|
| 38 | |
---|
| 39 | timeLine = 0; |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | void CContextClient::computeLeader(int clientRank, int clientSize, int serverSize, |
---|
| 43 | std::list<int>& rankRecvLeader, |
---|
| 44 | std::list<int>& rankRecvNotLeader) |
---|
| 45 | { |
---|
| 46 | if ((0 == clientSize) || (0 == serverSize)) return; |
---|
| 47 | |
---|
[595] | 48 | if (clientSize < serverSize) |
---|
| 49 | { |
---|
| 50 | int serverByClient = serverSize / clientSize; |
---|
| 51 | int remain = serverSize % clientSize; |
---|
| 52 | int rankStart = serverByClient * clientRank; |
---|
[300] | 53 | |
---|
[595] | 54 | if (clientRank < remain) |
---|
| 55 | { |
---|
| 56 | serverByClient++; |
---|
| 57 | rankStart += clientRank; |
---|
| 58 | } |
---|
| 59 | else |
---|
| 60 | rankStart += remain; |
---|
| 61 | |
---|
| 62 | for (int i = 0; i < serverByClient; i++) |
---|
[1232] | 63 | rankRecvLeader.push_back(rankStart + i); |
---|
[1021] | 64 | |
---|
[1232] | 65 | rankRecvNotLeader.resize(0); |
---|
[1158] | 66 | } |
---|
[595] | 67 | else |
---|
| 68 | { |
---|
| 69 | int clientByServer = clientSize / serverSize; |
---|
| 70 | int remain = clientSize % serverSize; |
---|
| 71 | |
---|
| 72 | if (clientRank < (clientByServer + 1) * remain) |
---|
| 73 | { |
---|
| 74 | if (clientRank % (clientByServer + 1) == 0) |
---|
[1232] | 75 | rankRecvLeader.push_back(clientRank / (clientByServer + 1)); |
---|
[1021] | 76 | else |
---|
[1232] | 77 | rankRecvNotLeader.push_back(clientRank / (clientByServer + 1)); |
---|
[595] | 78 | } |
---|
| 79 | else |
---|
| 80 | { |
---|
| 81 | int rank = clientRank - (clientByServer + 1) * remain; |
---|
| 82 | if (rank % clientByServer == 0) |
---|
[1232] | 83 | rankRecvLeader.push_back(remain + rank / clientByServer); |
---|
[1021] | 84 | else |
---|
[1232] | 85 | rankRecvNotLeader.push_back(remain + rank / clientByServer); |
---|
[595] | 86 | } |
---|
| 87 | } |
---|
[300] | 88 | } |
---|
| 89 | |
---|
[512] | 90 | /*! |
---|
| 91 | In case of attached mode, the current context must be reset to context for client |
---|
| 92 | \param [in] event Event sent to server |
---|
| 93 | */ |
---|
[300] | 94 | void CContextClient::sendEvent(CEventClient& event) |
---|
| 95 | { |
---|
[731] | 96 | list<int> ranks = event.getRanks(); |
---|
[1054] | 97 | |
---|
[1377] | 98 | if (CXios::checkEventSync) |
---|
| 99 | { |
---|
| 100 | int typeId, classId, typeId_in, classId_in, timeLine_out; |
---|
| 101 | typeId_in=event.getTypeId() ; |
---|
| 102 | classId_in=event.getClassId() ; |
---|
[1475] | 103 | // MPI_Allreduce(&timeLine,&timeLine_out, 1, MPI_UINT64_T, MPI_SUM, intraComm) ; // MPI_UINT64_T standardized by MPI 3 |
---|
| 104 | MPI_Allreduce(&timeLine,&timeLine_out, 1, MPI_LONG_LONG_INT, MPI_SUM, intraComm) ; |
---|
[1377] | 105 | MPI_Allreduce(&typeId_in,&typeId, 1, MPI_INT, MPI_SUM, intraComm) ; |
---|
| 106 | MPI_Allreduce(&classId_in,&classId, 1, MPI_INT, MPI_SUM, intraComm) ; |
---|
| 107 | if (typeId/clientSize!=event.getTypeId() || classId/clientSize!=event.getClassId() || timeLine_out/clientSize!=timeLine) |
---|
| 108 | { |
---|
| 109 | ERROR("void CContextClient::sendEvent(CEventClient& event)", |
---|
| 110 | << "Event are not coherent between client."); |
---|
| 111 | } |
---|
| 112 | } |
---|
| 113 | |
---|
[595] | 114 | if (!event.isEmpty()) |
---|
[300] | 115 | { |
---|
[731] | 116 | list<int> sizes = event.getSizes(); |
---|
[300] | 117 | |
---|
[1130] | 118 | // We force the getBuffers call to be non-blocking on classical servers |
---|
[1054] | 119 | list<CBufferOut*> buffList; |
---|
[1130] | 120 | bool couldBuffer = getBuffers(ranks, sizes, buffList, (!CXios::isClient && (CServer::serverLevel == 0) )); |
---|
[1184] | 121 | // bool couldBuffer = getBuffers(ranks, sizes, buffList, CXios::isServer ); |
---|
[509] | 122 | |
---|
[1054] | 123 | if (couldBuffer) |
---|
| 124 | { |
---|
| 125 | event.send(timeLine, sizes, buffList); |
---|
[731] | 126 | |
---|
[1054] | 127 | checkBuffers(ranks); |
---|
| 128 | |
---|
| 129 | if (isAttachedModeEnabled()) // couldBuffer is always true in attached mode |
---|
| 130 | { |
---|
| 131 | waitEvent(ranks); |
---|
| 132 | CContext::setCurrent(context->getId()); |
---|
| 133 | } |
---|
| 134 | } |
---|
| 135 | else |
---|
| 136 | { |
---|
| 137 | tmpBufferedEvent.ranks = ranks; |
---|
| 138 | tmpBufferedEvent.sizes = sizes; |
---|
| 139 | |
---|
| 140 | for (list<int>::const_iterator it = sizes.begin(); it != sizes.end(); it++) |
---|
| 141 | tmpBufferedEvent.buffers.push_back(new CBufferOut(*it)); |
---|
[1377] | 142 | info(100)<<"DEBUG : temporaly event created : timeline "<<timeLine<<endl ; |
---|
[1054] | 143 | event.send(timeLine, tmpBufferedEvent.sizes, tmpBufferedEvent.buffers); |
---|
| 144 | } |
---|
[300] | 145 | } |
---|
| 146 | |
---|
[1054] | 147 | timeLine++; |
---|
| 148 | } |
---|
| 149 | |
---|
| 150 | /*! |
---|
| 151 | * Send the temporarily buffered event (if any). |
---|
| 152 | * |
---|
[1158] | 153 | * \return true if a temporarily buffered event could be sent, false otherwise |
---|
[1054] | 154 | */ |
---|
| 155 | bool CContextClient::sendTemporarilyBufferedEvent() |
---|
| 156 | { |
---|
| 157 | bool couldSendTmpBufferedEvent = false; |
---|
| 158 | |
---|
| 159 | if (hasTemporarilyBufferedEvent()) |
---|
[511] | 160 | { |
---|
[1054] | 161 | list<CBufferOut*> buffList; |
---|
| 162 | if (getBuffers(tmpBufferedEvent.ranks, tmpBufferedEvent.sizes, buffList, true)) // Non-blocking call |
---|
| 163 | { |
---|
| 164 | list<CBufferOut*>::iterator it, itBuffer; |
---|
| 165 | |
---|
| 166 | for (it = tmpBufferedEvent.buffers.begin(), itBuffer = buffList.begin(); it != tmpBufferedEvent.buffers.end(); it++, itBuffer++) |
---|
| 167 | (*itBuffer)->put((char*)(*it)->start(), (*it)->count()); |
---|
| 168 | |
---|
[1377] | 169 | info(100)<<"DEBUG : temporaly event sent "<<endl ; |
---|
[1054] | 170 | checkBuffers(tmpBufferedEvent.ranks); |
---|
| 171 | |
---|
| 172 | tmpBufferedEvent.clear(); |
---|
| 173 | |
---|
| 174 | couldSendTmpBufferedEvent = true; |
---|
| 175 | } |
---|
[511] | 176 | } |
---|
| 177 | |
---|
[1054] | 178 | return couldSendTmpBufferedEvent; |
---|
[300] | 179 | } |
---|
[509] | 180 | |
---|
[512] | 181 | /*! |
---|
| 182 | If client is also server (attached mode), after sending event, it should process right away |
---|
| 183 | the incoming event. |
---|
| 184 | \param [in] ranks list rank of server connected this client |
---|
| 185 | */ |
---|
[300] | 186 | void CContextClient::waitEvent(list<int>& ranks) |
---|
| 187 | { |
---|
[595] | 188 | parentServer->server->setPendingEvent(); |
---|
| 189 | while (checkBuffers(ranks)) |
---|
[300] | 190 | { |
---|
[595] | 191 | parentServer->server->listen(); |
---|
| 192 | parentServer->server->checkPendingRequest(); |
---|
[300] | 193 | } |
---|
[386] | 194 | |
---|
[595] | 195 | while (parentServer->server->hasPendingEvent()) |
---|
[386] | 196 | { |
---|
[595] | 197 | parentServer->server->eventLoop(); |
---|
[386] | 198 | } |
---|
[300] | 199 | } |
---|
| 200 | |
---|
[512] | 201 | /*! |
---|
[1054] | 202 | * Get buffers for each connection to the servers. This function blocks until there is enough room in the buffers unless |
---|
| 203 | * it is explicitly requested to be non-blocking. |
---|
| 204 | * |
---|
| 205 | * \param [in] serverList list of rank of connected server |
---|
| 206 | * \param [in] sizeList size of message corresponding to each connection |
---|
| 207 | * \param [out] retBuffers list of buffers that can be used to store an event |
---|
| 208 | * \param [in] nonBlocking whether this function should be non-blocking |
---|
| 209 | * \return whether the already allocated buffers could be used |
---|
[512] | 210 | */ |
---|
[1071] | 211 | bool CContextClient::getBuffers(const list<int>& serverList, const list<int>& sizeList, list<CBufferOut*>& retBuffers, |
---|
| 212 | bool nonBlocking /*= false*/) |
---|
[300] | 213 | { |
---|
[1054] | 214 | list<int>::const_iterator itServer, itSize; |
---|
[595] | 215 | list<CClientBuffer*> bufferList; |
---|
[1054] | 216 | map<int,CClientBuffer*>::const_iterator it; |
---|
[595] | 217 | list<CClientBuffer*>::iterator itBuffer; |
---|
[884] | 218 | bool areBuffersFree; |
---|
[300] | 219 | |
---|
[595] | 220 | for (itServer = serverList.begin(); itServer != serverList.end(); itServer++) |
---|
[300] | 221 | { |
---|
[595] | 222 | it = buffers.find(*itServer); |
---|
| 223 | if (it == buffers.end()) |
---|
[300] | 224 | { |
---|
[595] | 225 | newBuffer(*itServer); |
---|
| 226 | it = buffers.find(*itServer); |
---|
[509] | 227 | } |
---|
[595] | 228 | bufferList.push_back(it->second); |
---|
[300] | 229 | } |
---|
[347] | 230 | |
---|
| 231 | CTimer::get("Blocking time").resume(); |
---|
[884] | 232 | do |
---|
[300] | 233 | { |
---|
[884] | 234 | areBuffersFree = true; |
---|
[595] | 235 | for (itBuffer = bufferList.begin(), itSize = sizeList.begin(); itBuffer != bufferList.end(); itBuffer++, itSize++) |
---|
[884] | 236 | areBuffersFree &= (*itBuffer)->isBufferFree(*itSize); |
---|
| 237 | |
---|
| 238 | if (!areBuffersFree) |
---|
[300] | 239 | { |
---|
[884] | 240 | checkBuffers(); |
---|
[1130] | 241 | if (CServer::serverLevel == 0) |
---|
| 242 | context->server->listen(); |
---|
[1071] | 243 | |
---|
[1130] | 244 | else if (CServer::serverLevel == 1) |
---|
| 245 | { |
---|
| 246 | context->server->listen(); |
---|
| 247 | for (int i = 0; i < context->serverPrimServer.size(); ++i) |
---|
| 248 | context->serverPrimServer[i]->listen(); |
---|
[1378] | 249 | CServer::contextEventLoop(false) ; // avoid dead-lock at finalize... |
---|
[1130] | 250 | } |
---|
| 251 | |
---|
| 252 | else if (CServer::serverLevel == 2) |
---|
| 253 | context->server->listen(); |
---|
| 254 | |
---|
[300] | 255 | } |
---|
[1054] | 256 | } while (!areBuffersFree && !nonBlocking); |
---|
[1130] | 257 | |
---|
[347] | 258 | CTimer::get("Blocking time").suspend(); |
---|
| 259 | |
---|
[1054] | 260 | if (areBuffersFree) |
---|
[300] | 261 | { |
---|
[1054] | 262 | for (itBuffer = bufferList.begin(), itSize = sizeList.begin(); itBuffer != bufferList.end(); itBuffer++, itSize++) |
---|
| 263 | retBuffers.push_back((*itBuffer)->getBuffer(*itSize)); |
---|
[300] | 264 | } |
---|
[1054] | 265 | |
---|
| 266 | return areBuffersFree; |
---|
[300] | 267 | } |
---|
[509] | 268 | |
---|
[512] | 269 | /*! |
---|
| 270 | Make a new buffer for a certain connection to server with specific rank |
---|
| 271 | \param [in] rank rank of connected server |
---|
| 272 | */ |
---|
[300] | 273 | void CContextClient::newBuffer(int rank) |
---|
| 274 | { |
---|
[1201] | 275 | if (!mapBufferSize_.count(rank)) |
---|
| 276 | { |
---|
| 277 | error(0) << "WARNING: Unexpected request for buffer to communicate with server " << rank << std::endl; |
---|
| 278 | mapBufferSize_[rank] = CXios::minBufferSize; |
---|
| 279 | maxEventSizes[rank] = CXios::minBufferSize; |
---|
| 280 | } |
---|
| 281 | CClientBuffer* buffer = buffers[rank] = new CClientBuffer(interComm, rank, mapBufferSize_[rank], maxEventSizes[rank], maxBufferedEvents); |
---|
| 282 | // Notify the server |
---|
| 283 | CBufferOut* bufOut = buffer->getBuffer(sizeof(StdSize)); |
---|
| 284 | bufOut->put(mapBufferSize_[rank]); // Stupid C++ |
---|
| 285 | buffer->checkBuffer(); |
---|
[509] | 286 | } |
---|
[300] | 287 | |
---|
[512] | 288 | /*! |
---|
| 289 | Verify state of buffers. Buffer is under pending state if there is no message on it |
---|
| 290 | \return state of buffers, pending(true), ready(false) |
---|
| 291 | */ |
---|
[300] | 292 | bool CContextClient::checkBuffers(void) |
---|
| 293 | { |
---|
[595] | 294 | map<int,CClientBuffer*>::iterator itBuff; |
---|
| 295 | bool pending = false; |
---|
[1130] | 296 | for (itBuff = buffers.begin(); itBuff != buffers.end(); itBuff++) |
---|
| 297 | pending |= itBuff->second->checkBuffer(); |
---|
[595] | 298 | return pending; |
---|
[509] | 299 | } |
---|
[300] | 300 | |
---|
[512] | 301 | //! Release all buffers |
---|
[1071] | 302 | void CContextClient::releaseBuffers() |
---|
[300] | 303 | { |
---|
[595] | 304 | map<int,CClientBuffer*>::iterator itBuff; |
---|
[1077] | 305 | for (itBuff = buffers.begin(); itBuff != buffers.end(); itBuff++) |
---|
[1139] | 306 | { |
---|
[1077] | 307 | delete itBuff->second; |
---|
[1139] | 308 | } |
---|
[1077] | 309 | buffers.clear(); |
---|
[509] | 310 | } |
---|
[300] | 311 | |
---|
[512] | 312 | /*! |
---|
| 313 | Verify state of buffers corresponding to a connection |
---|
| 314 | \param [in] ranks list rank of server to which client connects to |
---|
| 315 | \return state of buffers, pending(true), ready(false) |
---|
| 316 | */ |
---|
[300] | 317 | bool CContextClient::checkBuffers(list<int>& ranks) |
---|
| 318 | { |
---|
[595] | 319 | list<int>::iterator it; |
---|
| 320 | bool pending = false; |
---|
| 321 | for (it = ranks.begin(); it != ranks.end(); it++) pending |= buffers[*it]->checkBuffer(); |
---|
| 322 | return pending; |
---|
[509] | 323 | } |
---|
[300] | 324 | |
---|
[512] | 325 | /*! |
---|
[917] | 326 | * Set the buffer size for each connection. Warning: This function is collective. |
---|
| 327 | * |
---|
| 328 | * \param [in] mapSize maps the rank of the connected servers to the size of the correspoinding buffer |
---|
| 329 | * \param [in] maxEventSize maps the rank of the connected servers to the size of the biggest event |
---|
[512] | 330 | */ |
---|
[917] | 331 | void CContextClient::setBufferSize(const std::map<int,StdSize>& mapSize, const std::map<int,StdSize>& maxEventSize) |
---|
[509] | 332 | { |
---|
| 333 | mapBufferSize_ = mapSize; |
---|
[1201] | 334 | maxEventSizes = maxEventSize; |
---|
[917] | 335 | |
---|
| 336 | // Compute the maximum number of events that can be safely buffered. |
---|
| 337 | double minBufferSizeEventSizeRatio = std::numeric_limits<double>::max(); |
---|
| 338 | for (std::map<int,StdSize>::const_iterator it = mapSize.begin(), ite = mapSize.end(); it != ite; ++it) |
---|
| 339 | { |
---|
[1474] | 340 | double ratio = double(it->second) / maxEventSizes[it->first]; |
---|
[917] | 341 | if (ratio < minBufferSizeEventSizeRatio) minBufferSizeEventSizeRatio = ratio; |
---|
| 342 | } |
---|
| 343 | MPI_Allreduce(MPI_IN_PLACE, &minBufferSizeEventSizeRatio, 1, MPI_DOUBLE, MPI_MIN, intraComm); |
---|
| 344 | |
---|
| 345 | if (minBufferSizeEventSizeRatio < 1.0) |
---|
[1201] | 346 | { |
---|
[917] | 347 | ERROR("void CContextClient::setBufferSize(const std::map<int,StdSize>& mapSize, const std::map<int,StdSize>& maxEventSize)", |
---|
| 348 | << "The buffer sizes and the maximum events sizes are incoherent."); |
---|
[1201] | 349 | } |
---|
| 350 | else if (minBufferSizeEventSizeRatio == std::numeric_limits<double>::max()) |
---|
| 351 | minBufferSizeEventSizeRatio = 1.0; // In this case, maxBufferedEvents will never be used but we want to avoid any floating point exception |
---|
[917] | 352 | |
---|
| 353 | maxBufferedEvents = size_t(2 * minBufferSizeEventSizeRatio) // there is room for two local buffers on the server |
---|
| 354 | + size_t(minBufferSizeEventSizeRatio) // one local buffer can always be fully used |
---|
| 355 | + 1; // the other local buffer might contain only one event |
---|
[509] | 356 | } |
---|
| 357 | |
---|
[1158] | 358 | /*! |
---|
| 359 | Get leading server in the group of connected server |
---|
| 360 | \return ranks of leading servers |
---|
| 361 | */ |
---|
| 362 | const std::list<int>& CContextClient::getRanksServerNotLeader(void) const |
---|
| 363 | { |
---|
| 364 | return ranksServerNotLeader; |
---|
| 365 | } |
---|
[1021] | 366 | |
---|
[1158] | 367 | /*! |
---|
| 368 | Check if client connects to leading server |
---|
| 369 | \return connected(true), not connected (false) |
---|
| 370 | */ |
---|
| 371 | bool CContextClient::isServerNotLeader(void) const |
---|
| 372 | { |
---|
| 373 | return !ranksServerNotLeader.empty(); |
---|
| 374 | } |
---|
[1021] | 375 | |
---|
[595] | 376 | /*! |
---|
| 377 | Get leading server in the group of connected server |
---|
| 378 | \return ranks of leading servers |
---|
| 379 | */ |
---|
| 380 | const std::list<int>& CContextClient::getRanksServerLeader(void) const |
---|
| 381 | { |
---|
| 382 | return ranksServerLeader; |
---|
| 383 | } |
---|
[509] | 384 | |
---|
[595] | 385 | /*! |
---|
| 386 | Check if client connects to leading server |
---|
| 387 | \return connected(true), not connected (false) |
---|
| 388 | */ |
---|
| 389 | bool CContextClient::isServerLeader(void) const |
---|
| 390 | { |
---|
| 391 | return !ranksServerLeader.empty(); |
---|
| 392 | } |
---|
[300] | 393 | |
---|
[704] | 394 | /*! |
---|
| 395 | * Check if the attached mode is used. |
---|
| 396 | * |
---|
| 397 | * \return true if and only if attached mode is used |
---|
| 398 | */ |
---|
| 399 | bool CContextClient::isAttachedModeEnabled() const |
---|
| 400 | { |
---|
| 401 | return (parentServer != 0); |
---|
| 402 | } |
---|
[697] | 403 | |
---|
[512] | 404 | /*! |
---|
[1130] | 405 | * Finalize context client and do some reports. Function is non-blocking. |
---|
[512] | 406 | */ |
---|
[1130] | 407 | void CContextClient::finalize(void) |
---|
[1054] | 408 | { |
---|
| 409 | map<int,CClientBuffer*>::iterator itBuff; |
---|
| 410 | bool stop = false; |
---|
[731] | 411 | |
---|
[1054] | 412 | CTimer::get("Blocking time").resume(); |
---|
| 413 | while (hasTemporarilyBufferedEvent()) |
---|
| 414 | { |
---|
| 415 | checkBuffers(); |
---|
| 416 | sendTemporarilyBufferedEvent(); |
---|
| 417 | } |
---|
| 418 | CTimer::get("Blocking time").suspend(); |
---|
[509] | 419 | |
---|
[1054] | 420 | CEventClient event(CContext::GetType(), CContext::EVENT_ID_CONTEXT_FINALIZE); |
---|
| 421 | if (isServerLeader()) |
---|
| 422 | { |
---|
| 423 | CMessage msg; |
---|
| 424 | const std::list<int>& ranks = getRanksServerLeader(); |
---|
| 425 | for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) |
---|
[1377] | 426 | { |
---|
| 427 | info(100)<<"DEBUG : Sent context Finalize event to rank "<<*itRank<<endl ; |
---|
[1054] | 428 | event.push(*itRank, 1, msg); |
---|
[1377] | 429 | } |
---|
[1054] | 430 | sendEvent(event); |
---|
| 431 | } |
---|
| 432 | else sendEvent(event); |
---|
[509] | 433 | |
---|
[1054] | 434 | CTimer::get("Blocking time").resume(); |
---|
[1130] | 435 | // while (!stop) |
---|
[1054] | 436 | { |
---|
| 437 | checkBuffers(); |
---|
| 438 | if (hasTemporarilyBufferedEvent()) |
---|
| 439 | sendTemporarilyBufferedEvent(); |
---|
[511] | 440 | |
---|
[1054] | 441 | stop = true; |
---|
[1130] | 442 | // for (itBuff = buffers.begin(); itBuff != buffers.end(); itBuff++) stop &= !itBuff->second->hasPendingRequest(); |
---|
[1054] | 443 | } |
---|
| 444 | CTimer::get("Blocking time").suspend(); |
---|
| 445 | |
---|
| 446 | std::map<int,StdSize>::const_iterator itbMap = mapBufferSize_.begin(), |
---|
| 447 | iteMap = mapBufferSize_.end(), itMap; |
---|
[1071] | 448 | |
---|
[1054] | 449 | StdSize totalBuf = 0; |
---|
| 450 | for (itMap = itbMap; itMap != iteMap; ++itMap) |
---|
| 451 | { |
---|
| 452 | report(10) << " Memory report : Context <" << context->getId() << "> : client side : memory used for buffer of each connection to server" << endl |
---|
| 453 | << " +) To server with rank " << itMap->first << " : " << itMap->second << " bytes " << endl; |
---|
| 454 | totalBuf += itMap->second; |
---|
| 455 | } |
---|
| 456 | report(0) << " Memory report : Context <" << context->getId() << "> : client side : total memory used for buffer " << totalBuf << " bytes" << endl; |
---|
| 457 | |
---|
[1130] | 458 | //releaseBuffers(); // moved to CContext::finalize() |
---|
[1054] | 459 | } |
---|
[1130] | 460 | |
---|
[1139] | 461 | |
---|
| 462 | /*! |
---|
| 463 | */ |
---|
[1130] | 464 | bool CContextClient::havePendingRequests(void) |
---|
| 465 | { |
---|
| 466 | bool pending = false; |
---|
| 467 | map<int,CClientBuffer*>::iterator itBuff; |
---|
| 468 | for (itBuff = buffers.begin(); itBuff != buffers.end(); itBuff++) |
---|
| 469 | pending |= itBuff->second->hasPendingRequest(); |
---|
| 470 | return pending; |
---|
| 471 | } |
---|
| 472 | |
---|
| 473 | |
---|
[509] | 474 | } |
---|