GraphBLAS in MATLAB: simple, fast, and ready-to-use.

I just posted a formal release of SuiteSparse:GraphBLAS 3.1.0 with a new MATLAB interface.

See http://faculty.cse.tamu.edu/davis/GraphBLAS.html for the latest code.

Version 3.1.0  introduces the GrB object to MATLAB, with all operators fully overloaded.  You can even call the built-in m-file gmres on a GrB sparse matrix (either 'double' or 'single', as you prefer) and it works without a problem.

The new GrB object is many times faster than the built-in MATLAB sparse matrix computations, for most operations.  For example, my MATLAB solution to the Sparse Deep Neural Network problem for the Graph Challenge, is about 60x to 120x faster than the MATLAB reference implementation, while at the same time being extremely simple to write.

The interface is stable and ready to use in production, but it does have a few limitations that I will be addressing in the future.  For example, when working with "sparse" vectors where ever entry is present, it's faster to use a MATLAB dense vector, as opposed to a GraphBLAS sparse vector.

The GraphBLAS GrB_Vector and GrB_Matrix objects are opaque, of course.  So in my next release, I plan on adding a feature where I drop the integer indices if every entry is present in the vector or matrix.  Then I can use the dense BLAS on them, so I'll match the performance of MATLAB.

I've already found that it's quicker to prototype an algorithm in MATLAB, with GraphBLAS, than writing in the C API.  And you don't lose any performance:  about 2% performance loss for the bigger problems is what I've seen.

In some cases, using MATLAB + GraphBLAS is faster than C. My GrB.pagerank method uses MATLAB dense vectors mixed with GraphBLAS sparse matrices, and it is many times faster than the built-in pagerank method in MATLAB (see 'help centrality' in MATLAB). In fact, GrB.pagerank in MATLAB is only 3x slower than the GAP pagerank benchmark (http://gap.cs.berkeley.edu/benchmark.html) The performance gap (no pun intended) will be reduced further in the future.

MATLAB sparse and dense matrices and vectors can be freely mixed with GraphBLAS sparse matrices. On input, if the MATLAB matrix or vector is full, I have to add its integer indices to convert it into a GrB_Matrix or GrB_Vector to use with GraphBLAS. That adds some time, but it's what I'm doing on each iteration of GrB.pagerank. Once I add dense GrB_Vectors and GrB_matrices to GraphBLAS, I can skip this step, and get even closer to the GAP performance benchmark.

So stay tuned ...

Leave a Reply

Your email address will not be published. Required fields are marked *