1

I just discovered that SparseBLAS is included in the Accelerate Framework of OSX in OSX.

% ls -l /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A 
total 25360
drwxr-xr-x  5 root  wheel       170 May 18 09:49 Resources/
drwxr-xr-x  3 root  wheel       102 May 18 09:49 _CodeSignature/
-rwxr-xr-x  1 root  wheel   5115440 May  5 08:00 libBLAS.dylib*
-rwxr-xr-x  1 root  wheel  13518752 May  5 08:00 libLAPACK.dylib*
-rwxr-xr-x  1 root  wheel    254240 May  5 08:00 libLinearAlgebra.dylib*
-rwxr-xr-x  1 root  wheel    334128 May  5 08:00 libSparseBLAS.dylib*
-rwxr-xr-x  1 root  wheel   3715824 May  5 08:00 libvDSP.dylib*
-rwxr-xr-x  1 root  wheel   2602304 May  5 08:00 libvMisc.dylib*
-rwxr-xr-x  1 root  wheel     50320 May  5 08:07 vecLib*

I am trying to find if I can use that to optimize my computations, but information on this topic is scarce to none.

The only sensible code I've found is this question, but including the Accelerate.h header isn't sufficient to find sparse routines such as BLAS_duscr_begin, mentioned in the question.

To be clear, I cannot find any reference to sparse-anything in the official Accelerate Framework from Apple.

Any luck on the topic?

Community
  • 1
  • 1
senseiwa
  • 2,369
  • 3
  • 24
  • 47

2 Answers2

2

I haven't found any sign that SparseBLAS exists in Accelerate Framework.

But if you would accept other options, I would suggest MKL, which is free to use for all users now.

https://software.intel.com/en-us/articles/free-mkl

If you would accept some performance penalty and want to make you life easier, you could use Eigen.

http://eigen.tuxfamily.org/index.php?title=Main_Page

Or Eigen with MKL support. Although only dense matrix operation will be accelerated by MKL, it is still good to use Eigen as a container.

https://eigen.tuxfamily.org/dox/TopicUsingIntelMKL.html


With the help of MKL link line advisor

https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor

you sould be able to use threaded MKL with clang compiler.

Note that threaded MKL need Intel OpenMP support does not mean you need a compiler that supports OpenMP as you do not attempt to use #pragma omp in you code.

kangshiyin
  • 9,681
  • 1
  • 17
  • 29
  • Thanks @Eric, but it seems that MKL won't support threads with `clang`. – senseiwa Jun 15 '16 at 08:59
  • I haven't tried but according to this, it supports openmp with `-liomp5` link option. https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor – kangshiyin Jun 15 '16 at 09:04
  • True, but I don't have OpenMP, so I cannot link `libiomp5.dylib`. I think the `i` stands for Intel, so it could be a `icc`-only library. – senseiwa Jun 15 '16 at 10:56
  • The link I provided indicates that it can be used with clang. Linking a lib that uses openmp does not means you need a compiler that supports openmp. You just need a linker that can link you obj, the lib (MKL) and the openmp lib (iomp5) together. MKL link line advisor (the link) can generate the correct link and compile options for you to use threaded MKL with clang. – kangshiyin Jun 15 '16 at 11:05
  • Thanks @Eric. There is no OpenMP library I can use though. At least, not without resorting to GCC. Am I missing something? – senseiwa Jun 29 '16 at 17:10
  • `clang -liomp5 -lall_mkl_libs your_code_calling_mkl_routines.cc -o out.exe` should work. @senseiwa – kangshiyin Jun 29 '16 at 17:14
2
#include <veclib/Sparse/BLAS.h>

Behold the wonders within!

https://developer.apple.com/videos/play/wwdc2015/712/ Luke Chang

Ian Ollmann
  • 1,592
  • 9
  • 16
  • Thanks for the pointer, I missed the video. It seems though, I cannot see how to "properly" use the library. I mean, it's not in the list of libraries I can add in Xcode. Have you succeeded in having openblas "the apple way"? – senseiwa Jun 29 '16 at 17:08
  • #include and -framework Accelerate should be enough – Ian Ollmann Jul 06 '16 at 02:11
  • Nope... **main.cpp:43:10: fatal error: 'veclib/Sparse/BLAS.h' file not found** `#include `. I don't even get to the linker, does it work for you? Of course `#include ` works, I am using OSX 10.11.5, Xcode 7.3.1 with Apple LLVM version 7.3.0 (clang-703.0.31). – senseiwa Jul 06 '16 at 08:24