Kokkos Node API and Local Linear Algebra Kernels Version of the Day

Classes  
class  Kokkos::CrsGraphHostCompute< Ordinal, Node, LocalMatOps > 
A default hostcompute compressedrow sparse graph. More...  
class  Kokkos::CrsGraphDeviceCompute< Ordinal, Node, LocalMatOps > 
A default devicecompute compressedrow sparse graph.This is externally identical to the hostbased graph; in fact, it derives from CrsGraphHostCompute. The difference is that that it contains additional storage and logic for devicebound compute buffers. More...  
class  Kokkos::CrsGraph< Ordinal, Node, LocalMatOps > 
Kokkos compressedrow sparse graph class.Default specialization is a hostbound CrsGraphHostCompute object. More...  
class  Kokkos::CrsMatrixHostCompute< Scalar, Ordinal, Node, LocalMatOps > 
A default hostcompute compressedrow sparse matrix. More...  
class  Kokkos::CrsMatrixDeviceCompute< Scalar, Ordinal, Node, LocalMatOps > 
A default devicecompute compressedrow sparse matrix.This is externally identical to the hostbased matrix; in fact, it derives from CrsMatrixHostCompute. The difference is that that it contains additional storage and logic for devicebound compute buffers. More...  
class  Kokkos::CrsMatrix< Scalar, Ordinal, Node, LocalMatOps > 
Kokkos compressedrow sparse matrix class.Default specialization is a hostbound CrsMatrixHostCompute object. More...  
struct  Kokkos::DefaultKernels< Scalar, Ordinal, Node > 
Traits class providing default kernel types for CRS, block CRS and relaxation kernels. More...  
class  Kokkos::DefaultHostSparseOps< Scalar, Ordinal, Node > 
Default implementation of sparse matrixvector multiplication and solve routines, for hostbased nodes. More...  
class  Kokkos::DefaultDeviceSparseOps< Scalar, Ordinal, Node > 
Default implementation of sparse matrixvector multiplication and solve routines, for devicebased nodes. More...  
class  Kokkos::CrsGraph< Ordinal, Node, KokkosExamples::DummySparseKernel< Node > > 
A partial specialization of CrsGraph for use with KokkosExamples::DummySparseKernelThis specialization inherits from CrsGraphHostCompute. The consequence of this is that it is only appropriate for use on hostbased nodes; and that it doesn't specialize any capability based on the KokkosExamples::DummySparseKernel provider (which is fine, because this is for demonstration purposes only.) More...  
class  Kokkos::CrsMatrix< Scalar, Ordinal, Node, KokkosExamples::DummySparseKernel< Node > > 
A partial specialization of CrsMatrix for use with KokkosExamples::DummySparseKernelThis specialization inherits from CrsMatrixHostCompute. The consequence of this is that it is only appropriate for use on hostbased nodes; and that it doesn't specialize any capability based on the KokkosExamples::DummySparseKernel provider (which is fine, because this is for demonstration purposes only.) More...  
class  KokkosExamples::DummySparseKernel< Node > 
A dummyclass illustrating the components necessary for a Kokkos sparse operations provider. More... 
In order to facilitate the substitution of sparse matrix kernels in classes such as Tpetra::CrsMatrix, Kokkos separates the data structure interface for a compressedsparserow (CRS) matrix from the kernel for implemeneting sparse matrixvector multiplication and solves. However, the appropriate implementation of these kernels for a particular platform may dictate some of the design of the storage classes. Furthermore, for efficiency reasons, these decisions must be implemented statically. The approach that Tpetra employs is to template the distributed Tpetra::CrsMatrix objects on the type of the local matrix kernels. This decision permeates down to the level of the CRS objects in the Kokkos linear algebra library.
The primary object in this discussion is the class providing the sparse matrix kernels. The simplest way to modify the operation of the Tpetra objects is to first create a new sparse kernels class and then to template the Tpetra::CrsMatrix and Tpetra::CrsGraph objects on this kernel class.
The following simplified code demonstrates the relationship between these objects and their typical usage:
Graph< int, SparseKernels > G; Matrix< double, int, SparseKernels > M(G); SparseKernels ops; ops.submitData( M ); ops.multiply( x, y ); ops.solve( b, x );
In this example, we instantiate a graph and a matrix. Note, the sparse kernel object SparseKernels
is a template parameter of the CrsGraph
and CrsMatrix
objects. By parametrizing these classes in this way, we can effect the design of these classes according to the sparse kernels that we are interested in using, for example, by specializing these classes. After creating the sparse graph and sparse matrix objets, we instantiate a SparseKernel
object and submit the data. Finally, the sparse kernel object can be used to apply the sparse matrix mutiply and solve routines.
The sparse kernel class must obviously provide the functionality for matrixvector multiply and matrixvector solve. Some other functionality is required of this class as well.
The code below illustrates these use cases for a sparse kernel provider, as they appear in Tpetra and other Kokkosenabled linear algebra packages. This example is located at kokkos/LinAlg/examples/DummySparseKernelDriver.cpp.
#include "Kokkos_DummySparseKernelClass.hpp" #include <Kokkos_MultiVector.hpp> #include <Kokkos_DefaultNode.hpp> int main() { typedef Kokkos::DefaultNode::DefaultNodeType Node; typedef KokkosExamples::DummySparseKernel<Node> SparseOps; typedef Kokkos::CrsGraph < int,Node,SparseOps> Graph; typedef Kokkos::CrsMatrix<double,int,Node,SparseOps> DoubleMat; typedef Kokkos::CrsMatrix< float,int,Node,SparseOps> FloatMat; typedef Kokkos::MultiVector<double,Node> DoubleVec; typedef Kokkos::MultiVector<float,Node> FloatVec; std::cout << "Note, this class doesn't actually do anything. We are only testing that it compiles." << std::endl; // get a pointer to the default node Teuchos::RCP<Node> node = Kokkos::DefaultNode::getDefaultNode(); // create the graph G const size_t numRows = 5; Graph G(numRows,node); // create a doublevalued matrix dM using the graph G DoubleMat dM(G); // create a doublevalued sparse kernel using the rebind functionality SparseOps::rebind<double>::other doubleKernel(node); // initialize it with G and dM doubleKernel.initializeStructure(G); doubleKernel.initializeValues(dM); // create doublevalued vectors and initialize them DoubleVec dx(node), dy(node); // test the sparse kernel operator interfaces doubleKernel.multiply( Teuchos::NO_TRANS, 1.0, dx, dy); doubleKernel.multiply( Teuchos::NO_TRANS, 1.0, dx, 1.0, dy); doubleKernel.solve( Teuchos::NO_TRANS, Teuchos::UPPER_TRI, Teuchos::UNIT_DIAG, dy, dx); // create a floatvalued matrix fM using the graph G FloatMat fM(G); // create a doublevalued sparse kernel using the rebind functionality SparseOps::rebind<float>::other floatKernel(node); // initialize it with G and fM floatKernel.initializeStructure(G); floatKernel.initializeValues(fM); // create floatvalued vectors and initialize them FloatVec fx(node), fy(node); // test the sparse kernel operator interfaces floatKernel.multiply( Teuchos::NO_TRANS, 1.0f, fx, fy); floatKernel.multiply( Teuchos::NO_TRANS, 1.0f, fx, 1.0f, fy); floatKernel.solve( Teuchos::NO_TRANS, Teuchos::UPPER_TRI, Teuchos::UNIT_DIAG, fy, fx); std::cout << "End Result: TEST PASSED" << std::endl; return 0; }
This example makes use of the sparse kernel provider stubbed in the class KokkosExamples::DummySparseKernel, located in the file kokkos/LinAlg/examples/Kokkos_DummySparseKernelClass.hpp. This file, along with the unit test kokkos/LinAlg/test/CrsMatrix/CrsMatrix_DefaultMultiply.cpp, demonstrate the implementation requirements for a sparse kernel provider.