How can I make definitions inside ParallelTable to use them outside?
For example, if I execute:
ParallelTable[a[i] = i, {i, 1, 3}]
and after that, I try to access the value of a[1], I don't get 1 as I'd expect. Is there a way to make definitions inside ParallelTable so that I can access to them outside?
Note that what I want to do is more sophisticated than the trivial example above. Though there would probably be a way to do it without making definitions inside ParallelTable, it would really make my life easier if I could do it.
a! There are as manya's as you started subkernels and everyahas a different value. If the situation is as simple as in your toy example, alla's are equal of course, but then there would be no reason to do this on the parallel kernels. Question: Which of thea's would like to be defined on your main kernel? – halirutan Jan 03 '14 at 23:35aindeed depends on the executed code of the sub-kernel:ParallelTable[a = i; i, {i, 1, 20}]; ParallelEvaluate[a]– halirutan Jan 03 '14 at 23:36SetSharedVariable[a]. The value ofawill be held only in the master kernel and read by the slave kernels only via callbacks, so there could be some performance implications in this case. – Oleksandr R. Jan 04 '14 at 00:20ParallelTablecould be useful. I'll edit the question. Suppose that instead ofa = 4ora = i, I doa[i] = i. That's more similar to my actual problem. I do have severala's (onea[i]for eachi), and their values are independent, so there should be no conflict between kernels. – a06e Jan 04 '14 at 13:45a = 4toa[i] = i. I think that makes the issue clearer. – a06e Jan 04 '14 at 13:48