- edited description
vector, indexed not working?
Issue #77
invalid
It does not look like vector or indexed datatypes work. I am using Anaconda3 and mpi4py 2.0.0 installed with conda. I tried installing the latest one from git repo over it but the result is the same.
#!/bin/env python
import numpy as np
from mpi4py import MPI
comm = MPI.COMM_WORLD
size = comm.size
rank = comm.rank
count = 4
stride = 5 #weird results when it is not divisible by size and blk_length!=1, bug?
blk_length = 2 #weird results with non 1, bug?
ns = count*stride
nr = count*blk_length
blk_lengths = [2, 4, 3, 1]
displacements = [0, 5, 13, 17]
if(rank == 0):
data = np.array(range(ns))
print("rank %d, data = %s" %(rank, data))
filetype = MPI.INT.Create_vector(count, blk_length, stride)
filetype.Commit()
comm.Send([data, 1, filetype], dest=1, tag=1)
filetype.Free()
filetype = MPI.INT.Create_indexed(blk_lengths, displacements)
filetype.Commit()
comm.Send([data, 1, filetype], dest=1, tag=2)
elif(rank == 1):
received = np.empty(nr , dtype='i')
comm.Recv([received, MPI.INT], source=0, tag=1)
print("rank %d, vector received = %s" %(rank, received))
received = np.empty(np.sum(blk_lengths) , dtype='i')
comm.Recv([received, MPI.INT], source=0, tag=2)
print("rank %d, indexed received = %s" %(rank, received))
$ python --version
Python 3.5.4
$ mpirun -n 2 python vector.py
rank 0, data = [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19]
rank 1, vector received = [0 0 0 3 5 0 0 8]
rank 1, indexed received = [0 0 0 3 0 4 0 7 0 0]
$ mpirun --version
HYDRA build details:
Version: 3.2
Release Date: Wed Nov 11 22:06:48 CST 2015
$ which mpirun
/usr/local/anaconda3/bin/mpirun
Should I, perhaps, combine mpi4py with a different distribution of MPI? or python?
Comments (3)
-
-
The problem is in your code, use
data = np.array(range(ns), dtype='i')
, otherwise numpy will create your array with 64 bits integers, and then you are sending garbage. -
- changed status to invalid
- Log in to comment