From 1e2102c0a0c47ea3933435f802b302630ac6cf71 Mon Sep 17 00:00:00 2001 From: Kevin Sala Date: Tue, 22 Aug 2023 17:39:41 +0200 Subject: [PATCH] Add TAMPI emu tests --- test/emu/CMakeLists.txt | 1 + test/emu/tampi/CMakeLists.txt | 7 ++++ test/emu/tampi/instr_tampi.h | 39 ++++++++++++++++++++ test/emu/tampi/ss-comm.c | 55 ++++++++++++++++++++++++++++ test/emu/tampi/ss-mismatch.c | 23 ++++++++++++ test/emu/tampi/ss-polling.c | 69 +++++++++++++++++++++++++++++++++++ 6 files changed, 194 insertions(+) create mode 100644 test/emu/tampi/CMakeLists.txt create mode 100644 test/emu/tampi/instr_tampi.h create mode 100644 test/emu/tampi/ss-comm.c create mode 100644 test/emu/tampi/ss-mismatch.c create mode 100644 test/emu/tampi/ss-polling.c diff --git a/test/emu/CMakeLists.txt b/test/emu/CMakeLists.txt index d87efb3..4d3c6de 100644 --- a/test/emu/CMakeLists.txt +++ b/test/emu/CMakeLists.txt @@ -11,3 +11,4 @@ add_subdirectory(common) add_subdirectory(ovni) add_subdirectory(nosv) add_subdirectory(nanos6) +add_subdirectory(tampi) diff --git a/test/emu/tampi/CMakeLists.txt b/test/emu/tampi/CMakeLists.txt new file mode 100644 index 0000000..2d9cf76 --- /dev/null +++ b/test/emu/tampi/CMakeLists.txt @@ -0,0 +1,7 @@ +# Copyright (c) 2023 Barcelona Supercomputing Center (BSC) +# SPDX-License-Identifier: GPL-3.0-or-later + +test_emu(ss-comm.c MP) +test_emu(ss-polling.c MP) +test_emu(ss-mismatch.c SHOULD_FAIL + REGEX "thread [0-9]\\+ ended with 1 stacked tampi subsystems") diff --git a/test/emu/tampi/instr_tampi.h b/test/emu/tampi/instr_tampi.h new file mode 100644 index 0000000..a65e40e --- /dev/null +++ b/test/emu/tampi/instr_tampi.h @@ -0,0 +1,39 @@ +/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC) + * SPDX-License-Identifier: GPL-3.0-or-later */ + +#ifndef INSTR_TAMPI_H +#define INSTR_TAMPI_H + +#include "instr.h" + +INSTR_0ARG(instr_tampi_issue_nonblk_op_enter, "TCi") +INSTR_0ARG(instr_tampi_issue_nonblk_op_exit, "TCI") + +INSTR_0ARG(instr_tampi_check_global_array_enter, "TGc") +INSTR_0ARG(instr_tampi_check_global_array_exit, "TGC") + +INSTR_0ARG(instr_tampi_library_interface_enter, "TLi") +INSTR_0ARG(instr_tampi_library_interface_exit, "TLI") +INSTR_0ARG(instr_tampi_library_polling_enter, "TLp") +INSTR_0ARG(instr_tampi_library_polling_exit, "TLP") + +INSTR_0ARG(instr_tampi_add_queues_enter, "TQa") +INSTR_0ARG(instr_tampi_add_queues_exit, "TQA") +INSTR_0ARG(instr_tampi_transfer_queues_enter, "TQt") +INSTR_0ARG(instr_tampi_transfer_queues_exit, "TQT") + +INSTR_0ARG(instr_tampi_completed_request_enter, "TRc") +INSTR_0ARG(instr_tampi_completed_request_exit, "TRC") +INSTR_0ARG(instr_tampi_test_request_enter, "TRt") +INSTR_0ARG(instr_tampi_test_request_exit, "TRT") +INSTR_0ARG(instr_tampi_testall_requests_enter, "TRa") +INSTR_0ARG(instr_tampi_testall_requests_exit, "TRA") +INSTR_0ARG(instr_tampi_testsome_requests_enter, "TRs") +INSTR_0ARG(instr_tampi_testsome_requests_exit, "TRS") + +INSTR_0ARG(instr_tampi_create_ticket_enter, "TTc") +INSTR_0ARG(instr_tampi_create_ticket_exit, "TTC") +INSTR_0ARG(instr_tampi_wait_ticket_enter, "TTw") +INSTR_0ARG(instr_tampi_wait_ticket_exit, "TTW") + +#endif /* INSTR_TAMPI_H */ diff --git a/test/emu/tampi/ss-comm.c b/test/emu/tampi/ss-comm.c new file mode 100644 index 0000000..5ded74b --- /dev/null +++ b/test/emu/tampi/ss-comm.c @@ -0,0 +1,55 @@ +/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC) + * SPDX-License-Identifier: GPL-3.0-or-later */ + +#include +#include "compat.h" +#include "instr.h" +#include "instr_tampi.h" + +int +main(void) +{ + /* Test that simulates a communication task executing TAMPI operations */ + + const int rank = atoi(getenv("OVNI_RANK")); + const int nranks = atoi(getenv("OVNI_NRANKS")); + + instr_start(rank, nranks); + + const int ncomms = 100; + + /* Simulate multiple task-aware communications */ + for (int c = 0; c < ncomms; c++) { + instr_tampi_library_interface_enter(); + + /* Issue the non-blocking MPI operation and test it */ + instr_tampi_issue_nonblk_op_enter(); + sleep_us(100); + instr_tampi_issue_nonblk_op_exit(); + instr_tampi_test_request_enter(); + sleep_us(10); + instr_tampi_test_request_exit(); + + /* Create a ticket if it was not completed */ + if (c % 2 == 0) { + instr_tampi_create_ticket_enter(); + instr_tampi_create_ticket_exit(); + + instr_tampi_add_queues_enter(); + instr_tampi_add_queues_exit(); + + /* Wait the ticket if the operation was blocking */ + if (c % 4 == 0) { + instr_tampi_wait_ticket_enter(); + sleep_us(100); + instr_tampi_wait_ticket_exit(); + } + } + + instr_tampi_library_interface_exit(); + } + + instr_end(); + + return 0; +} diff --git a/test/emu/tampi/ss-mismatch.c b/test/emu/tampi/ss-mismatch.c new file mode 100644 index 0000000..26c6801 --- /dev/null +++ b/test/emu/tampi/ss-mismatch.c @@ -0,0 +1,23 @@ +/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC) + * SPDX-License-Identifier: GPL-3.0-or-later */ + +#include +#include "compat.h" +#include "instr.h" +#include "instr_tampi.h" + +int +main(void) +{ + /* Test that a thread ending while the subsystem still has a value in + * the stack causes the emulator to fail */ + + instr_start(0, 1); + + instr_tampi_library_interface_enter(); + /* The thread is left in the library interface state (should fail) */ + + instr_end(); + + return 0; +} diff --git a/test/emu/tampi/ss-polling.c b/test/emu/tampi/ss-polling.c new file mode 100644 index 0000000..8d1ca54 --- /dev/null +++ b/test/emu/tampi/ss-polling.c @@ -0,0 +1,69 @@ +/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC) + * SPDX-License-Identifier: GPL-3.0-or-later */ + +#include +#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); + + 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; +}