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
#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 |