Problem
Let's define a simple recursion.
f[1] = 1;
f[n_] := f[n] = f[n - 1]*n;
If I evaluate f in parallel
ParallelTable[f[i], {i, 10}];
and then query f
?f
Global`f
f[1]=1
f[n_]:=f[n]=f[n-1] n
Question
How can I tell the sub kernels to build up the recursion, so that
?f
Global`f
f[1]=1
....
f[10]=3628800
f[n_]:=f[n]=f[n-1] n
Thanks !
PS: of course the actual function is not that trivial.
SetSharedFunction[f]do what you want? – sebhofer Aug 7 '12 at 16:49Table[f[i], {i, 5000}]; // Timing(* {0.005126,Null} )ParallelTable[f[i], {i, 5000}]; // Timing( {6.69067,Null} *) – chris Aug 7 '12 at 17:22DownValuesfrom the subkernels. Maybe you can formulate your question more generally (with a different title?), so you get more attention! – sebhofer Aug 7 '12 at 18:05