mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add internal parRun guards to some UPstream methods
- simplifies coding * finishedRequest(), waitRequest(), waitRequests() with parRun guards * nRequests() is noexcept - more consistent use of UPstream::defaultCommsType in branching
This commit is contained in:
@ -55,7 +55,7 @@ void do_exchangeBuf
|
||||
const bool wait
|
||||
)
|
||||
{
|
||||
const label startOfRequests = Pstream::nRequests();
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
|
||||
// Set up receives
|
||||
// ~~~~~~~~~~~~~~~
|
||||
@ -132,7 +132,7 @@ void do_exchangeContainer
|
||||
const bool wait
|
||||
)
|
||||
{
|
||||
const label startOfRequests = Pstream::nRequests();
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
|
||||
// Set up receives
|
||||
// ~~~~~~~~~~~~~~~
|
||||
|
||||
@ -43,7 +43,8 @@ void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
|
||||
{
|
||||
auto& fldBf = fld.boundaryFieldRef();
|
||||
|
||||
const UPstream::commsTypes commsType(UPstream::defaultCommsType);
|
||||
const UPstream::commsTypes commsType = UPstream::defaultCommsType;
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
|
||||
if
|
||||
(
|
||||
@ -51,8 +52,6 @@ void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
|
||||
|| commsType == UPstream::commsTypes::nonBlocking
|
||||
)
|
||||
{
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
|
||||
forAll(fldBf, patchi)
|
||||
{
|
||||
fvPatchField<Type>& tgtField = fldBf[patchi];
|
||||
@ -68,11 +67,7 @@ void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
|
||||
}
|
||||
|
||||
// Wait for outstanding requests
|
||||
if
|
||||
(
|
||||
UPstream::parRun()
|
||||
&& commsType == UPstream::commsTypes::nonBlocking
|
||||
)
|
||||
if (commsType == UPstream::commsTypes::nonBlocking)
|
||||
{
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
}
|
||||
|
||||
@ -396,19 +396,22 @@ public:
|
||||
|
||||
// Non-blocking comms
|
||||
|
||||
//- Get number of outstanding requests
|
||||
static label nRequests();
|
||||
//- Number of outstanding requests
|
||||
static label nRequests() noexcept;
|
||||
|
||||
//- Truncate number of outstanding requests
|
||||
static void resetRequests(const label sz);
|
||||
//- Truncate outstanding requests to given length
|
||||
static void resetRequests(const label n);
|
||||
|
||||
//- Wait until all requests (from start onwards) have finished.
|
||||
// A no-op if parRun() == false
|
||||
static void waitRequests(const label start = 0);
|
||||
|
||||
//- Wait until request i has finished.
|
||||
// A no-op if parRun() == false
|
||||
static void waitRequest(const label i);
|
||||
|
||||
//- Non-blocking comms: has request i finished?
|
||||
// A no-op and returns true if parRun() == false
|
||||
static bool finishedRequest(const label i);
|
||||
|
||||
static int allocateTag(const char*);
|
||||
|
||||
@ -437,7 +437,8 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::evaluate()
|
||||
/// InfoInFunction << nl;
|
||||
///}
|
||||
|
||||
const UPstream::commsTypes commsType(UPstream::defaultCommsType);
|
||||
const UPstream::commsTypes commsType = UPstream::defaultCommsType;
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
|
||||
if
|
||||
(
|
||||
@ -445,19 +446,13 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::evaluate()
|
||||
|| commsType == UPstream::commsTypes::nonBlocking
|
||||
)
|
||||
{
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
|
||||
for (auto& pfld : *this)
|
||||
{
|
||||
pfld.initEvaluate(commsType);
|
||||
}
|
||||
|
||||
// Wait for outstanding requests
|
||||
if
|
||||
(
|
||||
UPstream::parRun()
|
||||
&& commsType == Pstream::commsTypes::nonBlocking
|
||||
)
|
||||
if (commsType == Pstream::commsTypes::nonBlocking)
|
||||
{
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
}
|
||||
@ -506,7 +501,8 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::evaluateCoupled()
|
||||
/// InfoInFunction << nl;
|
||||
///}
|
||||
|
||||
const UPstream::commsTypes commsType(UPstream::defaultCommsType);
|
||||
const UPstream::commsTypes commsType = UPstream::defaultCommsType;
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
|
||||
if
|
||||
(
|
||||
@ -514,8 +510,6 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::evaluateCoupled()
|
||||
|| commsType == UPstream::commsTypes::nonBlocking
|
||||
)
|
||||
{
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
|
||||
for (auto& pfld : *this)
|
||||
{
|
||||
const auto* cpp = isA<CoupledPatchType>(pfld.patch());
|
||||
@ -527,11 +521,7 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::evaluateCoupled()
|
||||
}
|
||||
|
||||
// Wait for outstanding requests
|
||||
if
|
||||
(
|
||||
UPstream::parRun()
|
||||
&& commsType == UPstream::commsTypes::nonBlocking
|
||||
)
|
||||
if (commsType == UPstream::commsTypes::nonBlocking)
|
||||
{
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
}
|
||||
|
||||
@ -440,7 +440,7 @@ bool Foam::OFstreamCollator::write
|
||||
// Gather all data onto master. Is done in local communicator since
|
||||
// not in write thread. Note that we do not store in contiguous
|
||||
// buffer since that would limit to 2G chars.
|
||||
const label startOfRequests = Pstream::nRequests();
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
if (Pstream::master(localComm_))
|
||||
{
|
||||
for (label proci = 1; proci < slaveData.size(); proci++)
|
||||
@ -479,7 +479,7 @@ bool Foam::OFstreamCollator::write
|
||||
<< Foam::abort(FatalError);
|
||||
}
|
||||
}
|
||||
Pstream::waitRequests(startOfRequests);
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(mutex_);
|
||||
|
||||
@ -40,10 +40,12 @@ void Foam::LduMatrix<Type, DType, LUType>::initMatrixInterfaces
|
||||
Field<Type>& result
|
||||
) const
|
||||
{
|
||||
const UPstream::commsTypes commsType = UPstream::defaultCommsType;
|
||||
|
||||
if
|
||||
(
|
||||
Pstream::defaultCommsType == Pstream::commsTypes::blocking
|
||||
|| Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
|
||||
commsType == UPstream::commsTypes::blocking
|
||||
|| commsType == UPstream::commsTypes::nonBlocking
|
||||
)
|
||||
{
|
||||
forAll(interfaces_, interfacei)
|
||||
@ -59,12 +61,12 @@ void Foam::LduMatrix<Type, DType, LUType>::initMatrixInterfaces
|
||||
psiif,
|
||||
interfaceCoeffs[interfacei],
|
||||
//Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
|
||||
Pstream::defaultCommsType
|
||||
commsType
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Pstream::defaultCommsType == Pstream::commsTypes::scheduled)
|
||||
else if (commsType == UPstream::commsTypes::scheduled)
|
||||
{
|
||||
const lduSchedule& patchSchedule = this->patchSchedule();
|
||||
|
||||
@ -88,7 +90,7 @@ void Foam::LduMatrix<Type, DType, LUType>::initMatrixInterfaces
|
||||
psiif,
|
||||
interfaceCoeffs[interfacei],
|
||||
//Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
|
||||
Pstream::commsTypes::blocking
|
||||
UPstream::commsTypes::blocking
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -97,7 +99,7 @@ void Foam::LduMatrix<Type, DType, LUType>::initMatrixInterfaces
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unsupported communications type "
|
||||
<< Pstream::commsTypeNames[Pstream::defaultCommsType]
|
||||
<< UPstream::commsTypeNames[commsType]
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
@ -112,17 +114,18 @@ void Foam::LduMatrix<Type, DType, LUType>::updateMatrixInterfaces
|
||||
Field<Type>& result
|
||||
) const
|
||||
{
|
||||
const UPstream::commsTypes commsType = UPstream::defaultCommsType;
|
||||
|
||||
if
|
||||
(
|
||||
Pstream::defaultCommsType == Pstream::commsTypes::blocking
|
||||
|| Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
|
||||
commsType == UPstream::commsTypes::blocking
|
||||
|| commsType == UPstream::commsTypes::nonBlocking
|
||||
)
|
||||
{
|
||||
// Block until all sends/receives have been finished
|
||||
if (Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking)
|
||||
if (commsType == UPstream::commsTypes::nonBlocking)
|
||||
{
|
||||
IPstream::waitRequests();
|
||||
OPstream::waitRequests();
|
||||
UPstream::waitRequests();
|
||||
}
|
||||
|
||||
forAll(interfaces_, interfacei)
|
||||
@ -138,12 +141,12 @@ void Foam::LduMatrix<Type, DType, LUType>::updateMatrixInterfaces
|
||||
psiif,
|
||||
interfaceCoeffs[interfacei],
|
||||
//Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
|
||||
Pstream::defaultCommsType
|
||||
commsType
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Pstream::defaultCommsType == Pstream::commsTypes::scheduled)
|
||||
else if (commsType == UPstream::commsTypes::scheduled)
|
||||
{
|
||||
const lduSchedule& patchSchedule = this->patchSchedule();
|
||||
|
||||
@ -165,7 +168,7 @@ void Foam::LduMatrix<Type, DType, LUType>::updateMatrixInterfaces
|
||||
psiif,
|
||||
interfaceCoeffs[interfacei],
|
||||
//Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
|
||||
Pstream::commsTypes::scheduled
|
||||
commsType
|
||||
);
|
||||
}
|
||||
else
|
||||
@ -179,7 +182,7 @@ void Foam::LduMatrix<Type, DType, LUType>::updateMatrixInterfaces
|
||||
psiif,
|
||||
interfaceCoeffs[interfacei],
|
||||
//Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
|
||||
Pstream::commsTypes::scheduled
|
||||
commsType
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -214,7 +217,7 @@ void Foam::LduMatrix<Type, DType, LUType>::updateMatrixInterfaces
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unsupported communications type "
|
||||
<< Pstream::commsTypeNames[Pstream::defaultCommsType]
|
||||
<< UPstream::commsTypeNames[commsType]
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ bool Foam::lduCalculatedProcessorField<Type>::ready() const
|
||||
if
|
||||
(
|
||||
this->outstandingSendRequest_ >= 0
|
||||
&& this->outstandingSendRequest_ < Pstream::nRequests()
|
||||
&& this->outstandingSendRequest_ < UPstream::nRequests()
|
||||
)
|
||||
{
|
||||
if (!UPstream::finishedRequest(this->outstandingSendRequest_))
|
||||
@ -84,7 +84,7 @@ bool Foam::lduCalculatedProcessorField<Type>::ready() const
|
||||
if
|
||||
(
|
||||
this->outstandingRecvRequest_ >= 0
|
||||
&& this->outstandingRecvRequest_ < Pstream::nRequests()
|
||||
&& this->outstandingRecvRequest_ < UPstream::nRequests()
|
||||
)
|
||||
{
|
||||
if (!UPstream::finishedRequest(this->outstandingRecvRequest_))
|
||||
@ -210,7 +210,7 @@ void Foam::lduCalculatedProcessorField<Type>::updateInterfaceMatrix
|
||||
if
|
||||
(
|
||||
outstandingRecvRequest_ >= 0
|
||||
&& outstandingRecvRequest_ < Pstream::nRequests()
|
||||
&& outstandingRecvRequest_ < UPstream::nRequests()
|
||||
)
|
||||
{
|
||||
UPstream::waitRequest(outstandingRecvRequest_);
|
||||
|
||||
@ -56,7 +56,7 @@ void Foam::lduMatrix::Amul
|
||||
const scalar* const __restrict__ upperPtr = upper().begin();
|
||||
const scalar* const __restrict__ lowerPtr = lower().begin();
|
||||
|
||||
const label startRequest = Pstream::nRequests();
|
||||
const label startRequest = UPstream::nRequests();
|
||||
|
||||
// Initialise the update of interfaced interfaces
|
||||
initMatrixInterfaces
|
||||
@ -122,7 +122,7 @@ void Foam::lduMatrix::Tmul
|
||||
const scalar* const __restrict__ lowerPtr = lower().begin();
|
||||
const scalar* const __restrict__ upperPtr = upper().begin();
|
||||
|
||||
const label startRequest = Pstream::nRequests();
|
||||
const label startRequest = UPstream::nRequests();
|
||||
|
||||
// Initialise the update of interfaced interfaces
|
||||
initMatrixInterfaces
|
||||
@ -246,7 +246,7 @@ void Foam::lduMatrix::residual
|
||||
// To compensate for this, it is necessary to turn the
|
||||
// sign of the contribution.
|
||||
|
||||
const label startRequest = Pstream::nRequests();
|
||||
const label startRequest = UPstream::nRequests();
|
||||
|
||||
// Initialise the update of interfaced interfaces
|
||||
initMatrixInterfaces
|
||||
|
||||
@ -40,10 +40,12 @@ void Foam::lduMatrix::initMatrixInterfaces
|
||||
const direction cmpt
|
||||
) const
|
||||
{
|
||||
const UPstream::commsTypes commsType = UPstream::defaultCommsType;
|
||||
|
||||
if
|
||||
(
|
||||
Pstream::defaultCommsType == Pstream::commsTypes::blocking
|
||||
|| Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
|
||||
commsType == UPstream::commsTypes::blocking
|
||||
|| commsType == UPstream::commsTypes::nonBlocking
|
||||
)
|
||||
{
|
||||
forAll(interfaces, interfacei)
|
||||
@ -59,12 +61,12 @@ void Foam::lduMatrix::initMatrixInterfaces
|
||||
psiif,
|
||||
coupleCoeffs[interfacei],
|
||||
cmpt,
|
||||
Pstream::defaultCommsType
|
||||
commsType
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Pstream::defaultCommsType == Pstream::commsTypes::scheduled)
|
||||
else if (commsType == UPstream::commsTypes::scheduled)
|
||||
{
|
||||
const lduSchedule& patchSchedule = this->patchSchedule();
|
||||
|
||||
@ -88,7 +90,7 @@ void Foam::lduMatrix::initMatrixInterfaces
|
||||
psiif,
|
||||
coupleCoeffs[interfacei],
|
||||
cmpt,
|
||||
Pstream::commsTypes::blocking
|
||||
UPstream::commsTypes::blocking
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -97,7 +99,7 @@ void Foam::lduMatrix::initMatrixInterfaces
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unsupported communications type "
|
||||
<< Pstream::commsTypeNames[Pstream::defaultCommsType]
|
||||
<< UPstream::commsTypeNames[commsType]
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
@ -114,7 +116,9 @@ void Foam::lduMatrix::updateMatrixInterfaces
|
||||
const label startRequest
|
||||
) const
|
||||
{
|
||||
if (Pstream::defaultCommsType == Pstream::commsTypes::blocking)
|
||||
const UPstream::commsTypes commsType = UPstream::defaultCommsType;
|
||||
|
||||
if (commsType == UPstream::commsTypes::blocking)
|
||||
{
|
||||
forAll(interfaces, interfacei)
|
||||
{
|
||||
@ -129,12 +133,12 @@ void Foam::lduMatrix::updateMatrixInterfaces
|
||||
psiif,
|
||||
coupleCoeffs[interfacei],
|
||||
cmpt,
|
||||
Pstream::defaultCommsType
|
||||
commsType
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking)
|
||||
else if (commsType == UPstream::commsTypes::nonBlocking)
|
||||
{
|
||||
// Try and consume interfaces as they become available
|
||||
bool allUpdated = false;
|
||||
@ -160,7 +164,7 @@ void Foam::lduMatrix::updateMatrixInterfaces
|
||||
psiif,
|
||||
coupleCoeffs[interfacei],
|
||||
cmpt,
|
||||
Pstream::defaultCommsType
|
||||
commsType
|
||||
);
|
||||
}
|
||||
else
|
||||
@ -210,12 +214,12 @@ void Foam::lduMatrix::updateMatrixInterfaces
|
||||
psiif,
|
||||
coupleCoeffs[interfacei],
|
||||
cmpt,
|
||||
Pstream::defaultCommsType
|
||||
commsType
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Pstream::defaultCommsType == Pstream::commsTypes::scheduled)
|
||||
else if (commsType == UPstream::commsTypes::scheduled)
|
||||
{
|
||||
const lduSchedule& patchSchedule = this->patchSchedule();
|
||||
|
||||
@ -237,7 +241,7 @@ void Foam::lduMatrix::updateMatrixInterfaces
|
||||
psiif,
|
||||
coupleCoeffs[interfacei],
|
||||
cmpt,
|
||||
Pstream::commsTypes::scheduled
|
||||
commsType
|
||||
);
|
||||
}
|
||||
else
|
||||
@ -251,7 +255,7 @@ void Foam::lduMatrix::updateMatrixInterfaces
|
||||
psiif,
|
||||
coupleCoeffs[interfacei],
|
||||
cmpt,
|
||||
Pstream::commsTypes::scheduled
|
||||
commsType
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -286,7 +290,7 @@ void Foam::lduMatrix::updateMatrixInterfaces
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unsupported communications type "
|
||||
<< Pstream::commsTypeNames[Pstream::defaultCommsType]
|
||||
<< UPstream::commsTypeNames[commsType]
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ void Foam::GaussSeidelSmoother::smooth
|
||||
{
|
||||
bPrime = source;
|
||||
|
||||
const label startRequest = Pstream::nRequests();
|
||||
const label startRequest = UPstream::nRequests();
|
||||
|
||||
matrix_.initMatrixInterfaces
|
||||
(
|
||||
|
||||
@ -142,7 +142,7 @@ void Foam::nonBlockingGaussSeidelSmoother::smooth
|
||||
{
|
||||
bPrime = source;
|
||||
|
||||
const label startRequest = Pstream::nRequests();
|
||||
const label startRequest = UPstream::nRequests();
|
||||
|
||||
matrix_.initMatrixInterfaces
|
||||
(
|
||||
|
||||
@ -115,7 +115,7 @@ void Foam::symGaussSeidelSmoother::smooth
|
||||
{
|
||||
bPrime = source;
|
||||
|
||||
const label startRequest = Pstream::nRequests();
|
||||
const label startRequest = UPstream::nRequests();
|
||||
|
||||
matrix_.initMatrixInterfaces
|
||||
(
|
||||
|
||||
@ -272,7 +272,7 @@ void Foam::GAMGAgglomeration::agglomerateLduAddressing
|
||||
patchFaceRestrictAddressing_[fineLevelIndex];
|
||||
|
||||
|
||||
const label nReq = Pstream::nRequests();
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
|
||||
// Initialise transfer of restrict addressing on the interface
|
||||
// The finest mesh uses patchAddr from the original lduAdressing.
|
||||
@ -301,10 +301,7 @@ void Foam::GAMGAgglomeration::agglomerateLduAddressing
|
||||
}
|
||||
}
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
Pstream::waitRequests(nReq);
|
||||
}
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
|
||||
|
||||
// Add the coarse level
|
||||
|
||||
@ -147,7 +147,7 @@ Foam::labelListList Foam::GAMGProcAgglomeration::globalCellCells
|
||||
// Get the interface cells
|
||||
PtrList<labelList> nbrGlobalCells(interfaces.size());
|
||||
{
|
||||
const label nReq = Pstream::nRequests();
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
|
||||
// Initialise transfer of restrict addressing on the interface
|
||||
forAll(interfaces, inti)
|
||||
@ -162,10 +162,7 @@ Foam::labelListList Foam::GAMGProcAgglomeration::globalCellCells
|
||||
}
|
||||
}
|
||||
|
||||
if (UPstream::parRun())
|
||||
{
|
||||
UPstream::waitRequests(nReq);
|
||||
}
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
|
||||
forAll(interfaces, inti)
|
||||
{
|
||||
|
||||
@ -52,7 +52,7 @@ void Foam::GAMGSolver::interpolate
|
||||
Apsi = 0;
|
||||
solveScalar* __restrict__ ApsiPtr = Apsi.begin();
|
||||
|
||||
const label startRequest = Pstream::nRequests();
|
||||
const label startRequest = UPstream::nRequests();
|
||||
|
||||
m.initMatrixInterfaces
|
||||
(
|
||||
|
||||
@ -169,7 +169,7 @@ void Foam::processorGAMGInterfaceField::updateInterfaceMatrix
|
||||
if
|
||||
(
|
||||
outstandingRecvRequest_ >= 0
|
||||
&& outstandingRecvRequest_ < Pstream::nRequests()
|
||||
&& outstandingRecvRequest_ < UPstream::nRequests()
|
||||
)
|
||||
{
|
||||
UPstream::waitRequest(outstandingRecvRequest_);
|
||||
|
||||
@ -170,9 +170,9 @@ Foam::solverPerformance Foam::PPCG::scalarSolveCG
|
||||
)
|
||||
{
|
||||
// Make sure gamma,delta are available
|
||||
if (Pstream::parRun() && outstandingRequest != -1)
|
||||
if (outstandingRequest != -1)
|
||||
{
|
||||
Pstream::waitRequest(outstandingRequest);
|
||||
UPstream::waitRequest(outstandingRequest);
|
||||
outstandingRequest = -1;
|
||||
}
|
||||
|
||||
@ -249,9 +249,9 @@ Foam::solverPerformance Foam::PPCG::scalarSolveCG
|
||||
}
|
||||
|
||||
// Cleanup any outstanding requests
|
||||
if (Pstream::parRun() && outstandingRequest != -1)
|
||||
if (outstandingRequest != -1)
|
||||
{
|
||||
Pstream::waitRequest(outstandingRequest);
|
||||
UPstream::waitRequest(outstandingRequest);
|
||||
}
|
||||
|
||||
return solverPerf;
|
||||
|
||||
@ -129,10 +129,8 @@ Foam::labelListList Foam::lduPrimitiveMesh::globalCellCells
|
||||
}
|
||||
}
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
Pstream::waitRequests();
|
||||
}
|
||||
// Wait for all
|
||||
UPstream::waitRequests();
|
||||
|
||||
forAll(interfaces, inti)
|
||||
{
|
||||
|
||||
@ -186,8 +186,8 @@ void Foam::mapDistributeBase::exchangeMasks
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for all to finish
|
||||
Pstream::waitRequests(startOfRequests);
|
||||
// Wait for outstanding requests
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
}
|
||||
|
||||
// Receiving myself is just a copy
|
||||
|
||||
@ -584,8 +584,7 @@ void Foam::mapDistributeBase::distribute
|
||||
}
|
||||
|
||||
|
||||
// Wait for all to finish
|
||||
|
||||
// Wait for outstanding requests
|
||||
Pstream::waitRequests(nOutstanding);
|
||||
|
||||
|
||||
@ -1044,8 +1043,7 @@ void Foam::mapDistributeBase::distribute
|
||||
}
|
||||
|
||||
|
||||
// Wait for all to finish
|
||||
|
||||
// Wait for outstanding requests
|
||||
Pstream::waitRequests(nOutstanding);
|
||||
|
||||
|
||||
|
||||
@ -142,7 +142,7 @@ void Foam::globalIndex::gatherValues
|
||||
|
||||
if (commsType == UPstream::commsTypes::nonBlocking)
|
||||
{
|
||||
// Wait for all to finish
|
||||
// Wait for outstanding requests
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
}
|
||||
}
|
||||
@ -242,7 +242,7 @@ void Foam::globalIndex::gather
|
||||
|
||||
if (commsType == UPstream::commsTypes::nonBlocking)
|
||||
{
|
||||
// Wait for all to finish
|
||||
// Wait for outstanding requests
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
}
|
||||
}
|
||||
@ -338,7 +338,7 @@ void Foam::globalIndex::gather
|
||||
|
||||
if (commsType == UPstream::commsTypes::nonBlocking)
|
||||
{
|
||||
// Wait for all to finish
|
||||
// Wait for outstanding requests
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
}
|
||||
}
|
||||
@ -945,7 +945,7 @@ void Foam::globalIndex::scatter
|
||||
|
||||
if (commsType == UPstream::commsTypes::nonBlocking)
|
||||
{
|
||||
// Wait for all to finish
|
||||
// Wait for outstanding requests
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,13 +87,13 @@ void Foam::UPstream::freePstreamCommunicator(const label)
|
||||
{}
|
||||
|
||||
|
||||
Foam::label Foam::UPstream::nRequests()
|
||||
Foam::label Foam::UPstream::nRequests() noexcept
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void Foam::UPstream::resetRequests(const label i)
|
||||
void Foam::UPstream::resetRequests(const label n)
|
||||
{}
|
||||
|
||||
|
||||
@ -107,8 +107,7 @@ void Foam::UPstream::waitRequest(const label i)
|
||||
|
||||
bool Foam::UPstream::finishedRequest(const label i)
|
||||
{
|
||||
NotImplemented;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -609,23 +609,28 @@ void Foam::UPstream::freePstreamCommunicator(const label communicator)
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::UPstream::nRequests()
|
||||
Foam::label Foam::UPstream::nRequests() noexcept
|
||||
{
|
||||
return PstreamGlobals::outstandingRequests_.size();
|
||||
}
|
||||
|
||||
|
||||
void Foam::UPstream::resetRequests(const label i)
|
||||
void Foam::UPstream::resetRequests(const label n)
|
||||
{
|
||||
if (i < PstreamGlobals::outstandingRequests_.size())
|
||||
if (n >= 0 && n < PstreamGlobals::outstandingRequests_.size())
|
||||
{
|
||||
PstreamGlobals::outstandingRequests_.setSize(i);
|
||||
PstreamGlobals::outstandingRequests_.resize(n);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::UPstream::waitRequests(const label start)
|
||||
{
|
||||
if (!UPstream::parRun())
|
||||
{
|
||||
return; // No-op for non-parallel
|
||||
}
|
||||
|
||||
if (UPstream::debug)
|
||||
{
|
||||
Pout<< "UPstream::waitRequests : starting wait for "
|
||||
@ -672,6 +677,11 @@ void Foam::UPstream::waitRequests(const label start)
|
||||
|
||||
void Foam::UPstream::waitRequest(const label i)
|
||||
{
|
||||
if (!UPstream::parRun())
|
||||
{
|
||||
return; // No-op for non-parallel
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "UPstream::waitRequest : starting wait for request:" << i
|
||||
@ -717,13 +727,18 @@ void Foam::UPstream::waitRequest(const label i)
|
||||
|
||||
bool Foam::UPstream::finishedRequest(const label i)
|
||||
{
|
||||
if (!UPstream::parRun())
|
||||
{
|
||||
return true; // No-op for non-parallel
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "UPstream::finishedRequest : checking request:" << i
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (i >= PstreamGlobals::outstandingRequests_.size())
|
||||
if (i < 0 || i >= PstreamGlobals::outstandingRequests_.size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "There are " << PstreamGlobals::outstandingRequests_.size()
|
||||
|
||||
@ -305,7 +305,7 @@ Foam::faMeshDistributor::distribute
|
||||
// Processor-processor connections
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
const label startOfRequests = Pstream::nRequests();
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
|
||||
const faBoundaryMesh& oldBndMesh = oldMesh.boundary();
|
||||
|
||||
@ -339,8 +339,9 @@ Foam::faMeshDistributor::distribute
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for all to finish
|
||||
Pstream::waitRequests(startOfRequests);
|
||||
// Wait for outstanding requests
|
||||
// (commsType == UPstream::commsTypes::nonBlocking)
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
|
||||
// Receive values
|
||||
for (const faPatch& fap : oldBndMesh)
|
||||
|
||||
@ -111,7 +111,7 @@ Foam::SolverPerformance<Type> Foam::faMatrix<Type>::solve
|
||||
PrecisionAdaptor<solveScalar, scalar> sourceCmpt_ss(sourceCmpt);
|
||||
ConstPrecisionAdaptor<solveScalar, scalar> psiCmpt_ss(psiCmpt);
|
||||
|
||||
const label startRequest = Pstream::nRequests();
|
||||
const label startRequest = UPstream::nRequests();
|
||||
|
||||
initMatrixInterfaces
|
||||
(
|
||||
|
||||
@ -92,7 +92,7 @@ bool Foam::calculatedProcessorFvPatchField<Type>::ready() const
|
||||
if
|
||||
(
|
||||
this->outstandingSendRequest_ >= 0
|
||||
&& this->outstandingSendRequest_ < Pstream::nRequests()
|
||||
&& this->outstandingSendRequest_ < UPstream::nRequests()
|
||||
)
|
||||
{
|
||||
if (!UPstream::finishedRequest(this->outstandingSendRequest_))
|
||||
@ -105,7 +105,7 @@ bool Foam::calculatedProcessorFvPatchField<Type>::ready() const
|
||||
if
|
||||
(
|
||||
this->outstandingRecvRequest_ >= 0
|
||||
&& this->outstandingRecvRequest_ < Pstream::nRequests()
|
||||
&& this->outstandingRecvRequest_ < UPstream::nRequests()
|
||||
)
|
||||
{
|
||||
if (!UPstream::finishedRequest(this->outstandingRecvRequest_))
|
||||
@ -201,7 +201,7 @@ void Foam::calculatedProcessorFvPatchField<Type>::evaluate
|
||||
if
|
||||
(
|
||||
outstandingRecvRequest_ >= 0
|
||||
&& outstandingRecvRequest_ < Pstream::nRequests()
|
||||
&& outstandingRecvRequest_ < UPstream::nRequests()
|
||||
)
|
||||
{
|
||||
UPstream::waitRequest(outstandingRecvRequest_);
|
||||
@ -327,7 +327,7 @@ void Foam::calculatedProcessorFvPatchField<Type>::updateInterfaceMatrix
|
||||
if
|
||||
(
|
||||
outstandingRecvRequest_ >= 0
|
||||
&& outstandingRecvRequest_ < Pstream::nRequests()
|
||||
&& outstandingRecvRequest_ < UPstream::nRequests()
|
||||
)
|
||||
{
|
||||
UPstream::waitRequest(outstandingRecvRequest_);
|
||||
|
||||
@ -283,7 +283,7 @@ void Foam::processorFvPatchField<Type>::evaluate
|
||||
if
|
||||
(
|
||||
outstandingRecvRequest_ >= 0
|
||||
&& outstandingRecvRequest_ < Pstream::nRequests()
|
||||
&& outstandingRecvRequest_ < UPstream::nRequests()
|
||||
)
|
||||
{
|
||||
UPstream::waitRequest(outstandingRecvRequest_);
|
||||
@ -416,7 +416,7 @@ void Foam::processorFvPatchField<Type>::updateInterfaceMatrix
|
||||
if
|
||||
(
|
||||
outstandingRecvRequest_ >= 0
|
||||
&& outstandingRecvRequest_ < Pstream::nRequests()
|
||||
&& outstandingRecvRequest_ < UPstream::nRequests()
|
||||
)
|
||||
{
|
||||
UPstream::waitRequest(outstandingRecvRequest_);
|
||||
@ -565,7 +565,7 @@ void Foam::processorFvPatchField<Type>::updateInterfaceMatrix
|
||||
if
|
||||
(
|
||||
outstandingRecvRequest_ >= 0
|
||||
&& outstandingRecvRequest_ < Pstream::nRequests()
|
||||
&& outstandingRecvRequest_ < UPstream::nRequests()
|
||||
)
|
||||
{
|
||||
UPstream::waitRequest(outstandingRecvRequest_);
|
||||
@ -606,11 +606,10 @@ bool Foam::processorFvPatchField<Type>::ready() const
|
||||
if
|
||||
(
|
||||
outstandingSendRequest_ >= 0
|
||||
&& outstandingSendRequest_ < Pstream::nRequests()
|
||||
&& outstandingSendRequest_ < UPstream::nRequests()
|
||||
)
|
||||
{
|
||||
bool finished = UPstream::finishedRequest(outstandingSendRequest_);
|
||||
if (!finished)
|
||||
if (!UPstream::finishedRequest(outstandingSendRequest_))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -620,11 +619,10 @@ bool Foam::processorFvPatchField<Type>::ready() const
|
||||
if
|
||||
(
|
||||
outstandingRecvRequest_ >= 0
|
||||
&& outstandingRecvRequest_ < Pstream::nRequests()
|
||||
&& outstandingRecvRequest_ < UPstream::nRequests()
|
||||
)
|
||||
{
|
||||
bool finished = UPstream::finishedRequest(outstandingRecvRequest_);
|
||||
if (!finished)
|
||||
if (!UPstream::finishedRequest(outstandingRecvRequest_))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ Foam::SolverPerformance<Type> Foam::fvMatrix<Type>::solveSegregated
|
||||
PrecisionAdaptor<solveScalar, scalar> sourceCmpt_ss(sourceCmpt);
|
||||
ConstPrecisionAdaptor<solveScalar, scalar> psiCmpt_ss(psiCmpt);
|
||||
|
||||
const label startRequest = Pstream::nRequests();
|
||||
const label startRequest = UPstream::nRequests();
|
||||
|
||||
initMatrixInterfaces
|
||||
(
|
||||
|
||||
@ -108,6 +108,7 @@ void Foam::volPointInterpolation::addSeparated
|
||||
}
|
||||
|
||||
// Wait for outstanding requests
|
||||
// (commsType == UPstream::commsTypes::nonBlocking)
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
|
||||
forAll(pfbf, patchi)
|
||||
|
||||
@ -38,7 +38,8 @@ void Foam::functionObjects::mapFields::evaluateConstraintTypes
|
||||
{
|
||||
auto& fldBf = fld.boundaryFieldRef();
|
||||
|
||||
const UPstream::commsTypes commsType(UPstream::defaultCommsType);
|
||||
const UPstream::commsTypes commsType = UPstream::defaultCommsType;
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
|
||||
if
|
||||
(
|
||||
@ -46,8 +47,6 @@ void Foam::functionObjects::mapFields::evaluateConstraintTypes
|
||||
|| commsType == UPstream::commsTypes::nonBlocking
|
||||
)
|
||||
{
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
|
||||
forAll(fldBf, patchi)
|
||||
{
|
||||
fvPatchField<Type>& tgtField = fldBf[patchi];
|
||||
@ -63,11 +62,7 @@ void Foam::functionObjects::mapFields::evaluateConstraintTypes
|
||||
}
|
||||
|
||||
// Wait for outstanding requests
|
||||
if
|
||||
(
|
||||
UPstream::parRun()
|
||||
&& commsType == UPstream::commsTypes::nonBlocking
|
||||
)
|
||||
if (commsType == UPstream::commsTypes::nonBlocking)
|
||||
{
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ void Foam::MGridGenGAMGAgglomeration::swap
|
||||
PtrList<labelList>& nbrValues
|
||||
) const
|
||||
{
|
||||
const label nReq = Pstream::nRequests();
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
|
||||
// Initialise transfer of restrict addressing on the interface
|
||||
forAll(interfaces, inti)
|
||||
@ -70,10 +70,10 @@ void Foam::MGridGenGAMGAgglomeration::swap
|
||||
}
|
||||
}
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
Pstream::waitRequests(nReq);
|
||||
}
|
||||
// Wait for outstanding requests
|
||||
// (commsType == UPstream::commsTypes::nonBlocking)
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
|
||||
|
||||
// Get the interface agglomeration
|
||||
nbrValues.setSize(interfaces.size());
|
||||
|
||||
@ -119,22 +119,19 @@ void Foam::dynamicOversetFvMesh::correctBoundaryConditions
|
||||
const bool typeOnly
|
||||
)
|
||||
{
|
||||
const UPstream::commsTypes commsType = UPstream::defaultCommsType;
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
|
||||
forAll(bfld, patchi)
|
||||
{
|
||||
if (typeOnly == (isA<PatchType>(bfld[patchi]) != nullptr))
|
||||
{
|
||||
bfld[patchi].initEvaluate(UPstream::defaultCommsType);
|
||||
bfld[patchi].initEvaluate(commsType);
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for outstanding requests
|
||||
if
|
||||
(
|
||||
UPstream::parRun()
|
||||
&& UPstream::defaultCommsType == UPstream::commsTypes::nonBlocking
|
||||
)
|
||||
if (commsType == UPstream::commsTypes::nonBlocking)
|
||||
{
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
}
|
||||
@ -143,7 +140,7 @@ void Foam::dynamicOversetFvMesh::correctBoundaryConditions
|
||||
{
|
||||
if (typeOnly == (isA<PatchType>(bfld[patchi]) != nullptr))
|
||||
{
|
||||
bfld[patchi].evaluate(UPstream::defaultCommsType);
|
||||
bfld[patchi].evaluate(commsType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -903,6 +900,7 @@ void Foam::dynamicOversetFvMesh::correctCoupledBoundaryConditions(GeoField& fld)
|
||||
{
|
||||
typename GeoField::Boundary& bfld = fld.boundaryFieldRef();
|
||||
|
||||
const UPstream::commsTypes commsType = UPstream::defaultCommsType;
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
|
||||
forAll(bfld, patchi)
|
||||
@ -910,16 +908,12 @@ void Foam::dynamicOversetFvMesh::correctCoupledBoundaryConditions(GeoField& fld)
|
||||
if (bfld[patchi].coupled())
|
||||
{
|
||||
//Pout<< "initEval of " << bfld[patchi].patch().name() << endl;
|
||||
bfld[patchi].initEvaluate(Pstream::defaultCommsType);
|
||||
bfld[patchi].initEvaluate(commsType);
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for outstanding requests
|
||||
if
|
||||
(
|
||||
UPstream::parRun()
|
||||
&& UPstream::defaultCommsType == UPstream::commsTypes::nonBlocking
|
||||
)
|
||||
if (commsType == UPstream::commsTypes::nonBlocking)
|
||||
{
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
}
|
||||
@ -929,7 +923,7 @@ void Foam::dynamicOversetFvMesh::correctCoupledBoundaryConditions(GeoField& fld)
|
||||
if (bfld[patchi].coupled())
|
||||
{
|
||||
//Pout<< "eval of " << bfld[patchi].patch().name() << endl;
|
||||
bfld[patchi].evaluate(Pstream::defaultCommsType);
|
||||
bfld[patchi].evaluate(commsType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,7 +171,7 @@ void Foam::calculatedProcessorGAMGInterfaceField::updateInterfaceMatrix
|
||||
if
|
||||
(
|
||||
outstandingRecvRequest_ >= 0
|
||||
&& outstandingRecvRequest_ < Pstream::nRequests()
|
||||
&& outstandingRecvRequest_ < UPstream::nRequests()
|
||||
)
|
||||
{
|
||||
UPstream::waitRequest(outstandingRecvRequest_);
|
||||
|
||||
@ -130,9 +130,9 @@ Foam::label Foam::metisLikeDecomp::decomposeGeneral
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for outstanding requests
|
||||
if (commsType == UPstream::commsTypes::nonBlocking)
|
||||
{
|
||||
// Wait for all to finish
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user