Hi --
You are creating your datatype in the wrong way. Check how to create a
datatype of type struct (Create_struct) at
http://www.mpi-forum.org/docs/mpi-11-html/node55.html#Node55.
(This will show you the C syntax, but the concept is the same)
Hints:
- Check the count argument
- Check the array disp that you are passing. More specifically the length
and the distribution. It does not work as expected.
Lemme know how it goes!
-Vishal
On Tue, 30 Mar 2004, Evadream wrote:
# Sorry,
#
# But you should read
#
# void Create_MPI_CLIENT_STATS(MPI::Datatype& newtype)
# {
# // build datatype
#
# MPI::Datatype type[2] = { MPI::DOUBLE, MPI::UNSIGNED_LONG_LONG }
# ;
# int blocklen[2] = { 7, 2 } ;
# MPI::Aint disp[9] ;
#
# ...
#
# Instead of
#
# void Create_MPI_CLIENT_STATS(MPI::Datatype& newtype)
# {
# // build datatype
#
# MPI::Datatype type[2] = { MPI::DOUBLE, MPI::DOUBLE } ;
#
#
#
# On Tue, 2004-03-30 at 19:27, Evadream wrote:
#
# > Hello everybody,
# >
# > I spent a few hours on a little problem about sending structure. I'v got
# > no problem with contiguous data, like this one :
# >
# > typedef struct ComputeInfo {
# > unsigned long long line_number ;
# > unsigned long long total_charge ;
# > } ;
# >
# > which i commit with this few lines :
# >
# > void Create_MPI_ULONG_LONG_PAIR(MPI::Datatype& newtype)
# > {
# > newtype = MPI::UNSIGNED_LONG_LONG.Create_contiguous(2) ;
# > newtype.Commit() ;
# > }
# >
# > Now, i try to build up a MPI::Datatype based on heterogenous data. Take
# > this one :
# >
# > typedef struct ClientStats {
# > double network_wait_time ;
# > double network_send_time ;
# > double compute_time ;
# > double start_delay ;
# > double total_time ;
# > double mhz ;
# > double bogomips ;
# > unsigned long long line_number ;
# > unsigned long long total_charge ;
# > } ;
# >
# > This is the code i wrote to commit this new type :
# >
# > void Create_MPI_CLIENT_STATS(MPI::Datatype& newtype)
# > {
# > // build datatype
# >
# > MPI::Datatype type[2] = { MPI::DOUBLE, MPI::DOUBLE } ;
# > int blocklen[2] = { 7, 2 } ;
# > MPI::Aint disp[9] ;
# >
# > ClientStats stat ;
# >
# > disp[0] = MPI::Get_address(&stat.network_wait_time) ;
# > disp[1] = MPI::Get_address(&stat.network_send_time) ;
# > disp[2] = MPI::Get_address(&stat.compute_time) ;
# > disp[3] = MPI::Get_address(&stat.start_delay) ;
# > disp[4] = MPI::Get_address(&stat.total_time) ;
# > disp[5] = MPI::Get_address(&stat.mhz) ;
# > disp[6] = MPI::Get_address(&stat.bogomips) ;
# > disp[7] = MPI::Get_address(&stat.line_number) ;
# > disp[8] = MPI::Get_address(&stat.total_charge) ;
# >
# > for(int i = 8; i >= 0; i--) disp[i] -= disp[0] ;
# >
# > newtype = newtype.Create_struct(1, blocklen, disp, type) ;
# > newtype.Commit();
# > }
# >
# > It's compile fine without any warnings, but it works quite bad. Here is
# > the way i use this new datatype :
# >
# > // SENDER
# > ClientStats stat ;
# > [...]
# > MPI::COMM_WORLD.Send( &stat , 1, CLIENT_STATS, 0, TAG_STATS) ;
# >
# > // RECEPTION
# > ClientStats stat ;
# > MPI::COMM_WORLD.Recv(&stat, 1, CLIENT_STATS, worker, TAG_STATS, status)
# > ;
# >
# > When i read my ClientStats structure, the unsigned long long
# > line_number, unsigned long long total_charge variables are unchanged,
# > although i send a new value.
# >
# > I'm quite newbie with MPI stuff, so i think i'm doing something wrong.
# > It would be very nice if you can give me some advice about this problem
# > !
# >
# > Thanx !
# >
# > _______________________________________________
# > This list is archived at http://www.lam-mpi.org/MailArchives/lam/
# >
#
|