Ask Your Question

Linking to ATLAS/BLAS in Cython

asked 2011-03-21 15:46:42 +0100

updated 2011-03-22 00:57:40 +0100

I've been using GSL's CBLAS for performing "fast" matrix-vector arithmetic in a Cython script but I've been told that ATLAS' CBLAS is faster by a couple of factors. However, I'm having trouble locating the ATLAS libraries and headers in $SAGE_ROOT/local. Could someone provide tips on how to link to CBLAS in my Cython code? Thanks.

Edit: I found in how different implementations of BLAS are detected. However, I haven't found any example codes that cdef extern that functionality directly! Anyone have any examples of using Sage's detected version of ATLAS?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2011-03-22 01:41:55 +0100

William Stein gravatar image

Are you using OS X or Linux? The answer is slightly different on each platform.

Linux: Link in cblas instead of gslcblas. Observe:

wstein@sage:/tmp/wstein/$ ls -lh local/lib/*cblas*
-rw-r--r-- 1 wstein wstein 456K 2011-03-21 12:48 local/lib/libcblas.a
-rw-r--r-- 1 wstein wstein 147K 2011-02-25 08:33 local/lib/  # <---- see!

OS X: Link in cblas as well: it's the file /usr/lib/libcblas.dylib which comes with OS X. Note that OS X comes with its own excellent system-wide copy of ATLAS, which works well and has good parallel support.

edit flag offensive delete link more


But how would this work if I wanted to submit this code to Sage? I wouldn't want the user to have to specify which BLAS to use based on their operating system. Is there a way to get this information "dynamically"? If would I have to write a conditional similar to that near the top of for using "cdef extern..." in my code?

cswiercz gravatar imagecswiercz ( 2011-03-22 01:50:33 +0100 )edit

D'oh! I was a bit tired when I last commented and I understand now. Thanks!

cswiercz gravatar imagecswiercz ( 2011-03-24 19:49:06 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2011-03-21 15:46:42 +0100

Seen: 771 times

Last updated: Mar 22 '11