Tag Info

Hot answers tagged

4

In this case you would need SetSharedFunction as you are dealing with DownValues. However, the communication overhead you introduce with this is likely going to negate any benefits or parallelization. Try to write parallel code that never requires write access to the same variable from different threads. Reformulate your problem in terms of ParallelMap or ...


4

You have to replace SetSharedVariable with SetSharedFunction. longComputation[n_] := n SetSharedFunction[zeros] ParallelDo[ zeros[n] = longComputation[n], {n, 30, 70, 10} ] Why? From the docs of SetSharedVariable: Shared variables without a value evaluate to Null. This is what was happening to you, because zeros[30] = ... defines a function ...


3

To demonstrate evaluation in parallel computing on different number of kernels 1)Default list of kernels run for parallel computing `$ConfiguredKernels` (*("<<`1` local kernels>>", 6]}*) 2) Run ParallelTable on all kernels: LaunchKernels[]; ParallelTable[Pause[1]; f[i], {i, 6}] // AbsoluteTiming (*{1.009058, {f[1], f[2], f[3], ...


3

Before evaluating ParallelTable just launch however many kernels you want to use: LaunchKernels[4] By default ParallelTable and the other Parallel* functions call LaunchKernels[] which will launch whatever you have configured(default is essentially LaunchKernels[Min[$ProcessorCount, $MaxLicenseSubprocesses]]).


3

The integral over a spherical region is easily performed by Mathematica even analytically. Assuming f=1 and for brevity putting the center of the sphere at the origin: Timing@Integrate[1, {x, -r, +r}, {y, -Sqrt[r^2 - x^2], +Sqrt[ r^2 - x^2]}, {z, -Sqrt[r^2 - x^2 - y^2], +Sqrt[r^2 - x^2 - y^2]}] (*{0.218401, 4 Pi r^3 / 3}*) Assigning a numerical value to ...


3

For your example, I would simply do this: R = 2.3; {x0, y0, z0} = {1.2, 2.3, 3.4}; NIntegrate[1, {x, -R + x0, R + x0}, {y, y0 - Sqrt[R^2 - (x - x0)^2], y0 + Sqrt[R^2 - (x - x0)^2]}, {z, z0 - Sqrt[R^2 - (x - x0)^2 - (y - y0)^2], z0 + Sqrt[R^2 - (x - x0)^2 - (y - y0)^2]}]; For a general function func = Function[{x,y,z},body] and a set of boundaries ...


2

As mentioned by Albert Retey in the comment above, you can't expect that NDSolve makes use of your parallel kernels, period. However, since your equation set is just a system of 1st order linear ODEs, you can turn to MatrixExp, which seems to parallelize automatically: coe = gamma - DiagonalMatrix@Total@gamma; init = ConstantArray[0., 816]; init[[-2]] = ...



Only top voted, non community-wiki answers of a minimum length are eligible