Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
Tpetra_FECrsGraph_decl.hpp
Go to the documentation of this file.
1// @HEADER
2// ***********************************************************************
3//
4// Tpetra: Templated Linear Algebra Services Package
5// Copyright (2008) Sandia Corporation
6//
7// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8// the U.S. Government retains certain rights in this software.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38//
39// ************************************************************************
40// @HEADER
41
42#ifndef TPETRA_FECRSGRAPH_DECL_HPP
43#define TPETRA_FECRSGRAPH_DECL_HPP
44
47
50
51namespace Tpetra {
119
120 template <class LocalOrdinal,
121 class GlobalOrdinal,
122 class Node>
124 public CrsGraph<LocalOrdinal, GlobalOrdinal, Node>
125 {
128
129 template <class S, class LO, class GO, class N>
130 friend class FECrsMatrix;
131 public:
134
140 typedef Node node_type;
141
146
149
156
158
159
183 FECrsGraph(const Teuchos::RCP<const map_type> & ownedRowMap,
184 const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
185 const size_t maxNumEntriesPerRow,
186 const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter = Teuchos::null,
187 const Teuchos::RCP<const map_type> & domainMap = Teuchos::null,
188 const Teuchos::RCP<const map_type> & ownedRangeMap = Teuchos::null,
189 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
190
217 FECrsGraph (const Teuchos::RCP<const map_type> & ownedRowMap,
218 const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
219 const size_t maxNumEntriesPerRow,
220 const Teuchos::RCP<const map_type> & ownedPlusSharedDomainMap,
221 const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter = Teuchos::null,
222 const Teuchos::RCP<const map_type> & ownedDomainMap = Teuchos::null,
223 const Teuchos::RCP<const map_type> & ownedRangeMap = Teuchos::null,
224 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
225
249 FECrsGraph (const Teuchos::RCP<const map_type> & ownedRowMap,
250 const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
251 const Kokkos::DualView<const size_t*, device_type>& numEntPerRow,
252 const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter = Teuchos::null,
253 const Teuchos::RCP<const map_type> & domainMap = Teuchos::null,
254 const Teuchos::RCP<const map_type> & ownedRangeMap = Teuchos::null,
255 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
256
283 FECrsGraph (const Teuchos::RCP<const map_type> & ownedRowMap,
284 const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
285 const Kokkos::DualView<const size_t*, device_type>& numEntPerRow,
286 const Teuchos::RCP<const map_type> & ownedPlusSharedDomainMap,
287 const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter = Teuchos::null,
288 const Teuchos::RCP<const map_type> & ownedDomainMap = Teuchos::null,
289 const Teuchos::RCP<const map_type> & ownedRangeMap = Teuchos::null,
290 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
291
292
318 FECrsGraph(const Teuchos::RCP<const map_type> & ownedRowMap,
319 const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
320 const Teuchos::RCP<const map_type> & ownedPlusSharedColMap,
321 const size_t maxNumEntriesPerRow,
322 const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter = Teuchos::null,
323 const Teuchos::RCP<const map_type> & domainMap = Teuchos::null,
324 const Teuchos::RCP<const map_type> & ownedRangeMap = Teuchos::null,
325 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
326
354 FECrsGraph(const Teuchos::RCP<const map_type> & ownedRowMap,
355 const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
356 const Teuchos::RCP<const map_type> & ownedPlusSharedColMap,
357 const size_t maxNumEntriesPerRow,
358 const Teuchos::RCP<const map_type> & ownedPlusSharedDomainMap,
359 const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter = Teuchos::null,
360 const Teuchos::RCP<const map_type> & ownedDomainMap = Teuchos::null,
361 const Teuchos::RCP<const map_type> & ownedRangeMap = Teuchos::null,
362 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
363
364
388 FECrsGraph (const Teuchos::RCP<const map_type> & ownedRowMap,
389 const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
390 const Teuchos::RCP<const map_type> & ownedPlusSharedColMap,
391 const Kokkos::DualView<const size_t*, device_type>& numEntPerRow,
392 const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter = Teuchos::null,
393 const Teuchos::RCP<const map_type> & domainMap = Teuchos::null,
394 const Teuchos::RCP<const map_type> & ownedRangeMap = Teuchos::null,
395 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
396
421 FECrsGraph (const Teuchos::RCP<const map_type> & ownedRowMap,
422 const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
423 const Teuchos::RCP<const map_type> & ownedPlusSharedColMap,
424 const Kokkos::DualView<const size_t*, device_type>& numEntPerRow,
425 const Teuchos::RCP<const map_type> & ownedPlusSharedDomainMap,
426 const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter = Teuchos::null,
427 const Teuchos::RCP<const map_type> & ownedDomainMap = Teuchos::null,
428 const Teuchos::RCP<const map_type> & ownedRangeMap = Teuchos::null,
429 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
430
433
436
440
444
454 virtual ~FECrsGraph () = default;
455
457
459
460 Teuchos::RCP<const Teuchos::ParameterList>
461 getValidParameters () const override;
462
464
466
468 void endAssembly();
469 void endAssembly(const Teuchos::RCP<const map_type>& domainMap, const Teuchos::RCP<const map_type>& rangeMap);
470
472 void beginAssembly();
473
511 void
512 fillComplete (const Teuchos::RCP<const map_type>& ownedDomainMap,
513 const Teuchos::RCP<const map_type>& ownedRangeMap,
514 const Teuchos::RCP<Teuchos::ParameterList>& /* params */ = Teuchos::null) {
515 ownedDomainMap_ = ownedDomainMap;
516 ownedRangeMap_ = ownedRangeMap;
517 endFill();
518 }
519
547 void
548 fillComplete (const Teuchos::RCP<Teuchos::ParameterList>& /* params */ = Teuchos::null) {endFill();}
549
550
551 private:
552
554 void endFill();
555 void endFill(const Teuchos::RCP<const map_type>& domainMap, const Teuchos::RCP<const map_type>& rangeMap);
556
558 void beginFill();
559
563 void doOwnedPlusSharedToOwned(const CombineMode CM=Tpetra::ADD);
564
567 void doOwnedToOwnedPlusShared(const CombineMode CM=Tpetra::ADD);
568
569 public:
573
574 private:
575
576 // Common core guts of the constructor (the colMap argument is Teuchos::null if we're globally-indexed)
577 void setup(const Teuchos::RCP<const map_type> & ownedRowMap, const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,const Teuchos::RCP<const map_type> & ownedPlusSharedColMap, const Teuchos::RCP<Teuchos::ParameterList>& params);
578
579 // Template to avoid long type names...lazy.
580 // template<typename ViewType>
581 // Teuchos::RCP<const map_type> makeOwnedColMap (ViewType ownedGraphIndices);
582
583 // Enum for activity
584 enum FEWhichActive
585 {
586 FE_ACTIVE_OWNED,
587 FE_ACTIVE_OWNED_PLUS_SHARED
588 };
589
590 enum class FillState
591 {
592 open, // matrix is "open". Values can freely inserted
593 closed
594 };
595 Teuchos::RCP<FillState> fillState_;
596
597 // This is whichever graph isn't currently active
598 Teuchos::RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node> > inactiveCrsGraph_;
599
600 // This is in RCP to make shallow copies of the FECrsGraph work correctly
601 Teuchos::RCP<FEWhichActive> activeCrsGraph_;
602
603 // The importer between the rowmaps of the two graphs
604 Teuchos::RCP<const import_type> ownedRowsImporter_;
605
606 // The domainMap to use in endFill() for the owned graph
607 Teuchos::RCP<const map_type> ownedDomainMap_;
608
609 // The rangeMap to use in endFill() for the owned graph
610 Teuchos::RCP<const map_type> ownedRangeMap_;
611
612 protected:
622 size_t
624 const global_ordinal_type inputGblColInds[],
625 const size_t numInputInds);
626
636 size_t
637 insertGlobalIndicesImpl (const RowInfo& rowInfo,
638 const global_ordinal_type inputGblColInds[],
639 const size_t numInputInds,
640 std::function<void(const size_t, const size_t, const size_t)> fun =
641 std::function<void(const size_t, const size_t, const size_t)>());
642
643 void
644 insertLocalIndicesImpl (const local_ordinal_type lclRow,
645 const Teuchos::ArrayView<const local_ordinal_type>& gblColInds,
646 std::function<void(const size_t, const size_t, const size_t)> fun =
647 std::function<void(const size_t, const size_t, const size_t)>());
648
649 }; // class FECrsGraph
650
651
652} // namespace Tpetra
653
654#endif // TPETRA_FECRSGRAPH_DECL_HPP
Declaration of the Tpetra::CrsGraph class.
Forward declaration of Tpetra::FECrsGraph.
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
Kokkos::StaticCrsGraph< local_ordinal_type, Kokkos::LayoutLeft, device_type, void, size_t > local_graph_device_type
The type of the part of the sparse graph on each MPI process.
typename Node::device_type device_type
This class' Kokkos device type.
typename device_type::execution_space execution_space
This class' Kokkos execution space.
Struct that holds views of the contents of a CrsMatrix.
Communication plan for data redistribution from a (possibly) multiply-owned to a uniquely-owned distr...
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
CrsGraph< LocalOrdinal, GlobalOrdinal, Node >::device_type device_type
The Kokkos device type.
void endAssembly()
Migrates data to the owned mode.
CrsGraph< LocalOrdinal, GlobalOrdinal, Node > crs_graph_type
Parent class.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const override
Default parameter list suitable for validation.
FECrsGraph(const FECrsGraph< LocalOrdinal, GlobalOrdinal, Node > &)=delete
Copy constructor (forbidden).
void beginAssembly()
Activates the owned+shared mode for assembly.
FECrsGraph & operator=(const FECrsGraph< LocalOrdinal, GlobalOrdinal, Node > &)=delete
Copy assignment (forbidden).
void switchActiveCrsGraph()
Switches which CrsGraph is active (without migrating data)
void fillComplete(const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Tell the graph that you are done changing its structure; set default domain and range Maps.
LocalOrdinal local_ordinal_type
This class' first template parameter; the type of local indices.
size_t insertGlobalIndicesImpl(const local_ordinal_type lclRow, const global_ordinal_type inputGblColInds[], const size_t numInputInds)
Insert global indices, using an input local row index.
CrsGraph< LocalOrdinal, GlobalOrdinal, Node >::local_graph_device_type local_graph_device_type
The type of the part of the sparse graph on each MPI process.
FECrsGraph(FECrsGraph< LocalOrdinal, GlobalOrdinal, Node > &&)=delete
Move constructor (forbidden).
void fillComplete(const Teuchos::RCP< const map_type > &ownedDomainMap, const Teuchos::RCP< const map_type > &ownedRangeMap, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Tell the graph that you are done changing its structure.
virtual ~FECrsGraph()=default
Destructor (virtual for memory safety of derived classes).
Node node_type
This class' Kokkos Node type.
CrsGraph< LocalOrdinal, GlobalOrdinal, Node >::execution_space execution_space
The Kokkos execution space.
GlobalOrdinal global_ordinal_type
This class' second template parameter; the type of global indices.
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
A parallel distribution of indices over processes.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
CombineMode
Rule for combining data in an Import or Export.
@ ADD
Sum new values.