|
Tpetra Matrix/Vector Services
Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Tpetra: Templated Linear Algebra Services Package 00005 // Copyright (2008) Sandia Corporation 00006 // 00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00008 // the U.S. Government retains certain rights in this software. 00009 // 00010 // Redistribution and use in source and binary forms, with or without 00011 // modification, are permitted provided that the following conditions are 00012 // met: 00013 // 00014 // 1. Redistributions of source code must retain the above copyright 00015 // notice, this list of conditions and the following disclaimer. 00016 // 00017 // 2. Redistributions in binary form must reproduce the above copyright 00018 // notice, this list of conditions and the following disclaimer in the 00019 // documentation and/or other materials provided with the distribution. 00020 // 00021 // 3. Neither the name of the Corporation nor the names of the 00022 // contributors may be used to endorse or promote products derived from 00023 // this software without specific prior written permission. 00024 // 00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 // 00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00038 // 00039 // ************************************************************************ 00040 // @HEADER 00041 00042 #ifndef TPETRA_DISTOBJECT_DECL_HPP 00043 #define TPETRA_DISTOBJECT_DECL_HPP 00044 00045 #include "Tpetra_ConfigDefs.hpp" 00046 #include "Tpetra_Map.hpp" 00047 #include "Tpetra_Import.hpp" 00048 #include "Tpetra_Export.hpp" 00049 #include "Tpetra_SrcDistObject.hpp" 00050 00051 // #ifndef HAVE_TPETRA_TRANSFER_TIMERS 00052 // # define HAVE_TPETRA_TRANSFER_TIMERS 1 00053 // #endif // HAVE_TPETRA_TRANSFER_TIMERS 00054 00055 #ifdef HAVE_TPETRA_TRANSFER_TIMERS 00056 # undef HAVE_TPETRA_TRANSFER_TIMERS 00057 #endif // HAVE_TPETRA_TRANSFER_TIMERS 00058 00059 00060 namespace Tpetra { 00168 template <class Packet, 00169 class LocalOrdinal = Map<>::local_ordinal_type, 00170 class GlobalOrdinal = typename Map<LocalOrdinal>::global_ordinal_type, 00171 class Node = typename Map<LocalOrdinal, GlobalOrdinal>::node_type> 00172 class DistObject : 00173 virtual public SrcDistObject, 00174 virtual public Teuchos::Describable { 00175 public: 00177 00178 00183 typedef Packet packet_type; 00185 typedef LocalOrdinal local_ordinal_type; 00187 typedef GlobalOrdinal global_ordinal_type; 00189 typedef Node node_type; 00190 00192 00193 00194 00196 explicit DistObject (const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& map); 00197 00199 DistObject (const DistObject<Packet,LocalOrdinal,GlobalOrdinal,Node>& rhs); 00200 00202 virtual ~DistObject (); 00203 00205 00206 00207 00225 void 00226 doImport (const SrcDistObject& source, 00227 const Import<LocalOrdinal,GlobalOrdinal,Node>& importer, 00228 CombineMode CM); 00229 00247 void 00248 doExport (const SrcDistObject& source, 00249 const Export<LocalOrdinal,GlobalOrdinal,Node>& exporter, 00250 CombineMode CM); 00251 00270 void 00271 doImport (const SrcDistObject& source, 00272 const Export<LocalOrdinal,GlobalOrdinal,Node>& exporter, 00273 CombineMode CM); 00274 00293 void 00294 doExport (const SrcDistObject& source, 00295 const Import<LocalOrdinal,GlobalOrdinal,Node>& importer, 00296 CombineMode CM); 00297 00299 00300 00301 00307 bool isDistributed () const; 00308 00315 virtual Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > 00316 getMap() const { return map_; } 00317 00319 00320 00321 00326 void print (std::ostream &os) const; 00327 00329 00330 00331 00336 virtual std::string description () const; 00337 00338 00343 virtual void 00344 describe (Teuchos::FancyOStream &out, 00345 const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const; 00347 00348 00349 00395 virtual void 00396 removeEmptyProcessesInPlace (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& newMap); 00397 00398 // Forward declaration of nonmember function. 00399 template<class PT, class LO, class GO, class NT> 00400 friend void 00401 removeEmptyProcessesInPlace (Teuchos::RCP<Tpetra::DistObject<PT, LO, GO, NT> >& input, 00402 const Teuchos::RCP<const Map<LO, GO, NT> >& newMap); 00403 // Forward declaration of nonmember function. 00404 template<class PT, class LO, class GO, class NT> 00405 friend void 00406 removeEmptyProcessesInPlace (Teuchos::RCP<Tpetra::DistObject<PT, LO, GO, NT> >& input); 00408 00409 protected: 00417 enum ReverseOption { 00418 DoForward, //*!< Perform the transfer in forward mode. 00419 DoReverse //*!< Perform the transfer in reverse mode. 00420 }; 00421 00437 virtual size_t constantNumberOfPackets () const; 00438 00461 virtual void 00462 doTransfer (const SrcDistObject& src, 00463 CombineMode CM, 00464 size_t numSameIDs, 00465 const Teuchos::ArrayView<const LocalOrdinal> &permuteToLIDs, 00466 const Teuchos::ArrayView<const LocalOrdinal> &permuteFromLIDs, 00467 const Teuchos::ArrayView<const LocalOrdinal> &remoteLIDs, 00468 const Teuchos::ArrayView<const LocalOrdinal> &exportLIDs, 00469 Distributor &distor, 00470 ReverseOption revOp); 00471 00482 00483 00487 virtual bool 00488 checkSizes (const SrcDistObject& source) = 0; 00489 00507 virtual void 00508 copyAndPermute (const SrcDistObject& source, 00509 size_t numSameIDs, 00510 const Teuchos::ArrayView<const LocalOrdinal>& permuteToLIDs, 00511 const Teuchos::ArrayView<const LocalOrdinal>& permuteFromLIDs) = 0; 00512 00535 virtual void 00536 packAndPrepare (const SrcDistObject& source, 00537 const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs, 00538 Teuchos::Array<Packet>& exports, 00539 const Teuchos::ArrayView<size_t>& numPacketsPerLID, 00540 size_t& constantNumPackets, 00541 Distributor &distor) = 0; 00542 00564 virtual void 00565 unpackAndCombine (const Teuchos::ArrayView<const LocalOrdinal> &importLIDs, 00566 const Teuchos::ArrayView<const Packet> &imports, 00567 const Teuchos::ArrayView<size_t> &numPacketsPerLID, 00568 size_t constantNumPackets, 00569 Distributor &distor, 00570 CombineMode CM) = 0; 00572 00579 virtual void createViews () const; 00580 00596 virtual void createViewsNonConst (KokkosClassic::ReadWriteOption rwo); 00597 00608 virtual void releaseViews () const; 00609 00611 Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > map_; 00612 00613 protected: 00615 Teuchos::Array<Packet> imports_; 00616 00627 Teuchos::Array<size_t> numImportPacketsPerLID_; 00628 00630 Teuchos::Array<Packet> exports_; 00631 00642 Teuchos::Array<size_t> numExportPacketsPerLID_; 00643 00644 private: 00645 #ifdef HAVE_TPETRA_TRANSFER_TIMERS 00646 Teuchos::RCP<Teuchos::Time> doXferTimer_; 00647 Teuchos::RCP<Teuchos::Time> copyAndPermuteTimer_; 00648 Teuchos::RCP<Teuchos::Time> packAndPrepareTimer_; 00649 Teuchos::RCP<Teuchos::Time> doPostsAndWaitsTimer_; 00650 Teuchos::RCP<Teuchos::Time> unpackAndCombineTimer_; 00651 #endif // HAVE_TPETRA_TRANSFER_TIMERS 00652 }; // class DistObject 00653 00654 00737 template<class DistObjectType> 00738 void 00739 removeEmptyProcessesInPlace (Teuchos::RCP<DistObjectType>& input, 00740 const Teuchos::RCP<const Map<typename DistObjectType::local_ordinal_type, 00741 typename DistObjectType::global_ordinal_type, 00742 typename DistObjectType::node_type> >& newMap); 00743 00780 template<class DistObjectType> 00781 void 00782 removeEmptyProcessesInPlace (Teuchos::RCP<DistObjectType>& input); 00783 00784 } // namespace Tpetra 00785 00786 // Include KokkosRefactor partial specialisation if enabled 00787 #if defined(TPETRA_HAVE_KOKKOS_REFACTOR) 00788 #include "Tpetra_KokkosRefactor_DistObject_decl.hpp" 00789 #endif 00790 00791 #endif /* TPETRA_DISTOBJECT_DECL_HPP */
1.7.6.1