Monday, December 5, 2011

Just snorted my beer -- Awesomeness of NumPy built with Intel's MKL

A quick shout out to Christoph Gohlke and his Python Windows installers, one of which is NumPy compiled against Intel's MKL.  Thanks man.  I've never met you, but I owe you a coffee.


Last night I installed Python, PyDev, and NumPy.  Numpy is a math library for Python.  Revisited the timings I saw in R and Python was faster (no surprise).  I got to thinking, what it you built Numpy against a BLAS/LAPACK library like MKL or ACML (AMD's version)?  Quick searching found Mr. Gohlke's site, from which I re-installed Numpy and grabbed a few others.


Tonight I reran the tests.
import numpy
import time

def flops(ops, sec):
    Gflops = op/sec/1000000000
    outStr =  "{0:6.2f} GFlops on {1:13.0f} operations in {2:3.2f} seconds.".format(Gflops, ops, sec)
    print outStr

n = 4000

a = numpy.eye(n)
a = numpy.matrix(a)

time.clock()

s = time.clock()
b = a*a
e = time.clock()

op = (2*n**3 - n**2)
s = e-s

flops(op,s)
a = numpy.ones((n,n))*.9 + a*.1

s = time.clock()
b = numpy.linalg.cholesky(a)
e = time.clock()

flops((n**3)/3,(e-s))
print b[0:3,0:3]
  
Here is the output:
 17.09 GFlops on  127984000000 operations in 7.49 seconds.
 67.83 GFlops on   21333333333 operations in 1.89 seconds.
[[ 1.          0.                   0.                 ]
 [ 0.9         0.43588989  0.                 ]
 [ 0.9         0.20647416  0.38388595]] 
 Beer Snorted.

No comments:

Post a Comment