comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: An optimisation question
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: An optimisation question [message #79709 is a reply to message #79708] Tue, 27 March 2012 15:45 Go to previous messageGo to previous message
Matt Francis is currently offline  Matt Francis
Messages: 94
Registered: May 2010
Member
Okay, just probing my original approach further to understand what is
going on and I'm going completely insane. Have a look at this test
code:

function do_3d,arr,lat,lon,indx
temp = reform(arr[indx,*,*])
return,temp[lat,lon]
end

function do_2d_first,arr,lat,lon
return,arr[lat,lon]
end

function do_2d_second,arr,lat,lon
return,arr[lat,lon]
end

pro crazy_idl
lat = intarr(10000)
lon = intarr(10000)

arr3d = fltarr(10,1000,1000)
arr2d = fltarr(1000,1000)

for i=0,100 do begin
res3d = do_3d(arr3d,lat,lon,0)
res2d = do_2d_first(arr2d,lat,lon)
res2d = do_2d_second(reform(arr3d[0,*,*]),lat,lon)
endfor
end

The '3d' version first uses REFORM to obtain a 2d matrix and then does
the same thing as the '2d' version. The second call to the 2d version
does the REFORM command before sending the array to the subroutine.
All three approaches are essentially the same, apart from some minor
overhead coming from using REFORM. Well, no. Apparently these are all
very different! Check out the profiler report:

Module Type Count Only(s) Avg.(s) Time(s) Avg.(s)
CRAZY_IDL (U) 1 0.967564 0.967564 1.963462 1.963462
DO_2D_FIRST (U) 101 0.003964 0.000039 0.003964 0.000039
DO_2D_SECOND (U) 101 0.004870 0.000048 0.004870 0.000048
DO_3D (U) 101 0.973172 0.009635 0.973531 0.009639
FLTARR (S) 2 0.013167 0.006583 0.013167 0.006583
INTARR (S) 2 0.000012 0.000006 0.000012 0.000006
PROFILER (S) 2 1.007490 0.503745 1.007490 0.503745
REFORM (S) 202 0.000711 0.000004 0.000711 0.000004

What the hell?? One of either me or IDL is doing something completely
screwy and frankly I don't care which it is, I just want to understand
what is going on. I guess the other possibility is that the profiler
is getting this completely wrong a misreporting the times in some
weird way?
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Undefined Variable: DC_Write_Fixed/DC_Write_Free - PV WAVE
Next Topic: Cellular automata

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 09:26:58 PDT 2025

Total time taken to generate the page: 0.56155 seconds