The goal is to measure run-time vs #of processes.
I am just a beginner in MPI and get stuck somewhere.
I wrote a hello world program and want to test global run-time.
I tried using barrier, to make sure all processes terminate before measuring the system time, but I get a segmentation fault.
My code:
#include <mpi.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
double time1, time2;
double duration=0.0000;
int npes, myrank;
time1 = clock();
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &npes);
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
printf("From process %d out of %d, Hello World!\n", myrank, npes);
time2 = clock();
if (time2-time1>duration) {
duration = time2-time1;
}
duration = time2-time1;
MPI_BARRIER(MPI_COMM_WORLD);
printf("runtime is %f ", duration);
MPI_Finalize();
return 0;
}
Help me figure out why I am getting segmentation fault?