Add merge-cpus-loom test
Ensure we can merge the information of CPUs from multiple threads.
This commit is contained in:
parent
94ede68bab
commit
24805f607b
@ -11,6 +11,7 @@ test_emu(sort-first-and-full-ring.c SORT
|
|||||||
SHOULD_FAIL REGEX "cannot find a event previous to clock")
|
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(burst-stats.c REGEX "burst stats: median/avg/max = 33/ 33/ 33 ns")
|
||||||
test_emu(mp-simple.c MP)
|
test_emu(mp-simple.c MP)
|
||||||
|
test_emu(merge-cpus-loom.c MP)
|
||||||
test_emu(version-good.c)
|
test_emu(version-good.c)
|
||||||
test_emu(version-bad.c SHOULD_FAIL REGEX "incompatible .* version")
|
test_emu(version-bad.c SHOULD_FAIL REGEX "incompatible .* version")
|
||||||
test_emu(clockgate.c MP SHOULD_FAIL REGEX "detected large clock gate")
|
test_emu(clockgate.c MP SHOULD_FAIL REGEX "detected large clock gate")
|
||||||
|
52
test/emu/ovni/merge-cpus-loom.c
Normal file
52
test/emu/ovni/merge-cpus-loom.c
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/* Copyright (c) 2024 Barcelona Supercomputing Center (BSC)
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user