IPython Documentation

Table Of Contents

Previous topic

autoreload

Next topic

storemagic

This Page

parallelmagic

Magic command interface for interactive parallel work.

Usage

%autopx

Toggles auto parallel mode.

To use this a DirectView instance must be created and then activated by calling its activate() method. Once this is called, all commands typed at the command line are send to the engines to be executed in parallel. To control which engine are used, set the targets attributed of the multiengine client before entering %autopx mode.

Then you can do the following:

In [25]: %autopx
%autopx to enabled

In [26]: a = 10
Parallel execution on engine(s): [0,1,2,3]
In [27]: print a
Parallel execution on engine(s): [0,1,2,3]
[stdout:0] 10
[stdout:1] 10
[stdout:2] 10
[stdout:3] 10


In [27]: %autopx
%autopx disabled

%px

Executes the given python command in parallel.

To use this a DirectView instance must be created and then activated by calling its activate() method.

Then you can do the following:

In [24]: %px a = 5
Parallel execution on engine(s): all
Out[24]:
<Results List>
[0] In [7]: a = 5
[1] In [7]: a = 5

%result

Print the result of command i on all engines..

To use this a DirectView instance must be created and then activated by calling its activate() method.

Then you can do the following:

In [23]: %result
Out[23]:
<Results List>
[0] In [6]: a = 10
[1] In [6]: a = 10

In [22]: %result 6
Out[22]:
<Results List>
[0] In [6]: a = 10
[1] In [6]: a = 10