2023-10-23 15:12:43 +02:00
|
|
|
/* Copyright (c) 2023-2024 Barcelona Supercomputing Center (BSC)
|
2023-07-27 19:21:19 +02:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later */
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "common.h"
|
|
|
|
#include "emu_prv.h"
|
|
|
|
#include "instr.h"
|
|
|
|
#include "instr_nosv.h"
|
|
|
|
#include "emu/nosv/nosv_priv.h"
|
|
|
|
|
|
|
|
int
|
|
|
|
main(void)
|
|
|
|
{
|
|
|
|
/* Tests the case where a task is paused from nosv_submit():
|
|
|
|
*
|
|
|
|
* A VTp event causes a pop of the subsystem channel, which is expected
|
|
|
|
* to be ST_TASK_RUNNING. This is not true in the case of a blocking
|
|
|
|
* submit (NOSV_SUBMIT_BLOCKING), which calls nosv_pause from inside
|
|
|
|
* nosv_submit, causing the transition to happen from the unexpected
|
|
|
|
* ST_API_SUBMIT state.
|
|
|
|
*/
|
|
|
|
|
|
|
|
instr_start(0, 1);
|
2023-11-10 12:34:57 +01:00
|
|
|
instr_nosv_init();
|
2023-07-27 19:21:19 +02:00
|
|
|
|
|
|
|
/* Match the PRV line in the trace */
|
|
|
|
FILE *f = fopen("match.sh", "w");
|
|
|
|
if (f == NULL)
|
|
|
|
die("fopen failed:");
|
|
|
|
|
|
|
|
uint32_t typeid = 100;
|
|
|
|
instr_nosv_type_create(typeid);
|
|
|
|
|
|
|
|
instr_nosv_task_create(1, typeid);
|
|
|
|
|
2023-10-23 15:12:43 +02:00
|
|
|
instr_nosv_task_execute(1, 0);
|
2023-07-27 19:21:19 +02:00
|
|
|
|
|
|
|
/* When starting a task, it must cause the subsystems to enter
|
|
|
|
* the "Task: In body" state */
|
|
|
|
int prvtype = PRV_NOSV_SUBSYSTEM;
|
|
|
|
int st = ST_TASK_BODY;
|
2024-04-19 16:04:53 +02:00
|
|
|
fprintf(f, "grep ':%" PRIi64 ":%d:%d$' ovni/thread.prv\n", get_delta(), prvtype, st);
|
|
|
|
fprintf(f, "grep ':%" PRIi64 ":%d:%d$' ovni/cpu.prv\n", get_delta(), prvtype, st);
|
2023-07-27 19:21:19 +02:00
|
|
|
|
|
|
|
instr_nosv_submit_enter(); /* Blocking submit */
|
2023-10-23 15:12:43 +02:00
|
|
|
instr_nosv_task_pause(1, 0);
|
2023-07-27 19:21:19 +02:00
|
|
|
|
|
|
|
/* Should be left in the submit state, so no state transition in
|
|
|
|
* subsystems view */
|
2024-04-19 16:04:53 +02:00
|
|
|
fprintf(f, "! grep ':%" PRIi64 ":%d:[0-9]*$' ovni/thread.prv\n", get_delta(), prvtype);
|
|
|
|
fprintf(f, "! grep ':%" PRIi64 ":%d:[0-9]*$' ovni/cpu.prv\n", get_delta(), prvtype);
|
2023-07-27 19:21:19 +02:00
|
|
|
|
|
|
|
/* But the task state must be set to pause, so the task id
|
|
|
|
* must be null */
|
|
|
|
prvtype = PRV_NOSV_TASKID;
|
2024-04-19 16:04:53 +02:00
|
|
|
fprintf(f, "grep ':%" PRIi64 ":%d:0$' ovni/thread.prv\n", get_delta(), prvtype);
|
|
|
|
fprintf(f, "grep ':%" PRIi64 ":%d:0$' ovni/cpu.prv\n", get_delta(), prvtype);
|
2023-07-27 19:21:19 +02:00
|
|
|
|
|
|
|
instr_nosv_submit_exit();
|
2023-10-23 15:12:43 +02:00
|
|
|
instr_nosv_task_resume(1, 0);
|
|
|
|
instr_nosv_task_end(1, 0);
|
2023-07-27 19:21:19 +02:00
|
|
|
|
|
|
|
fclose(f);
|
|
|
|
|
|
|
|
instr_end();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|