Re: Fast matrix filling in IDL [message #13976 is a reply to message #13792] |
Thu, 17 December 1998 00:00  |
Martin Schultz
Messages: 515 Registered: August 1997
|
Senior Member |
|
|
David Ritscher wrote:
>> Hopefully everyone is running this a few times and noting when
>> the times have become "stable". Here are three sequential runs
>> on a Sun Sparc 2 (IDL 5.1):
>>
>> IDL> test
>> Time for Loop: 2.7740721
>> Time for Matrix Operations: 5.2337180 ; OUT OF WHACK!
>> Time for Rebin Operations: 0.16969705
>> IDL> test
> [...]
> Perhaps the first one is not out of whack, but rather, the accurate
> time.
> When the test is being performed a second time, the operating system has
> information that is cached, thus avoiding doing part of the work
> associated with the task. Particularly in big tests, I often notice
> speed-ups each time, for the first few times I test something. I like
> to test by completely exiting my environment, doing other things, and
> coming back and repeating the test. If I'm feeling hard-core about it,
> I do a reboot in between.
>
> David Ritscher
>
Although I am definitively not a system expert, this sounds very reasonable
and corresponds to my experience. E.g., when I read a binary data file, it
usually takes much longer the first time than at subsequent times - often
it is not even too much faster than sequential reading of the same file in
ASCII(!) (but on subsequent attempts, the binary read is 1-2 orders of
magnitude faster). I would assume that this behaviour is somehow associated
with memory allocation/swapping, together with caching as David noted. The
speed difference should therefore depend on the array size. It would be
nice to devise some "objective" tests on this matter, except if some C
malloc guru out there already knows the exact answer.
Here another little piece of info on this: on my SGI, I get different
behaviour for two slightly different routines:
#1 is the same as Stein Vidar listed it - on the first call, the matrix
operations take longer than on subsequent calls
#2 I changed array to array1, array2, and array3, "declaring" all three of
them in the beginning: This time I get more pronounced changes in the rebin
version! (both tests done after exiting the shell and new login)
Interestingly, when I call test#1 first, then #2 (they are both in one pro
file), the times reported for #2 are stable from the beginning and vice
versa. There must be some overhead processing going on when IDL executes a
routine for the first time.
Just as a side: here are the numbers that I get on my SGI Origin 2000:
Time for Loop: 0.32725203
Time for Matrix Operations: 0.057738066
Time for Rebin Operations: 0.034290910
Martin.
------------------------------------------------------------ -------
Dr. Martin Schultz
Department for Engineering&Applied Sciences, Harvard University
109 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA
phone: (617)-496-8318
fax : (617)-495-4551
e-mail: mgs@io.harvard.edu
Internet-homepage: http://www-as.harvard.edu/people/staff/mgs/
------------------------------------------------------------ -------
|
|
|