[Numpy-discussion] performance comparison of C++ vs Numeric (MA) operations.
Paul F. Dubois
paul at pfdubois.com
Tue Jun 12 21:23:13 EDT 2001
PS my test was on double precision, failed to notice that too.
-----Original Message-----
From: numpy-discussion-admin at lists.sourceforge.net
[mailto:numpy-discussion-admin at lists.sourceforge.net]On Behalf Of Joe
Van Andel
Sent: Tuesday, June 12, 2001 5:20 PM
To: numpy-discussion
Subject: [Numpy-discussion] performance comparison of C++ vs Numeric
(MA) operations.
I was curious about the relative performance of C++ vs Numeric Python,
for operations on arrays of roughly 400,000 array elements. I built a
simple array single precision multiplication function in C++, that
performs an element by element multiply, checking whether each element
is "valid" or "missing data".
Then, for comparision, I wrote a similar multiplication routine, using
the Masked Array (MA) package of Numeric Python.
I compiled Numeric Python (20.1.0b2) with '-O3', by modifying setup.py
to contain lines like
OPTIMIZE=['-O3']
ext_modules =
.
.
Extension('multiarray', ['Src/multiarraymodule.c'],
extra_compile_args=OPTIMIZE
),
---------------------------------------
On an 800 Mhz dual processor Dell Linux box, using gcc 2.95.3,
Software Performance
------------------------------------------------
Numeric Python 5.0e6 multiplies/second
Numeric Python -03 6.1e6 multiplies/second
C++ 10.3e6 multiplies/second
C++ -O3 10.3e6 multiplies/second
(I tried using "plain" Numeric arrays, rather than Masked arrays, and it
didn't seem to make much difference.)
Has anyone else benchmarked the relative performance of C/C++ vs Numeric
Python?
Does anyone know of other optimizations to Numeric Python that could be
implemented?
I know a more realistic benchmark would include I/O, which might tend to
reduce the apparent difference in performance.
I've attached the benchmark modules, in case someone would like to
examine them.
--
Joe VanAndel
National Center for Atmospheric Research
http://www.atd.ucar.edu/~vanandel/
Internet: vanandel at ucar.edu
More information about the NumPy-Discussion
mailing list