Tag Info

5

You don't have to write all your code within ParallelSubmit. You can wrap your code in Module or Block and assign it to a variable using SetDelayed (:=) so it won't be evaluated immediately. Here is a toy example: eval1 := PrimeQ[528973465287364528736543] eval2 := Module[{}, Pause[2]; 3] evaluators = ParallelSubmit[{eval1, eval2}] You then run the ...

4

Your cube file had a very large grid ( 117*117*130 = 1779570), and 2 million points is just far too many for testing a function. So I created cube files for the electron density and electrostatic potential for the molecule furan, using a much sparser grid (around 8000 grid points instead). Here they are: Density cube file Potential cube file Now that ...

5

This is an extended comment. This behaviour is new in 10.4. I can reproduce it with 10.4.1 on OS X, but not with 10.3.1. This may be related: DistributeDefinitions and synchronization in Mathematica 10 We can try to analyse what happens like this: z := (Print[$KernelID]; 1); SetSharedVariable[z]; ParallelEvaluate[z] ... 2 OP wrote: I want to be able to simply call Needs["Test"] and have functions such as Testf available for use inside ParallelTable without any further calling of$DistributedContexts or DistributeDefinitions We had a similar problem designing mathStatica functions to operate in a parallel environment. There can be varying degrees of complexity. For ...

0

Baseline As a baseline for computational results and speed, use H = 100; Ncases = H (2 H + 1)^2; Nreducible = 0; Nirreducible = 0; Do[If[GCD[r, s, t] == 1, If[IntegerQ[Sqrt[s^2 - 4 r t]], Nreducible++, Nirreducible++]], {r, 1, +H}, {s, -H, +H}, {t, -H, +H}] // AbsoluteTiming {Ncases, Nreducible, Nirreducible, Nreducible + Nirreducible} which yields ...

2

The output variable lives on the main kernel. This variable is special, it represents an open file. It cannot be used on the parallel kernels if the file was opened on the main kernel. Is it still possible to write to the same file in parallel from multiple different kernels? Yes, but to do it robustly you must use an advanced parallel programming ...

1

To make my comment more concrete (for a four-processor machine), {ParallelEvaluate[f[largelist[[1 ;; 20]]], 1], ParallelEvaluate[f[largelist[[21 ;; 40]]], 2], ParallelEvaluate[f[largelist[[41 ;; 60]]], 3], ParallelEvaluate[f[largelist[[61 ;; 80]]], 4]} Total[%] (* {{20, 210}, {20, 610}, {20, 1010}, {20, 1410}} {80, 3240} *)

3

Thanks to Wolfram Technical Support, I am now able to answer my own question and explain the results I showed in the Edit. My question was: what exactly has changed in DistributeDefinitions? The answer is simple: nothing. What I observed is due to a undocumented change in ParallelEvaluate. Since version 10.4, it has an option DistributedContexts with ...

9

In short, the reason is that SumCommand's (temporary) definition won't automatically get distributed to the parallel kernels because now SumCommand lives in the packagePrivate context, not Global`. This means that SumCommand won't get evaluated to Sum on the subkernels. It gets returned as-is to the main kernel, where now SumCommand does have a ...

2

As pointed out by @szabolcs part of the problem is associated with the distribution over the kernels. But I think that is not only problem. We can generalize the foo function to run in parallel and achieve the same performance as the unpackage code. The code is much slower in the packaged case, because it is different and lot more complex. If you create a ...

Top 50 recent answers are included