#include #include #include #include #include #include #include #include "ovni.h" static double get_time() { struct timespec tv; if(clock_gettime(CLOCK_MONOTONIC, &tv) != 0) { perror("clock_gettime failed"); exit(EXIT_FAILURE); } return (double)(tv.tv_sec) * 1.0e-9 + (double)tv.tv_nsec; } static int cmp_double(const void *pa, const void *pb) { double a, b; a = *(const double *) pa; b = *(const double *) pb; if(a < b) return -1; else if(a > b) return 1; else return 0; } /* Called by rank 0 */ static void get_offset(double *timetable, char (*hosttable)[OVNI_MAX_HOSTNAME], int nproc, int nsamples) { int i, j; double median, mean, var, std; double *offset; double *delta; offset = malloc(nproc * sizeof(double)); delta = malloc(nsamples * sizeof(double)); if(!offset || !delta) { perror("malloc"); exit(EXIT_FAILURE); } /* We use as ref the clock in rank 0 */ printf("%-10s %-20s %-20s %-20s\n", "rank", "hostname", "offset_median", "offset_std"); for(i=0; i 0) ? hosttable[rank] : MPI_IN_PLACE; MPI_Gather(sendbuff, sizeof(*hosttable), MPI_CHAR, hosttable[0], sizeof(*hosttable), MPI_CHAR, 0, MPI_COMM_WORLD); MPI_Gather(t, nsamples, MPI_DOUBLE, timetable, nsamples, MPI_DOUBLE, 0, MPI_COMM_WORLD); if(rank == 0) get_offset(timetable, hosttable, nprocs, nsamples); free(hosttable); free(timetable); free(t); MPI_Finalize(); return 0; }