Kokkos Node API and Local Linear Algebra Kernels Version of the Day
KokkosExamples_EmptySparseKernelClass.hpp
Go to the documentation of this file.
00001 /*
00002 //@HEADER
00003 // ************************************************************************
00004 //
00005 //          Kokkos: Node API and Parallel Node Kernels
00006 //              Copyright (2008) Sandia Corporation
00007 //
00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009 // the U.S. Government retains certain rights in this software.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00039 //
00040 // ************************************************************************
00041 //@HEADER
00042 */
00043 
00044 #ifndef KOKKOS_EMPTY_SPARSE_KERNEL_CLASS_HPP
00045 #define KOKKOS_EMPTY_SPARSE_KERNEL_CLASS_HPP
00046 
00047 #include <Kokkos_CrsMatrixBase.hpp>
00048 #include <Kokkos_CrsGraphBase.hpp>
00049 #include <Kokkos_MultiVector.hpp>
00050 #include <Kokkos_DefaultNode.hpp>
00051 #include <Teuchos_BLAS_types.hpp>
00052 #include <Kokkos_DefaultSparseOps.hpp>
00053 
00057 
00058 namespace KokkosExamples {
00059 
00060   using Teuchos::RCP;
00061   using Teuchos::ArrayRCP;
00062   using Teuchos::arcp;
00063   using Teuchos::ArrayView;
00064   using Teuchos::ParameterList;
00065 
00067 
00069   template <class Node>
00070   class EmptyCrsGraph : public Kokkos::CrsGraphBase<int,Node> {
00071   public:
00072     EmptyCrsGraph(int numrows, int numcols, const RCP<Node> &node, const RCP<ParameterList> &params) : Kokkos::CrsGraphBase<int,Node>(numrows,numcols,node,params) {}
00073     ~EmptyCrsGraph() {}
00074     void setStructure(const ArrayRCP<const size_t>&, const ArrayRCP<const int>&) {}
00075   };
00076 
00078 
00080   template <class Scalar, class Node>
00081   class EmptyCrsMatrix : public Kokkos::CrsMatrixBase<Scalar,int,Node> {
00082   public:
00083     EmptyCrsMatrix(const RCP<const EmptyCrsGraph<Node> > &graph, const RCP<ParameterList> &params) : Kokkos::CrsMatrixBase<Scalar,int,Node>(graph,params) {}
00084     ~EmptyCrsMatrix() {}
00085     void setValues(const ArrayRCP<const Scalar> &) {}
00086   };
00087 
00101   template <class Scalar, class Node>
00102   class EmptySparseKernel {
00103   public:
00105 
00106 
00113     typedef Scalar  scalar_type;
00120     typedef void ordinal_type;
00122     typedef Node    node_type;
00124     typedef EmptySparseKernel<Scalar,Node> sparse_ops_type;
00125 
00127     template <class O, class N>
00128     struct graph {
00129       typedef EmptyCrsGraph<N> graph_type;
00130     };
00131 
00133     template <class S, class O, class N>
00134     struct matrix {
00135       typedef EmptyCrsMatrix<S,N> matrix_type;
00136     };
00137 
00152     template <class T>
00153     struct bind_scalar {
00154       typedef EmptySparseKernel<T,Node> other_type;
00155     };
00156 
00158 
00159 
00160 
00162     EmptySparseKernel(const RCP<Node> & node) : node_(node) {}
00163 
00165     ~EmptySparseKernel() {}
00166 
00168 
00169 
00170 
00175     RCP<Node> getNode() const {return node_;}
00176 
00178 
00179 
00180 
00182     static ArrayRCP<size_t> allocRowPtrs(const RCP<Node> &node, const ArrayView<const size_t> &numEntriesPerRow)
00183     {
00184       return Kokkos::details::DefaultCRSAllocator::template allocRowPtrs<size_t,Node>(node,numEntriesPerRow);
00185     }
00186 
00188     template <class T> 
00189     static ArrayRCP<T> allocStorage(const RCP<Node> &node, const ArrayView<const size_t> &rowPtrs)
00190     { 
00191       return Kokkos::details::DefaultCRSAllocator::template allocStorage<T,int,Node>(node,rowPtrs);
00192     }
00193 
00195     inline static void finalizeGraph(Teuchos::EUplo uplo, Teuchos::EDiag diag, EmptyCrsGraph<Node> &graph, const RCP<ParameterList> &params) {}
00196 
00198     inline static void finalizeMatrix(const EmptyCrsGraph<Node> &graph, EmptyCrsMatrix<Scalar,Node> &matrix, const RCP<ParameterList> &params) {}
00199     
00201     inline static void finalizeGraphAndMatrix(Teuchos::EUplo uplo, Teuchos::EDiag diag, EmptyCrsGraph<Node> &graph, EmptyCrsMatrix<Scalar,Node> &matrix, const RCP<ParameterList> &params) {}
00202 
00217     void setGraphAndMatrix(const RCP<const EmptyCrsGraph<Node> >         &graph,
00218                            const RCP<const EmptyCrsMatrix<Scalar,Node> > &node) {};
00219 
00221 
00222 
00223 
00248     template <class DomainScalar, class RangeScalar>
00249     void
00250     multiply (Teuchos::ETransp trans,
00251               RangeScalar alpha,
00252               const Kokkos::MultiVector<DomainScalar,Node> &X,
00253               Kokkos::MultiVector<RangeScalar,Node> &Y) const
00254     {}
00255 
00280     template <class DomainScalar, class RangeScalar>
00281     void
00282     multiply (Teuchos::ETransp trans,
00283               RangeScalar alpha,
00284               const Kokkos::MultiVector<DomainScalar,Node> &X,
00285               RangeScalar beta,
00286               Kokkos::MultiVector<RangeScalar,Node> &Y) const
00287     {}
00288 
00315     template <class DomainScalar, class RangeScalar>
00316     void
00317     solve (Teuchos::ETransp trans,
00318            const Kokkos::MultiVector<DomainScalar,Node> &Y,
00319            Kokkos::MultiVector<RangeScalar,Node> &X) const
00320     {}
00321 
00323   protected:
00325     EmptySparseKernel(const EmptySparseKernel& source);
00326 
00328     RCP<Node> node_;
00329   };
00330 
00337 } // end of namespace KokkosExamples
00338 
00339 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends