ParallelTable[onePathList[s, parametri], {s, {1, 2, 3, 4}}]; // AbsoluteTiming

{14.771845, Null}

Table[onePathList[s, parametri], {s, {1, 2, 3, 4}}]; // AbsoluteTiming

{14.649838, Null}

I am also watching on the ParallelKernelStatus window and on the TaskManager (I am on a Windows 7 machine with 8 physical cores) and there is zero sign of the parallel kernel running. On the other hand, 4 of them do start up when evaluating the ParallelTable cell the first time. (I have default options in config, and limited to 4 cores by licence).

The function onePathList is defined in a package (see below for details) The vector "parametri" is a vector of real numbers, e.g. parametri={333.333,333.333,116.667,1,0,1,18,0.001}

Any help greatly appreciated, thanks

PS Function definitions from package

onePathList[σ_, params_] := 
With[{Tmax = params[[7]], dt = params[[8]]},
RandomFunction[proc[σ, params], {0, Tmax, dt}]["PathStates"]]

proc[σ_, params_] := With[{x0 = params[[6]]},
ItoProcess[{totForce[x, t, params], σ}, {x, x0}, t]]

totForce[x_, t_, params_] := 
With[{a = params[[1]], 
b = params[[2]], \[ScriptCapitalA] = params[[3]], ω = 
params[[4]], α = params[[5]]}, (a x - 
b x^3 + \[ScriptCapitalA] Sin[ω t + α])]
  • 1
    $\begingroup$ What values are in parametri? Could you give an example so that your code can be run? $\endgroup$ May 21, 2014 at 18:19
  • $\begingroup$ Did you see the following in the documentation? "The default value is DistributedContexts:>$DistributedContexts with $DistributedContexts:=$Context, which distributes definitions of all symbols in the current context, but does not distribute definitions of symbols from packages." $\endgroup$ May 21, 2014 at 18:24
  • $\begingroup$ Your proc function uses undefined global variables x and t. $\endgroup$ May 21, 2014 at 18:36
  • 1
    $\begingroup$ As Sjoerd says, your code is incomplete, so we can't test it to see how it performs. Please post comlete code and read through this post. $\endgroup$
    – Szabolcs
    May 21, 2014 at 21:53
  • $\begingroup$ very useful link thank you $\endgroup$
    – ac1965
    May 22, 2014 at 13:27

1 Answer 1


Use this

ParallelTable[onePathList[s, parametri], {s, {1, 2, 3, 4}}, DistributedContexts -> All];
  • $\begingroup$ This seems to do it thank you. I do not understand why it is needed, but frankly who cares... I am just happy that now it works [PS I understood that something like that is needed if the ParallelTable is inside the package, but this is not the case here... one hope that in next release they make it the default behaviour. God knows why it is not default now...] $\endgroup$
    – ac1965
    May 22, 2014 at 13:20
  • 1
    $\begingroup$ @Alberto The fact that DistributedContexts -> All seems to solve the problem here doesn't mean that it is a good default and that it can't bring other issues. If you have some of the functions defined in a package, I'd recommend you use ParallelNeeds to load the package into the subkernels instead. Distributing all contexts is a bit too uncomfortable for me since I don't know what's going on in all the contexts I did not create myself ... it's asking for trouble. $\endgroup$
    – Szabolcs
    May 22, 2014 at 13:30
  • 1
    $\begingroup$ @Alberto Please take a look at sections 3.2 and 3.3 here. I tried to cover your issue in 3.3 and explain what's likely happening. $\endgroup$
    – Szabolcs
    May 22, 2014 at 13:36
  • $\begingroup$ thank you I will follow up. Am now going to post a really embarassing, rookie question on Plot colouring... $\endgroup$
    – ac1965
    May 23, 2014 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.