Commit Graph

27396 Commits

Author SHA1 Message Date
Mark Olesen
ae638c2b9c CONFIG: improvements to mpirunDebug
- the '-no-core' to limit coredumps to zero size
- the '-quick' option, which changes valgrind --leak-check from "full"
  to "summary", and implies -no-core as well.
- enforce tcp libfabrics provider under valgrind since valgrind
  does not otherwie work nicely with RMA
2025-03-10 16:29:47 +01:00
Mark Olesen
9cd0aa8816 COMP: avoid in-place reduce for OPEN-MPI as well (#3331)
- fails with MPI_ARG_ERR.
  Do not assume that any vendors actually support in-place handling
  for MPI_Reduce(), regardless of what their documentation may claim.
2025-03-07 09:29:28 +01:00
Mattijs Janssens
939ca03495 Merge branch 'pstream-typed-handling' into 'develop'
increased use of intrinsic data types and ops for communication

See merge request Development/openfoam!730
2025-03-06 16:16:01 +00:00
Mark Olesen
28818c73f9 COMP: workaround for broken in-place reduce INTEL-MPI (#3331)
- since that particular vendor version of MPI_Reduce() does not work
  with MPI_IN_PLACE, create a local copy of the data to pass into the
  routine.
2025-03-06 16:54:32 +01:00
Mark Olesen
20b2f46315 STYLE: prefer listReduce() to using listCombineReduce() when possible
- potentially allows access into the builtin MPI operations
2025-03-06 16:54:31 +01:00
Mark Olesen
5d9f8e9a9d ENH: remove gatherv/scatterv direct coding
- includes intrinsic MPI types, but no component aggregates since we
  barely wish to use gatherv/scatterv (slow!) in the first place
  and it makes no sense to recalculate the list of counts for
  component aggregates which we will never use.
2025-03-06 16:54:31 +01:00
Mark Olesen
3bf1399098 ENH: generalize mpiGather/mpiScatter/mpiAllGather
- include MPI and component aggregates
2025-03-06 16:54:31 +01:00
Mark Olesen
20b6aeb4dd ENH: generalize reduce/all-reduce to include MPI types
- for known data types (and component aggregates),
  and intrisic reduction operation can now use

     UPstream::mpiReduce(), UPstream::mpiAllReduce().

  This change permits more operations to use MPI calls directly.
  eg,

      reduce(vec, sumOp<vector>);

   now calls mpiAllReduce(..., op_sum) instead of point-to-point,
   followed by a broadcast.

   Similarly, when called as a simple reduction (not all-reduce)

      Pstream::gather(vec, sumOp<vector>);

   now calls mpiReduce(..., op_sum) instead of point-to-point

- extend use of MPI calls to list-wise reductions as well

- extend sumReduce() to bundle/unbundle vector-space types,
  which lowers overall communication.

  Before:
    1) send/recv + binary op through a communication tree
    2) broadcast
    3) all-reduce of the count

  Now:
    1) pack into a local bundle
    2) all-reduce
    3) unpack the bundle
2025-03-06 16:54:31 +01:00
Mark Olesen
c7fc9d4ddc ENH: extend MPI send/recv types
- support send/recv of basic types (int32, float, double, ...) in
  addition to common OpenFOAM vectorspace types (floatVector,
  doubleVector, ...)

  This permits sending NUM items of the given types instead of sending
  NUM sizeof() bytes.
  For a vector (as double): 1 item instead of 24 items (3*8 bytes).
  For a tensor (as double): 1 item instead of 72 items (9*8 bytes).
2025-03-06 16:54:31 +01:00
Mark Olesen
f0b844eb47 ENH: generalize MPI broadcast to basic and user-defined MPI types
- simplify and rationalize some of the broadcast methods for more code
  reuse.

  The bottom level UPstream::broadcast is now always to/from "root=0".
  This was previously passed as a default parameter, but never used
  anything other than '0' in the code. Fixing it as '0' makes it
  consistent with the 'top-down' logical for node-based broadcast.
2025-03-06 16:54:31 +01:00
Mark Olesen
151f4df546 ENH: add opaque data types to UPstream bridge code
- permits more flexible handling at the caller level
2025-03-06 16:54:31 +01:00
Mark Olesen
7ac83f22c7 ENH: refine the dataTypes handling
- now distinguish between basic MPI types and user-defined types.

  The new front-facing trait UPstream_basic_dataType unwinds components
  and other types, but only for MPI fundamental types
  (including any aliases)

- additional helper to combine a test for binary operator validity and
  basic data type validity, which better expresses intent:

     template<class BinaryOp, class T>
     UPstream_data_opType;

- relax bit-wise operators to also accept signed integrals
  and 'void' generic
2025-03-06 16:54:31 +01:00
Mark Olesen
8c395357f3 STYLE: more consistency in communicator types (int vs label) 2025-03-06 16:54:31 +01:00
Mark Olesen
d4b5280742 ENH: cleanup broadcast streams
- remove unused/unusable broadcast stream constructors/methods

- provide OPBstream::sends() and IPBstream::recvs() methods,
  refactored from Pstream::broadcasts. These will always use
  serializations, even for contiguous content.

- additional methods to support special handling of zero-sized lists.
  For example,

    if (UPstream::master(comm))
    {
        if (list.empty()) OPBstream::send(Foam::zero, comm);
        else              OPBstream::send(list, comm);
    }
    else
    {
        IPBstream is(comm);
        if (is.remaining()) { is >> list; }
        else { list.clear(); }
    }

   This avoids serialization of an empty list and the resulting double
   broadcast (size + content), using instead a single broadcast (size).

STYLE: more consistency in communicator types (int vs label)
2025-03-06 16:54:31 +01:00
Mark Olesen
be30598e3d ENH: add UPstream::localNode_parentProcs() method
- returns the (start/size) range of the commLocalNode ranks in terms
  of the (const) world communicator processors. This allows mapping
  back into lists defined in terms of the world ranks.
2025-03-06 16:54:30 +01:00
Mark Olesen
d64682a7af ENH: expand VectorSpaceOps to include copy_n/fill_n methods
- similar to what std::copy_n and std::fill_n would do, except with
  templated loops. This allows compile-time transcribing with loop
  unrolling. For example,

     vector vec1 = ..., vec2 = ...;

     FixedList<scalar, 6> values;

     VectorSpaceOps<3>::copy_n(vec1.begin(), values.begin());
     VectorSpaceOps<3>::copy_n(vec2.begin(), values.begin(3))

     // do something with all of these values

STYLE: make start index of VectorSpaceOps optional

ENH: add clamped begin(int) versions to FixedList as per UList
2025-03-06 16:54:30 +01:00
Mark Olesen
cf9fa16788 COMP: add pTraits for int16/uint16 types (simplifies messages) 2025-03-06 16:54:30 +01:00
Mark Olesen
9437e8d068 ENH: simplify operator calls for error, messageStream
- use move semantics for string parameters and reuse more code
2025-03-06 16:54:30 +01:00
mattijs
dd09aa1289 ENH: PatchTools: version with supplied local points 2025-03-06 13:05:20 +00:00
mattijs
56c52fd69e COMP: fix up merg e 2025-02-27 12:04:58 +00:00
mattijs
34c933c1ce ENH: AMIInterpolation: use local communicator
- allocate communicator with only those ranks that have
patch faces
- use this communicator everywhere
- communicator preserved during mesh motion
2025-02-27 12:04:58 +00:00
Mark Olesen
f276016896 SUBMODULE: runTime postProcessing updated for change in minMaxOp 2025-02-27 12:48:34 +01:00
Kutalmış Berçin
e3703c7626 Merge branch 'pstream-types' into 'develop'
add compile-time type system for MPI data/ops

See merge request Development/openfoam!729
2025-02-25 14:51:21 +00:00
Mark Olesen
dccdb263e8 ENH: add UPstreamTraits support to map data types and opcodes
The front-end traits:

- UPstream_dataType trait:
  This wrapper is unwinds the type to check against base/alias, but also
  checks if it is a component aggregate of a supported UPstream data type.
  This will be that main entry point for usage.

- UPstream_opType trait:
  Provides a mapping of OpenFOAM ops to their MPI equivalent.
  The \c opcode_id is the corresponding internal representation.

The lower-level traits (not normally used within coding)

- UPstream_base_dataType trait:
  Tests true/false if the specified data type has an internal MPI equivalent.
  The \c datatype_id is the corresponding internal enumeration.
  Even if this tests as false, it will always return \c type_byte as the
  fallback for general contiguous data

- UPstream_alias_dataType trait:
  Provides mapping for <int/long/long long,...> to the fundamental 32/64
  integrals, since <int/long/long long,...> may not otherwise directly map
  on all systems.

NOTE: can use the updates Test-machine-sizes test application to
determine if all data types and aliases are properly defined on
different systems
2025-02-25 10:09:38 +01:00
Mark Olesen
bf60a124ab ENH: add mapping for fundamental and OpenFOAM types -> MPI data types
- this will allow send/recv/broadcast of various data types directly
  without reinterpreting as bytes. No performance benefit, but makes
  programming more flexible. In addition to the normal MPI types, also
  provide some convenient groupings such as double[3], double[9] etc.

- the additional user-defined data types are created on the start of
  MPI and removed before shutdown
2025-02-25 09:52:12 +01:00
Mark Olesen
c448ea2a11 ENH: add simple handling for point-to-point barriers
- provides an additional means of process synchronization
2025-02-25 09:44:44 +01:00
Kutalmış Berçin
d41c644a49 Merge branch 'pstream-cleanups' into 'develop'
various cleanup and add support for non-worldComm reduction of DimensionedField, GeometricField

See merge request Development/openfoam!728
2025-02-24 12:38:40 +00:00
Mark Olesen
d2dfd115be ENH: provide isolated "*_algorithm" versions of Pstream gather routines
- enables better selection of linear vs tree and improves future reuse.

ENH: optimize listReduce/listCombineReduce for single-value lists
2025-02-24 09:06:21 +01:00
Mark Olesen
8f3d29c1b7 ENH: retain linear vs tree state in commsStructList
- previously there were two places that used nProcsSimpleSum for
  defining the communication pattern. However, this meant in practice
  that filling of linearCommunication_ and treeCommunication_ themselves
  where globally controlled.

  Now retain the state within commsStructList and use linear/tree
  when populating.
2025-02-24 09:06:12 +01:00
Mark Olesen
e67fffac3f STYLE: use UPstream::reduceAnd(), UPstream::reduceOr() instead of longer forms 2025-02-24 09:04:04 +01:00
Mark Olesen
2783e78ae2 STYLE: unify some handling of warn communicator, minor code cleanup 2025-02-24 09:03:56 +01:00
Mark Olesen
e041af9481 DEFEATURE: remove non-blocking reduce() with global request tracking
- deprecated and replaced (JAN-2023) with a version that uses
  UPstream::Request to track the request. This avoids placing a
  request on the global list and then having difficulty isolating it
  later (or having it cleared out by someone else).

ENH: UPstream::addRequest() now ignores null requests

- avoids placing useless requests on the global list
2025-02-24 09:03:47 +01:00
Mark Olesen
e8e90a8de3 ENH: support non-worldComm for Dimensioned/Geometric field functions 2025-02-24 09:03:31 +01:00
Mark Olesen
0aecb25024 ENH: update MinMax to accept multiple values for add()
- now also provide its own member data (previously inherited from
  Tuple2) to provide better isolation from future changes
2025-02-24 09:03:19 +01:00
Mark Olesen
14b2302b38 COMP: remove 'special purpose' minMaxOp (#3326)
- replace with plusOp for reductions. The old use didn't necessarily work
  well with compiler resolution in all cases.
  Simplify to use plusOp (and removed the old version).
  [Does not affect very much code...]

COMP: incorrect include ordering for GeometricFieldFunctions

- header was included after the template code

REGRESSION: combineAllGather mapped to incorrect method (81fa7d08ee)

STYLE: use UPstream::commWarn(...) setter method
2025-02-24 08:57:36 +01:00
Mark Olesen
d655c2d343 ENH: print node/topology information in human-readable form at startup 2025-02-24 08:56:25 +01:00
Kutalmis Bercin
533d3b58f8 TUT: backwardFacingStep2D: add missing probes (fixes #3319) 2025-02-21 16:49:36 +00:00
Mattijs Janssens
0c282bda65 Merge branch 'pstream-adjustments' into 'develop'
Additional refinements for Pstream and minor restructuring of combine vs reduce operations

See merge request Development/openfoam!727
2025-02-19 14:47:27 +00:00
Mark Olesen
4720b61313 REGRESSION: globalIndex::gatherInplaceOp was not forwarding to gatherInplace
- regression introduced by 512ec01328 (recent develop only)
2025-02-17 13:40:44 +01:00
Mark Olesen
a66be057c2 GIT: relocate Pstream template '.C' files to '.txx' prior to further changes
- reduces confusion about 'real' code vs template code
2025-02-17 13:40:44 +01:00
Mark Olesen
eae448c7aa CONFIG: handle embedded WM_COMPILE_CONTROL flags in wmakeLnInclude
- with WM_COMPILE_CONTROL="... lnInclude-extra ..." will treat like
  'wmakeLnInclude -extra' and include all source files into the
  lnInclude/ directory
2025-02-17 13:40:44 +01:00
Mark Olesen
81fa7d08ee ENH: extend Pstream gather templates to support combine or assign operation
- eliminates nearly identical code between 'gather' and 'combineGather'

  * Normal gather updates by assigning the result of the binary operation.
  * Combine gather updates by using a binary operator that modifies
    its first parameter in-place

  By-product of this refactoring are these new variants:

      listGather(), listGatherReduce()
      mapGather(), mapGatherReduce()

  that mirror the previously existing ones

      listCombineGather(), listCombineReduce()
      mapCombineGather(), mapCombineReduce()

  except that they use the 'regular' binary operator
2025-02-17 13:40:44 +01:00
Mark Olesen
0ce5053c75 ENH: mpiGather/mpiScatter now also support in-place use
- the general OpenFOAM way of collecting data often looks like this:

      List<scalar> allValues(numProcs);
      allValues[myProc] = localValue;

      Pstream::gatherList(allValues);

      // Now possible like this

      List<scalar> allValues(numProcs);
      allValues[myProc] = localValue;

      UPstream::mpiGather(nullptr, allValues.data_bytes(), sizeof(scalar));

- adjusted Pstream::gatherList accordingly.
  Split out the manual implementations, give them new names
  (..._tree_algorithm) and make them private.

STYLE: rename UPstream::gather -> UPstream::mpiGatherv

- easier to identify and establishes the connection to the MPI call
2025-02-17 13:40:44 +01:00
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
mattijs
15ac0bc30b BUG: GAMG: processor agglomeration. Fixes #3323 2025-02-17 12:33:14 +00:00
Mattijs Janssens
21f36b18e5 Merge branch 'feature-UPstream-startup' into 'develop'
enhance UPstream communicator support

See merge request Development/openfoam!725
2025-02-13 15:12:42 +00:00
Mark Olesen
3852f7c5b7 ENH: add node-based globalIndex::gather (topology-aware handling) 2025-02-13 12:31:16 +01:00
Mark Olesen
a3e1376117 ENH: combine gathers of sizes in GAMGAgglomeration
- replace two listGatherValues with listGatherValues of labelPair and
  calculate offsets from the corresponding tuple members.
2025-02-13 12:31:16 +01:00
Mark Olesen
512ec01328 ENH: rationalize some globalIndex gather routines
- replace gatherValues() with listGatherValues(), which returns the
  gathered values instead of passing by argument. This makes it less
  fragile and more convenient. Naming as per
  Pstream::listGatherValues(), but still retaining the original
  parameter order.

- rename inplace 'gather' variant as 'gatherInplace' for clarity.

- changed signature of lowest-level globalIndex::gather routines from
  List<Type> to UList<Type> for the output and removed any resizing.
  This means that the caller is responsible for ensuring that the
  receiving field is adequately sized (on master). This change allows
  potential reuse of 'work' arrays etc.

  The only code change for using this low-level gather was in
  GAMGAgglomeration.
2025-02-13 12:31:16 +01:00
Mark Olesen
3e8b0a2c73 ENH: introduce UPstream::commsStructList class
- was previously simply a List<commsStruct>, but now wrap it into a
  class so that the associated communicator index can be easily
  recovered etc.
2025-02-13 12:31:16 +01:00