From 97dac6e83bcb37c6902ee9d1cc6949c93450be2a Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Fri, 24 Feb 2023 11:58:53 +0100 Subject: [PATCH] Add switch-same-type nosv test Generates a script with the values of the delta clock, PRV type and value to be matched in the .prv traces, to ensure the emulator emitted the switching type event. --- test/emu/nosv/CMakeLists.txt | 1 + test/emu/nosv/switch-same-type.c | 47 ++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 test/emu/nosv/switch-same-type.c diff --git a/test/emu/nosv/CMakeLists.txt b/test/emu/nosv/CMakeLists.txt index 0ab9bf4..4bed229 100644 --- a/test/emu/nosv/CMakeLists.txt +++ b/test/emu/nosv/CMakeLists.txt @@ -7,3 +7,4 @@ ovni_test(nested-tasks-bad.c SHOULD_FAIL ovni_test(task-types.c MP) ovni_test(pause.c MP) ovni_test(mp-rank.c MP) +ovni_test(switch-same-type.c) diff --git a/test/emu/nosv/switch-same-type.c b/test/emu/nosv/switch-same-type.c new file mode 100644 index 0000000..c1bd4a1 --- /dev/null +++ b/test/emu/nosv/switch-same-type.c @@ -0,0 +1,47 @@ +/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC) + * SPDX-License-Identifier: GPL-3.0-or-later */ + +#include "instr_nosv.h" + +#include "emu_prv.h" + +int +main(void) +{ + /* Tests that switching to a nested task of the same type produces a + * duplicated event in the Paraver trace with the task type. */ + + instr_start(0, 1); + + uint32_t typeid = 100; + uint32_t gid = instr_nosv_type_create(typeid); + + /* Create two tasks of the same type */ + instr_nosv_task_create(1, typeid); + instr_nosv_task_create(2, typeid); + + instr_nosv_task_execute(1); + /* Change subsystem to prevent duplicates */ + instr_nosv_submit_enter(); + /* Run another nested task with same type id */ + instr_nosv_task_execute(2); + + /* Match the PRV line in the trace */ + FILE *f = fopen("match.sh", "w"); + if (f == NULL) + die("fopen failed:"); + int prvtype = PRV_NOSV_TYPE; + int64_t t = get_delta(); + fprintf(f, "grep ':%ld:%d:%d' ovni/thread.prv\n", t, prvtype, gid); + fprintf(f, "grep ':%ld:%d:%d' ovni/cpu.prv\n", t, prvtype, gid); + fclose(f); + + /* Exit from tasks and subsystem */ + instr_nosv_task_end(2); + instr_nosv_submit_exit(); + instr_nosv_task_end(1); + + instr_end(); + + return 0; +}