I tried what you said and this is the output:
Code:
What size message do you want to test?
A) 1 KB
B) 10 KB
A
Start time after Send(): 1241648586.974699
End time after Recv(): 0.000000
Done.
End time after Recv(): 1241648586.975898
Done.
Now, there are two "End time..." and "Done." statements because that code is running on both processes. I am starting to wonder if this method is going to give me reasonable results.
This is a shortened version of the code:
Code:
if (myrank == 0){
printf("What size message do you want to test?\n");
printf("A) 1 KB\n");
printf("B) 10 KB\n");
choice = getchar();
start_time = 0.0;
start_time = MPI_Wtime();
switch(choice){
case 'A':
{
char message[1000];
for(int i = 0; i <= 1000; i++){
message[i] = 'a';
}
if (myrank == 0){
MPI_Send(message, 1000, MPI_CHAR, 1, 99, MPI_COMM_WORLD);
printf("Start time after Send(): %f\n", start_time);
}
break;
}
case 'B':
{
char message[10000];
for(int i = 0; i <= 10000; i++){
message[i] = 'a';
}
if (myrank == 0){
MPI_Send(message, 10000, MPI_CHAR, 1, 99, MPI_COMM_WORLD);
printf("Start time after Send(): %f\n", start_time);
}
break;
}
default: break;
}
}
if (myrank != 0){
MPI_Recv(message, 100000, MPI_CHAR, 0, 99, MPI_COMM_WORLD, &status);
printf("Start time after Send(): %f\n", start_time);
}
end_time = MPI_Wtime();
printf("End time after Recv(): %f\n", end_time);
fprintf(timing, "Total communication time was: %f\n", (end_time - start_time));
fprintf(timing, "Message: %s\n", message);
fprintf(timing, "Precision is: %f\n", precision);
printf("Done.\n");
MPI_Finalize();
fclose(timing);
return 0;
}
As you can see, because the information at the bottom is running on both processes, we get two "End time after..." and "Done." statements.
The issue is the astronomical values for the time periods. Do you have any ideas?