|
Anasazi Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Anasazi: Block Eigensolvers Package 00005 // Copyright (2010) 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 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 00028 00029 #ifndef __TSQR_Trilinos_TsqrFactory_TbbTsqr_hpp 00030 #define __TSQR_Trilinos_TsqrFactory_TbbTsqr_hpp 00031 00035 00036 #include "Kokkos_ConfigDefs.hpp" // HAVE_KOKKOS_TBB 00037 #include "Teuchos_ParameterListExceptions.hpp" 00038 00039 #ifdef HAVE_KOKKOS_TBB 00040 # include "TbbTsqr.hpp" 00041 #endif // HAVE_KOKKOS_TBB 00042 00045 00046 namespace TSQR { 00047 namespace Trilinos { 00048 00049 #ifdef HAVE_KOKKOS_TBB 00050 template< class LO, class S > 00051 class TbbTsqrFactory : 00052 public TsqrFactory< LO, S, TSQR::TBB::TbbTsqr< LO, S >, DistTsqr< LO, S > > 00053 { 00054 public: 00055 // Help C++ pull in the typedefs from the base class. C++ needs 00056 // help when both the base and the derived classes are 00057 // templated. 00058 typedef TsqrFactory< LO, S, TSQR::TBB::TbbTsqr< LO, S >, DistTsqr< LO, S > > base_type; 00059 typedef typename base_type::scalar_messenger_ptr scalar_messenger_ptr; 00060 typedef typename base_type::node_tsqr_type node_tsqr_type; 00061 typedef typename base_type::node_tsqr_ptr node_tsqr_ptr; 00062 typedef typename base_type::dist_tsqr_type dist_tsqr_type; 00063 typedef typename base_type::dist_tsqr_ptr dist_tsqr_ptr; 00064 typedef typename base_type::tsqr_type tsqr_type; 00065 typedef typename base_type::tsqr_ptr tsqr_ptr; 00066 00067 TbbTsqrFactory () {} 00068 virtual ~TbbTsqrFactory () {} 00069 00070 private: 00085 virtual node_tsqr_ptr 00086 makeNodeTsqr (const Teuchos::ParameterList& plist) const 00087 { 00088 using Teuchos::Exceptions::InvalidParameter; 00089 int numCores = 1; 00090 size_t cacheBlockSize = 0; 00091 00092 try { 00093 const std::string numCoresParamName ("numCores"); 00094 numCores = plist.get<int>(numCoresParamName); 00095 } catch (InvalidParameter&) { 00096 numCores = 1; 00097 } 00098 00099 try { 00100 const std::string cacheBlockSizeParamName ("cacheBlockSize"); 00101 cacheBlockSize = plist.get<size_t>(cacheBlockSizeParamName); 00102 } catch (InvalidParameter&) { 00103 // Intranode TSQR interprets cacheBlockSize==0 as "set cache 00104 // block size to a reasonable positive default value." 00105 cacheBlockSize = 0; 00106 } 00107 00108 node_tsqr_ptr nodeTsqr (new node_tsqr_type (numCores, cacheBlockSize)); 00109 return nodeTsqr; 00110 } 00111 00112 virtual dist_tsqr_ptr 00113 makeDistTsqr (const scalar_messenger_ptr& messenger, 00114 const Teuchos::ParameterList& plist) const 00115 { 00116 return Teuchos::rcp (new dist_tsqr_type (messenger)); 00117 } 00118 }; 00119 #endif // HAVE_KOKKOS_TBB 00120 00121 } // namespace Trilinos 00122 } // namespace TSQR 00123 00124 00125 #endif // __TSQR_Trilinos_TsqrFactory_TbbTsqr_hpp
1.7.4