List Info

Thread: LAM: derived datatype & memcpy




LAM: derived datatype & memcpy
user name
2008-03-12 04:25:35
Hi All,

       I want to copy derived datatype "newtype1" to "newtype2".
       This is for avoiding copying of each and every element of "newtype1" to "newtype2"
  ;     I tried the following conventions:

 ;      MPI_Type_size(newtype1, &newtype1_size);
  ;     memcpy(&newtype2, &newtype1, newtype1_size);

       As "newtype1_size" should be equal to "newtype2_size", either of them can be used.
      ;
       When I printed individual values of newtype2, it showed garbage/zero values.
       Can anyone please throw some light on this? Or any other idea of copying one derived datatype to another can be explained.

     ;  Thanks...
--
Manoj Vaghela

Re: LAM: derived datatype & memcpy
country flaguser name
United States
2008-03-13 22:35:42
On Mar 12, 2008, at 3:25 AM, Manoj Vaghela wrote:

>        I want to copy derived datatype
"newtype1" to "newtype2".
>        This is for avoiding copying of each and every
element of  
> "newtype1" to "newtype2"
>        I tried the following conventions:
>
>        MPI_Type_size(newtype1, &newtype1_size);
>        memcpy(&newtype2, &newtype1,
newtype1_size);
>
>        As "newtype1_size" should be equal to
"newtype2_size", either  
> of them can be used.
>
>        When I printed individual values of newtype2, it
showed  
> garbage/zero values.
>        Can anyone please throw some light on this? Or
any other idea  
> of copying one derived datatype to another can be
explained.

Well, the short answer is that you can't do that .  newtype1
is a  
handle to the actual datatype, not the actual datatype
itself.   
MPI_Type_size gives you the space that the data represented
by  
newtype1 takes, not the size of the backing information for
newtype1.

Hope that makes sense.  If not, you probably want to have
another read  
through the MPI datatype section.

Brian

-- 
   Brian Barrett
   LAM/MPI Developer
   Make today a LAM/MPI day!


_______________________________________________
This list is archived at http://www.l
am-mpi.org/MailArchives/lam/

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )