Re: [Numpy-discussion] debian benchmarks

2010-07-06 Thread Francesc Alted
A Monday 05 July 2010 15:32:51 Isaac Gouy escrigué:
 Sturla Molden sturla at molden.no writes:
  It is also the kind of tasks where NumPy would help. It would be nice to
  get NumPy into the shootout. At least for the sake of advertising
 
 http://shootout.alioth.debian.org/u32/program.php?test=spectralnormlang=py
 thonid=2

Let's join the game :-)  If I run the above version on my desktop computer 
(Intel E8600 Duo @ 3 GHz, DDR2 @ 800 MHz memory) I get:

$ time python -OO spectralnorm-numpy.py 5500
1.274224153

real0m9.724s
user0m9.295s
sys 0m0.269s

which should correspond to the 12.86s in shootout (so my machine is around 30% 
faster).  But, if I use ATLAS (3.9.25) so as to accelerate linear algebra:

$ python -OO spectralnorm-numpy.py 5500
1.274224153

real0m5.862s
user0m5.566s
sys 0m0.225s

Then, my profile said that building M matrix took a lot of time.  After using 
numexpr to improve this (see attached script), I get:

$ python -OO spectralnorm-numpy-numexpr.py 5500
1.274224153

real0m3.333s
user0m3.071s
sys 0m0.163s

Interestingly, memory consumption also dropped from 480 MB to 255 MB.  
Finally, if using Intel's MKL for taking advantage of my 2 cores:

$ python -OO spectralnorm-numpy-numexpr.py 5500
1.274224153

real0m2.785s
user0m4.117s
sys 0m0.139s

which is a 3.5x improvement over the initial version.  Also, this seems faster 
(around ~25%), and consumes similar memory than the fastest version written in 
pure C in interesting alternatives section:

http://shootout.alioth.debian.org/u32/performance.php?test=spectralnorm#about

I suppose that, provided that Matlab also have a JIT and supports Intel's MKL, 
it could beat this mark too.  Any Matlab user would accept the challenge?

-- 
Francesc Alted
# The Computer Language Benchmarks Game
# http://shootout.alioth.debian.org/
#
# Contributed by Sebastien Loisel
# Fixed by Isaac Gouy
# Sped up by Josh Goldfoot
# Dirtily sped up by Simon Descarpentries
# Sped up with numpy by Kittipong Piyawanno
# More speed-up with Numexpr by Francesc Alted

from sys import argv
import numpy as np
import numexpr as ne

def spectralnorm(n):
u = np.matrix(np.ones(n))
j = np.arange(n, dtype=np.float64)
M = np.empty(n*n, dtype=np.float64).reshape(n,n)
expr = 1.0 / ((i + j) * (i + j + 1) / 2 + i + 1)
for i in xrange(n):
M[i] = ne.evaluate(expr)
MT = M.T
for i in xrange(10):
v = (u*MT)*M
u = (v*MT)*M
print %0.9f % ((u*v.T).sum() / (v*v.T).sum())**0.5

spectralnorm(int(argv[1]))
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] debian benchmarks

2010-07-05 Thread Isaac Gouy
Sturla Molden sturla at molden.no writes:

   
 It is also the kind of tasks where NumPy would help. It would be nice to 
 get NumPy into the shootout. At least for the sake of advertising 



http://shootout.alioth.debian.org/u32/program.php?test=spectralnormlang=pythonid=2

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] debian benchmarks

2010-07-04 Thread Sebastian Haase
On Sun, Jul 4, 2010 at 4:32 AM, Sturla Molden stu...@molden.no wrote:
 I was just looking at Debian's benchmark. LuaJIT is now (on median)
 beating Intel Fortran! Consider that Lua is a dynamic language very
 similar to Python. I know it's just a benchmark but this has to count
 as insanely impressive. Beating Intel Fortran with a dynamic scripting
 language... How is that even possible?

 If this keeps up we'll need a Python to Lua compiler very soon. And
 LuaJIT 2 is rumoured to be much faster than the current...

 Looking at median runtimes, here is what I got:

      gcc               1.10
   LuaJIT            1.96
   Java 6 -server    2.13
   Intel Fortran     2.18
   OCaml             3.41
   SBCL              3.66
   JavaScript V8     7.57

   PyPy             31.5
   CPython          64.6
   Perl             67.2
   Ruby 1.9         71.1

 This means that LuaJIT can do in less than a day what CPython can do in
 a month. The only comfort for CPython is that Ruby and Perl did even worse.

 I wonder how much better CPython would do with NumPy on this benchmark?

 Sturla

Hi Sturla,
what is this even about ... ? Do you have some references ?  It does
indeed sound interesting ... but what kind of code / problem are they
actually testing here ?

Thanks,
Sebastian Haase
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] debian benchmarks

2010-07-04 Thread Sturla Molden
Sebastian Haase skrev:
 Hi Sturla,
 what is this even about ... ? Do you have some references ?  It does
 indeed sound interesting ... but what kind of code / problem are they
 actually testing here ?

   
http://shootout.alioth.debian.org/u32/which-programming-languages-are-fastest.php

They are benchmarking with tasks that burns the CPU, like computing and 
bitmapping Mandelbrot sets and processing DNA data.



Sturla

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] debian benchmarks

2010-07-04 Thread Sturla Molden
Sturla Molden skrev:
 http://shootout.alioth.debian.org/u32/which-programming-languages-are-fastest.php

 They are benchmarking with tasks that burns the CPU, like computing and 
 bitmapping Mandelbrot sets and processing DNA data.

   
It is also the kind of tasks where NumPy would help. It would be nice to 
get NumPy into the shootout. At least for the sake of advertising :-)


___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion