From 740d8b0d4b70bb1d6a3c3e73531991d98e1c216b Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Tue, 21 Mar 2023 16:55:59 +0100 Subject: [PATCH] Only allow one rank per host in ovnisync --- src/emu/ovnisync.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/emu/ovnisync.c b/src/emu/ovnisync.c index a129362..ef58ce1 100644 --- a/src/emu/ovnisync.c +++ b/src/emu/ovnisync.c @@ -368,6 +368,27 @@ print_drift_row(FILE *out, struct offset_table *table) static void print_table_detailed(FILE *out, struct offset_table *table) { + int fail = 0; + + /* Ensure each hostname is unique */ + for (int i = 0; i < table->nprocs; i++) { + struct offset *a = table->offset[i]; + for (int j = 0; j < i; j++) { + struct offset *b = table->offset[j]; + + if (strcmp(a->hostname, b->hostname) == 0) { + fprintf(stderr, "FATAL: ranks %d and %d run in same hostname %s\n", + j, i, a->hostname); + fail = 1; + } + } + } + + if (fail) { + fprintf(stderr, "Please run %s with one rank per host\n", progname); + exit(EXIT_FAILURE); + } + fprintf(out, "%-10s %-20s %-20s %-20s %-20s\n", "rank", "hostname", "offset_median", "offset_mean", "offset_std");