Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

From: jody (jody.xha_at_[hidden])
Date: 2007-07-10 12:36:01


I think there is still some problem.
I create different datatypes by resizing MPI_SHORT with
different negative lower bounds (depending on the rank)
and the same extent (only depending on the number of processes).

However, I get an error as soon as MPI_File_set_view is called with my new
datatype:

Error: Unsupported datatype passed to ADIOI_Count_contiguous_blocks
[aim-nano_02:22229] MPI_ABORT invoked on rank 0 in communicator
MPI_COMM_WORLD with errorcode 1

The same error occurs, if i set the lower bounds to 0.
Is it perhaps not possible to use resized datatypes in MPI_File_set_view?

Here's my code:

#include <stdio.h>
#include "mpi.h"

//-----------------------------------------------------------------------------
// main
//
//
int main(int iArgC, char *apArgV[]) {

    int iNumProcs;
    int iID;

    MPI_Init(&iArgC, &apArgV);

    MPI_Comm_size(MPI_COMM_WORLD, &iNumProcs);
    MPI_Comm_rank(MPI_COMM_WORLD, &iID);

    // get the size of a MPI_SHORT
    MPI_Aint lbs;
    MPI_Aint exts;
    MPI_Type_get_extent(MPI_SHORT, &lbs, &exts);

    // resize the MPI_SHORT datatype
    // same extent but differennt position of the MPI_SHORT
    MPI_Datatype dtWHoles;
    MPI_Aint lb = -iID * exts;
    MPI_Aint ext = iNumProcs * exts;
    MPI_Type_create_resized(MPI_SHORT, lb, ext, &dtWHoles);

    // commit the datatype
    MPI_Type_commit(&dtWHoles);

    // open the file for writing
    MPI_File fh;
    MPI_File_open(MPI_COMM_WORLD, "testwrite.dat", MPI_MODE_WRONLY |
MPI_MODE_CREATE, MPI_INFO_NULL, &fh);

    // set the file view
    MPI_File_set_view(fh, 0, MPI_SHORT, dtWHoles, "native", MPI_INFO_NULL);

    // here we would do some writing

    // close the file
    MPI_File_close(&fh);

    // clean up
    MPI_Type_free(&dtWHoles);

    MPI_Finalize();
}

On 7/10/07, George Bosilca <bosilca_at_[hidden]> wrote:
>
> MPI_LB and MPI_UB is what you're looking for. Or better, for MPI-2
> compliant libraries such as Open MPI and MPICH2, you can use
> MPI_Type_create_resized. This will allow you to create the gap at the
> beginning and/or the end of a data-type description.
>
> george.
>
> On Jul 10, 2007, at 10:53 AM, jody wrote:
>
> > hi
> > I want to create datatypes of the form
> > XX000000...
> > 00XX0000...
> > 0000XX00...
> > etc.
> >
> > I tried MPI_Type_indexed(1, ais, ait, MPI_SHORT, &dtNewType)
> > where ais= {2} and ait = {2} but this only gives me a datatype of
> > the form
> > 00XX, i.e. no holes at the end.
> >
> > I guess MPI_Type_vector won't work, because there seems to be
> > no way to create holes at the beginning of the datatype
> >
> >
> > I need these datatypes to let each process write its data into the
> > file
> > in the following way:
> > XXYYZZXXYYZZXXYYZZ....
> > (X is data from proc 0, Y is data from proc 1, Z is data from proc 2)
> >
> > My intended approach was to define datatypes of the form XX0000,
> > 00XX00, 0000XX
> > for the respective processors, and then call MPI_File_set_view
> > with displacement 0 and the respective datatypes fo the "filetype"
> > parameter,
> > and finally let each processor write its stuff to file
> > sequentially using MPI_File_write.
> >
> > However, my plan failed since i am unable to create datatypes with
> > holes in front and at the end.
> >
> > What function should i use to create the desired datatypes?
> >
> > Thank You
> >
> > Jody
> > _______________________________________________
> > users mailing list
> > users_at_[hidden]
> > http://www.open-mpi.org/mailman/listinfo.cgi/users
>
> _______________________________________________
> users mailing list
> users_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/users
>