[mpich-discuss] Query regarding structure of dynamic array derived datatype

Pavan Balaji balaji at mcs.anl.gov
Thu Mar 21 20:29:58 CDT 2013


You'll still need to create a datatype for MPI_Pack.  This is the
structure you mentioned:

struct A
{
    int size;
    int *lptr;
};

I'm assuming you want to send the size and the data associated with lptr
in a single message.  In this case, the only approaches I can think of are:

1. Create a datatype every time you want to send this information and
free it once you are done.

2. Send two messages, one with the size parameter and the second with
the data pointed to by lptr.

Someone else might have a better way to do this.

 -- Pavan

On 03/21/2013 08:21 PM US Central Time, Raghu Reddy wrote:
> As far as I know, since your struct contains a pointer, I don’t believe
> you have a choice other than to pack. 
> 
>  
> 
> Someone can correct me if I’m wrong.
> 
>  
> 
> Thanks,
> 
>  
> 
> Raghu
> 
>  
> 
>  
> 
>  
> 
> *From:*discuss-bounces at mpich.org [mailto:discuss-bounces at mpich.org] *On
> Behalf Of *Mahesh Doijade
> *Sent:* Thursday, March 21, 2013 4:42 AM
> *To:* mpich-discuss at mcs.anl.gov
> *Subject:* Re: [mpich-discuss] Query regarding structure of dynamic
> array derived datatype
> 
>  
> 
> Hi,
>      Thanks for your reply, after looking at various MPI derived
> datatype creation functions other than MPI_Pack according to me option
> can probably be of using MPI_Type_create_struct but then for each
> structure element I have to create a separate derived datatype as the
> block lengths will be different due to dynamic array present in them, so
> again the extra memory will be required now for type-maps of these
> datatypes.
>       Is the approach of MPI_Type_create_struct mentioned above will be
> better than MPI_Pack in this case?  also is there any other optimal way
> to do this?
> 
> 
> -- 
> 
> Regards,
> -- Mahesh Doijade
> 
> On Thu, Mar 21, 2013 at 2:36 AM, Pavan Balaji <balaji at mcs.anl.gov
> <mailto:balaji at mcs.anl.gov>> wrote:
> 
> 
> Please look through the derived datatype constructs in MPI.  Google can
> help you find some tutorials.
> 
>  -- Pavan
> 
> 
> On 03/19/2013 06:12 AM US Central Time, Mahesh Doijade wrote:
>> Hi,
>>      I have a struct as -
>> struct A
>> {
>>     int size;
>>     int *lptr;
>> };
>>      And then I have array of such structure, I want to only send
>> dynamic array present in each of the structs to other process.
>> One of the options is to do it with MPI_Pack but then I have read it is
>> not so good from performance point of view.
>> What can be the other opt
>>
>> --
>>
>> Regards,
>> -- Mahesh Doijade
>>
>>
>>
>>
>>
> 
>> _______________________________________________
>> discuss mailing list     discuss at mpich.org <mailto:discuss at mpich.org>
>> To manage subscription options or unsubscribe:
>> https://lists.mpich.org/mailman/listinfo/discuss
>>
> 
> --
> Pavan Balaji
> http://www.mcs.anl.gov/~balaji <http://www.mcs.anl.gov/%7Ebalaji>
> 
> 
> 
>                                                                           
> 
> 
> 
> _______________________________________________
> discuss mailing list     discuss at mpich.org
> To manage subscription options or unsubscribe:
> https://lists.mpich.org/mailman/listinfo/discuss
> 

-- 
Pavan Balaji
http://www.mcs.anl.gov/~balaji



More information about the discuss mailing list