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 (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 __TSQR_TestUtils_hpp
00043 #define __TSQR_TestUtils_hpp
00044 
00045 
00046 
00047 
00048 
00049 
00050 // The header file included below includes Kokkos_ConfigDefs.hpp, so
00051 // this file doesn't have to.  Avoiding unnecessary includes can save
00052 // build time, since the file doesn't have to be opened and the
00053 // preprocessor doesn't have to look for the ifndef and define
00054 // directives.
00055 #include <Kokkos_DefaultNode.hpp>
00056 
00057 namespace Teuchos {
00058   // Forward declaration of Teuchos::Comm, so that we can use
00059   // RCP<Comm<int> > as the argument of methods defined in this header
00060   // file, without needing to include Teuchos_Comm.hpp.
00061   template<class Ordinal>
00062   class Comm;
00063 }
00064 
00065 namespace TSQR {
00066   namespace Test {
00067 
00074     template<class NodeType>
00075     Teuchos::RCP<Teuchos::ParameterList> getValidNodeParameters ();
00076 
00077 #ifdef HAVE_KOKKOS_TBB
00078     //
00079     // Specialization for TBBNode: 
00080     // - "Num Threads" (int) option, defaults to -1 for late init.
00081     //
00082     template<>
00083     Teuchos::RCP<Teuchos::ParameterList> 
00084     getValidNodeParameters<Kokkos::TBBNode> () 
00085     {
00086       using Teuchos::ParameterList;
00087       using Teuchos::parameterList;
00088       using Teuchos::RCP;
00089 
00090       RCP<ParameterList> plist = parameterList ("TBBNode");
00091       // -1 tells the task scheduler to control the number of threads.
00092       plist->set ("Num Threads", -1);
00093       return plist;
00094     }
00095 #endif // HAVE_KOKKOS_TBB
00096 
00097 #ifdef HAVE_KOKKOS_THREADPOOL
00098     //
00099     // Specialization for TPINode: 
00100     // - "Num Threads" (int) option, defaults to 0.  This number
00101     //   seems to be taken more seriously than TBBNode's input.
00102     //
00103     // - "Verbose" (int) option to print info about number of
00104     //   threads; defaults to 0.
00105     //
00106     template<>
00107     Teuchos::RCP<Teuchos::ParameterList> 
00108     getValidNodeParameters<Kokkos::TPINode> () 
00109     {
00110       using Teuchos::ParameterList;
00111       using Teuchos::parameterList;
00112       using Teuchos::RCP;
00113 
00114       const int numThreads = 8;
00115 
00116       RCP<ParameterList> plist = parameterList ("TPINode");
00117       plist->set ("Num Threads", numThreads);
00118       plist->set ("Verbose", 1);
00119       return plist;
00120     }
00121 #endif // HAVE_KOKKOS_THREADPOOL
00122 
00123     //
00124     // Specialization for SerialNode, which takes no parameters.
00125     //
00126     template<>
00127     Teuchos::RCP<Teuchos::ParameterList> 
00128     getValidNodeParameters<Kokkos::SerialNode> () 
00129     {
00130       using Teuchos::ParameterList;
00131       using Teuchos::parameterList;
00132       using Teuchos::RCP;
00133 
00134       RCP<ParameterList> plist = parameterList ("SerialNode");
00135       return plist;
00136     }
00137 
00145     template<class NodeType>
00146     Teuchos::RCP<NodeType>
00147     getNode (const Teuchos::RCP<Teuchos::ParameterList>& plist)
00148     {
00149       using Teuchos::rcp;
00150       using Teuchos::rcp_const_cast;
00151 
00152       return rcp (new NodeType (*plist));
00153     }
00154 
00168     template<class CarType, class CdrType>
00169     struct Cons {
00170       typedef CarType car_type;
00171       typedef CdrType cdr_type;
00172     };
00173 
00181     struct NullCons {};
00182 
00183   } // namespace Test
00184 } // namespace TSQR
00185 
00186 #endif // __TSQR_TestUtils_hpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends