Newsgroups: comp.parallel.mpi
From: "Marc A. Chiarini" <mac>
Subject: Heterogeneity, XDR, and mpich
Organization: Virginia Tech, Blacksburg, Virginia
Date: 27 Apr 1995 23:13:54 GMT
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 7bit
Message-ID: <3np8fj$4cs@solaris.cc.vt.edu>

Lately, I have been writing a few programs to test the correctness of mpich's
use of XDR.  I wrote the following program to see what happens when an unsigned
long gets passed back and forth between two different architectures, namely a
DEC Alpha running OSF/1 V3.0 and an Intel Pentium running Linux, where the
Alpha stores longs in 8 bytes whereas the Pentium uses 4:


#include "mpi.h"
#include <stdio.h>
#include <limits.h>

int main(argc, argv)
int argc;
char **argv;
{

  int me;
  unsigned long old, new;
  MPI_Datatype type;
  MPI_Status status;

  MPI_Init(&argc, &argv);
  MPI_Comm_rank(MPI_COMM_WORLD,&me);

  fprintf(stderr,"Process %d is alive\n", me);

  MPI_Barrier(MPI_COMM_WORLD);

  old = UINT_MAX;
  type = MPI_UNSIGNED_LONG;

  if (me == 0)
    {
      MPI_Send(&old, 1, type, 1, 100, MPI_COMM_WORLD);
      printf("%d:  Sent %lu to process 1\n", me, old);
      printf("%d:  Sizeof(%lu) is %d\n", me, old, sizeof(old));
      printf("%d:  Waiting for data from process 1\n", me);
      fflush(stdout);
      MPI_Recv(&new, 1, type, 1, 100, MPI_COMM_WORLD, &status);
      printf("%d:  Received %lu from process 1\n", me, new);
      fflush(stdout);
    }
  else
    {
      MPI_Recv(&new, 1, type, 0, 100, MPI_COMM_WORLD, &status);
      printf("%d:  Received %lu from process 0\n", me, new);
      printf("%d:  Sizeof(%lu) is %d\n", me, old, sizeof(old));
      fflush(stdout);
      MPI_Send(&old, 1, type, 0, 100, MPI_COMM_WORLD);
      printf("%d:  Sent data to process 0\n", me);
    }

  fflush(stdout);


  MPI_Finalize();
  return(0);
}


-------------
The result:

screamer.async.vt.edu 186% mpirun -arch LINUX -machine p4 -p4pg
hetr.convtest.pg convtest
Process 0 is alive
Process 1 is alive
0:  Sent 4294967295 to process 1
0:  Sizeof(4294967295) is 4
0:  Waiting for data from process 1
1:  Received 4294967295 from process 0
1:  Sending 4294967295 to process 0
1:  Sizeof(4294967295) is 8
Truncated message
Aborting program!
p0_1804:  p4_error: (null): 1
P4 procgroup file is hetr.convtest.pg.

-----------------------------------------
Now I was under the impression that this type of message-passing is taken care
of by the XDR implementation.  Am I wrong, or does my problem have nothing to
do with the fact that the architectures are different?

I also remain unconvinced that I can create a derived datatype with
MPI_Type_struct and successfully pass an instance of such a structure between
heterogeneous architectures with base datatypes of differing size and compilers
that pad the fields of said structures differently.  I hope someone can show me
an example to the contrary.

Any help is much appreciated....

-----------------------------------------------------------------------------
*.......MARC CHIARINI.......*  E-mail: mac@popeye.cs.vt.edu                 *
*..Systems Research Center..*  WWW   : http://manta.cs.vt.edu/Users/mac     *
*.......Virginia Tech.......*  Phone : (703) 231-6097 (W)                   *
*.Blacksburg, VA 24061-0106.* 	       (703) 951-2734 (H)                   *
-----------------------------------------------------------------------------


