BLAS in Maple

For double-precision ("hardware") real and complex floating-point operations on Matrices, Vectors, and Arrays Maple makes use of its external-calling mechanism to get to compiled code. A great deal of such compiled code for array operations requires what are known as Basic Linear Algebra Subprograms (BLAS). The BLAS libraries provide support not only directly for Matrix-Vector arithmetic but also indirectly in other external compiled libraries used by Statistics, ArrayTools, LinearAlgebra[Modular], etc.

In Maple 6, use was made on MS-Windows of the Intel Math Kernel Library (MKL) to provide BLAS faster than the soft of generic version found on netlib. MKL is still the "vendor" BLAS in use today for MS-Windows, in Maple 11.

On Linux, Solaris, and OSX on PowerPC, another set of BLAS that are faster than the generic implementation are used. This is the Automatically Tuned Linear Algebra Software (ATLAS).

I'm in the process of trying to sort out good use of ATLAS BLAS on OSX for Intel ("mactel"), with an eye to making the most out of the Core2 Duo's abilities.

On Linux and Solaris the ATLAS library used is a dynamic shared object. On OSX for PowerPC the ATLAS version used is still a static library, so doesn't appear immediately visible.

The rest of this note is mostly related specifically to Linux. If you have a question about MS-Windows, OSX, the history of BLAS in Maple, sparse BLAS, Goto BLAS, etc, then feel free to post a comment.

If people are interested in learning how one can unofficially "upgrade" the ATLAS version in use in Maple on Linux, I could add some detail on that. For most users it would not be worthwhile, as Maple 11 ships with a variety of ATLAS builds each tuned for speed on given architectural flavours of x86 and x86-64. But if you plan on buying one of the coming dual-core dual-cpu Athlon64s, or have some other exotic multi-CPU Linux machine, then it may be of interest. Feel free to add a comment, if it's of interest.

Two tips, to end up here:

To see details about your machine which Maple uses to decide which ATLAS version to run with, try this from a TTY Linux shell (console, xterm, etc):

< full path for Maple 11 >/bin.IBM_INTEL_LINUX/processor full

To see details on which ATLAS version is in use, try this from a TTY Linux shell (console, xterm, etc):

maple11 -s -z -q -c "define_external('ATL_buildinfo',LIB=\\\"libatlas.so\\\")()" -c quit

Dave Linder
Mathematical Software, Maplesoft

Comments

JacquesC's picture

ATLAS vs MKL

Are there some numbers (maybe from a 3rd party, out there on the web) comparing ATLAS vs MKL on various Intel processors and architectures? I am curious.

One question you did not address: AMD/Windows -- does that use ATLAS?

Is there no equivalent to the MKL for Linux? I thought the MKL was written in pure assembly and was self-contained, so that it would be O/S independent! Where was I being too naive?

Using an accelerated, fast BLAS

Using an accelerated, fast BLAS set is important, but after attaining a certain major proportional gain over generic refrence BLAS the smaller differences between fast implmentations becomes less important. An exception to that idea is that threaded parallel implementations for SMP or multi-core machines can still be a further major benefit. It's also often the case that resolving Maple Library level interpreted code bottlenecks is also a fruitful area for focus and improvement, especially once some fast BLAS has been utilized. In other words, once fast BLAS are in use on a platform then further tweaking to get a little more performance out of the BLAS is effort less well spent than would be finding other bottlenecks in the Maple Library -- with multithreading being a possible exception.

Cleve Moler made a brief mention in Cleve's Corner, Winter 2000, to the effect that there was not much difference between MKL and ATLAS. That statement is dated, or course. Any difference is going to change over time, depending on which makes best use of new chipset extensions in a timely fashion.

There is an AMD equivalent to Intel's MKL. It is the AMD ACML.

The past few releases of the Intel MKL have also been available for Linux. The Maple-NAG Connector toolbox allows for use of generic, MKL, or ACML BLAS where the corresponding supported NAG C Library allows.

Tip for today: The environment variable OMP_NUM_THREADS can be set to the number of SMP CPUs or cores, on a MS-Windows machine. The Intel MKL should pick this up and allow parallel computation, especially noticable in large floating-point level-3 BLAS calls. While this can bring a benefit for true multi-core machines, it can degrade performance on a single-core hyperthreaded CPU if nice access to cached data is ruined.

Dave Linder Mathematical Software, Maplesoft

alec's picture

Environment variable

I wonder why it was done this way, with introducing a new environment variable OMP_NUM_THREADS. Wouldn't it be more simle just to use standard Windows environment variable NUMBER_OF_PROCESSORS that is already set to the correct value by Windows?

Alec

MKL

Use of OMP_NUM_THREADS is an MKL thing rather than a Maple thing per se. I can conjecture as to the rationale of its use in MKL. It gives one some separate control of the CPU usage allotment which might not be possible were only a Windows variable used instead. Its use might also be seen as an effort to adhere to OpenMP.

Dave Linder
Mathematical Software, Maplesoft

alec's picture

Thank you

That's a very good explanation. Thank you!

Alec

alec's picture

Have no idea how this was posted

It has appeared after I posted a comment.

Windows tips?

<p>Actually, I would be interested to hear if there are any updates for Maple 12 (or future versions?) concerning the use of optimized external libraries. Moreover, I would appreciate some comments on the equivalent &quot;hacks&quot; for Windows of the above Linux &quot;hacks&quot;. Are there possibilities to make better use of the now widespread multi-core processors? Thanks for any comments...</p>

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}