Skip to content

cusplibrary/cusplibrary

Repository files navigation

CUSP : A C++ Templated Sparse Matrix Library

Linux Windows Coverage
Linux Windows Coverage

For more information, see the project documentation at CUSP Website.

A Simple Example

#include <cuda.h>
#include <thrust/version.h>

#include <cusp/version.h>
#include <cusp/hyb_matrix.h>
#include <cusp/io/matrix_market.h>
#include <cusp/krylov/cg.h>

#include <iostream>

int main(void)
{
    int cuda_major =  CUDA_VERSION / 1000;
    int cuda_minor = (CUDA_VERSION % 1000) / 10;
    int thrust_major = THRUST_MAJOR_VERSION;
    int thrust_minor = THRUST_MINOR_VERSION;
    int cusp_major = CUSP_MAJOR_VERSION;
    int cusp_minor = CUSP_MINOR_VERSION;
    std::cout << "CUDA   v" << cuda_major   << "." << cuda_minor   << std::endl;
    std::cout << "Thrust v" << thrust_major << "." << thrust_minor << std::endl;
    std::cout << "Cusp   v" << cusp_major   << "." << cusp_minor   << std::endl;

    // create an empty sparse matrix structure (HYB format)
    cusp::hyb_matrix<int, float, cusp::device_memory> A;

    // load a matrix stored in Matrix-Market format
    cusp::io::read_matrix_market_file(A, "./testing/data/laplacian/5pt_10x10.mtx");

    // allocate storage for solution (x) and right hand side (b)
    cusp::array1d<float, cusp::device_memory> x(A.num_rows, 0);
    cusp::array1d<float, cusp::device_memory> b(A.num_rows, 1);

    // solve the linear system A * x = b with the conjugate gradient method
    cusp::krylov::cg(A, x, b);

    return 0;
}

CUSP is a header-only library. To compile this example clone both CUSP and Nvidia/cccl:

git@github.com:cusplibrary/cusplibrary.git
cd cusplibrary
git clone git@github.com:NVIDIA/cccl.git
nvcc -Icccl/thrust -Icccl/libcudacxx/include -Icccl/cub -I. example.cu -o example

Stable Releases

CUSP releases are labeled using version identifiers having three fields:

Date Version Date Version
03/13/2015 CUSP v0.5.0
08/30/2013 CUSP v0.4.0
03/08/2012 CUSP v0.3.1
02/04/2012 CUSP v0.3.0
05/30/2011 CUSP v0.2.0
04/28/2015 CUSP v0.5.1 07/10/2010 CUSP v0.1.0

Contributors

CUSP is developed as an open-source project by NVIDIA Research. Nathan Bell was the original creator and Steven Dalton is the current primary contributor.

CUSP is available under the Apache v2.0 open source LICENSE

Citing

@MISC{Cusp,
  author = "Steven Dalton and Nathan Bell and Luke Olson and Michael Garland",
  title = "Cusp: Generic Parallel Algorithms for Sparse Matrix and Graph Computations",
  year = "2014",
  url = "http://cusplibrary.github.io/", note = "Version 0.5.0"
}