Re: () and execution speed [message #44950] |
Fri, 29 July 2005 09:27  |
Ken Mankoff
Messages: 158 Registered: February 2000
|
Senior Member |
|
|
On Fri, 29 Jul 2005, Gert wrote:
> I just played with and array of structures, each structure
> containing a (float) images. If i do
>
> SomeProc, psData[NumStruct].flIm[1:1000]
>
> or
>
> SomeProc, (psData[NumStruct].flIm)[1:1000]
>
> then the result is the same, but the second runs much slower.
> Anyone knows why this is so? My guess is that in the second run, a
> copy of the array is made.
Sounds like a good guess. A compiler optimization might be able to
catch the above special case, but () changes the precedence. You
could have (x[y].z +1)[42] so direct memory access won't work.
> I would be interested to find out if there are more 'pitfalls' out
> there.
TVSCL? The decompose keyword to DEVICE?
-k.
|
|
|
Re: () and execution speed [message #44951 is a reply to message #44950] |
Fri, 29 July 2005 09:41  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
"Gert" <Gert.VandeWouwerNO @ SPAM.com> writes:
> I just played with and array of structures, each structure containing a
> (float) images.
> If i do
>
> SomeProc, psData[NumStruct].flIm[1:1000]
>
> or
>
> SomeProc, (psData[NumStruct].flIm)[1:1000]
>
> then the result is the same, but the second runs much slower. Anyone knows
> why this is so? My guess is that in the second run, a copy of the array is
> made.
Yes, the parentheses are creating a temporary copy to be
subscripted, I think.
> I would be interested to find out if there are more 'pitfalls' out there.
Oh, goodness. Then I would make a daily practice out of
consulting this newsgroup. You will be surprised what you
learn. :-)
Here are some examples:
http://www.dfanning.com/code_tips/asterisk.html
http://www.dfanning.com/code_tips/slowloops.html
http://www.dfanning.com/tips/forloops.html
http://www.dfanning.com/tips/forloops2
http://www.dfanning.com/ographics_tips/slowrendering.html
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|