Mpipool Mpi4py
文章目录
mpi4py is a python API for MPI. MPIPoolExecutor is a subclass of mpi4py.futures
to create MPI processes to execute calls asynchronously
The MPIPoolExecutor class uses a pool of MPI processes to execute calls asynchronously. By performing computations in separate processes, it allows to side-step the Global Interpreter Lock but also means that only picklable objects can be executed and returned. The
__main__
module must be importable by worker processes
Test Script
The test script shows a way to calculate $2^{x}$ in a loop
|
|
executor
is an instance ofMPIPoolExecutor
withmax_workers
of 100- Calculate $2^x$ in a
map
where $x$ set from 0 to 31
Time length running
|
|
Run this script via mpiexec
script for MPIPoolExecutor could run via mpiexec in command line
|
|
the script would be execute with 100 cores
Comparision
- 2.7007s running with 1 core
- 0.1527s running with 100 core
Test script
|
|
文章作者 Mijian Xu
上次更新 2019-01-03