SetSharedFunction

SetSharedFunction[f1,f2,]

declares the symbols fi as shared functions whose downvalues are synchronized among all parallel kernels.

Details

  • Downvalues for a shared function defined on any kernel are maintained by the master kernel and every access on a parallel subkernel is synchronized through the master kernel.
  • Expressions of the form f[] that would remain unevaluated give Null.

Examples

open allclose all

Basic Examples  (1)

Make fs be a (global) shared function:

In[1]:=
Click for copyable input

Each subkernel makes a definition for the same shared variable:

In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=

Without sharing, each subkernel has its own (local) copy of the function:

In[4]:=
Click for copyable input
Out[4]=
In[5]:=
Click for copyable input
Out[5]=
In[6]:=
Click for copyable input

Scope  (4)

Generalizations & Extensions  (1)

Applications  (3)

Possible Issues  (3)

Neat Examples  (1)

See Also

$SharedFunctions  UnsetShared  SetSharedVariable  DistributeDefinitions  DownValues

Introduced in 2008
(7.0)