ENH: earlier exit from interface polling in updateMatrixInterfaces

- exit the wait-some polling loop when no interfaces are left
  to be updated
This commit is contained in:
Mark Olesen
2023-05-08 17:41:47 +02:00
parent 98c42479f6
commit bddda09a08
2 changed files with 64 additions and 29 deletions

View File

@ -128,28 +128,42 @@ void Foam::LduMatrix<Type, DType, LUType>::updateMatrixInterfaces
// without waiting for all requests. // without waiting for all requests.
DynamicList<int> indices; // (work array) DynamicList<int> indices; // (work array)
while
for
( (
UPstream::nPollProcInterfaces < 0 bool pollingActive = (UPstream::nPollProcInterfaces < 0);
&& UPstream::waitSomeRequests(startRequest, &indices) (
pollingActive
&& UPstream::waitSomeRequests(startRequest, &indices)
);
/*nil*/
) )
{ {
pollingActive = false;
forAll(interfaces_, interfacei) forAll(interfaces_, interfacei)
{ {
auto* intf = interfaces_.get(interfacei); auto* intf = interfaces_.get(interfacei);
if (intf && !intf->updatedMatrix() && intf->ready()) if (intf && !intf->updatedMatrix())
{ {
intf->updateInterfaceMatrix if (intf->ready())
( {
result, intf->updateInterfaceMatrix
add, (
lduMesh_.lduAddr(), result,
interfacei, add,
psiif, lduMesh_.lduAddr(),
interfaceCoeffs[interfacei], interfacei,
commsType psiif,
); interfaceCoeffs[interfacei],
commsType
);
}
else
{
pollingActive = true;
}
} }
} }
} }

View File

@ -131,29 +131,50 @@ void Foam::lduMatrix::updateMatrixInterfaces
// without waiting for all requests. // without waiting for all requests.
DynamicList<int> indices; // (work array) DynamicList<int> indices; // (work array)
while
// const label maxPolling =
// (
// (UPstream::nPollProcInterfaces < 0)
// ? (UPstream::nRequests() - startRequest)
// : UPstream::nPollProcInterfaces
// );
for
( (
UPstream::nPollProcInterfaces < 0 bool pollingActive = (UPstream::nPollProcInterfaces < 0);
&& UPstream::waitSomeRequests(startRequest, &indices) (
pollingActive
&& UPstream::waitSomeRequests(startRequest, &indices)
);
/*nil*/
) )
{ {
pollingActive = false;
forAll(interfaces, interfacei) forAll(interfaces, interfacei)
{ {
auto* intf = interfaces.get(interfacei); auto* intf = interfaces.get(interfacei);
if (intf && !intf->updatedMatrix() && intf->ready()) if (intf && !intf->updatedMatrix())
{ {
intf->updateInterfaceMatrix if (intf->ready())
( {
result, intf->updateInterfaceMatrix
add, (
mesh().lduAddr(), result,
interfacei, add,
psiif, mesh().lduAddr(),
coupleCoeffs[interfacei], interfacei,
cmpt, psiif,
commsType coupleCoeffs[interfacei],
); cmpt,
commsType
);
}
else
{
pollingActive = true;
}
} }
} }
} }