[mpich-discuss] Checks for buffer aliasing in coll ops?

Carsten Clauss c.clauss at fz-juelich.de
Fri Feb 28 08:13:52 CST 2014


Constantly, our users step into the common trap of aliasing send and 
receive buffers e.g. in (All)Gather(v) instead of using MPI_IN_PLACE.

Although these cases are frequently caught by lower-level memcpy() 
checks within MPICH, I wonder if it would be feasible to do so already 
in the upper MPI layer, e.g. by using MPIR_ERRTEST_ALIAS_COLL() in a 
more comprehensive manner.

IMHO it would be nice to extend the check e.g. in MPI_(All)Gather() from

/* catch common aliasing cases */
if (recvbuf != MPI_IN_PLACE && sendtype == recvtype && sendcount == 
recvcount && sendcount != 0)
                 MPIR_ERRTEST_ALIAS_COLL(sendbuf,recvbuf,mpi_errno);

-- that would only take effect for root=0 -- to let's say:

/* catch common aliasing cases */
MPID_Datatype_get_size_macro(recvtype, recvtype_size);
if (recvbuf != MPI_IN_PLACE && sendtype == recvtype && sendcount == 
recvcount && sendcount != 0)
                 MPIR_ERRTEST_ALIAS_COLL(sendbuf, (char*)recvbuf + 
comm_ptr->rank*recvcount*recvtype_size, mpi_errno);

And the same for MPI_(All)Gatherv() (which currently do not check for 
aliasing at all):

/* catch common aliasing cases */
MPID_Datatype_get_size_macro(recvtype, recvtype_size);
if (sendbuf != MPI_IN_PLACE && sendtype == recvtype && 
recvcounts[comm_ptr->rank] != 0 && sendcount != 0)
                 MPIR_ERRTEST_ALIAS_COLL(sendbuf, (char*)recvbuf + 
displs[comm_ptr->rank]*recvtype_size, mpi_errno);

I think this would lead to much more understandable error messages 
("PMPI_Gatherv(363): Buffers must not be aliased" vs. "memcpy argument 
memory ranges overlap") -- or is there something that speaks against 
this kind of checks?

With kind regards,
C. Clauss

-- 
Carsten Clauss
Possartstrasse 20
D-81679 Muenchen
www.par-tec.com
_____________________________________
ParTec Cluster Competence Center GmbH

Geschäftsführer RA. Dipl.-Ing. Bernhard Frohwitter Eingetragen beim
Amtsgericht München HRB 151545 Steuer-Nr. 08/32305, Ust-ID DE235527064




More information about the discuss mailing list