diff --git a/test/emu/ovni/CMakeLists.txt b/test/emu/ovni/CMakeLists.txt index 3a44cd2..d01eb2d 100644 --- a/test/emu/ovni/CMakeLists.txt +++ b/test/emu/ovni/CMakeLists.txt @@ -11,6 +11,7 @@ test_emu(sort-first-and-full-ring.c SORT SHOULD_FAIL REGEX "cannot find a event previous to clock") test_emu(burst-stats.c REGEX "burst stats: median/avg/max = 33/ 33/ 33 ns") test_emu(mp-simple.c MP) +test_emu(merge-cpus-loom.c MP) test_emu(version-good.c) test_emu(version-bad.c SHOULD_FAIL REGEX "incompatible .* version") test_emu(clockgate.c MP SHOULD_FAIL REGEX "detected large clock gate") diff --git a/test/emu/ovni/merge-cpus-loom.c b/test/emu/ovni/merge-cpus-loom.c new file mode 100644 index 0000000..746c06b --- /dev/null +++ b/test/emu/ovni/merge-cpus-loom.c @@ -0,0 +1,52 @@ +/* Copyright (c) 2024 Barcelona Supercomputing Center (BSC) + * SPDX-License-Identifier: GPL-3.0-or-later */ + +#include +#include "compat.h" +#include "instr.h" + +/* Ensure we can emit CPUs from multiple threads of the same loom */ + +static inline void +start(int rank, int nranks) +{ + char hostname[OVNI_MAX_HOSTNAME]; + + if (gethostname(hostname, OVNI_MAX_HOSTNAME) != 0) + die("gethostname failed"); + + ovni_version_check(); + + /* Only one loom */ + ovni_proc_init(1, hostname, getpid()); + ovni_proc_set_rank(rank, nranks); + ovni_thread_init(get_tid()); + + /* Only emit a subset of CPUs up to the rank number */ + for (int i = 0; i <= rank; i++) + ovni_add_cpu(i, i); + + int curcpu = rank; + + dbg("thread %d has cpu %d (ncpus=%d)", + get_tid(), curcpu, nranks); + + instr_require("ovni"); + instr_thread_execute(curcpu, -1, 0); +} + + +int +main(void) +{ + int rank = atoi(getenv("OVNI_RANK")); + int nranks = atoi(getenv("OVNI_NRANKS")); + + start(rank, nranks); + + sleep_us(50 * 1000); + + instr_end(); + + return 0; +}