Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #7640
| From | Szabolcs Horvát <szhorvat@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Prevent synchronizing a certain symbol between main and parallel |
| Date | 2012-01-07 10:27 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <je96n4$j6k$1@smc.vnet.net> (permalink) |
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
Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread
Prevent synchronizing a certain symbol between main and parallel Szabolcs Horvát <szhorvat@gmail.com> - 2012-01-07 10:27 +0000 Re: Prevent synchronizing a certain symbol between main and parallel "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2012-01-08 09:28 +0000 Re: Prevent synchronizing a certain symbol between main and parallel "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2012-01-08 09:31 +0000
csiph-web