MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / MultAdd

Method MultAdd

parallel/parallel_matrices.cpp:278–357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

276
277 template <typename TM>
278 void MasterInverse<TM> :: MultAdd (double s, const BaseVector & x, BaseVector & y) const
279 {
280 typedef typename mat_traits<TM>::TV_ROW TV;
281
282 NgMPI_Comm comm = paralleldofs->GetCommunicator();
283 int id = comm.Rank();
284 int ntasks = comm.Size();
285
286 bool is_x_cum = (dynamic_cast_ParallelBaseVector(x) . Status() == CUMULATED);
287 // x.Distribute();
288 y.Cumulate();
289
290 if (id > 0)
291 {
292 FlatVector<TV> fx = x.FV<TV> ();
293 FlatVector<TV> fy = y.FV<TV> ();
294
295 Array<TV> lx (select.Size());
296 for (int i = 0; i < select.Size(); i++)
297 lx[i] = fx(select[i]);
298
299 NgMPI_Request(comm.ISend (lx, 0, NG_MPI_TAG_SOLVE)).Wait();
300
301 // only for MUMPS:
302 if (inv)
303 y = (*inv) * x;
304
305 NgMPI_Request(comm.IRecv (lx, 0, NG_MPI_TAG_SOLVE)).Wait();
306
307 for (int i = 0; i < select.Size(); i++)
308 fy(select[i]) += s * lx[i];
309 }
310
311 else
312 {
313 VVector<TV> hx(inv->Height());
314 VVector<TV> hy(inv->Height());
315 hx = 0.0;
316
317 Array<int> sizes(ntasks);
318 for (int i = 0; i < ntasks; i++)
319 sizes[i] = loc2glob[i].Size();
320
321 Table<TV> exdata(sizes);
322
323
324 for (int src = 1; src < ntasks; src++)
325 {
326 FlatArray<int> selecti = loc2glob[src];
327
328 Array<TV> lx(selecti.Size());
329 comm.Recv (lx, src, NG_MPI_TAG_SOLVE);
330
331 if(is_x_cum) {
332 for (int i = 0; i < selecti.Size(); i++)
333 hx(selecti[i]) = lx[i];
334 }
335 else {

Callers

nothing calls this directly

Calls 13

RowTypeFunction · 0.85
ColTypeFunction · 0.85
CumulateMethod · 0.80
DistributeMethod · 0.80
GetParallelStatusMethod · 0.80
FVDoubleMethod · 0.80
GetDistantProcsMethod · 0.80
GetExchangeDofsMethod · 0.80
GetCommunicatorMethod · 0.45
SizeMethod · 0.45
HeightMethod · 0.45

Tested by

no test coverage detected