Giter Site home page Giter Site logo

jjmaldonis / mpi-parallelization Goto Github PK

View Code? Open in Web Editor NEW
20.0 7.0 1.0 29 KB

Examples for MPI Spawning and Splitting, and the differences between two implementations

License: MIT License

Fortran 15.75% Python 84.25%
mpi mpi4py openmpi spawning-programs

mpi-parallelization's Introduction

This repository contains MPI examples using mpi4py.

Examples

Basic Gather Examples

  • gather.py uses each core to update a different piece of information in a list and passes that information to all cores using the .gather and .bcast methods. The allgather.py example is similar, but uses the .allgather method instead; it then parses the resulting information to keep only the updated values.

Spawn Multiple Examples

  • spawn_multiple_worker.py is a program designed to be run as a worker/child process. spawn_multiple_worker_fortran.f90 is the corresponding FORTRAN example. These programs will be called in the spawning programs below. They distribute a calculation of pi over the cores that were allocated to them and return the reduced-sum value to their parent process.

  • spawn.py is the most basic example of spawning, and performs a single spawn. spawn_loop.py has similar functionality, but spawns workers iteratively, waiting for each child process to finish before starting a new one.

  • spawn_multiple.py spawns multiple copies of an executable with different data. spawn_multiple_loop.py spawns multiple executables during each iteration of a loop.

  • spawn_fortran_multiple.py and spawn_fortran_multiple_loop.py are the analogous programs that call the FORTRAN worker rather than the Python worker.

Split-Spawn Examples

  • split_multiple.py is an analogous program to spawn_multiple.py, only rather than using spawn_multiple, it splits the world communicator within the parent process and then spawns processes on the newly created communicators. The worker process can be found in split_multiple_worker.py.

  • split_multiple_loop.py splits and spawns multiple executables within a loop.

Notes

This code has only been tested with Open MPI 1.10.2 and mpi4py 2.0.0.

Open MPI sets the environment variable OMPI_MCA_orte_app_num, which is crucial for the spawn_multiple commands. This necessity can be avoided in other MPI implementations by passing the color in to the worker program. This is illustrated in the examples.

Spawn Multiple vs. Split-Spawn

The processes of spawning multiple individuals using Spawn_multiple vs. Split -> Spawn both take about the same amount of time (within the margin of error for the simple tests I ran).

The Spawn Multiple programs can take advantage of the OpenMPI environment variable OMPI_MCA_orte_app_num directly, while the splitting examples inherently cannot. The Spawn Multiple examples can therefore be made to run naturally using MPMD with OpenMPI.

If more MPI APIs were to specify an argument analogous to OMPI_MCA_orte_app_num, the MPI_COMM_Spawn_multiple function would become signficantly more useful.

mpi-parallelization's People

Contributors

jjmaldonis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

geofiber

mpi-parallelization's Issues

License ?

Hello, under what license is this project released under ? I would like to study it to learn from it. Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.