From: genaud Date: Fri, 10 Jul 2009 14:05:11 +0000 (+0000) Subject: MPI_Scatter() ok X-Git-Tag: SVN~1180 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/4fa2931658e07433d8bd09d002697114b1c67d9b MPI_Scatter() ok git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6468 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/examples/smpi/scatter.c b/examples/smpi/scatter.c index 9647aee838..2f68c916d4 100644 --- a/examples/smpi/scatter.c +++ b/examples/smpi/scatter.c @@ -29,14 +29,20 @@ int ibm_test(int rank, int size) { #define MAXLEN 10000 int success = 1; - int root,i,j,k; - int out[MAXLEN*64]; - int in[MAXLEN]; - - - for(j=1,root=0;j<=MAXLEN;j*=10,root=(root+1)%size) { - if(rank == root) - for(i=0;isize-1) * sizeof(smpi_mpi_request_t)); if (rank == root) { - // i am the root: distribute my sendbuf - for (i=0; i < comm->size; i++) { - cbuf = sendbuf; - cbuf += i*sendcount*datatype->size; - if ( i!=root ) { // send to processes ... - - retval = smpi_create_request((void *)cbuf, sendcount, - datatype, root, i, tag, comm, &(requests[cnt++])); - if (NULL != requests[cnt] && MPI_SUCCESS == retval) { - if (MPI_SUCCESS == retval) { - smpi_mpi_isend(requests[cnt]); - } + // i am the root: distribute my sendbuf + //print_buffer_int(sendbuf, comm->size, xbt_strdup("rcvbuf"), rank); + cptr = sendbuf; + for (i=0; i < comm->size; i++) { + if ( i!=root ) { // send to processes ... + + retval = smpi_create_request((void *)cptr, sendcount, + datatype, root, i, tag, comm, &(requests[cnt])); + if (NULL != requests[cnt] && MPI_SUCCESS == retval) { + if (MPI_SUCCESS == retval) { + smpi_mpi_isend(requests[cnt]); + } } cnt++; } else { // ... except if it's me. - memcpy(recvbuf, (void *)cbuf, recvcount*recvtype->size*sizeof(char)); + memcpy(recvbuf, (void *)cptr, recvcount*recvtype->size*sizeof(char)); } + cptr += sendcount*datatype->size; } for(i=0; i