STYLE: more consistency in communicator types (int vs label)
This commit is contained in:
parent
d4b5280742
commit
8c395357f3
@ -508,7 +508,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
const bool useLocalComms = UPstream::usingNodeComms();
|
||||
const bool useLocalComms = UPstream::usingNodeComms(UPstream::worldComm);
|
||||
bool useWindow = args.found("window");
|
||||
bool useBuiltin = args.found("builtin");
|
||||
|
||||
|
@ -61,14 +61,13 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct given process index to read from
|
||||
//- and optional buffer size, read format
|
||||
IPstream
|
||||
(
|
||||
const UPstream::commsTypes commsType,
|
||||
const int fromProcNo,
|
||||
const label bufSize = 0,
|
||||
const int bufferSize = 0, //!< optional buffer size
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm,
|
||||
const int communicator = UPstream::worldComm,
|
||||
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
|
||||
);
|
||||
|
||||
@ -83,7 +82,7 @@ public:
|
||||
Type& value,
|
||||
const int fromProcNo,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm,
|
||||
const int communicator = UPstream::worldComm,
|
||||
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
|
||||
)
|
||||
{
|
||||
@ -91,9 +90,9 @@ public:
|
||||
(
|
||||
UPstream::commsTypes::scheduled, // ie, MPI_Recv()
|
||||
fromProcNo,
|
||||
0, // bufSize
|
||||
0, // bufferSize
|
||||
tag,
|
||||
comm,
|
||||
communicator,
|
||||
fmt
|
||||
);
|
||||
is >> value;
|
||||
|
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2022-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -38,7 +38,7 @@ Foam::UIPstream::UIPstream
|
||||
DynamicList<char>& receiveBuf,
|
||||
label& receiveBufPosition,
|
||||
const int tag,
|
||||
const label comm,
|
||||
const int communicator,
|
||||
const bool clearAtEnd,
|
||||
IOstreamOption::streamFormat fmt
|
||||
)
|
||||
@ -50,7 +50,7 @@ Foam::UIPstream::UIPstream
|
||||
receiveBuf,
|
||||
receiveBufPosition,
|
||||
tag,
|
||||
comm,
|
||||
communicator,
|
||||
clearAtEnd,
|
||||
fmt
|
||||
)
|
||||
@ -105,13 +105,13 @@ Foam::IPstream::IPstream
|
||||
(
|
||||
const UPstream::commsTypes commsType,
|
||||
const int fromProcNo,
|
||||
const label bufSize,
|
||||
const int bufferSize,
|
||||
const int tag,
|
||||
const label comm,
|
||||
const int communicator,
|
||||
IOstreamOption::streamFormat fmt
|
||||
)
|
||||
:
|
||||
Pstream(commsType, bufSize),
|
||||
Pstream(commsType, bufferSize),
|
||||
UIPstream
|
||||
(
|
||||
commsType,
|
||||
@ -119,7 +119,7 @@ Foam::IPstream::IPstream
|
||||
Pstream::transferBuf_,
|
||||
UIPstreamBase::storedRecvBufPos_, // Internal only
|
||||
tag,
|
||||
comm,
|
||||
communicator,
|
||||
false, // Do not clear Pstream::transferBuf_ if at end
|
||||
fmt
|
||||
)
|
||||
|
@ -61,14 +61,13 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct for given process index to send to
|
||||
//- and optional buffer size, write format
|
||||
OPstream
|
||||
(
|
||||
const UPstream::commsTypes commsType,
|
||||
const int toProcNo,
|
||||
const label bufSize = 0,
|
||||
const int bufferSize = 0, //!< optional buffer size
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm,
|
||||
const int communicator = UPstream::worldComm,
|
||||
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
|
||||
);
|
||||
|
||||
@ -81,15 +80,15 @@ public:
|
||||
static void send
|
||||
(
|
||||
const Type& value,
|
||||
//! blocking or scheduled only!
|
||||
//! buffered or scheduled only!
|
||||
const UPstream::commsTypes commsType,
|
||||
const int toProcNo,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm,
|
||||
const int communicator = UPstream::worldComm,
|
||||
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
|
||||
)
|
||||
{
|
||||
OPstream os(commsType, toProcNo, 0, tag, comm, fmt);
|
||||
OPstream os(commsType, toProcNo, 0, tag, communicator, fmt);
|
||||
os << value;
|
||||
}
|
||||
|
||||
@ -101,7 +100,7 @@ public:
|
||||
const Type& value,
|
||||
const int toProcNo,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm,
|
||||
const int communicator = UPstream::worldComm,
|
||||
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
|
||||
)
|
||||
{
|
||||
@ -111,7 +110,7 @@ public:
|
||||
UPstream::commsTypes::scheduled, // ie, MPI_Send()
|
||||
toProcNo,
|
||||
tag,
|
||||
comm,
|
||||
communicator,
|
||||
fmt
|
||||
);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2022-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2022-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -37,7 +37,7 @@ Foam::UOPstream::UOPstream
|
||||
const int toProcNo,
|
||||
DynamicList<char>& sendBuf,
|
||||
const int tag,
|
||||
const label comm,
|
||||
const int comm,
|
||||
const bool sendAtDestruct,
|
||||
IOstreamOption::streamFormat fmt
|
||||
)
|
||||
@ -66,20 +66,20 @@ Foam::OPstream::OPstream
|
||||
(
|
||||
const UPstream::commsTypes commsType,
|
||||
const int toProcNo,
|
||||
const label bufSize,
|
||||
const int bufferSize,
|
||||
const int tag,
|
||||
const label comm,
|
||||
const int communicator,
|
||||
IOstreamOption::streamFormat fmt
|
||||
)
|
||||
:
|
||||
Pstream(commsType, bufSize),
|
||||
Pstream(commsType, bufferSize),
|
||||
UOPstream
|
||||
(
|
||||
commsType,
|
||||
toProcNo,
|
||||
Pstream::transferBuf_,
|
||||
tag,
|
||||
comm,
|
||||
communicator,
|
||||
true, // sendAtDestruct
|
||||
fmt
|
||||
)
|
||||
|
@ -75,18 +75,20 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given communication type, with optional buffer size
|
||||
explicit Pstream
|
||||
(
|
||||
const UPstream::commsTypes commsType,
|
||||
const label bufSize = 0
|
||||
)
|
||||
//- Construct for communication type with empty buffer
|
||||
explicit Pstream(const UPstream::commsTypes commsType) noexcept
|
||||
:
|
||||
UPstream(commsType)
|
||||
{}
|
||||
|
||||
//- Construct for communication type with given buffer size
|
||||
Pstream(const UPstream::commsTypes commsType, int bufferSize)
|
||||
:
|
||||
UPstream(commsType)
|
||||
{
|
||||
if (bufSize > 0)
|
||||
if (bufferSize > 0)
|
||||
{
|
||||
transferBuf_.setCapacity(bufSize + 2*sizeof(scalar) + 1);
|
||||
transferBuf_.setCapacity(bufferSize + 2*sizeof(scalar) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -300,7 +300,7 @@ Foam::PstreamBuffers::PstreamBuffers
|
||||
(
|
||||
UPstream::commsTypes commsType,
|
||||
int tag,
|
||||
label communicator,
|
||||
int communicator,
|
||||
IOstreamOption::streamFormat fmt
|
||||
)
|
||||
:
|
||||
@ -313,7 +313,7 @@ Foam::PstreamBuffers::PstreamBuffers
|
||||
nProcs_(UPstream::nProcs(comm_)),
|
||||
sendBuffers_(nProcs_),
|
||||
recvBuffers_(nProcs_),
|
||||
recvPositions_(nProcs_, Zero)
|
||||
recvPositions_(nProcs_, Foam::zero{})
|
||||
{
|
||||
DebugPoutInFunction
|
||||
<< "tag:" << tag_
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -182,10 +182,10 @@ class PstreamBuffers
|
||||
const int tag_;
|
||||
|
||||
//- Communicator
|
||||
const label comm_;
|
||||
const int comm_;
|
||||
|
||||
//- Number of ranks associated with PstreamBuffers (at construction)
|
||||
const label nProcs_;
|
||||
const int nProcs_;
|
||||
|
||||
|
||||
// Buffer storage
|
||||
@ -266,7 +266,7 @@ public:
|
||||
(
|
||||
UPstream::commsTypes commsType = UPstream::commsTypes::nonBlocking,
|
||||
int tag = UPstream::msgType(),
|
||||
label communicator = UPstream::worldComm,
|
||||
int communicator = UPstream::worldComm,
|
||||
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
|
||||
);
|
||||
|
||||
@ -274,7 +274,7 @@ public:
|
||||
//- (default: nonBlocking), message tag, IO format (default: binary)
|
||||
explicit PstreamBuffers
|
||||
(
|
||||
label communicator,
|
||||
int communicator,
|
||||
UPstream::commsTypes commsType = UPstream::commsTypes::nonBlocking,
|
||||
int tag = UPstream::msgType(),
|
||||
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
|
||||
@ -287,7 +287,7 @@ public:
|
||||
//- (default: nonBlocking), IO format (default: binary)
|
||||
PstreamBuffers
|
||||
(
|
||||
label communicator,
|
||||
int communicator,
|
||||
int tag,
|
||||
UPstream::commsTypes commsType = UPstream::commsTypes::nonBlocking,
|
||||
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
|
||||
@ -306,34 +306,19 @@ public:
|
||||
// Attributes
|
||||
|
||||
//- The associated buffer format (ascii | binary)
|
||||
IOstreamOption::streamFormat format() const noexcept
|
||||
{
|
||||
return format_;
|
||||
}
|
||||
IOstreamOption::streamFormat format() const noexcept { return format_; }
|
||||
|
||||
//- The communications type of the stream
|
||||
UPstream::commsTypes commsType() const noexcept
|
||||
{
|
||||
return commsType_;
|
||||
}
|
||||
UPstream::commsTypes commsType() const noexcept { return commsType_; }
|
||||
|
||||
//- The transfer message tag
|
||||
int tag() const noexcept
|
||||
{
|
||||
return tag_;
|
||||
}
|
||||
int tag() const noexcept { return tag_; }
|
||||
|
||||
//- The communicator index
|
||||
label comm() const noexcept
|
||||
{
|
||||
return comm_;
|
||||
}
|
||||
int comm() const noexcept { return comm_; }
|
||||
|
||||
//- Number of ranks associated with PstreamBuffers
|
||||
label nProcs() const noexcept
|
||||
{
|
||||
return nProcs_;
|
||||
}
|
||||
int nProcs() const noexcept { return nProcs_; }
|
||||
|
||||
|
||||
// Sizing
|
||||
|
@ -124,7 +124,7 @@ protected:
|
||||
DynamicList<char>& receiveBuf,
|
||||
label& receiveBufPosition,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm,
|
||||
const int communicator = UPstream::worldComm,
|
||||
const bool clearAtEnd = false, // destroy receiveBuf if at end
|
||||
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
|
||||
);
|
||||
@ -252,7 +252,7 @@ public:
|
||||
DynamicList<char>& receiveBuf,
|
||||
label& receiveBufPosition,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm,
|
||||
const int communicator = UPstream::worldComm,
|
||||
const bool clearAtEnd = false, // destroy receiveBuf if at end
|
||||
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
|
||||
);
|
||||
@ -292,7 +292,7 @@ public:
|
||||
char* buf,
|
||||
const std::streamsize bufSize,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm,
|
||||
const int communicator = UPstream::worldComm,
|
||||
//! [out] request information (for non-blocking)
|
||||
UPstream::Request* req = nullptr
|
||||
);
|
||||
@ -307,7 +307,7 @@ public:
|
||||
char* buf,
|
||||
const std::streamsize bufSize,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm
|
||||
const int communicator = UPstream::worldComm
|
||||
)
|
||||
{
|
||||
return UIPstream::read
|
||||
@ -317,7 +317,7 @@ public:
|
||||
buf,
|
||||
bufSize,
|
||||
tag,
|
||||
comm,
|
||||
communicator,
|
||||
&req
|
||||
);
|
||||
}
|
||||
@ -332,7 +332,7 @@ public:
|
||||
const int fromProcNo,
|
||||
UList<Type>& buffer,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm,
|
||||
const int communicator = UPstream::worldComm,
|
||||
//! [out] request information (for non-blocking)
|
||||
UPstream::Request* req = nullptr
|
||||
)
|
||||
@ -344,7 +344,7 @@ public:
|
||||
buffer.data_bytes(),
|
||||
buffer.size_bytes(),
|
||||
tag,
|
||||
comm,
|
||||
communicator,
|
||||
req
|
||||
);
|
||||
}
|
||||
@ -359,7 +359,7 @@ public:
|
||||
const int fromProcNo,
|
||||
SubList<Type> buffer, // passed by shallow copy
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm,
|
||||
const int communicator = UPstream::worldComm,
|
||||
//! [out] request information (for non-blocking)
|
||||
UPstream::Request* req = nullptr
|
||||
)
|
||||
@ -371,7 +371,7 @@ public:
|
||||
buffer.data_bytes(),
|
||||
buffer.size_bytes(),
|
||||
tag,
|
||||
comm,
|
||||
communicator,
|
||||
req
|
||||
);
|
||||
}
|
||||
@ -387,7 +387,7 @@ public:
|
||||
const int fromProcNo,
|
||||
UList<Type>& buffer,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm
|
||||
const int communicator = UPstream::worldComm
|
||||
)
|
||||
{
|
||||
return UIPstream::read
|
||||
@ -397,7 +397,7 @@ public:
|
||||
buffer.data_bytes(),
|
||||
buffer.size_bytes(),
|
||||
tag,
|
||||
comm,
|
||||
communicator,
|
||||
&req
|
||||
);
|
||||
}
|
||||
@ -413,7 +413,7 @@ public:
|
||||
const int fromProcNo,
|
||||
SubList<Type> buffer, // passed by shallow copy
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm
|
||||
const int communicator = UPstream::worldComm
|
||||
)
|
||||
{
|
||||
return UIPstream::read
|
||||
@ -423,7 +423,7 @@ public:
|
||||
buffer.data_bytes(),
|
||||
buffer.size_bytes(),
|
||||
tag,
|
||||
comm,
|
||||
communicator,
|
||||
&req
|
||||
);
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ Foam::UIPstreamBase::UIPstreamBase
|
||||
DynamicList<char>& receiveBuf,
|
||||
label& receiveBufPosition,
|
||||
const int tag,
|
||||
const label comm,
|
||||
const int communicator,
|
||||
const bool clearAtEnd,
|
||||
IOstreamOption::streamFormat fmt
|
||||
)
|
||||
@ -176,7 +176,7 @@ Foam::UIPstreamBase::UIPstreamBase
|
||||
Istream(fmt),
|
||||
fromProcNo_(fromProcNo),
|
||||
tag_(tag),
|
||||
comm_(comm),
|
||||
comm_(communicator),
|
||||
messageSize_(0),
|
||||
storedRecvBufPos_(0),
|
||||
clearAtEnd_(clearAtEnd),
|
||||
|
@ -121,7 +121,7 @@ protected:
|
||||
const int toProcNo,
|
||||
DynamicList<char>& sendBuf,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm,
|
||||
const int communicator = UPstream::worldComm,
|
||||
const bool sendAtDestruct = true,
|
||||
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
|
||||
);
|
||||
@ -325,7 +325,7 @@ public:
|
||||
const int toProcNo,
|
||||
DynamicList<char>& sendBuf,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm,
|
||||
const int communicator = UPstream::worldComm,
|
||||
const bool sendAtDestruct = true,
|
||||
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
|
||||
);
|
||||
@ -367,7 +367,7 @@ public:
|
||||
const char* buf,
|
||||
const std::streamsize bufSize,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm,
|
||||
const int communicator = UPstream::worldComm,
|
||||
//! [out] request information (for non-blocking)
|
||||
UPstream::Request* req = nullptr,
|
||||
const UPstream::sendModes sendMode = UPstream::sendModes::normal
|
||||
@ -383,7 +383,7 @@ public:
|
||||
const char* buf,
|
||||
const std::streamsize bufSize,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm,
|
||||
const int communicator = UPstream::worldComm,
|
||||
const UPstream::sendModes sendMode = UPstream::sendModes::normal
|
||||
)
|
||||
{
|
||||
@ -394,7 +394,7 @@ public:
|
||||
buf,
|
||||
bufSize,
|
||||
tag,
|
||||
comm,
|
||||
communicator,
|
||||
&req,
|
||||
sendMode
|
||||
);
|
||||
@ -410,7 +410,7 @@ public:
|
||||
const int toProcNo,
|
||||
const UList<Type>& buffer,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm,
|
||||
const int communicator = UPstream::worldComm,
|
||||
//! [out] request information (for non-blocking)
|
||||
UPstream::Request* req = nullptr,
|
||||
const UPstream::sendModes sendMode = UPstream::sendModes::normal
|
||||
@ -423,7 +423,7 @@ public:
|
||||
buffer.cdata_bytes(),
|
||||
buffer.size_bytes(),
|
||||
tag,
|
||||
comm,
|
||||
communicator,
|
||||
req,
|
||||
sendMode
|
||||
);
|
||||
@ -440,7 +440,7 @@ public:
|
||||
const int toProcNo,
|
||||
const UList<Type>& buffer,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm,
|
||||
const int communicator = UPstream::worldComm,
|
||||
const UPstream::sendModes sendMode = UPstream::sendModes::normal
|
||||
)
|
||||
{
|
||||
@ -451,7 +451,7 @@ public:
|
||||
buffer.cdata_bytes(),
|
||||
buffer.size_bytes(),
|
||||
tag,
|
||||
comm,
|
||||
communicator,
|
||||
&req,
|
||||
sendMode
|
||||
);
|
||||
|
@ -146,7 +146,7 @@ Foam::UOPstreamBase::UOPstreamBase
|
||||
const int toProcNo,
|
||||
DynamicList<char>& sendBuf,
|
||||
const int tag,
|
||||
const label comm,
|
||||
const int communicator,
|
||||
const bool sendAtDestruct,
|
||||
IOstreamOption::streamFormat fmt
|
||||
)
|
||||
@ -155,7 +155,7 @@ Foam::UOPstreamBase::UOPstreamBase
|
||||
Ostream(fmt),
|
||||
toProcNo_(toProcNo),
|
||||
tag_(tag),
|
||||
comm_(comm),
|
||||
comm_(communicator),
|
||||
sendAtDestruct_(sendAtDestruct),
|
||||
sendBuf_(sendBuf)
|
||||
{
|
||||
|
@ -112,7 +112,7 @@ void Foam::UPstream::printTopoControl(Ostream& os)
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::UPstream::setParRun(const label nProcs, const bool haveThreads)
|
||||
void Foam::UPstream::setParRun(const int nProcs, const bool haveThreads)
|
||||
{
|
||||
parRun_ = (nProcs > 0);
|
||||
haveThreads_ = haveThreads;
|
||||
@ -725,7 +725,7 @@ void Foam::UPstream::printCommTree
|
||||
}
|
||||
|
||||
|
||||
bool Foam::UPstream::usingNodeComms(const label communicator)
|
||||
bool Foam::UPstream::usingNodeComms(const int communicator)
|
||||
{
|
||||
// Starting point must be "real" world-communicator
|
||||
// ("real" means without any local trickery with worldComm)
|
||||
@ -849,10 +849,10 @@ Foam::DynamicList<Foam::UPstream::commsStructList>
|
||||
Foam::UPstream::treeCommunication_(16);
|
||||
|
||||
|
||||
Foam::label Foam::UPstream::constWorldComm_(0);
|
||||
Foam::label Foam::UPstream::numNodes_(1);
|
||||
Foam::label Foam::UPstream::commInterNode_(-1);
|
||||
Foam::label Foam::UPstream::commLocalNode_(-1);
|
||||
int Foam::UPstream::constWorldComm_(0);
|
||||
int Foam::UPstream::commInterNode_(-1);
|
||||
int Foam::UPstream::commLocalNode_(-1);
|
||||
int Foam::UPstream::numNodes_(1);
|
||||
|
||||
Foam::label Foam::UPstream::worldComm(0); // Initially same as constWorldComm_
|
||||
Foam::label Foam::UPstream::warnComm(-1);
|
||||
@ -860,7 +860,7 @@ Foam::label Foam::UPstream::warnComm(-1);
|
||||
|
||||
// Predefine world and self communicator slots.
|
||||
// These are overwritten in parallel mode (by UPstream::setParRun())
|
||||
const Foam::label nPredefinedComm = []()
|
||||
const int nPredefinedComm = []()
|
||||
{
|
||||
// 0: COMM_WORLD : commGlobal(), constWorldComm_, worldComm
|
||||
(void) Foam::UPstream::newCommunicator(-1, Foam::labelRange(1), false);
|
||||
@ -894,7 +894,6 @@ registerOptSwitch
|
||||
Foam::UPstream::nodeCommsMin_
|
||||
);
|
||||
|
||||
|
||||
int Foam::UPstream::topologyControl_
|
||||
(
|
||||
Foam::debug::optimisationSwitch("topoControl", 0)
|
||||
|
@ -389,18 +389,18 @@ private:
|
||||
//- Index to the world-communicator as defined at startup
|
||||
//- (after any multi-world definitions).
|
||||
//- Is unaffected by any later changes to worldComm.
|
||||
static label constWorldComm_;
|
||||
|
||||
//- The number of shared/host nodes in the (const) world communicator.
|
||||
static label numNodes_;
|
||||
static int constWorldComm_;
|
||||
|
||||
//- Index to the inter-node communicator (between nodes),
|
||||
//- defined based on constWorldComm_
|
||||
static label commInterNode_;
|
||||
static int commInterNode_;
|
||||
|
||||
//- Index to the intra-host communicator (within a node),
|
||||
//- defined based on constWorldComm_
|
||||
static label commLocalNode_;
|
||||
static int commLocalNode_;
|
||||
|
||||
//- The number of shared/host nodes in the (const) world communicator.
|
||||
static int numNodes_;
|
||||
|
||||
//- Names of all worlds
|
||||
static wordList allWorlds_;
|
||||
@ -433,7 +433,7 @@ private:
|
||||
// Private Member Functions
|
||||
|
||||
//- Set data for parallel running
|
||||
static void setParRun(const label nProcs, const bool haveThreads);
|
||||
static void setParRun(const int nProcs, const bool haveThreads);
|
||||
|
||||
//- Initialise entries for new communicator.
|
||||
//
|
||||
@ -557,16 +557,16 @@ public:
|
||||
|
||||
//- Communicator for all ranks, irrespective of any local worlds.
|
||||
// This value \em never changes during a simulation.
|
||||
static constexpr label commGlobal() noexcept { return 0; }
|
||||
static constexpr int commGlobal() noexcept { return 0; }
|
||||
|
||||
//- Communicator within the current rank only
|
||||
// This value \em never changes during a simulation.
|
||||
static constexpr label commSelf() noexcept { return 1; }
|
||||
static constexpr int commSelf() noexcept { return 1; }
|
||||
|
||||
//- Communicator for all ranks (respecting any local worlds).
|
||||
// This value \em never changes after startup. Unlike the commWorld()
|
||||
// which can be temporarily overriden.
|
||||
static label commConstWorld() noexcept { return constWorldComm_; }
|
||||
static int commConstWorld() noexcept { return constWorldComm_; }
|
||||
|
||||
//- Communicator for all ranks (respecting any local worlds)
|
||||
static label commWorld() noexcept { return worldComm; }
|
||||
@ -601,13 +601,13 @@ public:
|
||||
// Host Communicators
|
||||
|
||||
//- Communicator between nodes/hosts (respects any local worlds)
|
||||
static label commInterNode() noexcept
|
||||
static int commInterNode() noexcept
|
||||
{
|
||||
return (parRun_ ? commInterNode_ : constWorldComm_);
|
||||
}
|
||||
|
||||
//- Communicator within the node/host (respects any local worlds)
|
||||
static label commLocalNode() noexcept
|
||||
static int commLocalNode() noexcept
|
||||
{
|
||||
return (parRun_ ? commLocalNode_ : constWorldComm_);
|
||||
}
|
||||
@ -626,7 +626,7 @@ public:
|
||||
//- it is running in parallel, the starting point is the
|
||||
//- world-communicator and it is not an odd corner case
|
||||
//- (ie, all processes on one node, all processes on different nodes)
|
||||
static bool usingNodeComms(const label communicator = worldComm);
|
||||
static bool usingNodeComms(const int communicator);
|
||||
|
||||
|
||||
// Constructors
|
||||
@ -1168,19 +1168,16 @@ public:
|
||||
}
|
||||
|
||||
//- The number of shared/host nodes in the (const) world communicator.
|
||||
static label numNodes() noexcept
|
||||
{
|
||||
return numNodes_;
|
||||
}
|
||||
static int numNodes() noexcept { return numNodes_; }
|
||||
|
||||
//- The parent communicator
|
||||
static label parent(const label communicator)
|
||||
static label parent(int communicator)
|
||||
{
|
||||
return parentComm_(communicator);
|
||||
}
|
||||
|
||||
//- The list of ranks within a given communicator
|
||||
static List<int>& procID(const label communicator)
|
||||
static List<int>& procID(int communicator)
|
||||
{
|
||||
return procIDs_[communicator];
|
||||
}
|
||||
@ -1694,7 +1691,7 @@ public:
|
||||
// UPstream::Communicator::lookup(UPstream::commWorld())
|
||||
// )
|
||||
// \endcode
|
||||
static Communicator lookup(const label comm);
|
||||
static Communicator lookup(const int comm);
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -1713,6 +1710,9 @@ public:
|
||||
|
||||
//- Reset to default constructed value (MPI_COMM_NULL)
|
||||
void reset() noexcept;
|
||||
|
||||
//- The number of ranks associated with the communicator
|
||||
int size() const;
|
||||
};
|
||||
|
||||
|
||||
|
@ -137,6 +137,11 @@ public:
|
||||
|
||||
//- Reset to default constructed value (MPI_WIN_NULL)
|
||||
void reset() noexcept;
|
||||
|
||||
//- The number of ranks associated with the window group.
|
||||
// The same as querying the original communicator, assuming the
|
||||
// communicator is available within the current code scope.
|
||||
int size() const;
|
||||
};
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2021-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -45,7 +45,7 @@ std::streamsize Foam::UIPstream::read
|
||||
char* buf,
|
||||
const std::streamsize bufSize,
|
||||
const int tag,
|
||||
const label communicator,
|
||||
const int communicator,
|
||||
UPstream::Request* req
|
||||
)
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2022-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2022-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -46,7 +46,7 @@ bool Foam::UOPstream::write
|
||||
const char* buf,
|
||||
const std::streamsize bufSize,
|
||||
const int tag,
|
||||
const label communicator,
|
||||
const int communicator,
|
||||
UPstream::Request* req,
|
||||
const UPstream::sendModes sendMode
|
||||
)
|
||||
|
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2024 OpenCFD Ltd.
|
||||
Copyright (C) 2024-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -38,7 +38,7 @@ Foam::UPstream::Communicator::Communicator() noexcept
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::UPstream::Communicator
|
||||
Foam::UPstream::Communicator::lookup(const label comm)
|
||||
Foam::UPstream::Communicator::lookup(const int comm)
|
||||
{
|
||||
return UPstream::Communicator(nullptr);
|
||||
}
|
||||
@ -56,4 +56,10 @@ void Foam::UPstream::Communicator::reset() noexcept
|
||||
{}
|
||||
|
||||
|
||||
int Foam::UPstream::Communicator::size() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
@ -47,4 +47,10 @@ void Foam::UPstream::Window::reset() noexcept
|
||||
{}
|
||||
|
||||
|
||||
int Foam::UPstream::Window::size() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -47,7 +47,7 @@ static std::streamsize UPstream_mpi_receive
|
||||
const std::streamsize bufSize,
|
||||
const int fromProcNo,
|
||||
const int tag,
|
||||
const Foam::label communicator,
|
||||
const int communicator,
|
||||
Foam::UPstream::Request* req
|
||||
)
|
||||
{
|
||||
@ -344,7 +344,7 @@ std::streamsize Foam::UIPstream::read
|
||||
char* buf,
|
||||
const std::streamsize bufSize,
|
||||
const int tag,
|
||||
const label communicator,
|
||||
const int communicator,
|
||||
UPstream::Request* req
|
||||
)
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -55,7 +55,7 @@ bool Foam::UOPstream::write
|
||||
const char* buf,
|
||||
const std::streamsize bufSize,
|
||||
const int tag,
|
||||
const label communicator,
|
||||
const int communicator,
|
||||
UPstream::Request* req,
|
||||
const UPstream::sendModes sendMode
|
||||
)
|
||||
|
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2024 OpenCFD Ltd.
|
||||
Copyright (C) 2024-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -39,7 +39,7 @@ Foam::UPstream::Communicator::Communicator() noexcept
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::UPstream::Communicator
|
||||
Foam::UPstream::Communicator::lookup(const label comm)
|
||||
Foam::UPstream::Communicator::lookup(const int comm)
|
||||
{
|
||||
if (comm < 0 || comm >= PstreamGlobals::MPICommunicators_.size())
|
||||
{
|
||||
@ -70,4 +70,27 @@ void Foam::UPstream::Communicator::reset() noexcept
|
||||
}
|
||||
|
||||
|
||||
int Foam::UPstream::Communicator::size() const
|
||||
{
|
||||
int val = 0;
|
||||
|
||||
MPI_Comm comm = PstreamUtils::Cast::to_mpi(*this);
|
||||
|
||||
if (MPI_COMM_SELF == comm)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if
|
||||
(
|
||||
(MPI_COMM_NULL == comm)
|
||||
|| (MPI_SUCCESS != MPI_Comm_size(comm, &val))
|
||||
)
|
||||
{
|
||||
val = 0;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
@ -50,4 +50,29 @@ void Foam::UPstream::Window::reset() noexcept
|
||||
}
|
||||
|
||||
|
||||
int Foam::UPstream::Window::size() const
|
||||
{
|
||||
int val = 0;
|
||||
|
||||
MPI_Win win = PstreamUtils::Cast::to_mpi(*this);
|
||||
MPI_Group group;
|
||||
|
||||
// Get num of ranks from the group information
|
||||
if
|
||||
(
|
||||
(MPI_WIN_NULL != win)
|
||||
&& (MPI_SUCCESS == MPI_Win_get_group(win, &group))
|
||||
)
|
||||
{
|
||||
if (MPI_SUCCESS != MPI_Group_size(group, &val))
|
||||
{
|
||||
val = 0;
|
||||
}
|
||||
MPI_Group_free(&group);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
Loading…
Reference in New Issue
Block a user