types - MPI user-defined datatypes, is what I'm doing safe? -


First time using some simple practice apps using MPI, and something is not running right.

I have a class defined with the following members (excluding methods for readability and protected screen space):

  class particles {public: double _lastUpdate; Float _x, _y, _xvel, _yvel; Bull _Estatic; Bull_isierine; Float_shape; Private: int _isStaticInt; Copy of _isStatic to send to MPI // (because there is no MPI_BOOL in it: C)};  

I want to send the set of particles between the processes by sending the values ​​of some key members of each particle and copying other people on the spot. For that purpose, I define an MPI datatype; As you can see, the members are not included _lastUpdate, _isStatic and _isForeign:

  MPI_Datatype type [] = {MPI_FLOAT, MPI_FLOAT, MPI_FLOAT, MPI_FLOAT, MPI_INTEGER, MPI_FLOAT}; Std :: vector & lt; Integer & gt; Lane (6, 1); Std :: vector & lt; MPI_Ant> Disp (6, 0); Particle temporarily; MPI_Aint base; MPI_Address (& amp; Temporary, & Support); Mpi_adres (& amp; Tempk_ksh & Amp [0]] ;; Mpi_adres (& amp; Tempk_y, & amp; Disp [1]); Mpi_adres (& amp; Tempk_gvel & Amp [2]) ; Mpi_adres (& amp; Tempk_yvel, & amp; Disp [3]); Mpi_adres (& amp; Tempk_issttikint & Disp [4]); Mpi_adres (& amp; Tempk_saij, & amp; Disp [5 ]) for: (Int I = 0; i & lt; 6; ++ i) {disp [i] = disp [i] - based; MPI_Type_struct} (6, and LAN [0], & disp [0] , type, and amp; _particleType); MPI_Type_commit (& amp; _particleType);  

sends this way I particles have, 'parts' particle in a vector that particle goods * I send I want to point out, and 'size' is parts.size ()

  std :: vector.  lane (size, 1); std :: Vector & LT; MPI_Aint & gt; Disp (size, 0); MPI_Aint basis; MPI_Address (parts [0], and base); // datatype first starts for the selected object (select Intret = 1; left; Size ; ++) Select {MPI_Address (parts [selection], & select]); Disp [selection] = disp [selection] - base;} MPI_Type_hindexed (size, & amp; Lane [0], & amp; Disp [0], _particleType, & amp; _sendType); MPI_Type_commit (& amp; _sendType); MPI_Request payload_req; MPI_Isend (Part [0], 1, _sendType, NGB, 0, _cartesian_comm, and payload_reck); Similarly, in this case only, 'parts' is a vector of particle * that is made of previously "empty" particle objects, whose members are filled with data. We get the point:  
  std :: vector & lt; Int & gt; Lane (size, 1); Std :: vector & lt; MPI_Ant> Disp (size, 0); MPI_Aint base; MPI_Address (parts [0], and base); // Datatype (int part = 1; part & lt; size; ++ part) {MPIADER (part [part], & amp; [part]) starts on the first new cast object; Disp [part] = disp [part] - base; } MPI_Type_hindexed (size, & LAN [0], & disp [0], _particleType, and amp; _recvType); MPI_Type_commit (& amp; _recvType); MPI_Status status; MPI_Recv (Part [0], Size, _particleType, NGB, 0, _cartesian_comm, and Position);  

The problem is that all the particles except the first ones have the default "empty" value in their members. I wrote a small test app before it was something similar, And it worked no time, even though it only transmits some simple values. This leads me to believe that unless there is a coding mistake I'm not seeing here (fully possible), this type of datatype trickery is not guaranteed to work, and that's small job Does not do it by accident only.

Is this type of memory manipulation safe and should it depend on it?

Never mind, it seems that just writing the question made me realize what's wrong.

The order received should be:.

  MPI_Recv (parts [0], 1, _recvType, NGB, 0, _cartesian_comm, and position);  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -