Kokkos Node API and Local Linear Algebra Kernels Version of the Day
TsqrFactory_TbbTsqr.hpp
Go to the documentation of this file.
00001 //@HEADER
00002 // ************************************************************************
00003 // 
00004 //          Kokkos: Node API and Parallel Node Kernels
00005 //              Copyright (2009) 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 
00043 
00044 namespace TSQR {
00045   namespace Trilinos {
00046 
00047 #ifdef HAVE_KOKKOS_TBB
00048     template<class LO, class S>
00049     class TbbTsqrFactory :
00050       public TsqrFactory<LO, S, TSQR::TBB::TbbTsqr<LO, S>, DistTsqr<LO, S> >
00051     {
00052     public:
00053       // Help C++ pull in the typedefs from the base class.  C++ needs
00054       // help when both the base and the derived classes are
00055       // templated.
00056       typedef TsqrFactory< LO, S, TSQR::TBB::TbbTsqr< LO, S >, DistTsqr< LO, S > > base_type;
00057       typedef typename base_type::scalar_messenger_ptr scalar_messenger_ptr;
00058       typedef typename base_type::node_tsqr_type node_tsqr_type;
00059       typedef typename base_type::node_tsqr_ptr  node_tsqr_ptr;
00060       typedef typename base_type::dist_tsqr_type dist_tsqr_type;
00061       typedef typename base_type::dist_tsqr_ptr  dist_tsqr_ptr;
00062       typedef typename base_type::tsqr_type tsqr_type;
00063       typedef typename base_type::tsqr_ptr  tsqr_ptr;
00064 
00065       TbbTsqrFactory () {}
00066       virtual ~TbbTsqrFactory () {}
00067 
00068     private:
00083       virtual node_tsqr_ptr
00084       makeNodeTsqr (const Teuchos::ParameterList& plist) const
00085       {
00086   using Teuchos::Exceptions::InvalidParameter;
00087   int numCores = 1;
00088   size_t cacheSizeHint = 0;
00089 
00090   try {
00091     const std::string numCoresParamName ("numCores");
00092     numCores = plist.get<int>(numCoresParamName);
00093   } catch (InvalidParameter&) {
00094     numCores = 1;
00095   }
00096 
00097   try {
00098     const std::string cacheSizeHintParamName ("cacheSizeHint");
00099     cacheSizeHint = plist.get<size_t>(cacheSizeHintParamName);
00100   } catch (InvalidParameter&) {
00101     // Intranode TSQR interprets cacheSizeHint==0 as "set cache
00102     // block size to a reasonable positive default value."
00103     cacheSizeHint = 0;
00104   }
00105 
00106   node_tsqr_ptr nodeTsqr (new node_tsqr_type (numCores, cacheSizeHint));
00107   return nodeTsqr;
00108       }
00109 
00110       virtual dist_tsqr_ptr
00111       makeDistTsqr (const scalar_messenger_ptr& messenger,
00112         const Teuchos::ParameterList& plist) const
00113       {
00114   return Teuchos::rcp (new dist_tsqr_type (messenger));
00115       }
00116     };
00117 #endif // HAVE_KOKKOS_TBB
00118 
00119   } // namespace Trilinos
00120 } // namespace TSQR
00121 
00122 
00123 #endif // __TSQR_Trilinos_TsqrFactory_TbbTsqr_hpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends