Parallel Computing Toolkit — Examples Exact Single-Image StereogramsPreparationMake sure you have at least two kernels available. Sequential CodeThis material is taken from The Mathematica Programmer II, Chapter 12. Reference:
Roman E. Maeder, The Mathematica Programmer II, New York: Academic Press, 1996. Original CodeThis package is an excerpt from MathProg`SIS`. To work with the examples, you need to evaluate this whole section. ExampleParallelizationThe main part of the SIS function is a giant Table[] command, which we want to replace with ParallelTable[]. However, we have to make sure we do not access any nonlocal variables in the body of the table command because these will not be known on the remote kernels. Here is a code template that shows a nonlocal variable being used in a Table[]. There are two ways to solve this problem. The first is to instantiate all nonlocal variables with a construct like The second is to export all nonlocal variables to the remote kernels. In the body of the table there is also a local function next[] that in turn uses some nonlocal variables inside its body. We can treat it in the same way and then export it, too. The Parallel CodeHere is the code of ParallelSIS[], with the modifications highlighted in color. The code is packaged as an extension of MathProg`SIS`. Be sure to evaluate this package in the section Sequential Code first. ExamplesThe Bessel Function with Random DotsAn Example with Random CharactersRandomly Colored DotsA High-Resolution Image |