- Timestamp:
- 08/04/16 16:24:20 (8 years ago)
- Location:
- XIOS/trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/buffer_client.cpp
r732 r917 12 12 size_t CClientBuffer::maxRequestSize = 0; 13 13 14 CClientBuffer::CClientBuffer(MPI_Comm interComm_, int serverRank_, StdSize bfSize) 14 CClientBuffer::CClientBuffer(MPI_Comm interComm, int serverRank, StdSize bufferSize, StdSize maxBufferedEvents) 15 : interComm(interComm) 16 , serverRank(serverRank) 17 , bufferSize(bufferSize) 18 , current(0) 19 , count(0) 20 , bufferedEvents(0) 21 , maxBufferedEvents(maxBufferedEvents) 22 , pending(false) 15 23 { 16 interComm = interComm_;17 serverRank = serverRank_;18 bufferSize = bfSize;19 24 buffer[0] = new char[bufferSize]; // transform it with MPI_ALLOC_MEM later 20 25 buffer[1] = new char[bufferSize]; 21 current = 0;22 count = 0;23 pending = false;24 26 retBuffer = new CBufferOut(buffer[current], bufferSize); 25 info(10) << "CClientBuffer: allocated " << bufferSize << " bytes for server " << serverRank_<< endl;27 info(10) << "CClientBuffer: allocated 2 x " << bufferSize << " bytes for server " << serverRank << " with a maximum of " << maxBufferedEvents << " buffered events" << endl; 26 28 } 27 29 … … 46 48 << "The requested size (" << size << " bytes) is too big to fit the buffer (" << bufferSize << " bytes), please increase the client buffer size." << endl); 47 49 48 return (size <= remain() );50 return (size <= remain() && bufferedEvents < maxBufferedEvents); 49 51 } 50 52 … … 56 58 retBuffer->realloc(buffer[current] + count, size); 57 59 count += size; 60 bufferedEvents++; 58 61 return retBuffer; 59 62 } … … 88 91 else current = 1; 89 92 count = 0; 93 bufferedEvents = 0; 90 94 } 91 95 } -
XIOS/trunk/src/buffer_client.hpp
r732 r917 14 14 static size_t maxRequestSize; 15 15 16 CClientBuffer(MPI_Comm intercomm, int serverRank, StdSize bfSize = 0);16 CClientBuffer(MPI_Comm intercomm, int serverRank, StdSize bufferSize, StdSize maxBufferedEvents); 17 17 ~CClientBuffer(); 18 18 … … 28 28 int current; 29 29 int count; 30 int bufferSize; 31 int serverRank; 30 int bufferedEvents; 31 const int maxBufferedEvents; 32 const int bufferSize; 33 const int serverRank; 32 34 bool pending; 33 35 … … 35 37 36 38 CBufferOut* retBuffer; 37 MPI_Comm interComm;39 const MPI_Comm interComm; 38 40 }; 39 41 } 40 41 42 #endif -
XIOS/trunk/src/context_client.cpp
r884 r917 21 21 */ 22 22 CContextClient::CContextClient(CContext* parent, MPI_Comm intraComm_, MPI_Comm interComm_, CContext* cxtSer) 23 : mapBufferSize_(), parentServer(cxtSer) 23 : mapBufferSize_(), parentServer(cxtSer), maxBufferedEvents(4) 24 24 { 25 25 context = parent; … … 70 70 71 71 timeLine = 0; 72 73 72 } 74 73 … … 179 178 mapBufferSize_[rank] = CXios::minBufferSize; 180 179 } 181 CClientBuffer* buffer = buffers[rank] = new CClientBuffer(interComm, rank, mapBufferSize_[rank] );180 CClientBuffer* buffer = buffers[rank] = new CClientBuffer(interComm, rank, mapBufferSize_[rank], maxBufferedEvents); 182 181 // Notify the server 183 182 CBufferOut* bufOut = buffer->getBuffer(sizeof(StdSize)); … … 219 218 220 219 /*! 221 Set buffer size for each connection 222 \param [in] mapSize mapping rank of connected server to size of allocated buffer 223 */ 224 void CContextClient::setBufferSize(const std::map<int,StdSize>& mapSize) 220 * Set the buffer size for each connection. Warning: This function is collective. 221 * 222 * \param [in] mapSize maps the rank of the connected servers to the size of the correspoinding buffer 223 * \param [in] maxEventSize maps the rank of the connected servers to the size of the biggest event 224 */ 225 void CContextClient::setBufferSize(const std::map<int,StdSize>& mapSize, const std::map<int,StdSize>& maxEventSize) 225 226 { 226 227 mapBufferSize_ = mapSize; 228 229 // Compute the maximum number of events that can be safely buffered. 230 double minBufferSizeEventSizeRatio = std::numeric_limits<double>::max(); 231 for (std::map<int,StdSize>::const_iterator it = mapSize.begin(), ite = mapSize.end(); it != ite; ++it) 232 { 233 double ratio = double(it->second) / maxEventSize.at(it->first); 234 if (ratio < minBufferSizeEventSizeRatio) minBufferSizeEventSizeRatio = ratio; 235 } 236 MPI_Allreduce(MPI_IN_PLACE, &minBufferSizeEventSizeRatio, 1, MPI_DOUBLE, MPI_MIN, intraComm); 237 238 if (minBufferSizeEventSizeRatio < 1.0) 239 ERROR("void CContextClient::setBufferSize(const std::map<int,StdSize>& mapSize, const std::map<int,StdSize>& maxEventSize)", 240 << "The buffer sizes and the maximum events sizes are incoherent."); 241 242 maxBufferedEvents = size_t(2 * minBufferSizeEventSizeRatio) // there is room for two local buffers on the server 243 + size_t(minBufferSizeEventSizeRatio) // one local buffer can always be fully used 244 + 1; // the other local buffer might contain only one event 227 245 } 228 246 -
XIOS/trunk/src/context_client.hpp
r726 r917 49 49 void finalize(void); 50 50 51 void setBufferSize(const std::map<int,StdSize>& mapSize );51 void setBufferSize(const std::map<int,StdSize>& mapSize, const std::map<int,StdSize>& maxEventSize); 52 52 53 53 public: … … 71 71 //! Mapping of server and buffer size for each connection to server 72 72 std::map<int,StdSize> mapBufferSize_; 73 //! Maximum number of events that can be buffered 74 StdSize maxBufferedEvents; 73 75 74 76 //! Context for server (Only used in attached mode) -
XIOS/trunk/src/node/context.cpp
r909 r917 274 274 #undef DECLARE_NODE_PAR 275 275 276 std::map<int, StdSize> bufferSize = getAttributesBufferSize(); 277 std::map<int, StdSize> dataBufferSize = getDataBufferSize(); 276 std::map<int, StdSize> maxEventSize; 277 std::map<int, StdSize> bufferSize = getAttributesBufferSize(maxEventSize); 278 std::map<int, StdSize> dataBufferSize = getDataBufferSize(maxEventSize); 278 279 279 280 std::map<int, StdSize>::iterator it, ite = dataBufferSize.end(); … … 288 289 } 289 290 291 // We consider that the minimum buffer size is also the minimum event size 292 ite = maxEventSize.end(); 293 for (it = maxEventSize.begin(); it != ite; ++it) 294 if (it->second < minBufferSize) it->second = minBufferSize; 295 290 296 if (client->isServerLeader()) 291 297 { 292 298 const std::list<int>& ranks = client->getRanksServerLeader(); 293 299 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 294 if (!bufferSize.count(*itRank)) bufferSize[*itRank] = minBufferSize; 295 } 296 297 if (!bufferSize.empty()) 298 client->setBufferSize(bufferSize); 300 if (!bufferSize.count(*itRank)) bufferSize[*itRank] = maxEventSize[*itRank] = minBufferSize; 301 } 302 303 client->setBufferSize(bufferSize, maxEventSize); 299 304 } 300 305 … … 837 842 } 838 843 839 std::map<int, StdSize> CContext::getAttributesBufferSize() 844 /*! 845 * Compute the required buffer size to send the attributes (mostly those grid related). 846 * 847 * \param maxEventSize [in/out] the size of the bigger event for each connected server 848 */ 849 std::map<int, StdSize> CContext::getAttributesBufferSize(std::map<int, StdSize>& maxEventSize) 840 850 { 841 851 std::map<int, StdSize> attributesSize; … … 860 870 if (attributesSize[it->first] < it->second) 861 871 attributesSize[it->first] = it->second; 872 873 if (maxEventSize[it->first] < it->second) 874 maxEventSize[it->first] = it->second; 862 875 } 863 876 } … … 868 881 } 869 882 870 std::map<int, StdSize> CContext::getDataBufferSize() 883 /*! 884 * Compute the required buffer size to send the fields data. 885 * 886 * \param maxEventSize [in/out] the size of the bigger event for each connected server 887 */ 888 std::map<int, StdSize> CContext::getDataBufferSize(std::map<int, StdSize>& maxEventSize) 871 889 { 872 890 CFile::mode_attr::t_enum mode = hasClient ? CFile::mode_attr::write : CFile::mode_attr::read; … … 897 915 else if (dataSize[it->first] < it->second) 898 916 dataSize[it->first] = it->second; 917 918 if (maxEventSize[it->first] < it->second) 919 maxEventSize[it->first] = it->second; 899 920 } 900 921 } -
XIOS/trunk/src/node/context.hpp
r823 r917 123 123 void postProcessing(); 124 124 125 std::map<int, StdSize> getAttributesBufferSize( );126 std::map<int, StdSize> getDataBufferSize( );125 std::map<int, StdSize> getAttributesBufferSize(std::map<int, StdSize>& maxEventSize); 126 std::map<int, StdSize> getDataBufferSize(std::map<int, StdSize>& maxEventSize); 127 127 void setClientServerBuffer(); 128 128
Note: See TracChangeset
for help on using the changeset viewer.