# Tag Info

2

So, in the first place, if you're concerned about performance, you probably don't want to be looping like that and incrementing a counter. It's not going to be as fast as you'd like it to be. Unparallelized, this... AbsoluteTiming[c = 0; Do[If[RandomReal[] > 0.5, c += 1], {i, 100000}]; c] (* {0.111647, 49853} *) ...is about half as fast as this: ...

0

On a regular basis i have subkernels eating up my Memory. Still have not a great solution however if finished anyway (Or between two ParallelTables) I handle this problem via: CloseKernels[];LaunchKernels[]; This frees the memory of the subkernels.

2

Try this: ClearAll[discretePlot]; SetAttributes[discretePlot,HoldAll]; discretePlot[args___]:= Block[{SystemDiscretePlotDumpflatTable}, SetAttributes[SystemDiscretePlotDumpflatTable,HoldFirst]; SystemDiscretePlotDumpflatTable[expr_,eval_,{var_},{vals_}]:= ParallelTable[expr,{var,vals}]; ...

1

Yes, they run independently, as they are independent processes. But Mathematica takes the random seed from the system time, so if you start several independent processes at the same time, they will likely all generate the same sequence of random numbers. (When I tried this they did.) It sounds like you should use Mathematica's parallel tools instead, ...

0

Each instance of the kernel has no contact with other instances (unless there are explicitly shared variables). Thus, in your case, they are independent.

8

The key to speedup here is generating the set of random number in one go instead of calling RandomVariate repeatedly. Generally, instead of Table[RandomVariate[...], {size}] use RandomVariate[..., size] It can also generate a multidimensional array of random values in one go. I rewrote your code to do this: out = AbsoluteTiming[Table[ ...

1

Round 2: test=WaitAll[ Table[(b=a[[(i1)*1000/$KernelCount+1;;i*1000/$KernelCount]]; ParallelSubmit[{b},(Pause[1.0];$KernelID->f[b])]), {i,1,$KernelCount}]]; Inside Table chop out the bit of a you want to send to a specific Kernel and place in b. Pass b as a closure into ParallelSubmit rather than i. Apply f to b within the ...

Top 50 recent answers are included