From 3b65b0a52db7252b368b5c7a1d55833c436460c1 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Wed, 23 Jul 2025 17:08:09 +0200 Subject: [PATCH] Add tests for cpus out of order in metadata Reported-by: Arnau Cinca --- test/emu/ovni/CMakeLists.txt | 4 ++- test/emu/ovni/duplicated-cpu-index.c | 36 ++++++++++++++++++++++++++ test/emu/ovni/split-loom-cpus.c | 38 ++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 test/emu/ovni/duplicated-cpu-index.c create mode 100644 test/emu/ovni/split-loom-cpus.c diff --git a/test/emu/ovni/CMakeLists.txt b/test/emu/ovni/CMakeLists.txt index c43e3ad..064e37a 100644 --- a/test/emu/ovni/CMakeLists.txt +++ b/test/emu/ovni/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2024 Barcelona Supercomputing Center (BSC) +# Copyright (c) 2022-2025 Barcelona Supercomputing Center (BSC) # SPDX-License-Identifier: GPL-3.0-or-later test_emu(flush-overhead.c DISABLED) @@ -33,3 +33,5 @@ test_emu(dummy.c NAME "match-doc-events" DRIVER "match-doc-events.sh") test_emu(dummy.c NAME "match-doc-version" DRIVER "match-doc-version.sh") test_emu(libovni-attr.c) test_emu(libovni-mark.c MP) +test_emu(split-loom-cpus.c MP) +test_emu(duplicated-cpu-index.c MP SHOULD_FAIL REGEX "cpu with index 0 already taken") diff --git a/test/emu/ovni/duplicated-cpu-index.c b/test/emu/ovni/duplicated-cpu-index.c new file mode 100644 index 0000000..07c5fe8 --- /dev/null +++ b/test/emu/ovni/duplicated-cpu-index.c @@ -0,0 +1,36 @@ +/* Copyright (c) 2025 Barcelona Supercomputing Center (BSC) + * SPDX-License-Identifier: GPL-3.0-or-later */ + +#include +#include "compat.h" +#include "instr.h" + +int +main(void) +{ + int rank = atoi(getenv("OVNI_RANK")); + int nranks = atoi(getenv("OVNI_NRANKS")); + + if (nranks < 2) + die("need at least 2 ranks"); + + char hostname[OVNI_MAX_HOSTNAME]; + + if (gethostname(hostname, OVNI_MAX_HOSTNAME) != 0) + die("gethostname failed"); + + ovni_version_check(); + ovni_proc_init(1, hostname, getpid()); + ovni_thread_init(get_tid()); + + /* Wrongly set the logical index to 0 always */ + ovni_add_cpu(0, rank); + + instr_thread_execute(rank, -1, 0); + + sleep_us(50); + + instr_end(); + + return 0; +} diff --git a/test/emu/ovni/split-loom-cpus.c b/test/emu/ovni/split-loom-cpus.c new file mode 100644 index 0000000..be3ce28 --- /dev/null +++ b/test/emu/ovni/split-loom-cpus.c @@ -0,0 +1,38 @@ +/* Copyright (c) 2025 Barcelona Supercomputing Center (BSC) + * SPDX-License-Identifier: GPL-3.0-or-later */ + +#include +#include "compat.h" +#include "instr.h" + +int +main(void) +{ + int rank = atoi(getenv("OVNI_RANK")); + int nranks = atoi(getenv("OVNI_NRANKS")); + + if (nranks < 2) + die("need at least 2 ranks"); + + char hostname[OVNI_MAX_HOSTNAME]; + + if (gethostname(hostname, OVNI_MAX_HOSTNAME) != 0) + die("gethostname failed"); + + ovni_version_check(); + ovni_proc_init(1, hostname, getpid()); + ovni_thread_init(get_tid()); + + /* Define only one CPU per rank but in reverse order so they are not + * processed in increasing index order */ + int cpu = nranks - rank - 1; + ovni_add_cpu(cpu, cpu); + + instr_thread_execute(cpu, -1, 0); + + sleep_us(50); + + instr_end(); + + return 0; +}