I'm trying to test the total runtime using MPI_Wtime() however I'm getting incorrect outputs.
#include "mpi.h"
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
int main(int argc, char *argv[])
{
int rank, size, len;
double start, end, runtime;
char name[MPI_MAX_PROCESSOR_NAME];
MPI_Init(&argc, &argv);
MPI_Barrier(MPI_COMM_WORLD);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Get_processor_name(name, &len);
start = MPI_Wtime();
printf("Hello World! I am %d of %d on %s\n", rank, size, name);
fflush(stdout);
Sleep(1000);
MPI_Barrier(MPI_COMM_WORLD);
end = MPI_Wtime();
MPI_Finalize();
if (rank == 0)
{
runtime = end - start;
printf("Start time = %d\n", start);
printf("End time = %d\n\n", end);
printf("Runtime = %d\n", runtime);
}
system("pause");
return 0;
}
I get outputs like this:
Hello World! I am 0 of 1 on test
Start time = 505400631
End time = 521122106Runtime = -1878261760
Press any key to continue . . .
I'm expecting to get seconds, but I'm getting these long outputs instead. Any idea why?