File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,30 @@ with ipp.Cluster() as rc:
60
60
<source src =" _static/basic.mp4 " />
61
61
</video >
62
62
63
+ You can similarly run MPI code using IPyParallel:
64
+
65
+ ``` python
66
+ import ipyparallel as ipp
67
+
68
+ def mpi_example ():
69
+ from mpi4py import MPI
70
+ comm = MPI .COMM_WORLD
71
+ return f " Hello World from rank { comm.Get_rank()} . total ranks= { comm.Get_size()} "
72
+
73
+ # request an MPI cluster with 4 engines
74
+ with ipp.Cluster(engines = ' mpi' , n = 4 ) as rc:
75
+ # get a broadcast_view on the cluster which is best
76
+ # suited for MPI style computation
77
+ view = rc.broadcast_view()
78
+ # run the mpi_example function on all engines in parallel
79
+ r = view.apply_sync(mpi_example)
80
+ # Retrieve and print the result from the engines
81
+ print (" \n " .join(r))
82
+ # at this point, the cluster processes have been shutdown
83
+ ```
84
+
85
+ ![ IPyParallel-MPI-Example] ( ./_static/IPyParallel-MPI-Example.png )
86
+
63
87
Follow the [ tutorial] [ ] to learn more.
64
88
65
89
[ tutorial ] : ./tutorial/index
You can’t perform that action at this time.
0 commit comments