Re: Parallel computing with Mathematica 7?
- To: mathgroup at smc.vnet.net
- Subject: [mg95387] Re: Parallel computing with Mathematica 7?
- From: mark mcclure <mcmcclur at unca.edu>
- Date: Sat, 17 Jan 2009 05:29:38 -0500 (EST)
- References: <gkppvv$dsp$1@smc.vnet.net>
On Jan 16, 6:10 am, einsch... at gmail.com wrote: > I have installed Mathematica 7 on my new laptop (Intel Centrino double > core, Windows XP) and the first thing I tried was the long awaited > parallllllel computing. I have tried different new commands and what I > saw was a black box with input and no output. I could not see any > evidence that parallelization works for me. I'm not sure I quite understand your example, but here's an operation that is sped up tremendously via parallelization: t = AbsoluteTime[]; data = Table[PrimeQ[x + I*y, GaussianIntegers -> True], {x, -1000, 1000}, {y, -1000, 1000}]; time1 = AbsoluteTime[] - t 7.042566 To run it in parallel, it might make sense to LaunchKernels first: LaunchKernels[] I get 8 kernels on my machine. Now, simply change the Table to ParallelTable: t = AbsoluteTime[]; data = ParallelTable[PrimeQ[x + I*y, GaussianIntegers -> True], {x, -1000, 1000}, {y, -1000, 1000}]; time2 = AbsoluteTime[] - t 1.238292 A silly example, perhaps, but there are quite a few similar types of exercises at Project Euler: http://projecteuler.net/ Also, I posted a webpage a month or so ago illustrating a technique to use Mathematica to coordinate Java programs through JLink: http://facstaff.unca.edu/mcmcclur/Mathematica/ParallelJLink/ Finally, here are a couple more things to keep in mind with regard to parallel computation: * Due to overhead in running parallel computations (extra memory, interprocess communication, etc.) it is very unusual for a parallel computation on n kernels to run n times faster. * There's generally no apriori way to break the problem up, since we don't necessarily know which sub-parts will run faster than other sub-parts. It's best if, like in this example, the sub-problems run at similar rates. Mark McClure