Last active
August 29, 2015 14:11
-
-
Save donkirkby/eec37a7cf25f89c6f259 to your computer and use it in GitHub Desktop.
MPI4py spawn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mpi4py import MPI | |
import sys | |
import argparse | |
def main(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('worker_count', type=int) | |
args = parser.parse_args() | |
mpi_info = MPI.Info.Create() | |
mpi_info.Set("add-hostfile", "worker_hosts") | |
comm = MPI.COMM_SELF.Spawn(sys.executable, | |
args=['testworker.py'], | |
maxprocs=args.worker_count, | |
info=mpi_info).Merge() | |
process_rank = comm.Get_rank() | |
process_count = comm.Get_size() | |
process_host = MPI.Get_processor_name() | |
print ', '.join(map(str, ('manager', | |
process_rank, | |
process_count, | |
process_host))) | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mpi4py import MPI | |
def main(): | |
comm = MPI.Comm.Get_parent().Merge() | |
process_rank = comm.Get_rank() | |
process_count = comm.Get_size() | |
process_host = MPI.Get_processor_name() | |
print ', '.join(map(str, ('worker', | |
process_rank, | |
process_count, | |
process_host))) | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myhead1 slots=2 | |
mycompute1 slots=2 | |
mycompute2 slots=2 | |
mycompute3 slots=2 | |
mycompute4 slots=3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Trying to get the manager to spawn workers on multiple hosts, but it's not working.