Kokkos Node API and Local Linear Algebra Kernels Version of the Day
Tsqr_TestUtils.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_TestUtils_hpp
00030 #define __TSQR_TestUtils_hpp
00031 
00032 
00033 
00034 
00035 
00036 
00037 // The header file included below includes Kokkos_ConfigDefs.hpp, so
00038 // this file doesn't have to.  Avoiding unnecessary includes can save
00039 // build time, since the file doesn't have to be opened and the
00040 // preprocessor doesn't have to look for the ifndef and define
00041 // directives.
00042 #include <Kokkos_DefaultNode.hpp>
00043 
00044 namespace Teuchos {
00045   // Forward declaration of Teuchos::Comm, so that we can use
00046   // RCP<Comm<int> > as the argument of methods defined in this header
00047   // file, without needing to include Teuchos_Comm.hpp.
00048   template<class Ordinal>
00049   class Comm;
00050 }
00051 
00052 namespace TSQR {
00053   namespace Test {
00054 
00061     template<class NodeType>
00062     Teuchos::RCP<Teuchos::ParameterList> getValidNodeParameters ();
00063 
00064 #ifdef HAVE_KOKKOS_TBB
00065     //
00066     // Specialization for TBBNode: 
00067     // - "Num Threads" (int) option, defaults to -1 for late init.
00068     //
00069     template<>
00070     Teuchos::RCP<Teuchos::ParameterList> 
00071     getValidNodeParameters<Kokkos::TBBNode> () 
00072     {
00073       using Teuchos::ParameterList;
00074       using Teuchos::parameterList;
00075       using Teuchos::RCP;
00076 
00077       RCP<ParameterList> plist = parameterList ("TBBNode");
00078       // -1 tells the task scheduler to control the number of threads.
00079       plist->set ("Num Threads", -1);
00080       return plist;
00081     }
00082 #endif // HAVE_KOKKOS_TBB
00083 
00084 #ifdef HAVE_KOKKOS_THREADPOOL
00085     //
00086     // Specialization for TPINode: 
00087     // - "Num Threads" (int) option, defaults to 0.  This number
00088     //   seems to be taken more seriously than TBBNode's input.
00089     //
00090     // - "Verbose" (int) option to print info about number of
00091     //   threads; defaults to 0.
00092     //
00093     template<>
00094     Teuchos::RCP<Teuchos::ParameterList> 
00095     getValidNodeParameters<Kokkos::TPINode> () 
00096     {
00097       using Teuchos::ParameterList;
00098       using Teuchos::parameterList;
00099       using Teuchos::RCP;
00100 
00101       const int numThreads = 8;
00102 
00103       RCP<ParameterList> plist = parameterList ("TPINode");
00104       plist->set ("Num Threads", numThreads);
00105       plist->set ("Verbose", 1);
00106       return plist;
00107     }
00108 #endif // HAVE_KOKKOS_THREADPOOL
00109 
00110     //
00111     // Specialization for SerialNode, which takes no parameters.
00112     //
00113     template<>
00114     Teuchos::RCP<Teuchos::ParameterList> 
00115     getValidNodeParameters<Kokkos::SerialNode> () 
00116     {
00117       using Teuchos::ParameterList;
00118       using Teuchos::parameterList;
00119       using Teuchos::RCP;
00120 
00121       RCP<ParameterList> plist = parameterList ("SerialNode");
00122       return plist;
00123     }
00124 
00132     template<class NodeType>
00133     Teuchos::RCP<const NodeType>
00134     getNode (const Teuchos::RCP<Teuchos::ParameterList>& plist)
00135     {
00136       using Teuchos::rcp;
00137       using Teuchos::rcp_const_cast;
00138 
00139       return rcp_const_cast<const NodeType> (rcp (new NodeType (*plist)));
00140     }
00141 
00155     template<class CarType, class CdrType>
00156     struct Cons {
00157       typedef CarType car_type;
00158       typedef CdrType cdr_type;
00159     };
00160 
00168     struct NullCons {};
00169 
00170   } // namespace Test
00171 } // namespace TSQR
00172 
00173 #endif // __TSQR_TestUtils_hpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends