Kokkos Node API and Local Linear Algebra Kernels Version of the Day
Classes
Kokkos Compresssed-Row Sparse API

Classes

class  Kokkos::CrsGraphHostCompute< Ordinal, Node, LocalMatOps >
 A default host-compute compressed-row sparse graph. More...
class  Kokkos::CrsGraphDeviceCompute< Ordinal, Node, LocalMatOps >
 A default device-compute compressed-row sparse graph.This is externally identical to the host-based graph; in fact, it derives from CrsGraphHostCompute. The difference is that that it contains additional storage and logic for device-bound compute buffers, and it over-rides finalize() to fill these. More...
class  Kokkos::FirstTouchHostCrsGraph< Ordinal, Node, LocalMatOps >
 A host-compute compressed-row sparse graph with first-touch allocation. More...
class  Kokkos::CrsGraph< Ordinal, Node, LocalMatOps >
 Kokkos compressed-row sparse graph class.Default specialization is a host-bound CrsGraphHostCompute object. More...
class  Kokkos::CrsMatrixHostCompute< Scalar, Ordinal, Node, LocalMatOps >
 A default host-compute compressed-row sparse matrix. More...
class  Kokkos::CrsMatrixDeviceCompute< Scalar, Ordinal, Node, LocalMatOps >
 A default device-compute compressed-row sparse matrix.This is externally identical to the host-based matrix; in fact, it derives from CrsMatrixHostCompute. The difference is that that it contains additional storage and logic for device-bound compute buffers. More...
class  Kokkos::FirstTouchHostCrsMatrix< Scalar, Ordinal, Node, LocalMatOps >
 A host-compute compressed-row sparse matrix with first-touch allocation. More...
class  Kokkos::CrsMatrix< Scalar, Ordinal, Node, LocalMatOps >
 Kokkos compressed-row sparse matrix class.Default specialization is a host-bound CrsMatrixHostCompute object. More...
class  Kokkos::CUSPSparseOps< Scalar, Ordinal, Node >
 Access to sparse matrix multiply and solve using the CUSP project. More...
class  CrsGraph< Ordinal, Node, CUSPSparseOps< void, Ordinal, Node > >
 A partial specialization of CrsGraph for use with CUSPSparseOps.This implementation is supported by CrsGraphHostCompute, even though the computation will occur on the GPU. The reason is that CUSP will be responsible for the organization of data and the implementation of the kernel; parent CrsGraphHostCompute will handle of the interfaces needed by Kokkos. More...
class  CrsMatrix< Scalar, Ordinal, Node, CUSPSparseOps< void, Ordinal, Node > >
 A partial specialization of CrsMatrix for use with the CUSPSparseOps interface.This implementation is supported by CrsMatrixHostCompute, even though the computation will occur on the GPU. The reason is that CUSP will be responsible for the organization of data and the implementation of the kernel; parent CrsMatrixHostCompute will handle of the interfaces needed by Kokkos. 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 matrix-vector multiplication and solve routines, for host-based nodes. More...
class  Kokkos::DefaultDeviceSparseOps< Scalar, Ordinal, Node >
 Default implementation of sparse matrix-vector multiplication and solve routines, for device-based nodes. More...
class  KokkosExamples::DummySparseKernel< Node >
 A dummy-class illustrating the components necessary for a Kokkos sparse operations provider. More...

Detailed Description

In order to facilitate the substitution of sparse matrix kernels in classes such as Tpetra::CrsMatrix, Kokkos separates the data structure interface for a compressed-sparse-row (CRS) matrix from the kernel for implemeneting sparse matrix-vector 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.

Note:
It may seem strange that the Kokkos and Tpetra CRS graph objects are templated on the sparse kernels class, as the graph object does not provide multiplication and solve methods. However, because the sparse kernels may dictate the storage, they must have some input into the design of the sparse graph class, in addition to their obvious significance to the matrix 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 matrix-vector multiply and matrix-vector 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 Kokkos-enabled 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 double-valued matrix dM using the graph G
  DoubleMat dM(G);
  // create a double-valued 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 double-valued 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 float-valued matrix fM using the graph G
  FloatMat fM(G);
  // create a double-valued 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 float-valued 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.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends