Changeset 595 for XIOS/trunk/src/node/axis.cpp
- Timestamp:
- 05/26/15 16:13:46 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/axis.cpp
r594 r595 119 119 StdSize zoom_begin,zoom_end, zoom_size, axisSize; 120 120 121 zoom_begin = (this->zoom_begin.isEmpty()) ? 0 : this->zoom_begin.getValue();122 zoom_size = (this->zoom_size.isEmpty()) ? size.getValue() : this->zoom_size.getValue();123 zoom_end = (this->zoom_end.isEmpty()) ? (size.getValue() - 1) : this->zoom_end.getValue();124 125 if (this->zoom_begin.isEmpty()) zoom_begin =zoom_end-zoom_size+1;126 if (this->zoom_end.isEmpty()) zoom_end =zoom_begin+zoom_size-1;127 if (this->zoom_size.isEmpty()) zoom_size =zoom_end-zoom_begin+1;121 zoom_begin = this->zoom_begin.isEmpty() ? 0 : this->zoom_begin.getValue(); 122 zoom_size = this->zoom_size.isEmpty() ? size.getValue() : this->zoom_size.getValue(); 123 zoom_end = this->zoom_end.isEmpty() ? (size.getValue() - 1) : this->zoom_end.getValue(); 124 125 if (this->zoom_begin.isEmpty()) zoom_begin = zoom_end - zoom_size + 1; 126 if (this->zoom_end.isEmpty()) zoom_end = zoom_begin + zoom_size - 1; 127 if (this->zoom_size.isEmpty()) zoom_size = zoom_end - zoom_begin + 1; 128 128 axisSize = size.getValue(); 129 129 … … 132 132 << "One or more attributes among <zoom_begin>, <zoom_end>, <zoom_size> of axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] are not well specified"); 133 133 134 this->zoom_begin.setValue(zoom_begin) 135 this->zoom_end.setValue(zoom_end) 136 this->zoom_size.setValue(zoom_size) 134 this->zoom_begin.setValue(zoom_begin); 135 this->zoom_end.setValue(zoom_end); 136 this->zoom_size.setValue(zoom_size); 137 137 } 138 138 … … 158 158 if (mask.extent(0) != ni) 159 159 ERROR("CAxis::checkMask(void)", 160 << "the mask has not the same size than the local axis"<<endl161 << "Local size is "<<ni<<"x"<<endl162 << "Mask size is "<<mask.extent(0)<<"x");160 << "the mask has not the same size than the local axis" << endl 161 << "Local size is " << ni << "x" << endl 162 << "Mask size is " << mask.extent(0) << "x"); 163 163 for (int i = 0; i < ni; ++i) 164 164 { … … 181 181 bool CAxis::dispatchEvent(CEventServer& event) 182 182 { 183 if (SuperClass::dispatchEvent(event)) return true 183 if (SuperClass::dispatchEvent(event)) return true; 184 184 else 185 185 { … … 187 187 { 188 188 case EVENT_ID_SERVER_ATTRIBUT : 189 recvServerAttribut(event) 190 return true 191 break 189 recvServerAttribut(event); 190 return true; 191 break; 192 192 default : 193 193 ERROR("bool CContext::dispatchEvent(CEventServer& event)", 194 << "Unknown Event");195 return false 194 << "Unknown Event"); 195 return false; 196 196 } 197 197 } … … 202 202 { 203 203 if (this->areClientAttributesChecked_) return; 204 204 205 this->checkAttributes(); 205 206 206 CContext* context=CContext::getCurrent() ;207 if (context->hasClient)208 {209 computeServerIndex(globalDim, orderPositionInGrid, distType);210 }211 212 207 this->areClientAttributesChecked_ = true; 213 }214 215 void CAxis::computeServerIndex(const std::vector<int>& globalDim, int orderPositionInGrid,216 CServerDistributionDescription::ServerDistributionType distType)217 {218 CServerDistributionDescription serverDescription(globalDim);219 220 CContext* context=CContext::getCurrent() ;221 CContextClient* client=context->client ;222 int nbServer=client->serverSize ;223 int serverRank=client->getServerLeader() ;224 225 serverDescription.computeServerDistribution(nbServer, false, distType);226 std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin();227 std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes();228 begin_srv = (serverIndexBegin[serverRank])[orderPositionInGrid];229 ni_srv = serverDimensionSizes[serverRank][orderPositionInGrid];230 end_srv = begin_srv+ni_srv-1;231 208 } 232 209 … … 238 215 orderPositionInGrid, 239 216 distType); 240 CContext* context =CContext::getCurrent();217 CContext* context = CContext::getCurrent(); 241 218 242 219 if (this->isChecked) return; 243 220 if (context->hasClient) 244 221 { 245 sendServerAttribut( );222 sendServerAttribut(globalDim, orderPositionInGrid, distType); 246 223 } 247 224 … … 249 226 } 250 227 251 void CAxis::sendServerAttribut(void) 228 void CAxis::sendServerAttribut(const std::vector<int>& globalDim, int orderPositionInGrid, 229 CServerDistributionDescription::ServerDistributionType distType) 252 230 { 253 CContext* context=CContext::getCurrent(); 254 CContextClient* client=context->client; 255 256 CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT) ; 231 CContext* context = CContext::getCurrent(); 232 CContextClient* client = context->client; 233 234 CServerDistributionDescription serverDescription(globalDim); 235 236 int nbServer = client->serverSize; 237 238 serverDescription.computeServerDistribution(nbServer, false, distType); 239 std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); 240 std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); 241 242 CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT); 257 243 if (client->isServerLeader()) 258 244 { 259 CMessage msg ; 260 msg<<this->getId() ; 261 msg<<ni_srv<<begin_srv<<end_srv; 262 event.push(client->getServerLeader(),1,msg) ; 263 client->sendEvent(event) ; 245 std::list<CMessage> msgs; 246 247 const std::list<int>& ranks = client->getRanksServerLeader(); 248 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 249 { 250 // Use const int to ensure CMessage holds a copy of the value instead of just a reference 251 const int begin = serverIndexBegin[*itRank][orderPositionInGrid]; 252 const int ni = serverDimensionSizes[*itRank][orderPositionInGrid]; 253 const int end = begin + ni - 1; 254 255 msgs.push_back(CMessage()); 256 CMessage& msg = msgs.back(); 257 msg << this->getId(); 258 msg << ni << begin << end; 259 260 event.push(*itRank,1,msg); 261 } 262 client->sendEvent(event); 264 263 } 265 else client->sendEvent(event) 264 else client->sendEvent(event); 266 265 } 267 266 268 267 void CAxis::recvServerAttribut(CEventServer& event) 269 268 { 270 CBufferIn* buffer =event.subEvents.begin()->buffer;271 string axisId 272 *buffer >>axisId;273 get(axisId)->recvServerAttribut(*buffer) 269 CBufferIn* buffer = event.subEvents.begin()->buffer; 270 string axisId; 271 *buffer >> axisId; 272 get(axisId)->recvServerAttribut(*buffer); 274 273 } 275 274 … … 281 280 buffer>>ni_srv>>begin_srv>>end_srv; 282 281 283 zoom_begin_srv = zoom_begin.getValue() > begin_srv ? zoom_begin.getValue() : begin_srv 284 zoom_end_srv = zoom_end < end_srv ? zoom_end : end_srv 285 zoom_size_srv = zoom_end_srv -zoom_begin_srv+1;282 zoom_begin_srv = zoom_begin.getValue() > begin_srv ? zoom_begin.getValue() : begin_srv; 283 zoom_end_srv = zoom_end < end_srv ? zoom_end : end_srv; 284 zoom_size_srv = zoom_end_srv - zoom_begin_srv + 1; 286 285 287 286 if (zoom_size_srv<=0) 288 287 { 289 zoom_begin_srv =0 ; zoom_end_srv=0 ; zoom_size_srv=0;288 zoom_begin_srv = 0; zoom_end_srv = 0; zoom_size_srv = 0; 290 289 } 291 290 … … 294 293 zoom_begin_srv = zoom_begin.getValue(); 295 294 zoom_end_srv = zoom_end; 296 zoom_size_srv = zoom_end_srv -zoom_begin_srv+1;295 zoom_size_srv = zoom_end_srv - zoom_begin_srv + 1; 297 296 } 298 297 }
Note: See TracChangeset
for help on using the changeset viewer.