Prevent synchronizing a certain symbol between main and parallel
- To: mathgroup at smc.vnet.net
- Subject: [mg124061] Prevent synchronizing a certain symbol between main and parallel
- From: Szabolcs Horvát <szhorvat at gmail.com>
- Date: Sat, 7 Jan 2012 05:23:37 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
Hello, I am trying to use LibraryLink with remote parallel kernels. I end up with a library function (let's call it libFun[]) that has a different value on the main and parallel kernels due to different paths on the two machines. Unfortunately it is very easy to inadvertently synchronize the value of a symbol between the main and subkernels. My question is about how I can ensure that this syncing will not happen for libFun[]. I'll show in an isolated example how this might accidentally happen: In[1]:= LaunchKernels[2] Out[1]= {KernelObject[1, "local"], KernelObject[2, "local"]} Set value of x in main kernel: In[2]:= x = 1 Out[2]= 1 Note that it gets the same value in remote kernels too: In[3]:= ParallelEvaluate[x] Out[3]= {1, 1} Set a different value for x in the parallel kernels and verify that they keep it: In[4]:= ParallelEvaluate[x = 2] Out[4]= {2, 2} In[5]:= {x, ParallelEvaluate[x]} Out[5]= {1, {2, 2}} Now "innocently" use Parallelize on something containing x: In[6]:= Parallelize[Table[x, {10}]] Out[6]= {1, 1, 1, 1, 1, 1, 1, 1, 1, 1} And see how the value of x got re-synced between the main and subkernels. In[7]:= {x, ParallelEvaluate[x]} Out[7]= {1, {1, 1}} So the question is: How can I prevent a certain symbol from ever auto-syncing between the main and the subkernels? Related: http://stackoverflow.com/questions/8718256/remote-parallel-kernels-and-librarylink-how-to-make-them-work-together -- Szabolcs Horvát Mma QA site proposal: http://area51.stackexchange.com/proposals/37304