LAM/MPI logo

LAM/MPI General User's Mailing List Archives

  |   Home   |   Download   |   Documentation   |   FAQ   |   all just in this list

From: Evadream (evadream.mlist_at_[hidden])
Date: 2004-03-31 13:50:31


Hello,

Thanx for your response. I read this in the documentation

Let type1 have type map,
{ (double, 0), (char, 8) }
with extent 16. Let B = (2, 1, 3), D = (0, 16, 26), and T = (MPI_FLOAT,
type1, MPI_CHAR). Then a call to MPI_TYPE_STRUCT(3, B, D, T) ...

Ok, so here i've got B = (7,2) T = (MPI_DOUBLE, MPI_UNSIGNED_LONG_LONG)
and D = (0, 56) ?

I don't think this is the solution, because it doesn't seems to work

MPI::Datatype type[2] = { MPI::DOUBLE, MPI::UNSIGNED_LONG_LONG } ;
int blocklen[2] = { 7, 2 } ;
MPI::Aint disp[2] = { 0, 56 } ;

Escuse me if didnt understand your hints :/

On Wed, 2004-03-31 at 20:16, Vishal Sahay wrote:
> 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/
> # >
> #
>