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

Home » Public Forums » archive » Re: Threads in IDL 7.0
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: Threads in IDL 7.0 [message #63115 is a reply to message #63114] Mon, 27 October 2008 09:11 Go to previous messageGo to previous message
Foldy Lajos is currently offline  Foldy Lajos
Messages: 268
Registered: October 2001
Senior Member
On Mon, 27 Oct 2008, Bernhard Reinhardt wrote:

> David Fanning wrote:
>> Bernhard Reinhardt writes:
>>
>>> I have have read the Chapter "Multithreading in IDL" in the IDL-Help. As
>>> far as I can see some IDL functions use threads.
>>>
>>> Basically I want to count elements of a big array that exceed a given
>>> number.
>>>
>>> count=0
>>> for i = 0, 200000 do begin
>>> if array[i] ge 10. then count++
>>> endfor
>>
>> How about something like this:
>>
>> indices = Where(array GE 10, count)
>
> Well, I wasn´t really precise. I´m not doing this on a 1d-array but on a
> 4d-array, where 2 dimensions are time and 2 dimensions are space. I try to
> filter special events in time and count those on a 2d-map. Here´s the code:
>
> for i = 0, N_ELEMENTS(STRUC.data[*,0,0,0])-1 do begin
> for j = 0, N_ELEMENTS(STRUC.data[0,*,0,0])-1 do begin
> indices = Where(STRUC.data[i,j,*,*] GE 150., count)

You are accessing elements in the wrong order, resulting in cache misses
if struc.data is greater than the CPU data cache.

> freq [i,j]=count
> endfor
> endfor
>

Try this:

d=transpose(struc.data, [2,3,0,1])
dims=size(d, /dim)
for i = 0, dims[2]-1 do begin
for j = 0, dims[3]-1 do begin
indices = Where(d[*,*,i,j] GE 150., count)
freq [i,j]=count
endfor
endfor


regards,
lajos
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Typeconversion within structure?
Next Topic: Re: DEPTH_TEST_FUNCTION, DEPTH_TEST_DISABLE properties (send an object to back)

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

Current Time: Sun Nov 30 15:13:26 PST 2025

Total time taken to generate the page: 0.87627 seconds