Commit Graph

12 Commits

Author SHA1 Message Date
Mark Olesen
eb4345ed44 ENH: misc Pstream adjustments
- additional startup guard for inter-node/local-node queries (UPstream)

- impose linear communication tree for inter-node/local-node
  communicators. Was previously defaulted to a basic tree, but more
  consistent to have flat addressing for these types of connections.

- demand-driven UPstream::interNode_offsets() for walking
  inter-node ranges instead of creating it manually in various places.

- (style): List<int> instead of labelList for internal commsStruct
  since the communication structures are tied to MPI sizes
  and not to the OpenFOAM label sizes

- reduce the number of intermediate buffer allocations within
  gatherList, scatterList.
2025-02-17 13:40:44 +01:00
Mark Olesen
0ba4f36c60 ENH: use List containers for Pstream read/write calls
- using the List containers, and not their low-level data_bytes(),
  size_bytes() methods is more convenient and allows future
  adjustments to be centralized

ENH: trivial intptr_t wrapper for MPI_Win

STYLE: minor adjustments to mpirunDebug
2025-02-11 11:09:30 +01:00
Mark Olesen
cf2b305b4f ENH: upgrade to use some C++17 constructs
- 'if constexpr (...)'
   * instead of std::enable_if
   * terminate template recursion
   * compile-time elimination of code

- use C++14 '_t', '_v' versions,
  eg, std::is_integral_v<T> instead of std::is_integral<T>::value

- std::begin, std::end, std::void_t instead of prev stdFoam versions

- provide is_contiguous_v<..> as short form of is_contiguous<..>::value
  with the additional benefit of removing any cv qualifiers.

ENH: include is_rotational_vectorspace trait

- tests for vector-space and nComponents > 1 (ie, not sphericalTensor)

ENH: improve robustness of pTraits_.. tests by removing cv qualifiers
2025-01-31 09:51:44 +01:00
Mark Olesen
e15d696a24 STYLE: use Perr instead of Pout for UPstream::debug and warnComm
- avoids polluting standard output for utilities such as
  foamDictionary etc
2024-05-07 14:45:10 +02:00
Mark Olesen
04d880e2ce STYLE: use send/recv serializers for globalIndex and mapDistribute etc 2024-02-24 19:51:24 +01:00
Mark Olesen
47c44a5783 ENH: use UList instead of List for some Pstream gather/scatter
- can use UList signature since the routines do not resize the list
  or attempt to broadcast it: useful for SubList handling.

ENH: add IPstream/OPstream send/recv static methods
2024-02-07 10:02:28 +01:00
Mark Olesen
9ad3754ed7 ENH: remove obsolete Pstream functions (#3087)
- the old Pstream::scatter routines (which were largely a misnomer)
  have been superseded by various broadcast routines, but were left in
  the code with #ifndef/#ifdef Foam_Pstream_scatter_nobroadcast
  guards. Now noisily deprecate them, and remove the old manual tree
  communication in favour of MPI broadcast and/or
  serialize/de-serialize with wrapped Pstream::broadcast

- consolidate various gather methods to include the communication
  structure directly. No functional change, but reduces the number of
  methods.

ENH: add parallel guard to UPstream::whichCommunication() method

- returns List::null() as the schedule for non-parallel instead
  of an inappropriate linear or tree schedule

ENH: Pstream::listGatherValues, Pstream::listScatterValues

- like the existing UPstream versions but supporting non-contiguous
2024-02-01 13:52:39 +00:00
Mark Olesen
b277b913cf ENH: add guards for partially populated communicators
- these are primarily when encountering sparse (eg, inter-host)
  communicators. Additional UPstream convenience methods:

  is_rank(comm)
    => True if process corresponds to a rank in the communicators.
       Can be a master rank or a sub-rank.

  is_parallel(comm)
    => True if parallel algorithm or exchange is used on the process.
       same as

           (parRun() && (nProcs(comm) > 1) && is_rank(comm))
2023-04-18 14:08:39 +02:00
Mark Olesen
df61104ef5 ENH: add Pstream non-blocking consensus exchange infrastructure
- can be beneficial with increasing number of ranks
2023-02-07 23:02:02 +01:00
Mark Olesen
cbace69896 ENH: more consistent naming of MPI reductions
- combineReduce     (older: combineAllGather)
- listCombineReduce (older: listCombineAllGather)
- mapCombineReduce  (older: mapCombineAllGather)
2022-09-23 19:19:03 +02:00
Mark Olesen
d38de84d21 ENH: bundle Pstream:: AllGather methods
- bundles frequently used 'gather/scatter' patterns more consistently.

  - combineAllGather     -> combineGather + broadcast
  - listCombineAllGather -> listCombineGather + broadcast
  - mapCombineAllGather  -> mapCombineGather + broadcast
  - allGatherList        -> gatherList + scatterList
  - reduce               -> gather + broadcast (ie, allreduce)

- The allGatherList currently wraps gatherList/scatterList, but may be
  replaced with a different algorithm in the future.

STYLE: PstreamCombineReduceOps.H is mostly unneeded now
2022-03-31 15:56:04 +02:00
Mark Olesen
c086f22298 ENH: extend/improve broadcast handling
- split off a Pstream::genericBroadcast() which uses UOPBstream during
  serialization and UOPBstream during de-serialization.
  This function will not normally be used directly by callers, but
  provides a base layer for higher-level broadcast calls.

- low-level UPstream broadcast of string content.
  Since std::string has length and contiguous content, it is possible
  to handle directly by the following:
     1. broadcast size
     2. resize
     3. broadcast content when size != 0

  Although this is a similar amount of communication as the generic
  streaming version (min 1, max 2 broadcasts) it is more efficient
  by avoiding serialization/de-serialization overhead.

- handle broadcast of List content distinctly.
  Allows an optimized path for contiguous data, similar to how
  std::string is handled (broadcast size, resize container, broadcast
  content when size != 0), but can revert to genericBroadcast (streamed)
  for non-contiguous data.

- make various scatter variants simple aliases for broadcast, since
  that is what they are doing behind the scenes anyhow:

    * scatter()
    * combineScatter()
    * listCombineScatter()
    * mapCombineScatter()

  Except scatterList() which remains somewhat different.
  Beyond the additional (size == nProcs) check, the only difference to
  using broadcast(List<T>&) or a regular scatter(List<T>&) is that
  processor-local data is skipped. So leave this variant as-is.

STYLE: rename/prefix implementation code with 'Pstream'

- better association with its purpose and provides a unique name
2022-03-04 17:49:23 +00:00