The MPI standard, 3.0, says about mpi_scatterv:
The specification of counts, types, and displacements should not cause any location on the root to be read more than once."
However, my testing of mpi4py in python with the code below does not indicate that there is a problem with reading data from root more than once:
import numpy as np
from sharethewealth import sharethewealth
comm = MPI.COMM_WORLD
nprocs = comm.Get_size()
rank = comm.Get_rank()
counts = [16, 17, 16, 16, 16, 16, 15]
displs = [0, 14, 29, 43, 57, 71, 85]
if rank == 0:
bigx = np.arange(100, dtype=np.float64)
else:
bigx = None
my_size = counts[rank]
x = np.zeros(my_size)
comm.Scatterv([bigx, counts, displs, MPI.DOUBLE], x, root = 0)
print x
Command
> mpirun -np 7 python mycode.py
produces
[ 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72.]
[ 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96. 97. 98. 99.]
[ 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15.]
[ 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44.]
[ 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58.]
[ 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86.]
[ 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30.]
The output is clearly correct and the data from root ( process 0) has clearly been referenced more than once at each of the boundary points. Am I not understanding the MPI standard? Or is this a fortuitous behavior that cannot be relied on in general?
FWIW, I'm running python 2.7 on OSX.