[mpich-discuss] Create derived data type structure with C++bindings syntax

Rajeev Thakur thakur at mcs.anl.gov
Wed Apr 29 19:08:10 CDT 2009


You need to write it as 
inputDataType = inputDataType.Create_struct(2,blockcounts,offsets,oldTypes);


Rajeev

> -----Original Message-----
> From: mpich-discuss-bounces at mcs.anl.gov 
> [mailto:mpich-discuss-bounces at mcs.anl.gov] On Behalf Of Marc
> Sent: Wednesday, April 29, 2009 10:47 AM
> To: mpich-discuss at mcs.anl.gov
> Subject: [mpich-discuss] Create derived data type structure 
> with C++bindings syntax
> 
> Hi,
> 
> I'm trying to make a derived data type which consists of 4 
> integers and
> 9 doubles. I'm using the C++ bindings and I got the following 
> error while running mpirun:
> 
> 0 - MPI_TYPE_COMMIT : Datatype is MPI_TYPE_NULL
> 
> The commit don't seem to work... Here is an excerpt of the code:
> 
> int main(int argc, char *argv[])
> {
>   MPI::Datatype inputDataType;
>   MPI::Datatype oldTypes[2];
>   MPI::Aint offsets[2];
>   MPI::Aint intExtent;
>   MPI::Aint lb;
>   int blockcounts[2];
> 
>   MPI::Init(argc, argv);
> 
>   MPI::INT.Get_extent(lb,intExtent);
> 		
>   offsets[0] = 0;
>   oldTypes[0] = MPI::INT;
>   blockcounts[0] = 4;
> 
>   offsets[1] = blockcounts[0] * intExtent;
>   oldTypes[1] = MPI::DOUBLE;
>   blockcounts[1] = 9;
> 
>   inputDataType.Create_struct(2,blockcounts,offsets,oldTypes);
>   inputDataType.Commit();
> 
>   //Lot of computation and communications here
> 
>   inputDataType.Free();
>   MPI::Finalize();
> 
>   return 0;
> }
> 
> Why I'm getting that error? I'm using Mpich version 1.2.7-9ubuntu1.
> Also, could you explain me what is the lower bound lb nature 
> and what is it for?
> 
> Thanks,
> 
> Marc
> 
> 



More information about the mpich-discuss mailing list