I often use Accelerate framework on macOS to speedup my calculations with matrices. The main program is written in Fortran, and the call to dgemm is essentially identical to that of the documentation on netlib.
In my current project, great performance improvement is expected from the use of sparse-dense matrix multiplication. I found that Accelerate contains a sparse_matrix_product_dense_double function (documentation). According to the documentation, the function should work on macOS 10.11+ (I have 13.2). Here is my question: is it possible to directly call this function from fortran? My naive tests with gfortran
program dgemm_demo
integer, parameter :: m = 3, n = 4, k = 5
double precision, allocatable :: A(:,:), B(:,:), C(:,:)
allocate(A(m,k), B(k, n), C(m, n))
A = 1.0D0
B = 2.0D0
call dgemm ('N', 'N', M, N, K, 1.0D0, A, m, B, k, 0.0D0, C, m)
call sparse_matrix_product_dense_double('CblasColMajor', 'CblasTrans', n, 1.0D0,&
sparse_matrix_create_double(m, k), B, n, C, n)
end program dgemm_demo
return linking error
Undefined symbols for architecture arm64
It is possible. Accelerate exposes an API very similar to Sparse BLAS as part of vecLib. (The Sparse BLAS API is defined by the BLAS Technical Forum.)
Search for
BLAS.husing Finder to get a full overview of the available routines. You can also locate the header using the command:$ find /Library/Developer -name BLAS.h.As a vendor-agnostic, yet performant, cross-platform Sparse BLAS alternative, you might also consider librsb.
Here's an example of multiplying a sparse matrix A with a dense matrix B using the Sparse BLAS in Accelerate: