From 288df5011494bec086ea43b2468fc21054597496 Mon Sep 17 00:00:00 2001 From: Chris Siefert Date: Fri, 3 May 2019 11:16:28 -0600 Subject: [PATCH 1/5] Xpetra: ETI for TpetraCrsGraph --- .../CrsGraph/Xpetra_TpetraCrsGraph_decl.hpp | 332 +++++++++++++ ...raph.hpp => Xpetra_TpetraCrsGraph_def.hpp} | 441 +++++++----------- 2 files changed, 493 insertions(+), 280 deletions(-) create mode 100644 packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph_decl.hpp rename packages/xpetra/src/CrsGraph/{Xpetra_TpetraCrsGraph.hpp => Xpetra_TpetraCrsGraph_def.hpp} (67%) diff --git a/packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph_decl.hpp b/packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph_decl.hpp new file mode 100644 index 0000000000..fdc8e73a8d --- /dev/null +++ b/packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph_decl.hpp @@ -0,0 +1,332 @@ +// @HEADER +// +// *********************************************************************** +// +// Xpetra: A linear algebra interface package +// Copyright 2012 Sandia Corporation +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the Corporation nor the names of the +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Questions? Contact +// Jonathan Hu (jhu@sandia.gov) +// Andrey Prokopenko (aprokop@sandia.gov) +// Ray Tuminaro (rstumin@sandia.gov) +// +// *********************************************************************** +// +// @HEADER +#ifndef XPETRA_TPETRACRSGRAPH_DECL_HPP +#define XPETRA_TPETRACRSGRAPH_DECL_HPP + +/* this file is automatically generated - do not edit (see script/tpetra.py) */ + +#include "Xpetra_TpetraConfigDefs.hpp" +#include "Xpetra_Exceptions.hpp" + +#include "Tpetra_CrsGraph.hpp" + +#include "Xpetra_CrsGraph.hpp" +#include "Xpetra_Utils.hpp" +#include "Xpetra_TpetraMap.hpp" +#include "Xpetra_TpetraImport.hpp" +#include "Xpetra_TpetraExport.hpp" + +namespace Xpetra { + + + template ::local_ordinal_type, + class GlobalOrdinal = typename CrsGraph::global_ordinal_type, + class Node = typename CrsGraph::node_type> + class TpetraCrsGraph + : public CrsGraph + { + + // The following typedef is used by the XPETRA_DYNAMIC_CAST() macro. + typedef TpetraCrsGraph TpetraCrsGraphClass; + typedef Map map_type; + +#ifdef HAVE_XPETRA_KOKKOS_REFACTOR + typedef typename Xpetra::CrsGraph::local_graph_type local_graph_type; +#endif + + public: + + //! @name Constructor/Destructor Methods + //@{ + + //! Constructor specifying fixed number of entries for each row. + TpetraCrsGraph(const RCP< const map_type > &rowMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null); + + //! Constructor specifying (possibly different) number of entries in each row. + TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null); + + //! Constructor specifying column Map and fixed number of entries for each row. + TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null); + + //! Constructor specifying column Map and number of entries in each row. + TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null); + +#ifdef HAVE_XPETRA_KOKKOS_REFACTOR + /// \brief Constructor specifying column Map and arrays containing the graph in sorted, local ids. + /// + /// + /// \param rowMap [in] Distribution of rows of the graph. + /// + /// \param colMap [in] Distribution of columns of the graph. + /// + /// \param rowPointers [in] The beginning of each row in the graph, + /// as in a CSR "rowptr" array. The length of this vector should be + /// equal to the number of rows in the graph, plus one. This last + /// entry should store the nunber of nonzeros in the graph. + /// + /// \param columnIndices [in] The local indices of the columns, + /// as in a CSR "colind" array. The length of this vector + /// should be equal to the number of unknowns in the graph. + /// + /// \param params [in/out] Optional list of parameters. If not + /// null, any missing parameters will be filled in with their + /// default values. + TpetraCrsGraph(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, + const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, + const typename local_graph_type::row_map_type& rowPointers, + const typename local_graph_type::entries_type::non_const_type& columnIndices, + const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null); + + /// \brief Constructor specifying column Map and a local (sorted) /// graph, which the resulting CrsGraph views.; +#endif + + //! @name Insertion/Removal Methods + //@{ + + //! Insert global indices into the graph. + void insertGlobalIndices(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &indices); + + //! Insert local indices into the graph. + void insertLocalIndices(const LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &indices); + + //! Remove all graph indices from the specified local row. + void removeLocalIndices(LocalOrdinal localRow); + + //@} + + //! @name Transformational Methods + //@{ + + //! Signal that data entry is complete, specifying domain and range maps. + void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > ¶ms=null); + + //! Signal that data entry is complete. + void fillComplete(const RCP< ParameterList > ¶ms=null); + + //@} + + //! @name Methods implementing RowGraph. + //@{ + + //! Returns the communicator. + RCP< const Comm< int > > getComm() const; + + //! Returns the Map that describes the row distribution in this graph. + RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const; + + //! Returns the Map that describes the column distribution in this graph. + RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const; + + //! Returns the Map associated with the domain of this graph. + RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const; + + //! Returns the Map associated with the domain of this graph. + RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const; + + //! Returns the importer associated with this graph. + RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > getImporter() const; + + //! Returns the exporter associated with this graph. + RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > getExporter() const; + + //! Returns the number of global rows in the graph. + global_size_t getGlobalNumRows() const; + + //! Returns the number of global columns in the graph. + global_size_t getGlobalNumCols() const; + + //! Returns the number of graph rows owned on the calling node. + size_t getNodeNumRows() const; + + //! Returns the number of columns connected to the locally owned rows of this graph. + size_t getNodeNumCols() const; + + //! Returns the index base for global indices for this graph. + GlobalOrdinal getIndexBase() const; + + //! Returns the global number of entries in the graph. + global_size_t getGlobalNumEntries() const; + + //! Returns the local number of entries in the graph. + size_t getNodeNumEntries() const; + + //! Returns the current number of entries on this node in the specified global row. + size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const; + + //! Returns the current number of entries on this node in the specified local row. + size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const; + + //! Returns the current number of allocated entries for this node in the specified global row . + size_t getNumAllocatedEntriesInGlobalRow(GlobalOrdinal globalRow) const; + + //! Returns the current number of allocated entries on this node in the specified local row. + size_t getNumAllocatedEntriesInLocalRow(LocalOrdinal localRow) const; + + //! Maximum number of entries in all rows over all processes. + size_t getGlobalMaxNumRowEntries() const; + + //! Maximum number of entries in all rows owned by the calling process. + size_t getNodeMaxNumRowEntries() const; + + //! Whether the graph has a column Map. + bool hasColMap() const; + + //! Whether column indices are stored using local indices on the calling process. + bool isLocallyIndexed() const; + + //! Whether column indices are stored using global indices on the calling process. + bool isGloballyIndexed() const; + + //! Whether fillComplete() has been called and the graph is in compute mode. + bool isFillComplete() const; + + //! Returns true if storage has been optimized. + bool isStorageOptimized() const; + + //! Return a const, nonpersisting view of global indices in the given row. + void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &Indices) const; + + //! Return a const, nonpersisting view of local indices in the given row. + void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices) const; + +#ifdef HAVE_XPETRA_KOKKOS_REFACTOR + /// \brief Access the local KokkosSparse::StaticCrsGraph data + local_graph_type getLocalGraph () const; +#endif + + + //! Force the computation of global constants if we don't have them + void computeGlobalConstants(); + + //@} + + //! @name Overridden from Teuchos::Describable + //@{ + + //! Return a simple one-line description of this object. + std::string description() const; + + //! Print the object with some verbosity level to an FancyOStream object. + void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const; + + //@} + + //! @name Advanced methods, at increased risk of deprecation. + //@{ + + //! Get an ArrayRCP of the row-offsets. + ArrayRCP< const size_t > getNodeRowPtrs() const; + + //@} + + //! Implements DistObject interface + //{@ + + //! Access function for the Tpetra::Map this DistObject was constructed with. + Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const; + + //! Import. + void doImport(const DistObject &source, + const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM); + + //! Export. + void doExport(const DistObject &dest, + const Import< LocalOrdinal, GlobalOrdinal, Node >& importer, CombineMode CM); + + //! Import (using an Exporter). + void doImport(const DistObject &source, + const Export< LocalOrdinal, GlobalOrdinal, Node >& exporter, CombineMode CM); + + //! Export (using an Importer). + void doExport(const DistObject &dest, + const Export< LocalOrdinal, GlobalOrdinal, Node >& exporter, CombineMode CM); + + // @} + + //! @name Xpetra specific + //@{ + + //! TpetraCrsGraph constructor to wrap a Tpetra::CrsGraph object + TpetraCrsGraph(const Teuchos::RCP > &graph) : graph_(graph); + + //! Get the underlying Tpetra graph + RCP< const Tpetra::CrsGraph > getTpetra_CrsGraph() const; + + //@} + + private: + RCP< Tpetra::CrsGraph > graph_; + }; // TpetraCrsGraph class + + + // TODO: move that elsewhere + template + RCP > + toXpetra (RCP > graph) + { //TODO: return TpetraCrsGraph instead of CrsGraph + // typedef TpetraCrsGraph TpetraCrsGraphClass; + // XPETRA_RCP_DYNAMIC_CAST(const TpetraCrsGraphClass, graph, tGraph, "toTpetra"); + if (graph.is_null ()) { + return Teuchos::null; + } + RCP > tGraph = + Teuchos::rcp_const_cast > (graph); + return rcp (new Xpetra::TpetraCrsGraph (tGraph)); + } + + template + RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > + toTpetra (const RCP > &graph) + { + typedef TpetraCrsGraph TpetraCrsGraphClass; + XPETRA_RCP_DYNAMIC_CAST(const TpetraCrsGraphClass, graph, tpetraCrsGraph, "toTpetra"); + return tpetraCrsGraph->getTpetra_CrsGraph (); + } + +} // Xpetra namespace + +#endif // XPETRA_TPETRACRSGRAPH_DECL_HPP + diff --git a/packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph.hpp b/packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph_def.hpp similarity index 67% rename from packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph.hpp rename to packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph_def.hpp index fab4831939..d4c3ab2561 100644 --- a/packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph.hpp +++ b/packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph_def.hpp @@ -43,312 +43,210 @@ // *********************************************************************** // // @HEADER -#ifndef XPETRA_TPETRACRSGRAPH_HPP -#define XPETRA_TPETRACRSGRAPH_HPP - -/* this file is automatically generated - do not edit (see script/tpetra.py) */ - -#include "Xpetra_TpetraConfigDefs.hpp" -#include "Xpetra_Exceptions.hpp" - -#include "Tpetra_CrsGraph.hpp" - -#include "Xpetra_CrsGraph.hpp" -#include "Xpetra_Utils.hpp" -#include "Xpetra_TpetraMap.hpp" -#include "Xpetra_TpetraImport.hpp" -#include "Xpetra_TpetraExport.hpp" - +#ifndef XPETRA_TPETRACRSGRAPH_DEF_HPP +#define XPETRA_TPETRACRSGRAPH_DEF_HPP namespace Xpetra { - - // TODO: move that elsewhere - template - RCP > - toXpetra (RCP > graph); - - template - RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > - toTpetra (const RCP >& graph); - - template ::local_ordinal_type, - class GlobalOrdinal = typename CrsGraph::global_ordinal_type, - class Node = typename CrsGraph::node_type> - class TpetraCrsGraph - : public CrsGraph - { - - // The following typedef is used by the XPETRA_DYNAMIC_CAST() macro. - typedef TpetraCrsGraph TpetraCrsGraphClass; - typedef Map map_type; - #ifdef HAVE_XPETRA_KOKKOS_REFACTOR - typedef typename Xpetra::CrsGraph::local_graph_type local_graph_type; #endif - public: - - //! @name Constructor/Destructor Methods - //@{ - - //! Constructor specifying fixed number of entries for each row. - TpetraCrsGraph(const RCP< const map_type > &rowMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null) - : graph_(Teuchos::rcp(new Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(rowMap), maxNumEntriesPerRow, toTpetra(pftype), params))) { } +template +TpetraCrsGraph::TpetraCrsGraph(const RCP< const map_type > &rowMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null) +: graph_(Teuchos::rcp(new Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(rowMap), maxNumEntriesPerRow, toTpetra(pftype), params))) { } - //! Constructor specifying (possibly different) number of entries in each row. - TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null) - : graph_(Teuchos::rcp(new Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(rowMap), NumEntriesPerRowToAlloc(), toTpetra(pftype), params))) { } +template +TpetraCrsGraph::TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null) +: graph_(Teuchos::rcp(new Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(rowMap), NumEntriesPerRowToAlloc(), toTpetra(pftype), params))) { } - //! Constructor specifying column Map and fixed number of entries for each row. - TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null) - : graph_(Teuchos::rcp(new Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(rowMap), toTpetra(colMap), maxNumEntriesPerRow, toTpetra(pftype), params))) { } +template +TpetraCrsGraph::TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null) +: graph_(Teuchos::rcp(new Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(rowMap), toTpetra(colMap), maxNumEntriesPerRow, toTpetra(pftype), params))) { } - //! Constructor specifying column Map and number of entries in each row. - TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null) - : graph_(Teuchos::rcp(new Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(rowMap), toTpetra(colMap), NumEntriesPerRowToAlloc(), toTpetra(pftype), params))) { } +template +TpetraCrsGraph::TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null) +: graph_(Teuchos::rcp(new Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(rowMap), toTpetra(colMap), NumEntriesPerRowToAlloc(), toTpetra(pftype), params))) { } #ifdef HAVE_XPETRA_KOKKOS_REFACTOR - /// \brief Constructor specifying column Map and arrays containing the graph in sorted, local ids. - /// - /// - /// \param rowMap [in] Distribution of rows of the graph. - /// - /// \param colMap [in] Distribution of columns of the graph. - /// - /// \param rowPointers [in] The beginning of each row in the graph, - /// as in a CSR "rowptr" array. The length of this vector should be - /// equal to the number of rows in the graph, plus one. This last - /// entry should store the nunber of nonzeros in the graph. - /// - /// \param columnIndices [in] The local indices of the columns, - /// as in a CSR "colind" array. The length of this vector - /// should be equal to the number of unknowns in the graph. - /// - /// \param params [in/out] Optional list of parameters. If not - /// null, any missing parameters will be filled in with their - /// default values. - TpetraCrsGraph(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, +template +TpetraCrsGraph:: +TpetraCrsGraph(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const typename local_graph_type::row_map_type& rowPointers, const typename local_graph_type::entries_type::non_const_type& columnIndices, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null) - : graph_(Teuchos::rcp(new Tpetra::CrsGraph(toTpetra(rowMap), toTpetra(colMap), rowPointers, columnIndices, plist))) { } - - /// \brief Constructor specifying column Map and a local (sorted) - /// graph, which the resulting CrsGraph views. - /// - /// Unlike most other CrsGraph constructors, successful completion - /// of this constructor will result in a fill-complete graph. - /// - /// \param rowMap [in] Distribution of rows of the graph. - /// - /// \param colMap [in] Distribution of columns of the graph. - /// - /// \param lclGraph [in] A locally indexed Kokkos::StaticCrsGraph - /// whose local row indices come from the specified row Map, and - /// whose local column indices come from the specified column - /// Map. - /// - /// \param params [in/out] Optional list of parameters. If not - /// null, any missing parameters will be filled in with their - /// default values. - TpetraCrsGraph(const Teuchos::RCP& rowMap, - const Teuchos::RCP& colMap, - const local_graph_type& lclGraph, - const Teuchos::RCP& params) - : graph_(Teuchos::rcp(new Tpetra::CrsGraph(toTpetra(rowMap), toTpetra(colMap), lclGraph, params))) { } - - /// \brief Constructor specifying column, domain and range maps, and a - /// local (sorted) graph, which the resulting CrsGraph views. - /// - /// Unlike most other CrsGraph constructors, successful completion - /// of this constructor will result in a fill-complete graph. - /// - /// \param rowMap [in] Distribution of rows of the graph. - /// - /// \param colMap [in] Distribution of columns of the graph. - /// - /// \param domainMap [in] The graph's domain Map. MUST be one to - /// one! - /// - /// \param rangeMap [in] The graph's range Map. MUST be one to - /// one! May be, but need not be, the same as the domain Map. - /// - /// \param lclGraph [in] A locally indexed Kokkos::StaticCrsGraph - /// whose local row indices come from the specified row Map, and - /// whose local column indices come from the specified column - /// Map. - /// - /// \param params [in/out] Optional list of parameters. If not - /// null, any missing parameters will be filled in with their - /// default values. - TpetraCrsGraph(const local_graph_type& lclGraph, - const Teuchos::RCP& rowMap, - const Teuchos::RCP& colMap, - const Teuchos::RCP& domainMap = Teuchos::null, - const Teuchos::RCP& rangeMap = Teuchos::null, - const Teuchos::RCP& params = Teuchos::null) - : graph_(Teuchos::rcp(new Tpetra::CrsGraph(lclGraph, toTpetra(rowMap), toTpetra(colMap), toTpetra(domainMap), toTpetra(rangeMap), params))) { } +: graph_(Teuchos::rcp(new Tpetra::CrsGraph(toTpetra(rowMap), toTpetra(colMap), rowPointers, columnIndices, plist))) { } + +template +TpetraCrsGraph:: +TpetraCrsGraph(const Teuchos::RCP& rowMap, + const Teuchos::RCP& colMap, + const local_graph_type& lclGraph, + const Teuchos::RCP& params) + : graph_(Teuchos::rcp(new Tpetra::CrsGraph(toTpetra(rowMap), toTpetra(colMap), lclGraph, params))) { } #endif - //! Destructor. - virtual ~TpetraCrsGraph() { } +template + TpetraCrsGraph::~TpetraCrsGraph() { } - //@} +template +void TpetraCrsGraph::insertGlobalIndices(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &indices) +{ XPETRA_MONITOR("TpetraCrsGraph::insertGlobalIndices"); graph_->insertGlobalIndices(globalRow, indices); } - //! @name Insertion/Removal Methods - //@{ +template +void TpetraCrsGraph::insertLocalIndices(const LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &indices) +{ XPETRA_MONITOR("TpetraCrsGraph::insertLocalIndices"); graph_->insertLocalIndices(localRow, indices); } - //! Insert global indices into the graph. - void insertGlobalIndices(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &indices) { XPETRA_MONITOR("TpetraCrsGraph::insertGlobalIndices"); graph_->insertGlobalIndices(globalRow, indices); } +template +void TpetraCrsGraph::removeLocalIndices(LocalOrdinal localRow) +{ XPETRA_MONITOR("TpetraCrsGraph::removeLocalIndices"); graph_->removeLocalIndices(localRow); } - //! Insert local indices into the graph. - void insertLocalIndices(const LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &indices) { XPETRA_MONITOR("TpetraCrsGraph::insertLocalIndices"); graph_->insertLocalIndices(localRow, indices); } +template +void TpetraCrsGraph::fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > ¶ms=null) +{ XPETRA_MONITOR("TpetraCrsGraph::fillComplete"); graph_->fillComplete(toTpetra(domainMap), toTpetra(rangeMap), params); } - //! Remove all graph indices from the specified local row. - void removeLocalIndices(LocalOrdinal localRow) { XPETRA_MONITOR("TpetraCrsGraph::removeLocalIndices"); graph_->removeLocalIndices(localRow); } +template +void TpetraCrsGraph::fillComplete(const RCP< ParameterList > ¶ms=null) +{ XPETRA_MONITOR("TpetraCrsGraph::fillComplete"); graph_->fillComplete(params); } - //@} +template +RCP< const Comm< int > > TpetraCrsGraph::getComm() const +{ XPETRA_MONITOR("TpetraCrsGraph::getComm"); return graph_->getComm(); } - //! @name Transformational Methods - //@{ +template +RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > TpetraCrsGraph::getRowMap() const +{ XPETRA_MONITOR("TpetraCrsGraph::getRowMap"); return toXpetra(graph_->getRowMap()); } - //! Signal that data entry is complete, specifying domain and range maps. - void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > ¶ms=null) { XPETRA_MONITOR("TpetraCrsGraph::fillComplete"); graph_->fillComplete(toTpetra(domainMap), toTpetra(rangeMap), params); } +template +RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > TpetraCrsGraph::getColMap() const +{ XPETRA_MONITOR("TpetraCrsGraph::getColMap"); return toXpetra(graph_->getColMap()); } - //! Signal that data entry is complete. - void fillComplete(const RCP< ParameterList > ¶ms=null) { XPETRA_MONITOR("TpetraCrsGraph::fillComplete"); graph_->fillComplete(params); } +template +RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > TpetraCrsGraph::getDomainMap() const +{ XPETRA_MONITOR("TpetraCrsGraph::getDomainMap"); return toXpetra(graph_->getDomainMap()); } - //@} +template +RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > TpetraCrsGraph::getRangeMap() const +{ XPETRA_MONITOR("TpetraCrsGraph::getRangeMap"); return toXpetra(graph_->getRangeMap()); } - //! @name Methods implementing RowGraph. - //@{ +template +RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > TpetraCrsGraph::getImporter() const +{ XPETRA_MONITOR("TpetraCrsGraph::getImporter"); return toXpetra(graph_->getImporter()); } - //! Returns the communicator. - RCP< const Comm< int > > getComm() const { XPETRA_MONITOR("TpetraCrsGraph::getComm"); return graph_->getComm(); } +template +RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > TpetraCrsGraph::getExporter() const +{ XPETRA_MONITOR("TpetraCrsGraph::getExporter"); return toXpetra(graph_->getExporter()); } - //! Returns the Map that describes the row distribution in this graph. - RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const { XPETRA_MONITOR("TpetraCrsGraph::getRowMap"); return toXpetra(graph_->getRowMap()); } +template +global_size_t TpetraCrsGraph::getGlobalNumRows() const +{ XPETRA_MONITOR("TpetraCrsGraph::getGlobalNumRows"); return graph_->getGlobalNumRows(); } - //! Returns the Map that describes the column distribution in this graph. - RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const { XPETRA_MONITOR("TpetraCrsGraph::getColMap"); return toXpetra(graph_->getColMap()); } +template +global_size_t TpetraCrsGraph::getGlobalNumCols() const +{ XPETRA_MONITOR("TpetraCrsGraph::getGlobalNumCols"); return graph_->getGlobalNumCols(); } - //! Returns the Map associated with the domain of this graph. - RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const { XPETRA_MONITOR("TpetraCrsGraph::getDomainMap"); return toXpetra(graph_->getDomainMap()); } +template +size_t TpetraCrsGraph::getNodeNumRows() const +{ XPETRA_MONITOR("TpetraCrsGraph::getNodeNumRows"); return graph_->getNodeNumRows(); } - //! Returns the Map associated with the domain of this graph. - RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const { XPETRA_MONITOR("TpetraCrsGraph::getRangeMap"); return toXpetra(graph_->getRangeMap()); } +template +size_t TpetraCrsGraph::getNodeNumCols() const +{ XPETRA_MONITOR("TpetraCrsGraph::getNodeNumCols"); return graph_->getNodeNumCols(); } - //! Returns the importer associated with this graph. - RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > getImporter() const { XPETRA_MONITOR("TpetraCrsGraph::getImporter"); return toXpetra(graph_->getImporter()); } +template +GlobalOrdinal TpetraCrsGraph::getIndexBase() const +{ XPETRA_MONITOR("TpetraCrsGraph::getIndexBase"); return graph_->getIndexBase(); } - //! Returns the exporter associated with this graph. - RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > getExporter() const { XPETRA_MONITOR("TpetraCrsGraph::getExporter"); return toXpetra(graph_->getExporter()); } +template +global_size_t TpetraCrsGraph::getGlobalNumEntries() const +{ XPETRA_MONITOR("TpetraCrsGraph::getGlobalNumEntries"); return graph_->getGlobalNumEntries(); } - //! Returns the number of global rows in the graph. - global_size_t getGlobalNumRows() const { XPETRA_MONITOR("TpetraCrsGraph::getGlobalNumRows"); return graph_->getGlobalNumRows(); } - - //! Returns the number of global columns in the graph. - global_size_t getGlobalNumCols() const { XPETRA_MONITOR("TpetraCrsGraph::getGlobalNumCols"); return graph_->getGlobalNumCols(); } +template +size_t TpetraCrsGraph::getNodeNumEntries() const +{ XPETRA_MONITOR("TpetraCrsGraph::getNodeNumEntries"); return graph_->getNodeNumEntries(); } - //! Returns the number of graph rows owned on the calling node. - size_t getNodeNumRows() const { XPETRA_MONITOR("TpetraCrsGraph::getNodeNumRows"); return graph_->getNodeNumRows(); } - - //! Returns the number of columns connected to the locally owned rows of this graph. - size_t getNodeNumCols() const { XPETRA_MONITOR("TpetraCrsGraph::getNodeNumCols"); return graph_->getNodeNumCols(); } +template +size_t TpetraCrsGraph::getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const +{ XPETRA_MONITOR("TpetraCrsGraph::getNumEntriesInGlobalRow"); return graph_->getNumEntriesInGlobalRow(globalRow); } - //! Returns the index base for global indices for this graph. - GlobalOrdinal getIndexBase() const { XPETRA_MONITOR("TpetraCrsGraph::getIndexBase"); return graph_->getIndexBase(); } +template +size_t TpetraCrsGraph::getNumEntriesInLocalRow(LocalOrdinal localRow) const +{ XPETRA_MONITOR("TpetraCrsGraph::getNumEntriesInLocalRow"); return graph_->getNumEntriesInLocalRow(localRow); } - //! Returns the global number of entries in the graph. - global_size_t getGlobalNumEntries() const { XPETRA_MONITOR("TpetraCrsGraph::getGlobalNumEntries"); return graph_->getGlobalNumEntries(); } +template +size_t TpetraCrsGraph::getNumAllocatedEntriesInGlobalRow(GlobalOrdinal globalRow) const +{ XPETRA_MONITOR("TpetraCrsGraph::getNumAllocatedEntriesInGlobalRow"); return graph_->getNumAllocatedEntriesInGlobalRow(globalRow); } - //! Returns the local number of entries in the graph. - size_t getNodeNumEntries() const { XPETRA_MONITOR("TpetraCrsGraph::getNodeNumEntries"); return graph_->getNodeNumEntries(); } +template +size_t TpetraCrsGraph::getNumAllocatedEntriesInLocalRow(LocalOrdinal localRow) const +{ XPETRA_MONITOR("TpetraCrsGraph::getNumAllocatedEntriesInLocalRow"); return graph_->getNumAllocatedEntriesInLocalRow(localRow); } - //! Returns the current number of entries on this node in the specified global row. - size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const { XPETRA_MONITOR("TpetraCrsGraph::getNumEntriesInGlobalRow"); return graph_->getNumEntriesInGlobalRow(globalRow); } +template +size_t TpetraCrsGraph::getGlobalMaxNumRowEntries() const +{ XPETRA_MONITOR("TpetraCrsGraph::getGlobalMaxNumRowEntries"); return graph_->getGlobalMaxNumRowEntries(); } - //! Returns the current number of entries on this node in the specified local row. - size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const { XPETRA_MONITOR("TpetraCrsGraph::getNumEntriesInLocalRow"); return graph_->getNumEntriesInLocalRow(localRow); } +template +size_t TpetraCrsGraph::getNodeMaxNumRowEntries() const +{ XPETRA_MONITOR("TpetraCrsGraph::getNodeMaxNumRowEntries"); return graph_->getNodeMaxNumRowEntries(); } - //! Returns the current number of allocated entries for this node in the specified global row . - size_t getNumAllocatedEntriesInGlobalRow(GlobalOrdinal globalRow) const { XPETRA_MONITOR("TpetraCrsGraph::getNumAllocatedEntriesInGlobalRow"); return graph_->getNumAllocatedEntriesInGlobalRow(globalRow); } +template +bool TpetraCrsGraph::hasColMap() const +{ XPETRA_MONITOR("TpetraCrsGraph::hasColMap"); return graph_->hasColMap(); } - //! Returns the current number of allocated entries on this node in the specified local row. - size_t getNumAllocatedEntriesInLocalRow(LocalOrdinal localRow) const { XPETRA_MONITOR("TpetraCrsGraph::getNumAllocatedEntriesInLocalRow"); return graph_->getNumAllocatedEntriesInLocalRow(localRow); } - - //! Maximum number of entries in all rows over all processes. - size_t getGlobalMaxNumRowEntries() const { XPETRA_MONITOR("TpetraCrsGraph::getGlobalMaxNumRowEntries"); return graph_->getGlobalMaxNumRowEntries(); } - - //! Maximum number of entries in all rows owned by the calling process. - size_t getNodeMaxNumRowEntries() const { XPETRA_MONITOR("TpetraCrsGraph::getNodeMaxNumRowEntries"); return graph_->getNodeMaxNumRowEntries(); } - - //! Whether the graph has a column Map. - bool hasColMap() const { XPETRA_MONITOR("TpetraCrsGraph::hasColMap"); return graph_->hasColMap(); } - - //! Whether column indices are stored using local indices on the calling process. - bool isLocallyIndexed() const { XPETRA_MONITOR("TpetraCrsGraph::isLocallyIndexed"); return graph_->isLocallyIndexed(); } - - //! Whether column indices are stored using global indices on the calling process. - bool isGloballyIndexed() const { XPETRA_MONITOR("TpetraCrsGraph::isGloballyIndexed"); return graph_->isGloballyIndexed(); } +template +bool TpetraCrsGraph::isLocallyIndexed() const +{ XPETRA_MONITOR("TpetraCrsGraph::isLocallyIndexed"); return graph_->isLocallyIndexed(); } - //! Whether fillComplete() has been called and the graph is in compute mode. - bool isFillComplete() const { XPETRA_MONITOR("TpetraCrsGraph::isFillComplete"); return graph_->isFillComplete(); } +template +bool TpetraCrsGraph::isGloballyIndexed() const +{ XPETRA_MONITOR("TpetraCrsGraph::isGloballyIndexed"); return graph_->isGloballyIndexed(); } - //! Returns true if storage has been optimized. - bool isStorageOptimized() const { XPETRA_MONITOR("TpetraCrsGraph::isStorageOptimized"); return graph_->isStorageOptimized(); } +template +bool TpetraCrsGraph::isFillComplete() const +{ XPETRA_MONITOR("TpetraCrsGraph::isFillComplete"); return graph_->isFillComplete(); } - //! Return a const, nonpersisting view of global indices in the given row. - void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &Indices) const { XPETRA_MONITOR("TpetraCrsGraph::getGlobalRowView"); graph_->getGlobalRowView(GlobalRow, Indices); } +template +bool TpetraCrsGraph::isStorageOptimized() const +{ XPETRA_MONITOR("TpetraCrsGraph::isStorageOptimized"); return graph_->isStorageOptimized(); } - //! Return a const, nonpersisting view of local indices in the given row. - void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices) const { XPETRA_MONITOR("TpetraCrsGraph::getLocalRowView"); graph_->getLocalRowView(LocalRow, indices); } +template +void TpetraCrsGraph::getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &Indices) const +{ XPETRA_MONITOR("TpetraCrsGraph::getGlobalRowView"); graph_->getGlobalRowView(GlobalRow, Indices); } +template +void TpetraCrsGraph::getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices) const +{ XPETRA_MONITOR("TpetraCrsGraph::getLocalRowView"); graph_->getLocalRowView(LocalRow, indices); } #ifdef HAVE_XPETRA_KOKKOS_REFACTOR - /// \brief Access the local KokkosSparse::StaticCrsGraph data - local_graph_type getLocalGraph () const { + +template +local_graph_type TpetraCrsGraph::getLocalGraph () const return getTpetra_CrsGraph()->getLocalGraph(); } #endif - - //! Force the computation of global constants if we don't have them - void computeGlobalConstants() { +template +void TpetraCrsGraph::computeGlobalConstants() // mfh 07 May 2018: See GitHub Issue #2565. constexpr bool computeLocalTriangularConstants = true; graph_->computeGlobalConstants(computeLocalTriangularConstants); } - //@} - - //! @name Overridden from Teuchos::Describable - //@{ - - //! Return a simple one-line description of this object. - std::string description() const { XPETRA_MONITOR("TpetraCrsGraph::description"); return graph_->description(); } - - //! Print the object with some verbosity level to an FancyOStream object. - void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const { XPETRA_MONITOR("TpetraCrsGraph::describe"); graph_->describe(out, verbLevel); } - - //@} +template +std::string TpetraCrsGraph::description() const +{ XPETRA_MONITOR("TpetraCrsGraph::description"); return graph_->description(); } - //! @name Advanced methods, at increased risk of deprecation. - //@{ +template +void TpetraCrsGraph::describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const +{ XPETRA_MONITOR("TpetraCrsGraph::describe"); graph_->describe(out, verbLevel); } - //! Get an ArrayRCP of the row-offsets. - ArrayRCP< const size_t > getNodeRowPtrs() const { XPETRA_MONITOR("TpetraCrsGraph::getNodeRowPtrs"); return graph_->getNodeRowPtrs(); } +template +ArrayRCP< const size_t > TpetraCrsGraph::getNodeRowPtrs() const +{ XPETRA_MONITOR("TpetraCrsGraph::getNodeRowPtrs"); return graph_->getNodeRowPtrs(); } - //@} +template +Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > TpetraCrsGraph::getMap() const +{ XPETRA_MONITOR("TpetraCrsGraph::getMap"); return rcp( new TpetraMap< LocalOrdinal, GlobalOrdinal, Node >(graph_->getMap()) ); } - //! Implements DistObject interface - //{@ - - //! Access function for the Tpetra::Map this DistObject was constructed with. - Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const { XPETRA_MONITOR("TpetraCrsGraph::getMap"); return rcp( new TpetraMap< LocalOrdinal, GlobalOrdinal, Node >(graph_->getMap()) ); } - - //! Import. - void doImport(const DistObject &source, - const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM) { +template +const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM) XPETRA_MONITOR("TpetraCrsGraph::doImport"); XPETRA_DYNAMIC_CAST(const TpetraCrsGraphClass, source, tSource, "Xpetra::TpetraCrsGraph::doImport only accept Xpetra::TpetraCrsGraph as input arguments.");//TODO: remove and use toTpetra() @@ -358,9 +256,8 @@ namespace Xpetra { graph_->doImport(*v, toTpetra(importer), toTpetra(CM)); } - //! Export. - void doExport(const DistObject &dest, - const Import< LocalOrdinal, GlobalOrdinal, Node >& importer, CombineMode CM) { +template +const Import< LocalOrdinal, GlobalOrdinal, Node >& importer, CombineMode CM) XPETRA_MONITOR("TpetraCrsGraph::doExport"); XPETRA_DYNAMIC_CAST(const TpetraCrsGraphClass, dest, tDest, "Xpetra::TpetraCrsGraph::doImport only accept Xpetra::TpetraCrsGraph as input arguments.");//TODO: remove and use toTpetra() @@ -369,9 +266,8 @@ namespace Xpetra { } - //! Import (using an Exporter). - void doImport(const DistObject &source, - const Export< LocalOrdinal, GlobalOrdinal, Node >& exporter, CombineMode CM) { +template +const Export< LocalOrdinal, GlobalOrdinal, Node >& exporter, CombineMode CM) XPETRA_MONITOR("TpetraCrsGraph::doImport"); XPETRA_DYNAMIC_CAST(const TpetraCrsGraphClass, source, tSource, "Xpetra::TpetraCrsGraph::doImport only accept Xpetra::TpetraCrsGraph as input arguments.");//TODO: remove and use toTpetra() @@ -381,9 +277,8 @@ namespace Xpetra { } - //! Export (using an Importer). - void doExport(const DistObject &dest, - const Export< LocalOrdinal, GlobalOrdinal, Node >& exporter, CombineMode CM) { +template +const Export< LocalOrdinal, GlobalOrdinal, Node >& exporter, CombineMode CM) XPETRA_MONITOR("TpetraCrsGraph::doExport"); XPETRA_DYNAMIC_CAST(const TpetraCrsGraphClass, dest, tDest, "Xpetra::TpetraCrsGraph::doImport only accept Xpetra::TpetraCrsGraph as input arguments.");//TODO: remove and use toTpetra() @@ -393,28 +288,16 @@ namespace Xpetra { } - // @} +template +TpetraCrsGraph::TpetraCrsGraph(const Teuchos::RCP > &graph) : graph_(graph) +{ } - //! @name Xpetra specific - //@{ - - //! TpetraCrsGraph constructor to wrap a Tpetra::CrsGraph object - TpetraCrsGraph(const Teuchos::RCP > &graph) : graph_(graph) { } - - //! Get the underlying Tpetra graph - RCP< const Tpetra::CrsGraph > getTpetra_CrsGraph() const { return graph_; } +template +RCP< const Tpetra::CrsGraph > TpetraCrsGraph::getTpetra_CrsGraph() const +{ return graph_; } - //@} - - private: - RCP< Tpetra::CrsGraph > graph_; - }; // TpetraCrsGraph class - - // TODO: move that elsewhere - template - RCP > - toXpetra (RCP > graph) - { //TODO: return TpetraCrsGraph instead of CrsGraph +template +GlobalOrdinal,::toXpetra (RCP > graph) { //TODO // typedef TpetraCrsGraph TpetraCrsGraphClass; // XPETRA_RCP_DYNAMIC_CAST(const TpetraCrsGraphClass, graph, tGraph, "toTpetra"); if (graph.is_null ()) { @@ -425,10 +308,8 @@ namespace Xpetra { return rcp (new Xpetra::TpetraCrsGraph (tGraph)); } - template - RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > - toTpetra (const RCP > &graph) - { +template +GlobalOrdinal,::toTpetra (const RCP > &graph) { typedef TpetraCrsGraph TpetraCrsGraphClass; XPETRA_RCP_DYNAMIC_CAST(const TpetraCrsGraphClass, graph, tpetraCrsGraph, "toTpetra"); return tpetraCrsGraph->getTpetra_CrsGraph (); @@ -1085,7 +966,7 @@ namespace Xpetra { #endif // HAVE_XPETRA_EPETRA + } // Xpetra namespace +#endif //XPETRA_TPETRACRSGRAPH_DEF_HPP -#define XPETRA_TPETRACRSGRAPH_SHORT -#endif // XPETRA_TPETRACRSGRAPH_HPP -- GitLab From 8d2735ddebf926718b083fc2fbf5623a806b68ec Mon Sep 17 00:00:00 2001 From: Chris Siefert Date: Fri, 3 May 2019 11:16:49 -0600 Subject: [PATCH 2/5] Xpetra: ETI --- packages/xpetra/src/Utils/ClassList/LO-GO-NO.classList | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/xpetra/src/Utils/ClassList/LO-GO-NO.classList b/packages/xpetra/src/Utils/ClassList/LO-GO-NO.classList index 2a8c27011f..29860c0b69 100644 --- a/packages/xpetra/src/Utils/ClassList/LO-GO-NO.classList +++ b/packages/xpetra/src/Utils/ClassList/LO-GO-NO.classList @@ -13,7 +13,7 @@ #StridedMapFactory #StridedTpetraMap ##TpetraBlockMap -#TpetraCrsGraph +TpetraCrsGraph #TpetraExport TpetraImport #TpetraMap -- GitLab From e22660d9efeb5c97f31536a4cce974c0b90757c3 Mon Sep 17 00:00:00 2001 From: Chris Siefert Date: Fri, 3 May 2019 11:17:40 -0600 Subject: [PATCH 3/5] Xpetra: ETI --- .../src/Utils/ExplicitInstantiation/ETI_LO_GO_NO_classes.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/xpetra/src/Utils/ExplicitInstantiation/ETI_LO_GO_NO_classes.cmake b/packages/xpetra/src/Utils/ExplicitInstantiation/ETI_LO_GO_NO_classes.cmake index 9dc0db22fd..f9267ac1e4 100644 --- a/packages/xpetra/src/Utils/ExplicitInstantiation/ETI_LO_GO_NO_classes.cmake +++ b/packages/xpetra/src/Utils/ExplicitInstantiation/ETI_LO_GO_NO_classes.cmake @@ -1,2 +1,3 @@ # This file is automatically generated by xpetra/src/Utils/ExplicitInstantiation/genClassLists.sh +APPEND_SET(XPETRA_LO_GO_NO_ETI_CLASSES Xpetra::TpetraCrsGraph ) APPEND_SET(XPETRA_LO_GO_NO_ETI_CLASSES Xpetra::TpetraImport ) -- GitLab From 940d2a2fe1915bfb90950c69fa46b007478640c4 Mon Sep 17 00:00:00 2001 From: Chris Siefert Date: Fri, 3 May 2019 11:42:10 -0600 Subject: [PATCH 4/5] Xpetra: More cleanup --- .../CrsGraph/Xpetra_TpetraCrsGraph_decl.hpp | 60 ++++++- .../CrsGraph/Xpetra_TpetraCrsGraph_def.hpp | 163 +++++++++--------- 2 files changed, 144 insertions(+), 79 deletions(-) diff --git a/packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph_decl.hpp b/packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph_decl.hpp index fdc8e73a8d..bc116b3319 100644 --- a/packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph_decl.hpp +++ b/packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph_decl.hpp @@ -120,9 +120,65 @@ namespace Xpetra { const typename local_graph_type::entries_type::non_const_type& columnIndices, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null); - /// \brief Constructor specifying column Map and a local (sorted) /// graph, which the resulting CrsGraph views.; + /// \brief Constructor specifying column, domain and range maps, and a + /// local (sorted) graph, which the resulting CrsGraph views. + /// + /// Unlike most other CrsGraph constructors, successful completion + /// of this constructor will result in a fill-complete graph. + /// + /// \param rowMap [in] Distribution of rows of the graph. + /// + /// \param colMap [in] Distribution of columns of the graph. + /// + /// \param domainMap [in] The graph's domain Map. MUST be one to + /// one! + /// + /// \param rangeMap [in] The graph's range Map. MUST be one to + /// one! May be, but need not be, the same as the domain Map. + /// + /// \param lclGraph [in] A locally indexed Kokkos::StaticCrsGraph + /// whose local row indices come from the specified row Map, and + /// whose local column indices come from the specified column + /// Map. + /// + /// \param params [in/out] Optional list of parameters. If not + /// null, any missing parameters will be filled in with their + /// default values. + TpetraCrsGraph(const local_graph_type& lclGraph, + const Teuchos::RCP& rowMap, + const Teuchos::RCP& colMap, + const Teuchos::RCP& domainMap = Teuchos::null, + const Teuchos::RCP& rangeMap = Teuchos::null, + const Teuchos::RCP& params = Teuchos::null); + + /// \brief Constructor specifying column Map and a local (sorted) + /// graph, which the resulting CrsGraph views. + /// + /// Unlike most other CrsGraph constructors, successful completion + /// of this constructor will result in a fill-complete graph. + /// + /// \param rowMap [in] Distribution of rows of the graph. + /// + /// \param colMap [in] Distribution of columns of the graph. + /// + /// \param lclGraph [in] A locally indexed Kokkos::StaticCrsGraph + /// whose local row indices come from the specified row Map, and + /// whose local column indices come from the specified column + /// Map. + /// + /// \param params [in/out] Optional list of parameters. If not + /// null, any missing parameters will be filled in with their + /// default values. + TpetraCrsGraph(const Teuchos::RCP& rowMap, + const Teuchos::RCP& colMap, + const local_graph_type& lclGraph, + const Teuchos::RCP& params); + #endif + //! Destructor. + virtual ~TpetraCrsGraph(); + //! @name Insertion/Removal Methods //@{ @@ -290,7 +346,7 @@ namespace Xpetra { //@{ //! TpetraCrsGraph constructor to wrap a Tpetra::CrsGraph object - TpetraCrsGraph(const Teuchos::RCP > &graph) : graph_(graph); + TpetraCrsGraph(const Teuchos::RCP > &graph); //! Get the underlying Tpetra graph RCP< const Tpetra::CrsGraph > getTpetra_CrsGraph() const; diff --git a/packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph_def.hpp b/packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph_def.hpp index d4c3ab2561..ae809b3aef 100644 --- a/packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph_def.hpp +++ b/packages/xpetra/src/CrsGraph/Xpetra_TpetraCrsGraph_def.hpp @@ -45,36 +45,50 @@ // @HEADER #ifndef XPETRA_TPETRACRSGRAPH_DEF_HPP #define XPETRA_TPETRACRSGRAPH_DEF_HPP +#include "Xpetra_TpetraConfigDefs.hpp" +#include "Xpetra_Exceptions.hpp" + +#include "Tpetra_CrsGraph.hpp" + +#include "Xpetra_CrsGraph.hpp" +#include "Xpetra_TpetraCrsGraph_decl.hpp" +#include "Xpetra_Utils.hpp" +#include "Xpetra_TpetraMap.hpp" +#include "Xpetra_TpetraImport.hpp" +#include "Xpetra_TpetraExport.hpp" + + namespace Xpetra { #ifdef HAVE_XPETRA_KOKKOS_REFACTOR #endif template -TpetraCrsGraph::TpetraCrsGraph(const RCP< const map_type > &rowMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null) +TpetraCrsGraph::TpetraCrsGraph(const RCP< const map_type > &rowMap, size_t maxNumEntriesPerRow, ProfileType pftype, const RCP< ParameterList > ¶ms) : graph_(Teuchos::rcp(new Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(rowMap), maxNumEntriesPerRow, toTpetra(pftype), params))) { } template -TpetraCrsGraph::TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null) +TpetraCrsGraph::TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype, const RCP< ParameterList > ¶ms) : graph_(Teuchos::rcp(new Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(rowMap), NumEntriesPerRowToAlloc(), toTpetra(pftype), params))) { } template -TpetraCrsGraph::TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null) +TpetraCrsGraph::TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, ProfileType pftype, const RCP< ParameterList > ¶ms) : graph_(Teuchos::rcp(new Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(rowMap), toTpetra(colMap), maxNumEntriesPerRow, toTpetra(pftype), params))) { } template -TpetraCrsGraph::TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=DynamicProfile, const RCP< ParameterList > ¶ms=null) +TpetraCrsGraph::TpetraCrsGraph(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype, const RCP< ParameterList > ¶ms) : graph_(Teuchos::rcp(new Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(rowMap), toTpetra(colMap), NumEntriesPerRowToAlloc(), toTpetra(pftype), params))) { } #ifdef HAVE_XPETRA_KOKKOS_REFACTOR template TpetraCrsGraph:: TpetraCrsGraph(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, - const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, - const typename local_graph_type::row_map_type& rowPointers, - const typename local_graph_type::entries_type::non_const_type& columnIndices, - const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null) -: graph_(Teuchos::rcp(new Tpetra::CrsGraph(toTpetra(rowMap), toTpetra(colMap), rowPointers, columnIndices, plist))) { } - + const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, + const typename local_graph_type::row_map_type& rowPointers, + const typename local_graph_type::entries_type::non_const_type& columnIndices, + const Teuchos::RCP< Teuchos::ParameterList > &plist) + : graph_(Teuchos::rcp(new Tpetra::CrsGraph(toTpetra(rowMap), toTpetra(colMap), rowPointers, columnIndices, plist))) { } + + template TpetraCrsGraph:: TpetraCrsGraph(const Teuchos::RCP& rowMap, @@ -82,6 +96,16 @@ TpetraCrsGraph(const Teuchos::RCP& rowMap, const local_graph_type& lclGraph, const Teuchos::RCP& params) : graph_(Teuchos::rcp(new Tpetra::CrsGraph(toTpetra(rowMap), toTpetra(colMap), lclGraph, params))) { } + +template +TpetraCrsGraph:: +TpetraCrsGraph(const local_graph_type& lclGraph, + const Teuchos::RCP& rowMap, + const Teuchos::RCP& colMap, + const Teuchos::RCP& domainMap, + const Teuchos::RCP& rangeMap, + const Teuchos::RCP& params) + : graph_(Teuchos::rcp(new Tpetra::CrsGraph(lclGraph, toTpetra(rowMap), toTpetra(colMap), toTpetra(domainMap), toTpetra(rangeMap), params))) { } #endif template @@ -100,11 +124,11 @@ void TpetraCrsGraph::removeLocalIndices(LocalOr { XPETRA_MONITOR("TpetraCrsGraph::removeLocalIndices"); graph_->removeLocalIndices(localRow); } template -void TpetraCrsGraph::fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > ¶ms=null) +void TpetraCrsGraph::fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > ¶ms) { XPETRA_MONITOR("TpetraCrsGraph::fillComplete"); graph_->fillComplete(toTpetra(domainMap), toTpetra(rangeMap), params); } template -void TpetraCrsGraph::fillComplete(const RCP< ParameterList > ¶ms=null) +void TpetraCrsGraph::fillComplete(const RCP< ParameterList > ¶ms) { XPETRA_MONITOR("TpetraCrsGraph::fillComplete"); graph_->fillComplete(params); } template @@ -214,16 +238,16 @@ void TpetraCrsGraph::getGlobalRowView(GlobalOrd template void TpetraCrsGraph::getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices) const { XPETRA_MONITOR("TpetraCrsGraph::getLocalRowView"); graph_->getLocalRowView(LocalRow, indices); } -#ifdef HAVE_XPETRA_KOKKOS_REFACTOR +#ifdef HAVE_XPETRA_KOKKOS_REFACTOR template -local_graph_type TpetraCrsGraph::getLocalGraph () const - return getTpetra_CrsGraph()->getLocalGraph(); - } +typename Xpetra::CrsGraph::local_graph_type TpetraCrsGraph::getLocalGraph () const { + return getTpetra_CrsGraph()->getLocalGraph(); +} #endif template -void TpetraCrsGraph::computeGlobalConstants() +void TpetraCrsGraph::computeGlobalConstants() { // mfh 07 May 2018: See GitHub Issue #2565. constexpr bool computeLocalTriangularConstants = true; graph_->computeGlobalConstants(computeLocalTriangularConstants); @@ -234,7 +258,7 @@ std::string TpetraCrsGraph::description() const { XPETRA_MONITOR("TpetraCrsGraph::description"); return graph_->description(); } template -void TpetraCrsGraph::describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const +void TpetraCrsGraph::describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const { XPETRA_MONITOR("TpetraCrsGraph::describe"); graph_->describe(out, verbLevel); } template @@ -246,47 +270,51 @@ Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > TpetraCrsGraph(graph_->getMap()) ); } template -const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM) - XPETRA_MONITOR("TpetraCrsGraph::doImport"); - - XPETRA_DYNAMIC_CAST(const TpetraCrsGraphClass, source, tSource, "Xpetra::TpetraCrsGraph::doImport only accept Xpetra::TpetraCrsGraph as input arguments.");//TODO: remove and use toTpetra() - RCP< const Tpetra::CrsGraph > v = tSource.getTpetra_CrsGraph(); - //graph_->doImport(toTpetraCrsGraph(source), *tImporter.getTpetra_Import(), toTpetra(CM)); - - graph_->doImport(*v, toTpetra(importer), toTpetra(CM)); - } - -template -const Import< LocalOrdinal, GlobalOrdinal, Node >& importer, CombineMode CM) - XPETRA_MONITOR("TpetraCrsGraph::doExport"); - - XPETRA_DYNAMIC_CAST(const TpetraCrsGraphClass, dest, tDest, "Xpetra::TpetraCrsGraph::doImport only accept Xpetra::TpetraCrsGraph as input arguments.");//TODO: remove and use toTpetra() - RCP< const Tpetra::CrsGraph > v = tDest.getTpetra_CrsGraph(); - graph_->doExport(*v, toTpetra(importer), toTpetra(CM)); - - } - -template -const Export< LocalOrdinal, GlobalOrdinal, Node >& exporter, CombineMode CM) - XPETRA_MONITOR("TpetraCrsGraph::doImport"); - - XPETRA_DYNAMIC_CAST(const TpetraCrsGraphClass, source, tSource, "Xpetra::TpetraCrsGraph::doImport only accept Xpetra::TpetraCrsGraph as input arguments.");//TODO: remove and use toTpetra() - RCP< const Tpetra::CrsGraph > v = tSource.getTpetra_CrsGraph(); - - graph_->doImport(*v, toTpetra(exporter), toTpetra(CM)); - - } - -template -const Export< LocalOrdinal, GlobalOrdinal, Node >& exporter, CombineMode CM) - XPETRA_MONITOR("TpetraCrsGraph::doExport"); - - XPETRA_DYNAMIC_CAST(const TpetraCrsGraphClass, dest, tDest, "Xpetra::TpetraCrsGraph::doImport only accept Xpetra::TpetraCrsGraph as input arguments.");//TODO: remove and use toTpetra() - RCP< const Tpetra::CrsGraph > v = tDest.getTpetra_CrsGraph(); - +void TpetraCrsGraph::doImport(const DistObject &source, + const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM){ + XPETRA_MONITOR("TpetraCrsGraph::doImport"); + + XPETRA_DYNAMIC_CAST(const TpetraCrsGraphClass, source, tSource, "Xpetra::TpetraCrsGraph::doImport only accept Xpetra::TpetraCrsGraph as input arguments.");//TODO: remove and use toTpetra() + RCP< const Tpetra::CrsGraph > v = tSource.getTpetra_CrsGraph(); + //graph_->doImport(toTpetraCrsGraph(source), *tImporter.getTpetra_Import(), toTpetra(CM)); + + graph_->doImport(*v, toTpetra(importer), toTpetra(CM)); +} + +template +void TpetraCrsGraph::doExport(const DistObject &dest, + const Import< LocalOrdinal, GlobalOrdinal, Node >& importer, CombineMode CM) { + XPETRA_MONITOR("TpetraCrsGraph::doExport"); + + XPETRA_DYNAMIC_CAST(const TpetraCrsGraphClass, dest, tDest, "Xpetra::TpetraCrsGraph::doImport only accept Xpetra::TpetraCrsGraph as input arguments.");//TODO: remove and use toTpetra() + RCP< const Tpetra::CrsGraph > v = tDest.getTpetra_CrsGraph(); + graph_->doExport(*v, toTpetra(importer), toTpetra(CM)); + +} + +template +void TpetraCrsGraph::doImport(const DistObject &source, + const Export< LocalOrdinal, GlobalOrdinal, Node >& exporter, CombineMode CM){ + XPETRA_MONITOR("TpetraCrsGraph::doImport"); + + XPETRA_DYNAMIC_CAST(const TpetraCrsGraphClass, source, tSource, "Xpetra::TpetraCrsGraph::doImport only accept Xpetra::TpetraCrsGraph as input arguments.");//TODO: remove and use toTpetra() + RCP< const Tpetra::CrsGraph > v = tSource.getTpetra_CrsGraph(); + + graph_->doImport(*v, toTpetra(exporter), toTpetra(CM)); + +} + +template +void TpetraCrsGraph::doExport(const DistObject &dest, + const Export< LocalOrdinal, GlobalOrdinal, Node >& exporter, CombineMode CM) { + XPETRA_MONITOR("TpetraCrsGraph::doExport"); + + XPETRA_DYNAMIC_CAST(const TpetraCrsGraphClass, dest, tDest, "Xpetra::TpetraCrsGraph::doImport only accept Xpetra::TpetraCrsGraph as input arguments.");//TODO: remove and use toTpetra() + RCP< const Tpetra::CrsGraph > v = tDest.getTpetra_CrsGraph(); + graph_->doExport(*v, toTpetra(exporter), toTpetra(CM)); - - } + +} template TpetraCrsGraph::TpetraCrsGraph(const Teuchos::RCP > &graph) : graph_(graph) @@ -296,25 +324,6 @@ template RCP< const Tpetra::CrsGraph > TpetraCrsGraph::getTpetra_CrsGraph() const { return graph_; } -template -GlobalOrdinal,::toXpetra (RCP > graph) { //TODO - // typedef TpetraCrsGraph TpetraCrsGraphClass; - // XPETRA_RCP_DYNAMIC_CAST(const TpetraCrsGraphClass, graph, tGraph, "toTpetra"); - if (graph.is_null ()) { - return Teuchos::null; - } - RCP > tGraph = - Teuchos::rcp_const_cast > (graph); - return rcp (new Xpetra::TpetraCrsGraph (tGraph)); - } - -template -GlobalOrdinal,::toTpetra (const RCP > &graph) { - typedef TpetraCrsGraph TpetraCrsGraphClass; - XPETRA_RCP_DYNAMIC_CAST(const TpetraCrsGraphClass, graph, tpetraCrsGraph, "toTpetra"); - return tpetraCrsGraph->getTpetra_CrsGraph (); - } - #ifdef HAVE_XPETRA_EPETRA -- GitLab From 8457f2b3102728f1f0ff522baa329d4f92c10a4f Mon Sep 17 00:00:00 2001 From: Chris Siefert Date: Fri, 3 May 2019 13:13:25 -0600 Subject: [PATCH 5/5] Xpetra: ETI --- packages/xpetra/src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/xpetra/src/CMakeLists.txt b/packages/xpetra/src/CMakeLists.txt index d9216812c2..a0b81badc8 100644 --- a/packages/xpetra/src/CMakeLists.txt +++ b/packages/xpetra/src/CMakeLists.txt @@ -101,6 +101,7 @@ IF (${PACKAGE_NAME}_ENABLE_Epetra) ENDIF() # Create the .hpp file in BUILD/packages/xpetra/src +TRILINOS_CREATE_CLIENT_TEMPLATE_HEADERS(${CMAKE_CURRENT_SOURCE_DIR}/CrsGraph NOSIERRABJAM) TRILINOS_CREATE_CLIENT_TEMPLATE_HEADERS(${CMAKE_CURRENT_SOURCE_DIR}/CrsMatrix NOSIERRABJAM) TRILINOS_CREATE_CLIENT_TEMPLATE_HEADERS(${CMAKE_CURRENT_SOURCE_DIR}/MultiVector NOSIERRABJAM) TRILINOS_CREATE_CLIENT_TEMPLATE_HEADERS(${CMAKE_CURRENT_SOURCE_DIR}/Vector NOSIERRABJAM) -- GitLab