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

Home » Public Forums » archive » Splitting large for loop over multiple processors
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Splitting large for loop over multiple processors [message #92830] Wed, 09 March 2016 02:40 Go to next message
joellama is currently offline  joellama
Messages: 8
Registered: July 2013
Junior Member
Hi all,

I know, I know before I get lots of hate that I shouldn't have a for loop in my code...this isn't my code, it's code someone else wrote and I just haven't got the time go through and vectorise it.

Basically I have an output array that is say

out = fltarr(nx, ny, nz) where nx=ny=nz=100 each

The way the code is currently written it has

for i = 0, nx-1 do begin
for j = 0, ny-1 do begin
for k = 0, nz-1 do begin
.... a lot of calculations
endfor
endfor
endfor

Basically, all I want to do is split this over all the cores on my mac pro so that it does say

0 - nx/6 on cpu 1
nx/6 - 2*nx/6 on cpu 2 etc...

I saw this article http://www.exelisvis.com/Company/PressRoom/Blogs/TabId/836/A rtMID/2928/ArticleID/14744/Using-IDL-IDLBridge-to-run-multip le-processes-in-parallel.aspx

but the example isn't exactly easy to follow.

If anyone has any tips I would really appreciate it.
Re: Splitting large for loop over multiple processors [message #92861 is a reply to message #92830] Tue, 15 March 2016 08:30 Go to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Wednesday, March 9, 2016 at 5:40:50 AM UTC-5, Joe Llama wrote:
> Hi all,
>
> I know, I know before I get lots of hate that I shouldn't have a for loop in my code...this isn't my code, it's code someone else wrote and I just haven't got the time go through and vectorise it.
>
> Basically I have an output array that is say
>
> out = fltarr(nx, ny, nz) where nx=ny=nz=100 each
>
> The way the code is currently written it has
>
> for i = 0, nx-1 do begin
> for j = 0, ny-1 do begin
> for k = 0, nz-1 do begin
> .... a lot of calculations
> endfor
> endfor
> endfor
>
> Basically, all I want to do is split this over all the cores on my mac pro so that it does say
>
> 0 - nx/6 on cpu 1
> nx/6 - 2*nx/6 on cpu 2 etc...
>
> I saw this article http://www.exelisvis.com/Company/PressRoom/Blogs/TabId/836/A rtMID/2928/ArticleID/14744/Using-IDL-IDLBridge-to-run-multip le-processes-in-parallel.aspx
>
> but the example isn't exactly easy to follow.
>
> If anyone has any tips I would really appreciate it.

I'd suggest Michael Galloy's library:

http://michaelgalloy.com/2015/05/26/a-simple-multicore-libra ry-for-idl.html

-Jeremy.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: speeding up code for fitting spectra for doppler map
Next Topic: Looping through a bunch of files?

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

Current Time: Wed Oct 08 11:37:52 PDT 2025

Total time taken to generate the page: 0.00467 seconds