swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multithreading question


From: Matteo Morini
Subject: Re: Multithreading question
Date: Wed, 29 Jan 2003 17:56:28 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01



Jason Alexander wrote:

I did go multithread by scheduling the independent steps like this (untested pseudocode follows :-)
I'm going by memory... sorry for errors)

[modelActions createActionForEach: agentsList message(step1)]
[modelActions createActionForEach: agentsList message(step2)]


You might want to check if making the following change speeds things up at all. Instead of writing

[modelActions createActionForEach: agentsList message(step1)]
[modelActions createActionForEach: agentsList message(step2)]

put

[modelActions createAction: self message(fooBar)]

(the right message might not be createAction... it's been a long time since I've used Swarm)

and then in the class file define fooBar as follows:

- (void) fooBar() {
// loop over agentsList using standard iterator techniques, calling step1 for each // loop over agentsList using standard iterator techniques, calling step2 for each
}

Introducing the above change into my code sped up one model by a factor of 10. Of course, in my case the slowdown was due to Swarm's message-passing methods in createActionForEach when the list contains heterogeneous agents. In your case, I would guess the forks(), etc. are much more of a bottleneck than Swarm's message-passing methods.

Cheers,

Jason

Thanks a lot for your advice: it's probably true that in my case the real bottleneck is not Swarm's expensive way of passing messages to the members of the list (uhm, a 10x speedup of your code? I think I need to check that createActionForEach CPU-eater more closely, in Swarm's source); still it looks a really neat trick that might help save many CPU cycles in those cases when one, after prototyping in Swarm, doesn't feel like restarting from scratch in C++ or Fortran or whatever, as Glen suggested.

---Matteo

                 ==================================
  Swarm-Support is for discussion of the technical details of the day
  to day usage of Swarm.  For list administration needs (esp.
  [un]subscribing), please send a message to <address@hidden>
  with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]