Nektar++
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Nektar::LibUtilities::GatherScatter Class Referenceabstract

A gather-scatter over universal ids, mirroring Gs::Init(), Gs::Gather() and Gs::Unique() behind an implementation-agnostic interface. More...

#include <GatherScatter.h>

Public Member Functions

virtual ~GatherScatter ()=default
 
 GatherScatter (const GatherScatter &)=delete
 
GatherScatter & operator= (const GatherScatter &)=delete
 
virtual void Gather (Array< OneD, NekDouble > u, GatherScatterOp op)=0
 The Gs::Gather() equivalent: fold the entries of u, in place, across every slot on every rank with the same id.
 
virtual void Unique (Array< OneD, long > &ids)=0
 The Gs::Unique() equivalent: negate all but one occurrence of each id across all ranks, in place. ids must hold the ids this handle was built from. Which occurrence survives differs between implementations; that exactly one does is what callers rely on.
 

Static Public Member Functions

static std::shared_ptr< GatherScatter > Create (const Array< OneD, long > &ids, const CommSharedPtr &comm, const GatherScatterConfig &config, bool verbose=false)
 Set up a gather-scatter over ids: the Gs::Init() equivalent.
 
static std::shared_ptr< GatherScatter > CreateNoOp ()
 A handle whose Gather() and Unique() do nothing.
 

Protected Member Functions

 GatherScatter ()=default
 

Detailed Description

A gather-scatter over universal ids, mirroring Gs::Init(), Gs::Gather() and Gs::Unique() behind an implementation-agnostic interface.

Create() picks the implementation from a #GatherScatterConfig: gslib's gs_data, or a #SharedIdPlan over one of its exchange backends. The subclasses live entirely in the implementation file, so a caller needs neither gslib's headers nor the shared-id module's to use one. This is what lets a solver be benchmarked with and without gslib just by adding, say, --gather-scatter pairwise to its command line.

On a serial communicator Create() returns the same do-nothing handle CreateNoOp() gives, as gslib is a no-op there too. Create() and Gather() are collective over the communicator, as is Unique() for gslib.

Definition at line 123 of file GatherScatter.h.

Constructor & Destructor Documentation

◆ ~GatherScatter()

virtual Nektar::LibUtilities::GatherScatter::~GatherScatter ( )
virtualdefault

◆ GatherScatter() [1/2]

Nektar::LibUtilities::GatherScatter::GatherScatter ( const GatherScatter &  )
delete

◆ GatherScatter() [2/2]

Nektar::LibUtilities::GatherScatter::GatherScatter ( )
protecteddefault

Member Function Documentation

◆ Create()

GatherScatterSharedPtr Nektar::LibUtilities::GatherScatter::Create ( const Array< OneD, long > &  ids,
const CommSharedPtr &  comm,
const GatherScatterConfig &  config,
bool  verbose = false 
)
static

Set up a gather-scatter over ids: the Gs::Init() equivalent.

Parameters
idsOne universal id per slot; 0 for slots to skip. The SharedIdPlan methods also skip negative ids, which gslib treats as "flagged" (see the implementation).
commCommunicator to gather over.
configImplementation to use.
verbosePrint a setup summary on rank 0.
Returns
A handle, never null.

Definition at line 343 of file GatherScatter.cpp.

347{
348 if (config.method == GatherScatterMethod::eGslib)
349 {
350 return std::make_shared<GsLibGatherScatter>(ids, comm, verbose);
351 }
352
353 // gslib has nothing to exchange on one rank and hands back a null handle;
354 // do the same, so both methods behave identically in serial.
355 if (comm->IsSerial())
356 {
357 return CreateNoOp();
358 }
359
360 return std::make_shared<PlanGatherScatter>(ids, comm, config, verbose);
361}
static std::shared_ptr< GatherScatter > CreateNoOp()
A handle whose Gather() and Unique() do nothing.
@ eGslib
gslib's gs_setup / gs_gather / gs_unique (the default)

References CreateNoOp(), Nektar::LibUtilities::eGslib, and Nektar::LibUtilities::GatherScatterConfig::method.

Referenced by Nektar::MultiRegions::AssemblyMapCG::AssemblyMapCG(), Nektar::CoupledAssemblyMap::CoupledAssemblyMap(), Nektar::MultiRegions::AssemblyMapCG::CreateGraph(), Nektar::MultiRegions::AssemblyMapCG::SetUpUniversalC0ContMap(), Nektar::MultiRegions::AssemblyMapDG::SetUpUniversalDGMap(), and Nektar::MultiRegions::AssemblyMapCG::v_LinearSpaceMap().

◆ CreateNoOp()

GatherScatterSharedPtr Nektar::LibUtilities::GatherScatter::CreateNoOp ( )
static

A handle whose Gather() and Unique() do nothing.

For slots that never had a gather-scatter set up over them, which callers previously expressed as a null Gs::gs_data * and relied on Gs::Gather() ignoring.

Definition at line 363 of file GatherScatter.cpp.

364{
365 return std::make_shared<NoOpGatherScatter>();
366}

Referenced by Create().

◆ Gather()

virtual void Nektar::LibUtilities::GatherScatter::Gather ( Array< OneD, NekDouble >  u,
GatherScatterOp  op 
)
pure virtual

The Gs::Gather() equivalent: fold the entries of u, in place, across every slot on every rank with the same id.

As with gslib, a slot whose id is neither shared nor repeated locally is never accessed, so u may be shorter than the id array this handle was built from provided it covers every other slot. AssemblyMap's multi-level static condensation relies on this.

◆ operator=()

GatherScatter & Nektar::LibUtilities::GatherScatter::operator= ( const GatherScatter &  )
delete

◆ Unique()

virtual void Nektar::LibUtilities::GatherScatter::Unique ( Array< OneD, long > &  ids)
pure virtual

The Gs::Unique() equivalent: negate all but one occurrence of each id across all ranks, in place. ids must hold the ids this handle was built from. Which occurrence survives differs between implementations; that exactly one does is what callers rely on.