[mpich-discuss] mpich-discuss Digest, Vol 20, Issue 16
sankar s
keanesankar at gmail.com
Wed May 12 02:02:55 CDT 2010
On Wed, May 12, 2010 at 12:25 PM, sankar s <keanesankar at gmail.com> wrote:
> Hi,
> Thank you for immediate reply.
> Now I used malloc for creating space for pointer profit and also used
> MPI_Recv instead of MPI_Irecv.Now its not giving any error.
> But instead of passing profit1 (MPI_DOUBLE), its passing only zeros. pls
> don't mind for asking some easy questions like this. am very new to this.
>
> /*CODE*/
> int main(int argc, char*argv[]){
> double *simulateRuns(int, int, int, int);
> double simulateOneRun(int,int,int);
> void stat(double *,int);
>
> int nprocs; /* number of processes */
> int rank,tag=1,i; /* the unique identification of this process */
> long int before,after;
> double * profit1,* profit2,* profit;
> int n=10,m=20000,s=80,S=200;
> MPI_Status status;
> before=GetTickCount();
>
> MPI_Init (&argc, &argv);
> MPI_Comm_rank (MPI_COMM_WORLD, &rank);
> MPI_Comm_size (MPI_COMM_WORLD, &nprocs);
> printf("rank=%d nproc=%d\n",rank,nprocs);
> if (rank==0){
> profit1=simulateRuns(n/nprocs,m,s,S);
> stat(profit1,n/2);
> MPI_Send(profit1,n/nprocs,MPI_DOUBLE,1,tag,MPI_COMM_WORLD);
> }
> if(rank==1){
> profit2=simulateRuns(n/nprocs,m,s,S);
> stat(profit2,n/2);
> profit = malloc (n/nprocs * sizeof(double));
> MPI_Recv(profit,n/nprocs,MPI_DOUBLE,0,tag,MPI_COMM_WORLD,&status);
> stat(profit,n/2);
> }
> MPI_Finalize ();
> after=GetTickCount();
> printf("time elapsed=%ld\n",(after-before));
> }
> /*OUTPUT*/
>
> C:\Users\Sankar\My Documents\visual studio
> 2008\Projects\Inventorympi\Debug>mpie
> xec -n 2 Inventorympi.exe
> rank=1 nproc=2
> 65.145380
> 64.170140
> 64.402515
> 65.238190
> 64.651180
> stats on profit
> num.obs min max average std.dev
> 5 64.170140 65.238190 64.721481 0.231481
> 0.000000
> 0.000000
> 0.000000
> 0.000000
> 0.000000
> stats on profit
> num.obs min max average std.dev
> 5 0.000000 0.000000 0.000000 0.000000
> time elapsed=266
> rank=0 nproc=2
> 65.145380
> 64.170140
> 64.402515
> 65.238190
> 64.651180
> stats on profit
> num.obs min max average std.dev
> 5 64.170140 65.238190 64.721481 0.231481
> time elapsed=188
>
> Thank you
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/mpich-discuss/attachments/20100512/f002d6df/attachment.htm>
More information about the mpich-discuss
mailing list