README.md 834 Bytes
Newer Older
otintopr's avatar
otintopr committed
# Make it Parallel

A few wrappers and decorators to make using mpi4py even easier.

### Simple example:
Reading a file in the root and distribute the contents:
```python
otintopr's avatar
otintopr committed
from makeitparallel import Communicator, initialization

communicator = Communicator()

# Define the function to read the data and add the initialization decorator.
@initialization
def read_file(filename):
    with open(filename) as f:
        _data = f.read()
    return _data

# Use the function
data = read_file()

# At this point, only the root process actually read the file
# The other processes will have data == None

# Broadcast the information
data = communicator.bcast(data)

# After this point, all the processes will have the data even though only the root processes had read it.
```

More useful examples can be found in the **examples** folder.