ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 24 Mar 2011 13:49:06 -0500Linking to ATLAS/BLAS in Cythonhttp://ask.sagemath.org/question/8017/linking-to-atlasblas-in-cython/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 ``module_list.py`` 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?Mon, 21 Mar 2011 09:46:42 -0500http://ask.sagemath.org/question/8017/linking-to-atlasblas-in-cython/Answer by William Stein for <p>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 <code>$SAGE_ROOT/local</code>. Could someone provide tips on how to link to CBLAS in my Cython code? Thanks.</p>
<p><em>Edit</em>: I found in <code>module_list.py</code> how different implementations of BLAS are detected. However, I haven't found any example codes that <code>cdef extern</code> that functionality directly! Anyone have any examples of using Sage's detected version of ATLAS?</p>
http://ask.sagemath.org/question/8017/linking-to-atlasblas-in-cython/?answer=12217#post-id-12217Are 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/sage-4.6.2-sage.math.washington.edu-x86_64-Linux$ 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/libcblas.so # <---- 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.
Mon, 21 Mar 2011 19:41:55 -0500http://ask.sagemath.org/question/8017/linking-to-atlasblas-in-cython/?answer=12217#post-id-12217Comment by cswiercz for <p>Are you using OS X or Linux? The answer is slightly different on each platform. </p>
<p>Linux: Link in cblas instead of gslcblas. Observe:</p>
<pre><code>wstein@sage:/tmp/wstein/sage-4.6.2-sage.math.washington.edu-x86_64-Linux$ 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/libcblas.so # <---- see!
</code></pre>
<p>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. </p>
http://ask.sagemath.org/question/8017/linking-to-atlasblas-in-cython/?comment=21945#post-id-21945D'oh! I was a bit tired when I last commented and I understand now. Thanks!Thu, 24 Mar 2011 13:49:06 -0500http://ask.sagemath.org/question/8017/linking-to-atlasblas-in-cython/?comment=21945#post-id-21945Comment by cswiercz for <p>Are you using OS X or Linux? The answer is slightly different on each platform. </p>
<p>Linux: Link in cblas instead of gslcblas. Observe:</p>
<pre><code>wstein@sage:/tmp/wstein/sage-4.6.2-sage.math.washington.edu-x86_64-Linux$ 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/libcblas.so # <---- see!
</code></pre>
<p>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. </p>
http://ask.sagemath.org/question/8017/linking-to-atlasblas-in-cython/?comment=21952#post-id-21952But 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 module_list.py for using "cdef extern..." in my code?Mon, 21 Mar 2011 19:50:33 -0500http://ask.sagemath.org/question/8017/linking-to-atlasblas-in-cython/?comment=21952#post-id-21952