Skip to content

Instantly share code, notes, and snippets.

View MartinGranados's full-sized avatar
💀

Martin Granados MartinGranados

💀
View GitHub Profile
@joezuntz
joezuntz / mpi4py_trivial.py
Created February 5, 2015 15:41
Simplest possible mpi4py job splitting
#Suppose you have a collection of tasks, which in this example I'll assume is just running a function f.
#If these tasks are completely separate and independent the most then you can parallelize them easily.
#In this gist I'll show the simplest possible way to do this using mpi4py.
#There are better ways to do this, in particular if the tasks vary significantly in time taken to run.
import mpi4py.MPI
def f(i):
"A fake task - in this case let just open a file and write a number to it"
#open file with name based on task number