Hi all,

I use a very simple datatype defined as follow:
    lng[0]= 1;
   dsp[0]= 1;
   err=MPI_Type_indexed(1, lng, dsp, MPI_CHAR, &offtype);
   err=MPI_Type_create_resized(offtype, 0, 2, &filetype);
   MPI_Type_commit(&filetype);

This datatype consists of a hole (of length 1 char) followed by a char.

The datatype with hole at the beginning is not correctly handled by ROMIO integrated in OpenMPI (I tried with MPICH2 and it worked fine).
You will see bellow a program to reproduce the problem.

After investigations, I see that the difference between OpenMPI and MPICH appears at line 542 in the file romio/adio/comm/flatten.c:

   case MPI_COMBINER_RESIZED:
   /* This is done similar to a type_struct with an lb, datatype, ub */

   /* handle the Lb */
       j = *curr_index;
       flat->indices[j] = st_offset + adds[0];
       flat->blocklens[j] = 0;

       (*curr_index)++;

       /* handle the datatype */

       MPI_Type_get_envelope(types[0], &old_nints, &old_nadds,
                             &old_ntypes, &old_combiner);
ADIOI_Datatype_iscontig(types[0], &old_is_contig); <========== ligne 542

For MPICH2, the datatype is not contiguous, but it is for OpenMPI. The routine ADIOI_Datatype_iscontig is quite different in OpenMPI because the datatypes are handled very differently. If I reset old_is_contig just after
line 542, the problem disappears (Of course, this is not a solution).

I am not able to propose a right solution. Can somebody help ?

Pascal

============ Program to reproduce the problem ========
#include <stdio.h>
#include "mpi.h"

char filename[256]="VIEW_TEST";
char buffer[100];
int err, i, myid, dsp[3], lng[3];
MPI_Status status;
MPI_File fh;
MPI_Datatype filetype, offtype;
MPI_Aint lb, extent;

int main(int argc, char **argv) {

MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &myid);
for (i=0; i<sizeof(buffer); i++) buffer[i] = i;

if (!myid) {
MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE | MPI_MODE_RDWR , MPI_INFO_NULL, &fh);
   MPI_File_write(fh, buffer, sizeof(buffer), MPI_CHAR, &status);
   MPI_File_close(&fh);

   lng[0]= 1;
   dsp[0]= 1;
   MPI_Type_indexed(1, lng, dsp, MPI_CHAR, &offtype);
   MPI_Type_create_resized(offtype, 0, 2, &filetype);
   MPI_Type_commit(&filetype);

MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_RDONLY , MPI_INFO_NULL, &fh);
   MPI_File_set_view(fh, 0, MPI_CHAR, filetype,"native", MPI_INFO_NULL);
   MPI_File_read(fh, buffer, 5, MPI_CHAR, &status);

   printf("Data: ");
   for (i=0 ; i<5 ; i++) printf(" %x ", buffer[i]);
if (buffer[1] != 3) printf("\n =======> test KO : buffer[1]=%d instead of %d \n", buffer[1], 4);
   else printf("\n =======> test OK\n");
   MPI_Type_free(&filetype);
   MPI_File_close(&fh);
}
MPI_Barrier(MPI_COMM_WORLD);
MPI_Finalize();
}
============ The result of the program with MPICH2 ========
Data:  1  3  5  7  9
=======> test OK

============ The result of the program with OpenMPI ========
Data:  0  2  4  6  8
=======>  test KO : buffer[1]=2 instead of 4

Comment: Only the first hole is ommited.



Reply via email to