[mpich-discuss] mpich-discuss Digest, Vol 20, Issue 16

Jayesh Krishna jayesh at mcs.anl.gov
Wed May 12 08:48:26 CDT 2010


 Typo - read as -  Looks like you are allocating memory for *profit1* and receiving data into *profit*.

-Jayesh
----- Original Message -----
From: "Jayesh Krishna" <jayesh at mcs.anl.gov>
To: mpich-discuss at mcs.anl.gov
Cc: keanesankar at gmail.com
Sent: Wednesday, May 12, 2010 8:45:19 AM GMT -06:00 US/Canada Central
Subject: Re: [mpich-discuss] mpich-discuss Digest, Vol 20, Issue 16

Hi,
 Did you intend to receive the *profits* to *profit* array or the *profit1* array ?

>> profit1 = malloc (n/nprocs * sizeof(double)); 
>> MPI_Recv(profit,n/nprocs,MPI_DOUBLE,0,tag,MPI_COMM_WORLD,&status); 

 Looks like you are allocation memory for *profit1* and receiving data into *profit*.

Regards,
Jayesh

----- Original Message -----
From: "sankar s" <keanesankar at gmail.com>
To: mpich-discuss at mcs.anl.gov
Sent: Wednesday, May 12, 2010 1:55:27 AM GMT -06:00 US/Canada Central
Subject: Re: [mpich-discuss] mpich-discuss Digest, Vol 20, Issue 16



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); 
profit1 = 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 

_______________________________________________
mpich-discuss mailing list
mpich-discuss at mcs.anl.gov
https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss
_______________________________________________
mpich-discuss mailing list
mpich-discuss at mcs.anl.gov
https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss


More information about the mpich-discuss mailing list