From 9ad3754ed74fec808a283fb895276a9cdb8ed983 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 24 Jan 2024 12:58:20 +0100 Subject: [PATCH] ENH: remove obsolete Pstream functions (#3087) - the old Pstream::scatter routines (which were largely a misnomer) have been superseded by various broadcast routines, but were left in the code with #ifndef/#ifdef Foam_Pstream_scatter_nobroadcast guards. Now noisily deprecate them, and remove the old manual tree communication in favour of MPI broadcast and/or serialize/de-serialize with wrapped Pstream::broadcast - consolidate various gather methods to include the communication structure directly. No functional change, but reduces the number of methods. ENH: add parallel guard to UPstream::whichCommunication() method - returns List::null() as the schedule for non-parallel instead of an inappropriate linear or tree schedule ENH: Pstream::listGatherValues, Pstream::listScatterValues - like the existing UPstream versions but supporting non-contiguous --- applications/test/gatherValues1/Make/files | 2 +- ...gatherValues1.C => Test-gatherValues1.cxx} | 72 +-- src/OpenFOAM/db/IOstreams/Pstreams/Pstream.H | 179 +++----- .../db/IOstreams/Pstreams/PstreamBroadcast.C | 26 +- .../IOstreams/Pstreams/PstreamCombineGather.C | 414 +----------------- .../db/IOstreams/Pstreams/PstreamGather.C | 236 ++++++---- .../db/IOstreams/Pstreams/PstreamGatherList.C | 26 +- .../db/IOstreams/Pstreams/PstreamReduceOps.H | 35 +- src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C | 1 + src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H | 23 +- .../db/IOstreams/Pstreams/UPstreamTemplates.C | 105 ++--- 11 files changed, 389 insertions(+), 730 deletions(-) rename applications/test/gatherValues1/{Test-gatherValues1.C => Test-gatherValues1.cxx} (81%) diff --git a/applications/test/gatherValues1/Make/files b/applications/test/gatherValues1/Make/files index 31bbb718f0..b5fc79cbe0 100644 --- a/applications/test/gatherValues1/Make/files +++ b/applications/test/gatherValues1/Make/files @@ -1,3 +1,3 @@ -Test-gatherValues1.C +Test-gatherValues1.cxx EXE = $(FOAM_USER_APPBIN)/Test-gatherValues1 diff --git a/applications/test/gatherValues1/Test-gatherValues1.C b/applications/test/gatherValues1/Test-gatherValues1.cxx similarity index 81% rename from applications/test/gatherValues1/Test-gatherValues1.C rename to applications/test/gatherValues1/Test-gatherValues1.cxx index 69ce09ce12..02bb8597ed 100644 --- a/applications/test/gatherValues1/Test-gatherValues1.C +++ b/applications/test/gatherValues1/Test-gatherValues1.cxx @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2021-2023 OpenCFD Ltd. + Copyright (C) 2021-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -52,7 +52,7 @@ int main(int argc, char *argv[]) const labelList localValues ( - identity(2 *(Pstream::myProcNo()+1), -5*Pstream::myProcNo()) + identity(2 *(UPstream::myProcNo()+1), -5*UPstream::myProcNo()) ); // Test resize @@ -76,8 +76,8 @@ int main(int argc, char *argv[]) // One-sided sizing! master only const globalIndex allProcAddr ( - sendData.size(), - globalIndex::gatherOnly{} + globalIndex::gatherOnly{}, + sendData.size() ); Pout<< "listGather sizes: " << flatOutput(allProcAddr.sizes()) << nl; @@ -98,8 +98,8 @@ int main(int argc, char *argv[]) // One-sided sizing! master only const globalIndex allProcAddr ( - sendData.size(), - globalIndex::gatherOnly{} + globalIndex::gatherOnly{}, + sendData.size() ); Pout<< "listGather sizes: " << flatOutput(allProcAddr.sizes()) << nl; @@ -116,7 +116,7 @@ int main(int argc, char *argv[]) { const labelList::subList& sendData = ( - Pstream::master() + UPstream::master() ? SubList