ovni/test/emu/tampi/ss-polling.c
Rodrigo Arias 354f2f50eb Register emulation models only if required
Until now, emulation models were always being registered via probe(),
which causes the emulator to initialize all the channels. To reduce the
overhead, the channels were not connected or registered in the bay
until the first event of that model was received. This delayed connect
was causing issues in muxes where the newly connected model required
refreshing the touched channels. Which in turn was causing unexpected
PRV events.

By determining which models we need to enable, we can remove the delayed
connect mechanism and just enable those models at initialization time,
and connect the channels.
2023-11-16 12:39:05 +01:00

71 lines
1.5 KiB
C

/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC)
* SPDX-License-Identifier: GPL-3.0-or-later */
#include <stdlib.h>
#include "compat.h"
#include "instr.h"
#include "instr_tampi.h"
int
main(void)
{
/* Test that simulates the polling task of TAMPI */
const int rank = atoi(getenv("OVNI_RANK"));
const int nranks = atoi(getenv("OVNI_NRANKS"));
instr_start(rank, nranks);
instr_tampi_init();
const int transfer_step = 5;
const int complete_step = 3;
int nreqs_to_transfer = 100;
int nreqs_to_test = 0;
int t, c;
/* Simulate the loop of the polling task */
while (nreqs_to_transfer || nreqs_to_test) {
instr_tampi_library_polling_enter();
t = 0;
instr_tampi_transfer_queues_enter();
while (nreqs_to_transfer && t < transfer_step) {
/* Transfer a request/ticket to the global array */
--nreqs_to_transfer;
++nreqs_to_test;
++t;
}
instr_tampi_transfer_queues_exit();
/* Check the global array of requests/tickets */
if (nreqs_to_test) {
instr_tampi_check_global_array_enter();
/* Testsome requests */
instr_tampi_testsome_requests_enter();
sleep_us(10);
instr_tampi_testsome_requests_exit();
c = 0;
while (nreqs_to_test && c < complete_step) {
/* Process a completed request */
instr_tampi_completed_request_enter();
sleep_us(1);
instr_tampi_completed_request_exit();
--nreqs_to_test;
++c;
}
instr_tampi_check_global_array_exit();
}
instr_tampi_library_polling_exit();
sleep_us(100);
}
instr_end();
return 0;
}