Created
August 14, 2017 05:32
-
-
Save iwiwi/f51e86ced0552fff737f0c9bf94a6f58 to your computer and use it in GitHub Desktop.
All-to-all collective communication for numpy & cupy arrays with ChainerMN (demo)
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
import chainermn | |
from chainermn.communicators._memory_utility import array_to_buffer_object | |
import mpi4py.MPI | |
comm = chainermn.create_communicator('naive') | |
def alltoall_demo(xp): | |
mpi_comm = comm.mpi_comm | |
n = comm.size | |
a = xp.arange(n * 3).reshape((n, -1)).astype(xp.float32) | |
print('BEFORE', comm.rank, ':', a.ravel()) | |
mpi_comm.Alltoall(mpi4py.MPI.IN_PLACE, array_to_buffer_object(a)) | |
print('AFTER', comm.rank, ':', a.ravel()) | |
import cupy as cp | |
import numpy as np | |
alltoall_demo(np) | |
alltoall_demo(cp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment