26 #ifndef KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_SYNC_SHAPE_INTERFACE_FOR_TYPE
27 #define KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_SYNC_SHAPE_INTERFACE_FOR_TYPE(...) \
28 bool SynchronizeShape(__VA_ARGS__&) const override; \
29 bool SynchronizeShape( \
30 const __VA_ARGS__& rSendValue, const int SendDestination, const int SendTag, \
31 __VA_ARGS__& rRecvValue, const int RecvSource, const int RecvTag) const override; \
35 #ifndef KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_REDUCE_INTERFACE_FOR_TYPE
36 #define KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_REDUCE_INTERFACE_FOR_TYPE(...) \
37 __VA_ARGS__ Sum(const __VA_ARGS__& rLocalValue, const int Root) const override; \
38 std::vector<__VA_ARGS__> Sum(const std::vector<__VA_ARGS__>& rLocalValues, const int Root) const override; \
39 void Sum(const std::vector<__VA_ARGS__>& rLocalValues, std::vector<__VA_ARGS__>& rGlobalValues, const int Root) const override; \
40 __VA_ARGS__ Min(const __VA_ARGS__& rLocalValue, const int Root) const override; \
41 std::vector<__VA_ARGS__> Min(const std::vector<__VA_ARGS__>& rLocalValues, const int Root) const override; \
42 void Min(const std::vector<__VA_ARGS__>& rLocalValues, std::vector<__VA_ARGS__>& rGlobalValues, const int Root) const override; \
43 __VA_ARGS__ Max(const __VA_ARGS__& rLocalValue, const int Root) const override; \
44 std::vector<__VA_ARGS__> Max(const std::vector<__VA_ARGS__>& rLocalValues, const int Root) const override; \
45 void Max(const std::vector<__VA_ARGS__>& rLocalValues, std::vector<__VA_ARGS__>& rGlobalValues, const int Root) const override; \
49 #ifndef KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_ALLREDUCE_INTERFACE_FOR_TYPE
50 #define KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_ALLREDUCE_INTERFACE_FOR_TYPE(...) \
51 __VA_ARGS__ SumAll(const __VA_ARGS__& rLocalValue) const override; \
52 std::vector<__VA_ARGS__> SumAll(const std::vector<__VA_ARGS__>& rLocalValues) const override; \
53 void SumAll(const std::vector<__VA_ARGS__>& rLocalValues, std::vector<__VA_ARGS__>& rGlobalValues) const override; \
54 __VA_ARGS__ MinAll(const __VA_ARGS__& rLocalValue) const override; \
55 std::vector<__VA_ARGS__> MinAll(const std::vector<__VA_ARGS__>& rLocalValues) const override; \
56 void MinAll(const std::vector<__VA_ARGS__>& rLocalValues, std::vector<__VA_ARGS__>& rGlobalValues) const override; \
57 __VA_ARGS__ MaxAll(const __VA_ARGS__& rLocalValue) const override; \
58 std::vector<__VA_ARGS__> MaxAll(const std::vector<__VA_ARGS__>& rLocalValues) const override; \
59 void MaxAll(const std::vector<__VA_ARGS__>& rLocalValues, std::vector<__VA_ARGS__>& rGlobalValues) const override; \
63 #ifndef KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_ALLREDUCE_LOC_INTERFACE_FOR_TYPE
64 #define KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_ALLREDUCE_LOC_INTERFACE_FOR_TYPE(...) \
65 std::pair<__VA_ARGS__, int> MinLocAll(const __VA_ARGS__& rLocalValue) const override; \
66 std::pair<__VA_ARGS__, int> MaxLocAll(const __VA_ARGS__& rLocalValue) const override;
69 #ifndef KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_SCANSUM_INTERFACE_FOR_TYPE
70 #define KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_SCANSUM_INTERFACE_FOR_TYPE(...) \
71 __VA_ARGS__ ScanSum(const __VA_ARGS__& rLocalValue) const override; \
72 std::vector<__VA_ARGS__> ScanSum(const std::vector<__VA_ARGS__>& rLocalValues) const override; \
73 void ScanSum(const std::vector<__VA_ARGS__>& rLocalValues, std::vector<__VA_ARGS__>& rGlobalValues) const override; \
77 #ifndef KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_SENDRECV_INTERFACE_FOR_TYPE
78 #define KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_SENDRECV_INTERFACE_FOR_TYPE(...) \
79 __VA_ARGS__ SendRecvImpl( \
80 const __VA_ARGS__& SendValue, const int SendDestination, const int SendTag, \
81 const int RecvSource, const int RecvTag) const override; \
82 std::vector<__VA_ARGS__> SendRecvImpl(const std::vector<__VA_ARGS__>& rSendValues, \
83 const int SendDestination, const int SendTag, \
84 const int RecvSource, const int RecvTag) const override; \
86 const __VA_ARGS__& SendValue, const int SendDestination, const int SendTag, \
87 __VA_ARGS__& RecvValue, const int RecvSource, const int RecvTag) const override; \
89 const std::vector<__VA_ARGS__>& rSendValues, const int SendDestination, const int SendTag, \
90 std::vector<__VA_ARGS__>& rRecvValues, const int RecvSource, const int RecvTag) const override; \
91 void SendImpl(const __VA_ARGS__& rSendValues, \
92 const int SendDestination, const int SendTag = 0) const override; \
93 void SendImpl(const std::vector<__VA_ARGS__>& rSendValues, \
94 const int SendDestination, const int SendTag = 0) const override; \
95 void RecvImpl(__VA_ARGS__& rRecvValues, \
96 const int RecvSource, const int RecvTag = 0) const override; \
97 void RecvImpl(std::vector<__VA_ARGS__>& rRecvValues, \
98 const int RecvSource, const int RecvTag = 0) const override; \
102 #ifndef KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_BROADCAST_INTERFACE_FOR_TYPE
103 #define KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_BROADCAST_INTERFACE_FOR_TYPE(...) \
104 void BroadcastImpl(__VA_ARGS__& rBuffer, const int SourceRank) const override; \
105 void BroadcastImpl(std::vector<__VA_ARGS__>& rBuffer, const int SourceRank) const override; \
109 #ifndef KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_SCATTER_INTERFACE_FOR_TYPE
110 #define KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_SCATTER_INTERFACE_FOR_TYPE(...) \
111 std::vector<__VA_ARGS__> Scatter( \
112 const std::vector<__VA_ARGS__>& rSendValues, const int SourceRank) const override; \
114 const std::vector<__VA_ARGS__>& rSendValues, std::vector<__VA_ARGS__>& rRecvValues, \
115 const int SourceRank) const override; \
116 std::vector<__VA_ARGS__> Scatterv( \
117 const std::vector<std::vector<__VA_ARGS__>>& rSendValues, const int SourceRank) const override; \
119 const std::vector<__VA_ARGS__>& rSendValues, \
120 const std::vector<int>& rSendCounts, const std::vector<int>& rSendOffsets, \
121 std::vector<__VA_ARGS__>& rRecvValues, const int SourceRank) const override; \
125 #ifndef KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_GATHER_INTERFACE_FOR_TYPE
126 #define KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_GATHER_INTERFACE_FOR_TYPE(...) \
127 std::vector<__VA_ARGS__> Gather(const std::vector<__VA_ARGS__>& rSendValues, const int DestinationRank) const override; \
129 const std::vector<__VA_ARGS__>& rSendValues, std::vector<__VA_ARGS__>& rRecvValues, \
130 const int DestinationRank) const override; \
131 std::vector<std::vector<__VA_ARGS__>> Gatherv( \
132 const std::vector<__VA_ARGS__>& rSendValues, const int DestinationRank) const override; \
133 void Gatherv(const std::vector<__VA_ARGS__>& rSendValues, \
134 std::vector<__VA_ARGS__>& rRecvValues, \
135 const std::vector<int>& rRecvCounts, \
136 const std::vector<int>& rRecvOffsets, \
137 const int DestinationRank) const override; \
138 std::vector<__VA_ARGS__> AllGather(const std::vector<__VA_ARGS__>& rSendValues) const override; \
139 void AllGather(const std::vector<__VA_ARGS__>& rSendValues, std::vector<__VA_ARGS__>& rRecvValues) const override; \
140 std::vector<std::vector<__VA_ARGS__>> AllGatherv(const std::vector<__VA_ARGS__>& rSendValues) const override; \
141 void AllGatherv(const std::vector<__VA_ARGS__>& rSendValues, std::vector<__VA_ARGS__>& rRecvValues, \
142 const std::vector<int>& rRecvCounts, const std::vector<int>& rRecvOffsets) const override;
145 #ifndef KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_PUBLIC_INTERFACE_FOR_TYPE
146 #define KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_PUBLIC_INTERFACE_FOR_TYPE(...) \
147 KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_REDUCE_INTERFACE_FOR_TYPE(__VA_ARGS__) \
148 KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_ALLREDUCE_INTERFACE_FOR_TYPE(__VA_ARGS__) \
149 KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_SCANSUM_INTERFACE_FOR_TYPE(__VA_ARGS__) \
150 KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_SCATTER_INTERFACE_FOR_TYPE(__VA_ARGS__) \
151 KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_GATHER_INTERFACE_FOR_TYPE(__VA_ARGS__) \
152 KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_SYNC_SHAPE_INTERFACE_FOR_TYPE(__VA_ARGS__) \
156 #ifndef KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_IMPLEMENTATION_FOR_TYPE
157 #define KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_IMPLEMENTATION_FOR_TYPE(...) \
158 KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_SENDRECV_INTERFACE_FOR_TYPE(__VA_ARGS__) \
159 KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_BROADCAST_INTERFACE_FOR_TYPE(__VA_ARGS__) \
210 static MPIDataCommunicator::UniquePointer
Create(MPI_Comm MPIComm);
212 void Barrier()
const override;
237 const int Root)
const override;
242 const int Root)
const override;
246 const int Root)
const override;
251 const int Root)
const override;
255 bool AndReduceAll(
const bool Value)
const override;
259 bool OrReduceAll(
const bool Value)
const override;
271 static MPI_Comm GetMPICommunicator(
const DataCommunicator& rDataCommunicator);
282 int Rank()
const override;
289 int Size()
const override;
295 bool IsDistributed()
const override;
302 bool IsDefinedOnThisRank()
const override;
309 bool IsNullOnThisRank()
const override;
319 const std::vector<int>& rRanks,
320 const std::string& rNewCommunicatorName
327 bool BroadcastErrorIfTrue(
bool Condition,
const int SourceRank)
const override;
329 bool BroadcastErrorIfFalse(
bool Condition,
const int SourceRank)
const override;
331 bool ErrorIfTrueOnAnyRank(
bool Condition)
const override;
333 bool ErrorIfFalseOnAnyRank(
bool Condition)
const override;
340 std::string
Info()
const override;
343 void PrintInfo(std::ostream &rOStream)
const override;
346 void PrintData(std::ostream &rOStream)
const override;
366 void BroadcastImpl(std::string& rBroadcastValues,
const int SourceRank)
const override;
370 std::string SendRecvImpl(
371 const std::string& rSendValues,
const int SendDestination,
const int SendTag,
372 const int RecvSource,
const int RecvTag)
const override;
375 const std::string& rSendValues,
const int SendDestination,
const int SendTag,
376 std::string& rRecvValues,
const int RecvSource,
const int RecvTag)
const override;
378 void SendImpl(
const std::string& rSendValues,
const int SendDestination,
const int SendTag = 0)
const override;
380 void RecvImpl(std::string& rRecvValues,
const int RecvSource,
const int RecvTag = 0)
const override;
392 void CheckMPIErrorCode(
const int ierr,
const std::string& MPICallName)
const;
394 template<
class TDataType>
bool SynchronizeShapeDetail(TDataType& rValue)
const;
396 template<
class TDataType>
bool SynchronizeShapeDetail(
397 const TDataType& rSendValue,
398 const int SendDestination,
400 TDataType& rRecvValue,
401 const int RecvSource,
402 const int RecvTag)
const;
404 template<
class TDataType>
void ReduceDetail(
405 const TDataType& rLocalValues,
406 TDataType& rReducedValues,
408 const int Root)
const;
410 template<
class TDataType> TDataType ReduceDetail(
411 const TDataType& rLocalValues,
413 const int Root)
const;
415 template<
class TDataType> std::vector<TDataType> ReduceDetailVector(
416 const std::vector<TDataType>& rLocalValues,
418 const int Root)
const;
420 template<
class TDataType>
void AllReduceDetail(
421 const TDataType& rLocalValues,
422 TDataType& rReducedValues,
425 template<
class TDataType> TDataType AllReduceDetail(
426 const TDataType& rLocalValues, MPI_Op
Operation)
const;
428 template<
class TDataType> std::vector<TDataType> AllReduceDetailVector(
429 const std::vector<TDataType>& rLocalValues,
440 template<
class TDataType>
441 std::pair<TDataType, int> AllReduceDetailWithLocation(
442 const std::pair<TDataType, int>& rLocalValues,
446 template<
class TDataType>
void ScanDetail(
447 const TDataType& rLocalValues,
448 TDataType& rReducedValues,
451 template<
class TDataType> TDataType ScanDetail(
452 const TDataType rLocalValues,
455 template<
class TDataType> std::vector<TDataType> ScanDetail(
456 const std::vector<TDataType>& rLocalValues,
459 template<
class TDataType>
void SendRecvDetail(
460 const TDataType& rSendMessage,
const int SendDestination,
const int SendTag,
461 TDataType& rRecvMessage,
const int RecvSource,
const int RecvTag)
const;
463 template<
class TDataType> TDataType SendRecvDetail(
464 const TDataType& rSendMessage,
465 const int SendDestination,
const int SendTag,
466 const int RecvSource,
const int RecvTag)
const;
468 template<
class TDataType> std::vector<TDataType> SendRecvDetail(
469 const std::vector<TDataType>& rSendMessage,
470 const int SendDestination,
const int SendTag,
471 const int RecvSource,
const int RecvTag)
const;
473 template<
class TDataType>
void SendDetail(
474 const TDataType& rSendValues,
const int SendDestination,
const int SendTag)
const;
476 template<
class TDataType>
void RecvDetail(
477 TDataType& rRecvValues,
const int RecvSource,
const int RecvTag)
const;
479 template<
class TDataType>
void BroadcastDetail(
480 TDataType& rBuffer,
const int SourceRank)
const;
482 template<
class TSendDataType,
class TRecvDataType>
void ScatterDetail(
483 const TSendDataType& rSendValues, TRecvDataType& rRecvValues,
const int SourceRank)
const;
485 template<
class TDataType> std::vector<TDataType> ScatterDetail(
486 const std::vector<TDataType>& rSendValues,
const int SourceRank)
const;
488 template<
class TDataType>
void ScattervDetail(
489 const TDataType& rSendValues,
490 const std::vector<int>& rSendCounts,
const std::vector<int>& rSendOffsets,
491 TDataType& rRecvValues,
const int SourceRank)
const;
493 template<
class TDataType> std::vector<TDataType> ScattervDetail(
494 const std::vector<std::vector<TDataType>>& rSendValues,
const int SourceRank)
const;
496 template<
class TSendDataType,
class TRecvDataType>
void GatherDetail(
497 const TSendDataType& rSendValues, TRecvDataType& rRecvValues,
const int RecvRank)
const;
499 template<
class TDataType> std::vector<TDataType> GatherDetail(
500 const std::vector<TDataType>& rSendValues,
const int DestinationRank)
const;
502 template<
class TDataType>
void GathervDetail(
503 const TDataType& rSendValues, TDataType& rRecvValues,
504 const std::vector<int>& rRecvCounts,
const std::vector<int>& rRecvOffsets,
505 const int RecvRank)
const;
507 template<
class TDataType> std::vector<std::vector<TDataType>>
508 GathervDetail(
const std::vector<TDataType>& rSendValues,
const int DestinationRank)
const;
510 template<
class TDataType>
void AllGatherDetail(
511 const TDataType& rSendValues, TDataType& rRecvValues)
const;
513 template<
class TDataType> std::vector<TDataType> AllGatherDetail(
514 const std::vector<TDataType>& rSendValues)
const;
516 template<
class TDataType>
517 void AllGathervDetail(
518 const TDataType& rSendValues, TDataType& rRecvValues,
519 const std::vector<int>& rRecvCounts,
const std::vector<int>& rRecvOffsets)
const;
521 template<
class TDataType>
522 std::vector<std::vector<TDataType>> AllGathervDetail(
523 const std::vector<TDataType>& rSendValues)
const;
525 bool IsEqualOnAllRanks(
const int LocalValue)
const;
527 bool IsValidRank(
const int Rank)
const;
529 template<
class TDataType>
void ValidateScattervInput(
530 const TDataType& rSendValues,
531 const std::vector<int>& rSendCounts,
const std::vector<int>& rSendOffsets,
532 TDataType& rRecvValues,
const int SourceRank)
const;
534 template<
class TDataType>
void ValidateGathervInput(
535 const TDataType& rSendValues, TDataType& rRecvValues,
536 const std::vector<int>& rRecvCounts,
const std::vector<int>& rRecvOffsets,
537 const int RecvRank)
const;
539 template<
class TDataType>
540 void ValidateAllGathervInput(
541 const TDataType& rSendValues, TDataType& rRecvValues,
542 const std::vector<int>& rRecvCounts,
const std::vector<int>& rRecvOffsets)
const;
544 template<
class TDataType>
void PrepareScattervBuffers(
545 const std::vector<std::vector<TDataType>>& rInputMessage,
546 std::vector<TDataType>& rScattervMessage,
547 std::vector<int>& rMessageLengths,
548 std::vector<int>& rMessageDistances,
549 std::vector<TDataType>& rResult,
550 const int SourceRank)
const;
552 template<
class TDataType>
void PrepareGathervBuffers(
553 const std::vector<TDataType>& rGathervInput,
554 std::vector<TDataType>& rGathervMessage,
555 std::vector<int>& rMessageLengths,
556 std::vector<int>& rMessageDistances,
557 const int DestinationRank)
const;
559 template<
class TDataType>
560 void PrepareAllGathervBuffers(
561 const std::vector<TDataType>& rGathervInput,
562 std::vector<TDataType>& rGathervMessage,
563 std::vector<int>& rMessageLengths,
564 std::vector<int>& rMessageDistances)
const;
566 template<
class TDataType>
void PrepareGathervReturn(
567 const std::vector<TDataType>& rGathervMessage,
568 const std::vector<int>& rMessageLengths,
569 const std::vector<int>& rMessageDistances,
570 std::vector<std::vector<TDataType>>& rOutputMessage,
571 const int DestinationRank)
const;
573 template<
class TDataType>
574 void PrepareAllGathervReturn(
575 const std::vector<TDataType>& rGathervMessage,
576 const std::vector<int>& rMessageLengths,
577 const std::vector<int>& rMessageDistances,
578 std::vector<std::vector<TDataType>>& rOutputMessage)
const;
580 template<
class TValue>
inline MPI_Datatype MPIDatatype(
const TValue&)
const;
582 template<
class TContainer>
inline void* MPIBuffer(TContainer& rValues)
const;
584 template<
class TContainer>
inline const void* MPIBuffer(
const TContainer& rValues)
const;
586 template<
class TContainer>
inline int MPIMessageSize(
const TContainer& rValues)
const;
619 rOStream << std::endl;
630 #undef KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_REDUCE_INTERFACE_FOR_TYPE
631 #undef KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_ALLREDUCE_INTERFACE_FOR_TYPE
632 #undef KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_SCANSUM_INTERFACE_FOR_TYPE
633 #undef KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_SENDRECV_INTERFACE_FOR_TYPE
634 #undef KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_BROADCAST_INTERFACE_FOR_TYPE
635 #undef KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_SCATTER_INTERFACE_FOR_TYPE
636 #undef KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_GATHER_INTERFACE_FOR_TYPE
637 #undef KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_PUBLIC_INTERFACE_FOR_TYPE
638 #undef KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_IMPLEMENTATION_FOR_TYPE
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
std::string Info() const override
Turn back information as a string.
Definition: periodic_interface_process.hpp:93
Base class for all Conditions.
Definition: condition.h:59
Serial (do-nothing) version of a wrapper class for MPI communication.
Definition: data_communicator.h:318
Wrapper for common MPI calls within Kratos.
Definition: mpi_data_communicator.h:182
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: mpi_data_communicator.cpp:512
KRATOS_CLASS_POINTER_DEFINITION(MPIDataCommunicator)
Pointer definition of MPIDataCommunicator.
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: mpi_data_communicator.cpp:517
The base class for all operations in Kratos.
Definition: operation.h:43
#define KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_ALLREDUCE_LOC_INTERFACE_FOR_TYPE(...)
Definition: mpi_data_communicator.h:64
#define KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_PUBLIC_INTERFACE_FOR_TYPE(...)
Definition: mpi_data_communicator.h:146
#define KRATOS_MPI_DATA_COMMUNICATOR_DECLARE_IMPLEMENTATION_FOR_TYPE(...)
Definition: mpi_data_communicator.h:157
Modeler::Pointer Create(const std::string &ModelerName, Model &rModel, const Parameters ModelParameters)
Checks if the modeler is registered.
Definition: modeler_factory.cpp:30
TSpaceType::IndexType Size(TSpaceType &dummy, typename TSpaceType::VectorType const &rV)
Definition: add_strategies_to_python.cpp:111
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432