4
$\begingroup$

BLAS is short for "Basic Linear Algebra Subprograms". It is a famous collection of routines for doing linear algebra. I just know from Oleksandr R. that mma can directly call BLAS under the context "LinearAlgebra`BLAS". I don't know why mma makes it undocumented.

Oleksandr R. provide an example of using GER

$$ \mathrm{GER}: \alpha, \vec{x}, \vec{y}, \mathbf{A} : \mathbf{A} \leftarrow \alpha \vec{x} {\vec{y}}^\mathrm{T} + \mathbf{A} $$

like this

A = RandomReal[1., {40000000, 2}];
alpha = 1.;
x = ConstantArray[1., Length[A]];
y = {1., 2.};
LinearAlgebra`BLAS`GER[alpha, x, y, A]; // AbsoluteTiming

to achieve the same result of

Transpose[{1., 2.} + Transpose@A]; // AbsoluteTiming

Oleksandr R.'s timing shows that BLAS approach is faster. While strangely, on my computer, I tried many times BLAS is much slower than double transpose with mma 10.3, windows system.

enter image description here

I also tried it on an HPC with linux version mma 10.3 installed

enter image description here

At this moment, it seems that maybe it is the problem of windows version 10.3. But after I tried on my friend's computer, I know it is not. Here is timing on his computer, also windows system

enter image description here

So what is wrong, how to explain this? My cpu is Intel Core i3-4500U, and 64 bit win8 system. My memory is 8GB, and there is 1.2GB for ramdisk

$\endgroup$

closed as unclear what you're asking by MarcoB, user9660, dr.blochwave, Dr. belisarius, bbgodfrey Nov 25 '15 at 6:04

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Try adding parentheses, e.g. (LinearAlgebra`BLAS`GER[alpha, x, y, A]; // AbsoluteTiming) to be sure you are not timing something else. Also keep in mind, as @OleksandrR mentioned, that it is not a fair comparison if you are overwriting A. $\endgroup$ – ilian Nov 21 '15 at 17:00
  • $\begingroup$ Does your computer have an AMD processor? How about the HPC cluster? It seems unlikely, but perhaps this could explain it. $\endgroup$ – Oleksandr R. Nov 21 '15 at 21:10
  • $\begingroup$ @OleksandrR. Yeah, unlikely, both are intel $\endgroup$ – matheorem Nov 22 '15 at 0:50
  • $\begingroup$ @ilian Actually, I didn't see any significant different whether to add overwriting A or not. So I just omitted. And after all, this is apparently not the point. Since on my friend's computer, the code is exactly the same $\endgroup$ – matheorem Nov 22 '15 at 0:53
  • 2
    $\begingroup$ @matheorem In your Linux screenshot, the timing measured for In[1] definitely includes generating A which is not correct. As for the Windows difference, I haven't been able to reproduce it. Could you perhaps include the exact CPU models and the amount of RAM for both machines? I'd also suggest setting $HistoryLength=0 first. $\endgroup$ – ilian Nov 22 '15 at 1:12