diff --git a/Makefile b/Makefile index 4277161..61cdd5c 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ CFLAGS+=-g -O0 #CFLAGS+=-fstack-protector-explicit #CFLAGS+=-flto -BIN=dump test_speed ovni2prv emu libovni.so +BIN=dump test_speed ovni2prv emu libovni.so ovnisync all: $(BIN) @@ -28,5 +28,8 @@ libovni.so: ovni.o ovni2prv: ovni2prv.c ovni.o +ovnisync: ovnisync.c + mpicc -lm $^ -o $@ + clean: rm -f *.o $(BIN) diff --git a/ovnisync.c b/ovnisync.c new file mode 100644 index 0000000..15974c7 --- /dev/null +++ b/ovnisync.c @@ -0,0 +1,155 @@ +#include +#include +#include +#include +#include +#include +#include + +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)[HOST_NAME_MAX], 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