Kokkos Node API and Local Linear Algebra Kernels Version of the Day
DummySparseKernelDriver.cpp
Go to the documentation of this file.
00001 #include "Kokkos_DummySparseKernelClass.hpp"
00002 #include <Kokkos_MultiVector.hpp>
00003 #include <Kokkos_DefaultNode.hpp>
00004 
00009 int main() {
00010 
00011   typedef Kokkos::DefaultNode::DefaultNodeType                 Node;
00012   typedef KokkosExamples::DummySparseKernel<Node>         SparseOps;
00013   typedef Kokkos::CrsGraph <       int,Node,SparseOps>        Graph;
00014   typedef Kokkos::CrsMatrix<double,int,Node,SparseOps>    DoubleMat;
00015   typedef Kokkos::CrsMatrix< float,int,Node,SparseOps>     FloatMat;
00016   typedef Kokkos::MultiVector<double,Node>                DoubleVec;
00017   typedef Kokkos::MultiVector<float,Node>                  FloatVec;
00018 
00019   std::cout << "Note, this class doesn't actually do anything. We are only testing that it compiles." << std::endl;
00020 
00021   // get a pointer to the default node
00022   Teuchos::RCP<Node> node = Kokkos::DefaultNode::getDefaultNode();
00023 
00024   // create the graph G
00025   const size_t numRows = 5;
00026   Graph G(numRows,node);
00027 
00028   // create a double-valued matrix dM using the graph G
00029   DoubleMat dM(G);
00030   // create a double-valued sparse kernel using the rebind functionality
00031   SparseOps::rebind<double>::other doubleKernel(node);
00032   // initialize it with G and dM
00033   doubleKernel.initializeStructure(G);
00034   doubleKernel.initializeValues(dM);
00035   // create double-valued vectors and initialize them
00036   DoubleVec dx(node), dy(node);
00037   // test the sparse kernel operator interfaces
00038   doubleKernel.multiply( Teuchos::NO_TRANS, 1.0, dx, dy);
00039   doubleKernel.multiply( Teuchos::NO_TRANS, 1.0, dx, 1.0, dy);
00040   doubleKernel.solve( Teuchos::NO_TRANS, Teuchos::UPPER_TRI, Teuchos::UNIT_DIAG, dy, dx);
00041 
00042   // create a float-valued matrix fM using the graph G
00043   FloatMat fM(G);
00044   // create a double-valued sparse kernel using the rebind functionality
00045   SparseOps::rebind<float>::other floatKernel(node);
00046   // initialize it with G and fM
00047   floatKernel.initializeStructure(G);
00048   floatKernel.initializeValues(fM);
00049   // create float-valued vectors and initialize them
00050   FloatVec fx(node), fy(node);
00051   // test the sparse kernel operator interfaces
00052   floatKernel.multiply( Teuchos::NO_TRANS, 1.0f, fx, fy);
00053   floatKernel.multiply( Teuchos::NO_TRANS, 1.0f, fx, 1.0f, fy);
00054   floatKernel.solve( Teuchos::NO_TRANS, Teuchos::UPPER_TRI, Teuchos::UNIT_DIAG, fy, fx);
00055 
00056   std::cout << "End Result: TEST PASSED" << std::endl;
00057   return 0;
00058 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends