There are two possible reasons for the error:
There is a bug in the data copy routines, present in older Open MPI versions, that appears to have been fixed in version 1.4.4. If this is the case, an upgrade of the Open MPI library to a newer version would solve the problem.
Another possible reason is that my_elements
is an array of single item of type T
. In the MPI_Allgather
call you pass a pointer to this element, but you specify instead sizeof(T*)
as the number of bytes to be sent. By default, Electric Fence places the newly allocated memory at the end of a memory page and then inserts an inaccessible memory page immediately after. If T
happens to be shorter than a pointer type (e.g. T
is int
and you are running on a 64-bit LP64 platform), then access to the inaccessible memory page would occur and hence the segfault. As your intention is to actually send a pointer to the data, then you should pass MPI_Allgather
a pointer to the value returned by my_elements.get()
instead.
By the way, passing pointers around is not a nice thing to do. MPI provides its own portable RDMA implementation. See the One-sided Communications chapter of the MPI standard. It is a bit cumbersome, but it should at least be portable.