LAM/MPI logo

LAM/MPI General User's Mailing List Archives

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

From: Sherif Abd El-Momen (sherif_samir75_at_[hidden])
Date: 2003-04-07 01:41:34


Hi!

I am using RMA, I want to create a variable of type SparseElt - which is a
struct- an let this variable available for other processes to get (read) the
variable, Can you help me?

   /********************************/
  struct SparseElt { /* representation of a sparse matrix element */
    int location[2]; /* where the element belongs in the overall matrix
*/
    double value; /* the value of the element */
  };

struct SparseElt anElement; /* a representative variable of this type */

  int lena[2]; /* the three arrays used to describe an MPI derived
type */
  MPI_Aint loca[2]; /* their size reflects the number of components in
SparseElt */
  MPI_Datatype typa[2];

  MPI_Aint baseaddress;

  MPI_Datatype MPI_SparseElt; /* a variable to hold the MPI type indicator
for SparseElt */

  /* set up the MPI description of SparseElt */
MPI_Address(&anElement, &baseaddress);
  lena[0] = 2; MPI_Address(&anElement.location,&loca[0]);
  loca[0] -= baseaddress; typa[0] = MPI_INT;
  lena[1] = 1; MPI_Address(&anElement.value ,&loca[1]);
  loca[1] -= baseaddress; typa[1] = MPI_DOUBLE;
  MPI_Type_create_struct(2, lena, loca, typa, &MPI_SparseElt);
  MPI_Type_commit(&MPI_SparseElt);

struct SparseElt mynode;
struct SparseElt mynodelocal;
....
MPI_Win_create(&mynode,
sizeof(MPI_SparseElt),disp_unit,MPI_INFO_NULL,MPI_COMM_WORLD,&nwin);
....
if (myid!=0)
      MPI_Get(&mynodelocal,1,MPI_SparseElt ,0,0,1,MPI_SparseElt ,nwin);
    MPI_Win_fence(0,nwin);
/****************************************/

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963