What is BLAS, and how to run MATLAB on an AMD processor

As we learned in class last week, BLAS, which stands for Basic Linear Algebra Subprogams, is a standardized application programming interface for publishing libraries to perform basic linear algebra operations. According to netlib, “BLAS are routines that provide standard building blocks for performing basic vector and matrix operations.” BLAS has three levels of routines, levels 1, 2, and 3.

Level 1 BLAS routines contain scalar, vector, and vector-vector operations, such as dot products and vector norms of the form

boldsymbol{y} leftarrow alpha boldsymbol{x} + boldsymbol{y} !

Level 2 BLAS routines contain matrix-vector operations of the form

boldsymbol{y} leftarrow alpha A boldsymbol{x} + beta boldsymbol{y} !

Level 3 BLAS routines contain matrix-matrix operations of the form

C leftarrow alpha A B + beta C !

The important thing to note about BLAS is that it is only a standard, not an implementation. Thus, there exist multiple implementations of BLAS by many different vendors.

Vendor

URL

AMD ACML
Apple Velocity Engine
Compaq CXML
Cray libsci
HP MLIB
IBM ESSL
Intel MKL
NEC PDLIB/SX
SGI SCSL
SUN Sun Performance Library

The list above contains machine-specific optimized implementations of BLAS. These vendor implemented optimizations are based on the hardware design of the processor they run on, because the architecture design can drastically effect the efficiency of a particular BLAS implementation.

Alternatively to one of the above vendor supported machine-specific optimizations, an open source BLAS implementation exists called ATLAS (Automatically Tuned Linear Algebra Software). ATLAS automatically generates an optimized BLAS library based on hardware information, but is performance often lags behind specialized vendor libraries because the minute hardware intricacies are unknown to open source developers and are not tailor made.

BLAS and MATLAB

According to MATLAB’s website, the software initially used ATLAS, but starting in release 14 Service Pack 1 (MATLAB 7.0.1), they switched over to hardware specific vendors, namely Intel’s Math Kernel Library (MKL), AMD’s Core Math Library (ACML), and vecLib on the Mac (Matlab 7.0).

However, for those running Microsoft Windows on an AMD machine (as opposed to some other OS) such as myself, we were out of luck. Because although MATLAB switched to ACML for AMD machines, it was only supported for non-windows machines.

“The AMD ACML BLAS is not supported on MATLAB 7.3 (R2006b) and on previous releases of MATLAB on the Windows platform.”

Thus, for 5 releases of MATLAB (R14.1, R14.2, R14.3, R2006a, R2006b), AMD users who ran Windows were unable to even start MATLAB due to a library incompatibility. The installation worked fine, you would double click on the MATLAB executable, the splash screen would load, and then MATLAB would close unexpectedly with no explanation and for no apparent reason.

Fortunately, however, there exists a quick fix. The actual problem isn’t that MATLAB R14.1 thru R2006b doesn’t support ACML on Windows machines. Although this is an inconvenience, and a big one at that, it is not the reason why MATLAB crashes. The problem is, for some reason MATLAB doesn’t recognize the processor string for AMD Athlon 64 processors (most AMD PC processors) in the Windows configuration. And to deal with such cases, MATLAB defaults to the Intel MKL in the event of an unrecognized CPU string, a big conflict for AMD users.

So MATLAB thinks you are running an Intel machine, and you still can’t run MATLAB. How is this fortunate, and how does this help you? Well, despite MATLAB’s transition from ATLAS to hardware vendor libraries, MATLAB continued to package the ATLAS libraries with its releases for some time after the switch, which means that on your computer there exists the libraries you need to run MATLAB. All that is needed is the addition of two lines at the bottom of the MATLAB’s BLAS specification file that is responsible for telling MATLAB which DLL file to use based on your processor vendor.

So to fix the problem, open

%MATLAB7%binwin32blas.spec

and append the following two lines to the end.

AuthenticAMD Family 15 Model 12 atlas_Athlon.dll # Athlon 64 (Newcastle)
AuthenticAMD Family 15 Model * atlas_Athlon.dll # AMD64

This will tell MATLAB to use the ATLAS libraries instead of defaulting to the Intel ones. Although it may not be as efficient as the ACML hardware optimized libraries, at least you can now run MATLAB on your AMD machine.

And for those who say, “who cares about an outdated version of MATLAB?” I agree. Since all releases since (R2007a, R2007b, R2008a) now have full and native ACML support, there appears to be no need. However, having spent countless wasted hours and days on the issue a few years ago and knowing how frustrating it can be finding a resolution, and after seeing numerous posts dating as recent as two days ago still searching for an answer with no reasonable help found, I thought I should pass along this bit of info.

http://www.netlib.org/blas/faq.html#1.6

http://en.wikipedia.org/wiki/Blas

http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/rn/f14-998197.html&http://www.mathworks.com/cgi-bin/texis/webinator/search_spt?db=MSS&prox=page&rorder=750&rprox=750&rdfreq=500&rwfreq=500&rlead=250&sufs=0&order=r&is_summary_on=1&pr=SPT&cq=1&collection=1&ResultCount=10&query=amd+64&x=0&y=0

http://www.mathworks.com/support/solutions/data/1-18QUC.html

http://en.wikipedia.org/wiki/Automatically_Tuned_Linear_Algebra_Software

http://unitstep.net/blog/2006/08/21/getting-matlab-to-run-on-a-newer-athlon-64-x2-cpu/

Posted in Topics: Uncategorized

Jump down to leave a comment.

One response to “What is BLAS, and how to run MATLAB on an AMD processor”

  1. Today is the great day - Blog Archive » matlab patch for amd processor Says:

    […] source reference […]

Leave a Comment

You must be logged in to post a comment.



* You can follow any responses to this entry through the RSS 2.0 feed.