Re: Parallel Toolkit Example
- To: mathgroup at smc.vnet.net
- Subject: [mg50451] Re: Parallel Toolkit Example
- From: nafod40 <noneya at business.com>
- Date: Sat, 4 Sep 2004 01:43:30 -0400 (EDT)
- Organization: Penn State University, Center for Academic Computing
- References: <ch97mm$fdn$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Geoff Hulette wrote: > Hi, > > I am looking for an efficient example of using the Parallel Toolkit. > Many other people on this forum seem to have noted what I have also > found to be the case, that the ParallelMap and ParallelTable commands > aren't terribly efficient. The example code in ParEval.nb, for > instance > > ParallelMap[FactorInteger, (10^Range[20, 40] )/9] > > only seems to run about 20% faster on a six-node cluster vs my laptop. > Does anyone have an example of how to solve this same problem using an > efficient parallel technique? I am fairly new to Mathematica, so > please be explicit. Here's a copy of a couple of my posts from way back when... ************* Hello, I am starting to use the parallel programming toolbox, and I've found the ParallelMap[ ] function to be essentially broken, most likely due to some sort of comm glitch. I was curious if anyone else has experienced a similar problem, or if it is just my network. If I run the following commands (listtt is a 5 element list of real numbers), with one remote server active... x1=SessionTime[]; ParallelMap[Sin,listtt] SessionTime[]-x1 It takes 5-7 seconds. This is to connect with a slave computer that is sharing a hub with the master. Obviously something is wrong. By contrast, if I define the function on the slave maparoni[x_]:=Map[Sin,x] and do the following... Do[ With[{x=listtt},RemoteEvaluate[maparoni[x]] ] , {20} ] SessionTime[]-x1 It only takes 5 seconds. Note the difference. I am executing the Sin[ ] function twenty times more, I am passing discrete hunks of data twenty times more, and I am passing twenty times the total amount of data, yet it takes less time to complete. So the basic linking between computers appears to work OK. Anybody else have experience with the ParallelMap[ ] function? I see similar performance with ParallelTable[ ] ************* I've traded email with the Mathematica support folks since, and here is the nugget of my point. Make a list of 100 elements. list = {0, ...., 100}; Start one remote processor. Compare these calls... ParallelMap[Sin, list]; Map[RemoteEvaluate[Sin[#]] &, list]; Both calls do the same thing, and theoretically have the exact same amount of communication and computation. Yet you see a six-fold difference in the time spent other than calculating, between these two. The first call takes 200 seconds. The second call takes 30 seconds. With two processors, it is still better to Map[ ] it across a single remote than it is to ParallelMap[ ] it across two remote. And so on up to six or so remote processors. These processors are on PCs communicating across a 10 MB ethernet hub. An even faster call is: RemoteEvaluate[Map[Sin,list]]] Which is almost instantaneous. This points out that it is much better to split a list up into N segments for N processors and farm them out, than it is to let ParallelMap[ ] handle the comms for you. The advantages for using ParallelMap[ ] are that it handles the admin details, and it will handle cases where the task time for each element differs.