Pierre,
There are several issues with the code you provided.

1. You can’t use an MPI_DATATYPE_NULL as the send datatype, not even when count 
is zero. At least the root must provide a real datatype. In fact the type 
signature of the send message (datatype and count) should match the type 
signature of the receiving datatype.

2. I know your count is zero, and no data will be transmitted but your code is 
difficult to read and understand.

3. MPI_Iscatter is a collective communication. As such all processes in the 
associated communicator (MPI_COMM_WORLD in your case) must participate to the 
collective. Thus, calling MPI_Iscatter only where tasked > 0 is incorrect (you 
explicitly excluded 0).

4. From the MPI standard perspective your example is not correct, as you are 
not allowed to call MPI_Finalize while there are messages pending. Now, Open 
MPI tolerate this, but it is clearly not standard behavior.

#include <mpi.h>

int main(int argc, char** argv)
{
    int          taskid, ntasks;
    MPI_Init(&argc, &argv);
    MPI_Request rq;
    MPI_Comm_rank(MPI_COMM_WORLD,&taskid);
    MPI_Comm_size(MPI_COMM_WORLD,&ntasks);
    double r;
    int l = 0;

    MPI_Iscatter(NULL, 0, MPI_DOUBLE, &r, l, MPI_DOUBLE, 0, MPI_COMM_WORLD, 
&rq);
    MPI_Wait(&rq, MPI_STATUS_IGNORE);

    MPI_Finalize();
}

  George.


On Nov 21, 2013, at 23:19 , Pierre Jolivet <joli...@ann.jussieu.fr> wrote:

> Hello,
> The following code doesn’t execute properly :
> #include <mpi.h>
> 
> int main(int argc, char** argv) {
>    int          taskid, ntasks;
>    MPI_Init(&argc, &argv);
>    MPI_Request rq;
> 
>    MPI_Comm_rank(MPI_COMM_WORLD,&taskid);
>    MPI_Comm_size(MPI_COMM_WORLD,&ntasks);
>    double* r;
>    int l = 0;
>    if(taskid > 0)
>        MPI_Iscatter(NULL, 0, MPI_DATATYPE_NULL, r, l, MPI_DOUBLE, 0, 
> MPI_COMM_WORLD, &rq);
>    MPI_Finalize();
> }
> 
> Outcome:
> *** An error occurred in MPI_Type_extent
> *** MPI_ERR_TYPE: invalid datatype
> 
> Hotfix: change MPI_DATATYPE_NULL to something else.
> 
> Thanks for a quick fix.
> _______________________________________________
> users mailing list
> us...@open-mpi.org
> http://www.open-mpi.org/mailman/listinfo.cgi/users

Reply via email to