Add tests for cpus out of order in metadata

Reported-by: Arnau Cinca <arnau.cinca@bsc.es>
This commit is contained in:
Rodrigo Arias 2025-07-23 17:08:09 +02:00
parent 23faac0c1b
commit 3b65b0a52d
3 changed files with 77 additions and 1 deletions

View File

@ -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")

View File

@ -0,0 +1,36 @@
/* Copyright (c) 2025 Barcelona Supercomputing Center (BSC)
* SPDX-License-Identifier: GPL-3.0-or-later */
#include <stdlib.h>
#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;
}

View File

@ -0,0 +1,38 @@
/* Copyright (c) 2025 Barcelona Supercomputing Center (BSC)
* SPDX-License-Identifier: GPL-3.0-or-later */
#include <stdlib.h>
#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;
}