[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
An example of poor C++ performance
From: |
Steve C. Thompson |
Subject: |
An example of poor C++ performance |
Date: |
Wed, 23 Feb 2005 12:58:32 -0800 |
User-agent: |
Mutt/1.3.28i |
Hello Group,
My previous posts have been leading up to this. I have successfully
converted my m-file simulation code to C++, which can then be loaded as
an .oct module. To test speed improvements, I've made a simple example
comparing the simulation with two approaches:
1) pure m-file (vectorized)
2) m-file/C++ hybrid
Each approach generates about 1e9 random numbers. The pure m-file is
vectorized by crunching numbers in 1e4 blocks (which I've found to be
optimum on my machine). However, over 50,000 loops are required. The
hybrid m-file/C++ diverts the looping C++. This approach only has 46
m-file loops and the rest is done in the compiled module. For each C++
loop a couple random number are generated with the command
octave_rand::scalar().
I was expecting C++ implementation to outperform the pure m-file
approach, but this isn't the case.
My feeling is that the octave_rand::scalar() is a bottleneck. Would it
be faster to call MT
(http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html) directly and
sidestep Octave's oct-rand.h header? In ``Octave: Past, Present, and
Future'' (2001) JWE says that there is overhead with octave_value. Is
the convenience of using the Octave headers and making the .oct module
resulting in a slower C++ implementation?
Please advise.
The source files with more discussion can be found at
http://elsteve.com/test_oct/index.html#bpsk_ber
Thanks,
Steve
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------