Suppose one wants to parallelize as much as possible N tasks, each task produces a graphics via ParametricPlot or something like that. If the system is allowed to run 4 parallel kernels, how do I assign the tasks to all the available kernels?

So far what I've been doing is opening multiple notebooks, each running on a separate kernel, and running on different batches of input data.

Is there a better approach for this? Is possible to spawn a clone of the current kernel, or possibly just invoke code to execute in other kernels, so that the master program runs inside a single notebook, but schedules commands to other kernels?


1 Answer 1


You can use ParallelDo and ParallelTable to parallelize automatically.

    ParametricPlot[p, ...],
    {p, {thingsToPlot}}

Depending on your case, you could use Export inside of ParallelDo to save the files as you go. Otherwise the results will be returned to the master kernel if you use ParallelTable.

  • $\begingroup$ ParallelDo sounds exactly what I need. Thanks $\endgroup$
    – lurscher
    Jan 1, 2016 at 2:40
  • $\begingroup$ You should be aware of some problems that may occure when using ParallelDo when writing to shared variable. ParallelTable handles this without additional programming effort, so you get back a "clean" list with all the elements in the right order. ParallelDo may have issue when trying to write an entry to a list while a second kernel is also doing so (see CriticalSection). In addition you may get a messed up order with ParallelDo depending on wich kernel finishes first. So there is no relation of list order and index order unless you store the index with the result. $\endgroup$
    – Eisbär
    Jan 1, 2016 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.