Isorropia: Partitioning, Load Balancing and more
Isorropia_Tpetra.hpp
Go to the documentation of this file.
00001 //@HEADER
00002 //************************************************************************
00003 //
00004 //              Isorropia: Partitioning and Load Balancing Package
00005 //                Copyright (2006) Sandia Corporation
00006 //
00007 //Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 //license for use of this work by or on behalf of the U.S. Government.
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 //************************************************************************
00038 //@HEADER
00039 
00040 #ifndef _Isorropia_Tpetra_hpp_
00041 #define _Isorropia_Tpetra_hpp_
00042 
00043 #include <Isorropia_ConfigDefs.hpp>
00044 #include <Teuchos_RCP.hpp>
00045 #include <Teuchos_ParameterList.hpp>
00046 
00047 #include <Isorropia_TpetraRedistributor.hpp>
00048 
00049 #ifdef HAVE_ISORROPIA_TPETRA
00050 #include <Tpetra_MultiVector_decl.hpp>
00051 #include <Tpetra_CrsGraph_decl.hpp>
00052 #include <Tpetra_CrsMatrix_decl.hpp>
00053 #include <Kokkos_DefaultNode.hpp>
00054 #endif
00055 
00056 namespace Isorropia {
00057 
00058 namespace Tpetra {
00059 
00060 
00061 #ifdef HAVE_ISORROPIA_TPETRA
00062 
00067 template <typename Node>
00068 ::Tpetra::MultiVector<double,int,int,Node> *
00069 createBalancedCopy(const ::Tpetra::MultiVector<double,int,int,Node>& input_vector);
00070 
00074 template <typename Node>
00075 ::Tpetra::MultiVector<double,int,int,Node> *
00076 createBalancedCopy(const ::Tpetra::MultiVector<double,int,int,Node>& input_vector,
00077                      const Teuchos::ParameterList& paramlist);
00078 
00082 template <typename Node>
00083 ::Tpetra::CrsGraph<int,int,Node>  *
00084 createBalancedCopy(const ::Tpetra::CrsGraph<int,int,Node> & input_graph);
00085 
00089 template <typename Node>
00090 ::Tpetra::CrsGraph<int,int,Node>  *
00091 createBalancedCopy(const ::Tpetra::CrsGraph<int,int,Node> & input_graph,
00092                      const Teuchos::ParameterList& paramlist);
00093 
00097 template <typename Node>
00098 ::Tpetra::CrsMatrix<double,int,int,Node> *
00099 createBalancedCopy(const ::Tpetra::CrsMatrix<double,int,int,Node>& input_matrix);
00100 
00104 template <typename Node>
00105 ::Tpetra::CrsMatrix<double,int,int,Node> *
00106 createBalancedCopy(const ::Tpetra::CrsMatrix<double,int,int,Node>& input_matrix,
00107                      const Teuchos::ParameterList& paramlist);
00108 
00126 template <typename Node>
00127 Teuchos::RCP< ::Tpetra::CrsMatrix<double,int,int,Node> >
00128   redistribute_rows(const ::Tpetra::CrsMatrix<double,int,int,Node>& input_matrix,
00129                     const ::Tpetra::Map<int,int,Node>& target_rowmap,
00130                     ::Tpetra::Import<int,int,Node> * importer=0);
00131 
00149 template <typename Node>
00150 Teuchos::RCP< ::Tpetra::CrsMatrix<double,int,int,Node> >
00151   redistribute_rows(const ::Tpetra::RowMatrix<int,int,Node> & input_matrix,
00152                     const ::Tpetra::Map<int,int,Node>& target_rowmap,
00153                     ::Tpetra::Import<int,int,Node> * importer=0);
00154 
00167 template <typename Node>
00168 Teuchos::RCP< ::Tpetra::CrsGraph<int,int,Node> >
00169   redistribute_rows(const ::Tpetra::CrsGraph<int,int,Node> & input_graph,
00170                     const ::Tpetra::Map<int,int,Node>& target_rowmap,
00171                     ::Tpetra::Import<int,int,Node> * importer=0);
00172 
00185 template <typename Node>
00186 Teuchos::RCP< ::Tpetra::MultiVector<double,int,int,Node> >
00187   redistribute(const ::Tpetra::MultiVector<double,int,int,Node>& input,
00188                const ::Tpetra::Map<int,int,Node> & target_map,
00189                ::Tpetra::Import<int,int,Node> * importer=0);
00190 
00203 template <typename Node>
00204 Teuchos::RCP< ::Tpetra::Vector<double,int,int,Node> >
00205      redistribute(const ::Tpetra::Vector<double,int,int,Node>& input,
00206                   const ::Tpetra::Map<int,int,Node>& target_map,
00207                   ::Tpetra::Import<int,int,Node> * importer=0);
00208 
00209 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00210 
00215 template <typename Node>
00216 ::Tpetra::MultiVector<double,int,int,Node>* create_row_weights_nnz(const ::Tpetra::RowMatrix<int,int,Node> & input_matrix);
00217 
00222 template <typename Node>
00223 ::Tpetra::MultiVector<double,int,int,Node>* create_row_weights_nnz(const ::Tpetra::CrsGraph<int,int,Node> & input_graph);
00224 
00225 template <typename Node>
00226 ::Tpetra::MultiVector<double,int,int,Node>* create_unit_weights(const ::Tpetra::MultiVector<double,int,int,Node>& input_coords);
00227 
00228 
00253 template <typename Node>
00254 int repartition(const ::Tpetra::Map<int,int,Node> & input_map,
00255       const ::Tpetra::MultiVector<double,int,int,Node>& weights,
00256       std::vector<int>& myNewElements,
00257       int& exportsSize,
00258       std::vector<int>& imports);
00259 
00268 template <typename Node>
00269 void gather_all_proc_global_offsets(const ::Tpetra::Map<int,int,Node> & blkmap,
00270                                     std::vector<int>& all_proc_offsets);
00271 
00272 
00281 double compute_imbalance(int nprocs, std::vector<int> &offsets, 
00282                          double *wgts, double target);
00283 
00284 #endif //DOXYGEN_SHOULD_SKIP_THIS
00285 #endif //HAVE_ISORROPIA_TPETRA
00286 
00287 }//namespace Tpetra
00288 }//namespace Isorropia
00289 
00290 #endif
00291