Re: multidimensional arrays
Re: multidimensional arrays
- Subject: Re: multidimensional arrays
- From: Pandaa <email@hidden>
- Date: Wed, 16 Mar 2005 01:33:53 +0100
2005-03-16 kl. 00.42 skrev Jeff Laing:
While I agree to a certain extent, I have never seen a case where this
kind of optimization can actually gain you anything significant other
that when you have *massive* data sets.
Where "massive" is in the eye of the beholder and needs to take *time*
into
account.
Whilst I agree in principle, I did encounter a problem a long time ago
where
I was set some work by a lecturer to "code in assembler" because he was
convinced that his 2D FFT could never be made fast enough in C. I
handed
him back a straight C version that was "too fast" - he had to
concentrate on
speeding up other areas in his system to cope.
Unrolling array accesses when you know they are sequential and using
pointers to iterate along them, combined with actually paying
attention to
the math you are actually doing in when processing your arrays pays
off big
time even in small datasets if you have to visit them over and over.
ie there aren't many gains to be made made by recognising that an array
access could be converted to a pointer dereference - the gains come
with
array iteration converted to pointer iteration.
I just have to point out that while this used to be true for older
compilers, it is not generally true today. Most compilers today can
optimize sequential array access better than iterated pointer
arithmetic and dereferencing. Internally, they try to rewrite the
pointer arithmetic/dereferencing to array accesses. Many optimizations
requires good data dependency analysis, which the compiler may have
difficulties doing on pointer arithmetic expressions.
So today, it's more often faster to use array access syntax than
explicit pointer arithmetic. Unless you have special circumstances that
allows you to remove equivalent induction variables or something
similar, it's often better to stick with array syntax.
Moral: understand your whole algorithm before you worry about tuning
little
bits of it.
Which is just reiterating what others have said.
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
. email@hidden . . www.synapticpulse.net .
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden