Ilia,
I did profile two versions of the code (one with ANCI-C
and another with C++ STL <vector>).
It seems that the bottleneck is in accessing <vector>
elements which is more expensive than accessing simple
array elements.
As an example
vector<int> x;
x[10];
is much slower than
int *y;
y[10]
The reason i started with <vector> was the clean way that
these were instantiated, etc.
Anyway, I am now reimplementing the code without using <vector>;
will get back to you on this.
Achilleas
Ilia Mirkin wrote:
Quoting Achilleas Anastasopoulos <[EMAIL PROTECTED]>:
Ilia,
you can find the relevant code here:
http://www.eecs.umich.edu/~anastas/gnuradio/
looking forward to your comments.
Achilleas
Have you tried profiling the code? This would allow you to definitively
determine what the culprits are.
From a quick glance you aren't doing anything *blatantly* wrong (i.e.
you're
passing vectors around by cref, which is good). However, from a performance
perspective, vector<> isn't really what you want to use in this case.
You're
just dealing with basic types, e.g. float/int/etc -- they don't have weird
constructors/destructors, and thus have to do a lot more work.
Also, when you do
vector<int> x;
x[0] = 5;
keep in mind that internally it instantiates a new int object, and then
calls
operator= on it. The compiler might optimize this to a certain extent, but
certainly not to the level of simplicity of a single memory
access/write. Note
that the gnuradio interface for, e.g. (general_)work uses these primitive
pointers (i.e. a vector<> of simple arrays). There doesn't really seem
to be a
good reason for you to be using vector<> in your code... (Do correct me
if I'm
wrong...)
-Ilia
Ilia Mirkin wrote:
Would you care to share your C++ implementation (e.g. post a link) so
that it
might be critiqued rather than say things like "C++ is slower than C"?
-Ilia
Quoting Achilleas Anastasopoulos <[EMAIL PROTECTED]>:
I have some new data on this.
Going from ANSI-C to C++ (NO Gnuradio) using
STL vectors results in a 5-fold speed reduction!
So Gnuradio seems to be responsible for the remaining
4-fold reduction (for an overall 20-fold as I reported earlier).
I am OK with Gnuradio resulting in this 4-fold speed reduction,
but I cannot swallow the fact that STL sucks that bad :-( !!!
I believe that this is not specific to my application, but should be
true for any algorithm that uses vectors/matrices.
I wonder if anyone can corroborate this.
Achilleas
Robert W McGwier wrote:
Yes. I was comparing Phil Karn's native code to it and it runs at
least 20 times faster.
Bob
Achilleas Anastasopoulos wrote:
I have noticed a huge speed dissadvantage when comparing my
ANSI-C implementation of a Viterbi decoder with my Gnuradio
implementation. The core code is pretty much the same, except
that in the Gnuradio implementation I am using STL vectors.
It seems that Gnuradio is about 20 times SLOWER than ANSI-C!!!
I was wondering if this has to do with Gnuradio itself (buffering +
python + other fat), or with the fact that I had to translate all
my ANCI-C code to C++ and use STL.
Does anyone have similar experiences?
Achilleas
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio
--
_______________________________________________________
Achilleas Anastasopoulos
Associate Professor
EECS Department Voice : (734)615-4024
UNIVERSITY OF MICHIGAN Fax : (734)763-8041
Ann Arbor, MI 48109-2122 E-mail: [EMAIL PROTECTED]
URL: http://www-personal.engin.umich.edu/~anastas/
_______________________________________________________
--
_______________________________________________________
Achilleas Anastasopoulos
Associate Professor
EECS Department Voice : (734)615-4024
UNIVERSITY OF MICHIGAN Fax : (734)763-8041
Ann Arbor, MI 48109-2122 E-mail: [EMAIL PROTECTED]
URL: http://www-personal.engin.umich.edu/~anastas/
_______________________________________________________
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio