LAM/MPI logo

LAM/MPI General User's Mailing List Archives

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

From: Peeyush Jain (jain.peeyush_at_[hidden])
Date: 2006-03-16 16:16:46


How do I define a global shared memory in LAM. I am having a problem
in running a program on more than 1 processor.
void indNodes(graph_t *G, int *vtxmap, MPI_Comm comm)
{
    int *xadj, *adjncy, *deg, *checksum, *checksum1, *tmp;
    int nvtx, u, v, i, istart, istop, j, jstart, jstop;
    int my_rank, p, ivert, count, vstart, vend, size, ierr; //t, devide;
    nvtx = G->nvtx;
    xadj = G->xadj;
    adjncy = G->adjncy;

    MPI_Comm_rank(comm, &my_rank);
    MPI_Comm_size(comm, &p);

    /* -------------------------
     set up the working arrays
     ------------------------- */

    mymalloc(checksum, nvtx, int);
    mymalloc(checksum1, nvtx, int);

    /* -------------------------------------------------
    compute for each vertex u its degree and checksum
    ------------------------------------------------- */

    count = 0; vstart = (int)(my_rank*(nvtx / p));
    if(my_rank == p-1)
            vend = nvtx;
    else
            vend = (int)((my_rank + 1) * (nvtx / p));

    size = vend - vstart;
    for(ivert = vstart; ivert < vend ; ivert ++)
    {
         istart = xadj[ivert];
         istop = xadj[ivert+1];
         checksum[ivert] = ivert + 1;
         for (i = istart; i < istop; i++)
                 checksum[ivert] += (adjncy[i]+1);
     }

    MPI_Allgather(checksum ,size ,MPI_INT ,checksum1 ,size ,MPI_INT ,comm);
    printf("checksums are %d %d %d %d\n", my_rank, checksum1[0],
checksum1[88], checksum1[200]);
    free(deg); free(checksum); free(tmp);
}

       Now after executing this on three computer(Because I have given
201 vertex for the size to be similar, I get the checksum1 is same for
all the three processor but that result is obtained by only rank 0
processor. Thats why I need to knpw whether i can have the global
shared memory or someone can give me the solution of this problem.

Peeyush