ENH: restrict scope of waitRequests() in LduMatrix update

- Only wait for locally invoked requests.
  Reflects behaviour of lduMatrix update.
This commit is contained in:
Mark Olesen
2023-01-12 19:59:52 +01:00
parent 568ced68e2
commit bd0ad07d40
5 changed files with 34 additions and 19 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019-2022 OpenCFD Ltd. Copyright (C) 2019-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -637,7 +637,8 @@ public:
const bool add, const bool add,
const FieldField<Field, LUType>& interfaceCoeffs, const FieldField<Field, LUType>& interfaceCoeffs,
const Field<Type>& psiif, const Field<Type>& psiif,
Field<Type>& result Field<Type>& result,
const label startRequest // starting request (for non-blocking)
) const; ) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd. Copyright (C) 2017-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -80,6 +80,8 @@ void Foam::LduMatrix<Type, DType, LUType>::Amul
const LUType* const __restrict__ upperPtr = upper().begin(); const LUType* const __restrict__ upperPtr = upper().begin();
const LUType* const __restrict__ lowerPtr = lower().begin(); const LUType* const __restrict__ lowerPtr = lower().begin();
const label startRequest = UPstream::nRequests();
// Initialise the update of interfaced interfaces // Initialise the update of interfaced interfaces
initMatrixInterfaces initMatrixInterfaces
( (
@ -109,7 +111,8 @@ void Foam::LduMatrix<Type, DType, LUType>::Amul
true, true,
interfacesUpper_, interfacesUpper_,
psi, psi,
Apsi Apsi,
startRequest
); );
tpsi.clear(); tpsi.clear();
@ -136,6 +139,8 @@ void Foam::LduMatrix<Type, DType, LUType>::Tmul
const LUType* const __restrict__ lowerPtr = lower().begin(); const LUType* const __restrict__ lowerPtr = lower().begin();
const LUType* const __restrict__ upperPtr = upper().begin(); const LUType* const __restrict__ upperPtr = upper().begin();
const label startRequest = UPstream::nRequests();
// Initialise the update of interfaced interfaces // Initialise the update of interfaced interfaces
initMatrixInterfaces initMatrixInterfaces
( (
@ -164,7 +169,8 @@ void Foam::LduMatrix<Type, DType, LUType>::Tmul
true, true,
interfacesLower_, interfacesLower_,
psi, psi,
Tpsi Tpsi,
startRequest
); );
tpsi.clear(); tpsi.clear();
@ -242,6 +248,8 @@ void Foam::LduMatrix<Type, DType, LUType>::residual
// Note: there is a change of sign in the coupled // Note: there is a change of sign in the coupled
// interface update to add the contibution to the r.h.s. // interface update to add the contibution to the r.h.s.
const label startRequest = UPstream::nRequests();
// Initialise the update of interfaced interfaces // Initialise the update of interfaced interfaces
initMatrixInterfaces initMatrixInterfaces
( (
@ -271,7 +279,8 @@ void Foam::LduMatrix<Type, DType, LUType>::residual
false, false,
interfacesUpper_, interfacesUpper_,
psi, psi,
rA rA,
startRequest
); );
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019-2022 OpenCFD Ltd. Copyright (C) 2019-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -111,23 +111,24 @@ void Foam::LduMatrix<Type, DType, LUType>::updateMatrixInterfaces
const bool add, const bool add,
const FieldField<Field, LUType>& interfaceCoeffs, const FieldField<Field, LUType>& interfaceCoeffs,
const Field<Type>& psiif, const Field<Type>& psiif,
Field<Type>& result Field<Type>& result,
const label startRequest
) const ) const
{ {
const UPstream::commsTypes commsType = UPstream::defaultCommsType; const UPstream::commsTypes commsType = UPstream::defaultCommsType;
// Block until sends/receives have finished
if (commsType == UPstream::commsTypes::nonBlocking)
{
UPstream::waitRequests(startRequest);
}
if if
( (
commsType == UPstream::commsTypes::blocking commsType == UPstream::commsTypes::blocking
|| commsType == UPstream::commsTypes::nonBlocking || commsType == UPstream::commsTypes::nonBlocking
) )
{ {
// Block until all sends/receives have been finished
if (commsType == UPstream::commsTypes::nonBlocking)
{
UPstream::waitRequests();
}
forAll(interfaces_, interfacei) forAll(interfaces_, interfacei)
{ {
if (interfaces_.set(interfacei)) if (interfaces_.set(interfacei))

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd. Copyright (C) 2017-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -98,6 +98,8 @@ void Foam::TGaussSeidelSmoother<Type, DType, LUType>::smooth
{ {
bPrime = matrix_.source(); bPrime = matrix_.source();
const label startRequest = UPstream::nRequests();
matrix_.initMatrixInterfaces matrix_.initMatrixInterfaces
( (
false, false,
@ -111,7 +113,8 @@ void Foam::TGaussSeidelSmoother<Type, DType, LUType>::smooth
false, false,
matrix_.interfacesUpper(), matrix_.interfacesUpper(),
psi, psi,
bPrime bPrime,
startRequest
); );
Type curPsi; Type curPsi;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2013-2017 OpenFOAM Foundation Copyright (C) 2013-2017 OpenFOAM Foundation
Copyright (C) 2019,2022 OpenCFD Ltd. Copyright (C) 2019-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -116,6 +116,8 @@ Foam::labelListList Foam::lduPrimitiveMesh::globalCellCells
// Get the interface cells // Get the interface cells
PtrList<labelList> nbrGlobalCells(interfaces.size()); PtrList<labelList> nbrGlobalCells(interfaces.size());
{ {
const label startOfRequests = UPstream::nRequests();
// Initialise transfer of restrict addressing on the interface // Initialise transfer of restrict addressing on the interface
forAll(interfaces, inti) forAll(interfaces, inti)
{ {
@ -129,8 +131,7 @@ Foam::labelListList Foam::lduPrimitiveMesh::globalCellCells
} }
} }
// Wait for all UPstream::waitRequests(startOfRequests);
UPstream::waitRequests();
forAll(interfaces, inti) forAll(interfaces, inti)
{ {