DFT-EFE
 
Loading...
Searching...
No Matches
MPIPatternP2P.h
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (c) 2021. *
3 * The Regents of the University of Michigan and DFT-EFE developers. *
4 * *
5 * This file is part of the DFT-EFE code. *
6 * *
7 * DFT-EFE is free software: you can redistribute it and/or modify *
8 * it under the terms of the Lesser GNU General Public License as *
9 * published by the Free Software Foundation, either version 3 of *
10 * the License, or (at your option) any later version. *
11 * *
12 * DFT-EFE is distributed in the hope that it will be useful, but *
13 * WITHOUT ANY WARRANTY; without even the implied warranty *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
15 * See the Lesser GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License at the top level of DFT-EFE distribution. If not, see *
19 * <https://www.gnu.org/licenses/>. *
20 ******************************************************************************/
21
22/*
23 * @author Sambit Das, Bikash Kanungo
24 */
25
26#ifndef dftefeMPIPatternP2P_h
27#define dftefeMPIPatternP2P_h
28
30#include <utils/MemoryStorage.h>
31#include <utils/MPITypes.h>
33#include <vector>
34namespace dftefe
35{
36 namespace utils
37 {
38 namespace mpi
39 {
195 template <dftefe::utils::MemorySpace memorySpace>
197 {
201 public:
205
206 public:
207 virtual ~MPIPatternP2P() = default;
208
245 const std::vector<std::pair<global_size_type, global_size_type>>
246 & locallyOwnedRanges,
247 const std::vector<dftefe::global_size_type> &ghostIndices,
248 const MPIComm & mpiComm);
249
282 MPIPatternP2P(const std::pair<global_size_type, global_size_type>
283 &locallyOwnedRange,
284 const std::vector<dftefe::global_size_type> &ghostIndices,
285 const MPIComm & mpiComm);
286
311 MPIPatternP2P(const std::vector<size_type> &sizes);
312
333 MPIPatternP2P(const size_type &size);
334
335 void
336 reinit(const std::vector<std::pair<global_size_type, global_size_type>>
337 & locallyOwnedRanges,
338 const std::vector<dftefe::global_size_type> &ghostIndices,
339 const MPIComm & mpiComm);
340
341 void
342 reinit(const std::vector<size_type> &sizes);
343
345 nGlobalRanges() const;
346
347 std::vector<std::pair<global_size_type, global_size_type>>
348 getGlobalRanges() const;
349
350 std::vector<std::pair<global_size_type, global_size_type>>
351 getLocallyOwnedRanges() const;
352
353 std::pair<global_size_type, global_size_type>
355
358
360 localOwnedSize() const;
361
363 localGhostSize() const;
364
376 std::pair<bool, size_type>
377 inLocallyOwnedRanges(const global_size_type globalId) const;
378
391 std::pair<bool, size_type>
392 isGhostEntry(const global_size_type globalId) const;
393
395 globalToLocal(const global_size_type globalId) const;
396
398 localToGlobal(const size_type localId) const;
399
408 std::pair<size_type, size_type>
409 globalToLocalAndRangeId(const global_size_type globalId) const;
410
419 std::pair<global_size_type, size_type>
420 localToGlobalAndRangeId(const size_type localId) const;
421
422 const std::vector<global_size_type> &
423 getGhostIndices() const;
424
425 const std::vector<size_type> &
426 getGhostProcIds() const;
427
428 const std::vector<size_type> &
430
432 getNumGhostIndicesInGhostProc(const size_type procId) const;
433
434 const SizeTypeVector &
436
439
440 const std::vector<size_type> &
442
443 const std::vector<size_type> &
444 getTargetProcIds() const;
445
446 const std::vector<size_type> &
448
450 getNumOwnedIndicesForTargetProc(const size_type procId) const;
451
454
455 const SizeTypeVector &
457
460
462 nmpiProcesses() const;
463
465 thisProcessId() const;
466
468 nGlobalIndices() const;
469
470 const MPIComm &
471 mpiCommunicator() const;
472
473 bool
475
476 private:
487 std::vector<std::pair<global_size_type, global_size_type>>
489
496
497
504 std::vector<std::pair<global_size_type, global_size_type>>
506
514 std::vector<size_type> d_locallyOwnedRangesIdPermutation;
515
529 std::vector<std::vector<std::pair<global_size_type, global_size_type>>>
531
539 std::vector<std::pair<global_size_type, global_size_type>>
541
547
561 std::vector<std::pair<size_type, size_type>>
563
568 std::vector<global_size_type> d_ghostIndices;
569
575
576
584
590 std::vector<size_type> d_ghostIndicesRangeId;
591
598
603 std::vector<size_type> d_ghostProcIds;
604
610 std::vector<size_type> d_numGhostIndicesInGhostProcs;
611
636
653 std::vector<size_type> d_localGhostIndicesRanges;
654
671 std::vector<std::vector<size_type>>
673
680
686 std::vector<size_type> d_targetProcIds;
687
694 std::vector<size_type> d_numOwnedIndicesForTargetProcs;
695
708
711
714
719
722 };
723
724 } // end of namespace mpi
725 } // end of namespace utils
726} // end of namespace dftefe
727
729#endif // dftefeMPIPatternP2P_h
size_type rangeId
Definition: MPIPatternP2P.t.cpp:594
Definition: OptimizedIndexSet.h:48
A class template to store the communication pattern (i.e., which entries/nodes to receive from which ...
Definition: MPIPatternP2P.h:197
const SizeTypeVector & getOwnedLocalIndicesForTargetProcs() const
Definition: MPIPatternP2P.t.cpp:1796
SizeTypeVector getGhostLocalIndicesForGhostProc(const size_type procId) const
Definition: MPIPatternP2P.t.cpp:1711
void reinit(const std::vector< std::pair< global_size_type, global_size_type > > &locallyOwnedRanges, const std::vector< dftefe::global_size_type > &ghostIndices, const MPIComm &mpiComm)
Definition: MPIPatternP2P.t.cpp:1422
const std::vector< size_type > & getNumGhostIndicesInGhostProcs() const
Definition: MPIPatternP2P.t.cpp:1668
size_type localOwnedSize() const
Definition: MPIPatternP2P.t.cpp:1875
size_type getNumOwnedIndicesForTargetProc(const size_type procId) const
Definition: MPIPatternP2P.t.cpp:1767
std::vector< std::vector< std::pair< global_size_type, global_size_type > > > d_allOwnedRanges
Definition: MPIPatternP2P.h:530
std::vector< std::pair< global_size_type, global_size_type > > d_locallyOwnedRanges
Definition: MPIPatternP2P.h:488
const std::vector< global_size_type > & getGhostIndices() const
Definition: MPIPatternP2P.t.cpp:1654
size_type nmpiProcesses() const
Definition: MPIPatternP2P.t.cpp:1854
std::vector< std::vector< size_type > > d_ghostProcLocallyOwnedRangesCumulative
Definition: MPIPatternP2P.h:672
std::pair< global_size_type, global_size_type > getLocallyOwnedRange(size_type rangeId) const
Definition: MPIPatternP2P.t.cpp:1647
std::vector< size_type > d_targetProcIds
Definition: MPIPatternP2P.h:686
global_size_type nGlobalIndices() const
Definition: MPIPatternP2P.t.cpp:1868
size_type nGlobalRanges() const
Definition: MPIPatternP2P.t.cpp:1626
const std::vector< size_type > & getGhostProcIds() const
Definition: MPIPatternP2P.t.cpp:1661
std::vector< size_type > d_ghostIndicesRangeId
Definition: MPIPatternP2P.h:590
const SizeTypeVector & getGhostLocalIndicesForGhostProcs() const
Definition: MPIPatternP2P.t.cpp:1703
const std::vector< size_type > & getTargetProcIds() const
Definition: MPIPatternP2P.t.cpp:1753
MPIComm d_mpiComm
MPI Communicator object.
Definition: MPIPatternP2P.h:721
size_type globalToLocal(const global_size_type globalId) const
Definition: MPIPatternP2P.t.cpp:1996
std::vector< size_type > d_numGhostIndicesInGhostProcs
Definition: MPIPatternP2P.h:610
size_type localGhostSize() const
Definition: MPIPatternP2P.t.cpp:1890
const MPIComm & mpiCommunicator() const
Definition: MPIPatternP2P.t.cpp:1847
OptimizedIndexSet< global_size_type > d_ghostIndicesOptimizedIndexSet
Definition: MPIPatternP2P.h:583
const std::vector< size_type > & getNumOwnedIndicesForTargetProcs() const
Definition: MPIPatternP2P.t.cpp:1760
std::pair< global_size_type, size_type > localToGlobalAndRangeId(const size_type localId) const
For a given local index, returns a pair containing its global index and the index of the global-range...
Definition: MPIPatternP2P.t.cpp:1945
std::vector< size_type > d_numOwnedIndicesForTargetProcs
Definition: MPIPatternP2P.h:694
size_type thisProcessId() const
Definition: MPIPatternP2P.t.cpp:1861
int d_myRank
Rank of the current processor.
Definition: MPIPatternP2P.h:713
std::pair< size_type, size_type > globalToLocalAndRangeId(const global_size_type globalId) const
For a given global index, returns a pair containing the local index in the procesor and the index of ...
Definition: MPIPatternP2P.t.cpp:2038
size_type getTotalOwnedIndicesForTargetProcs() const
Definition: MPIPatternP2P.t.cpp:1840
size_type d_numLocallyOwnedIndices
Definition: MPIPatternP2P.h:546
size_type d_numGhostIndices
Definition: MPIPatternP2P.h:574
std::vector< std::pair< size_type, size_type > > d_locallyOwnedRangesCumulativePairs
Definition: MPIPatternP2P.h:562
std::vector< size_type > d_locallyOwnedRangesIdPermutation
Definition: MPIPatternP2P.h:514
SizeTypeVector getOwnedLocalIndicesForTargetProc(const size_type procId) const
Definition: MPIPatternP2P.t.cpp:1803
std::vector< global_size_type > d_ghostIndices
Definition: MPIPatternP2P.h:568
size_type getNumGhostIndicesInGhostProc(const size_type procId) const
Definition: MPIPatternP2P.t.cpp:1675
size_type d_nGlobalRanges
Definition: MPIPatternP2P.h:495
bool isCompatible(const MPIPatternP2P< memorySpace > &rhs) const
Definition: MPIPatternP2P.t.cpp:2120
std::vector< size_type > d_localGhostIndicesRanges
Definition: MPIPatternP2P.h:653
size_type d_numTargetProcs
Definition: MPIPatternP2P.h:679
SizeTypeVector d_flattenedLocalGhostIndices
Definition: MPIPatternP2P.h:635
std::vector< size_type > d_ghostProcIds
Definition: MPIPatternP2P.h:603
std::pair< bool, size_type > inLocallyOwnedRanges(const global_size_type globalId) const
For a given globalId, returns whether it lies in any of the locally-owned-ranges and if true the inde...
Definition: MPIPatternP2P.t.cpp:2085
SizeTypeVector d_flattenedLocalTargetIndices
Definition: MPIPatternP2P.h:707
const std::vector< size_type > & getGhostLocalIndicesRanges() const
Definition: MPIPatternP2P.t.cpp:1746
std::pair< bool, size_type > isGhostEntry(const global_size_type globalId) const
For a given globalId, returns whether it belongs to the current processor's ghost-set and if true the...
Definition: MPIPatternP2P.t.cpp:2104
global_size_type d_nGlobalIndices
Definition: MPIPatternP2P.h:718
std::vector< std::pair< global_size_type, global_size_type > > d_globalRanges
Definition: MPIPatternP2P.h:540
int d_nprocs
Number of processors in the MPI Communicator.
Definition: MPIPatternP2P.h:710
size_type d_numGhostProcs
Definition: MPIPatternP2P.h:597
global_size_type localToGlobal(const size_type localId) const
Definition: MPIPatternP2P.t.cpp:1898
std::vector< std::pair< global_size_type, global_size_type > > d_locallyOwnedRangesSorted
Definition: MPIPatternP2P.h:505
std::vector< std::pair< global_size_type, global_size_type > > getLocallyOwnedRanges() const
Definition: MPIPatternP2P.t.cpp:1640
std::vector< std::pair< global_size_type, global_size_type > > getGlobalRanges() const
Definition: MPIPatternP2P.t.cpp:1633
int MPIComm
Definition: MPITypes.h:83
dealii includes
Definition: AtomFieldDataSpherical.cpp:31
unsigned int size_type
Definition: TypeConfig.h:8
unsigned long int global_size_type
Definition: TypeConfig.h:9