Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |  

This web mail archive is frozen.

This page is part of a frozen web archive of this mailing list.

You can still navigate around this archive, but know that no new mails have been added to it since July of 2016.

Click here to be taken to the new web archives of this list; it includes all the mails that are in this frozen archive plus all new mails that have been sent to the list since it was migrated to the new archives.

Subject: [OMPI users] wrong results from MPI_Scatter with strided vector
From: Siegmar Gross (Siegmar.Gross_at_[hidden])
Date: 2008-06-16 02:36:33


I have a problem with derived data types and MPI_Scatter/MPI_Gather in C
(Solaris 10 sparc, openmpi-1.2.4).

I want to distribute the columns of a matrix with MPI_Scatter/MPI_Gather.
Unfortunately my program didn't work with my derived data type, so I used
a 2x2 matrix to figure out what's wrong and added a printf statement after
MPI_Scatter to print the contents of the column vector of each process. The
process with rank 1 didn't get the values "2" and "4" (see below), but more
or less 0. Now I used a 4x2 matrix and still a 2-element column vector (so
I should see the upper 2x2 "matrix" in my columns) to get an idea which
values are used for process 1. As you can see below it got "5" and "7", i.e.
the values of the first column of the lower 2x2 matrix and not the values of
the block which starts after the first element of the first block (a[2][0]
instead of a[0][1]).

Since I wasn't sure if I could use MPI_Type_struct I rewrote the program
with MPI_Type_vector. This time the result was better but still not
satisfying. Process 1 got values from the second column but one value too
late (starting with a[1][1] instead of a[1][0]).

I run into the same problem with MPICH, MPICH2, and LAM-MPI, so that I have
probably misunderstood something or have a programming error. Since I dont't
know how to proceed, I would be very grateful if someone could tell me if I
can't use a strided vector with MPI_Scatter or if it is eventually a bug in
the implementations of the MPI libraries (how unlikely it is). Mainly I've
implemented this part in the following way (the full program code is appended).

  int blockcounts[2] = {1, 1};

  MPI_Datatype types[2] = {MPI_DOUBLE, MPI_UB};
  MPI_Aint offsets[2] = {0, Q * sizeof (double)};
  MPI_Datatype coltype;
  MPI_Type_struct (2, blockcounts, offsets, types, &coltype);
  MPI_Type_commit (&coltype);
  MPI_Scatter (matrix, P, coltype, column, P, MPI_DOUBLE, 0,


tyr e5 158 mpiexec -mca btl ^udapl -np 2 e5_1a

original matrix:

     1 2
     3 4

rank: 0 c0: 1 c1: 3
rank: 1 c0: 5.51719e-313 c1: 4.24399e-314

tyr e5 160 mpiexec -mca btl ^udapl -np 2 e5_1a

original matrix:

     1 2
     3 4
     5 6
     7 8

rank: 0 c0: 1 c1: 3
rank: 1 c0: 5 c1: 7


tyr e5 119 mpiexec -mca btl ^udapl -np 2 e5_1b

original matrix:

     1 2
     3 4
     5 6
     7 8

rank: 0 c0: 1 c1: 3
rank: 1 c0: 4 c1: 6

Thank you very much for any help or suggestions in advance.

Kind regards


  • TEXT/x-sun-c-file attachment: e5_1a.c

  • TEXT/x-sun-c-file attachment: e5_1b.c