diff --git a/emu_nanos6.c b/emu_nanos6.c
index 25b55de..caa25d7 100644
--- a/emu_nanos6.c
+++ b/emu_nanos6.c
@@ -417,6 +417,23 @@ hook_pre_nanos6(struct ovni_emu *emu)
check_affinity(emu);
}
+static void
+end_lint(struct ovni_emu *emu)
+{
+ /* Ensure we run out of subsystem states */
+ for(size_t i = 0; i < emu->total_nthreads; i++)
+ {
+ struct ovni_ethread *th = emu->global_thread[i];
+ struct ovni_chan *ch = &th->chan[CHAN_NANOS6_SUBSYSTEM];
+ if(ch->n != 1)
+ {
+ int top = ch->stack[ch->n - 1];
+ die("thread %ld has left %d state(s) in the subsystem channel, top state=%d\n",
+ i, ch->n - 1, top);
+ }
+ }
+}
+
void
hook_end_nanos6(struct ovni_emu *emu)
{
@@ -437,4 +454,8 @@ hook_end_nanos6(struct ovni_emu *emu)
}
}
}
+
+ /* When running in linter mode perform additional checks */
+ if(emu->enable_linter)
+ end_lint(emu);
}
diff --git a/emu_task.c b/emu_task.c
index 8003f90..85f00d5 100644
--- a/emu_task.c
+++ b/emu_task.c
@@ -32,14 +32,14 @@ task_create(uint32_t task_id, uint32_t type_id, struct task **task_map, struct t
HASH_FIND_INT(*task_map, &task_id, task);
if(task != NULL)
- die("a task with id %u already exists\n", task_id);
+ die("cannot create a task with id %u: already exists\n", task_id);
/* Ensure the type exists */
struct task_type *type = NULL;
HASH_FIND_INT(*type_map, &type_id, type);
if(type == NULL)
- die("unknown task type id %u\n", type_id);
+ die("cannot create task: unknown type id %u\n", type_id);
task = calloc(1, sizeof(*task));
@@ -68,7 +68,7 @@ task_execute(uint32_t task_id, struct ovni_ethread *cur_thread, struct task **ta
die("cannot find task with id %u\n", task_id);
if(task->state != TASK_ST_CREATED)
- die("task state is not created\n");
+ die("cannot execute task %u: state is not created\n", task_id);
if(task->thread != NULL)
die("task already has a thread assigned\n");
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 1e7bcc6..e24cd0b 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -27,17 +27,21 @@ endif()
ovni_test(NAME flush)
ovni_test(NAME mp-simple MP)
ovni_test(NAME mp-rank MP)
+
ovni_test(NAME nosv-nested-tasks)
-ovni_test(NAME nosv-nested-tasks-bad
- SHOULD_FAIL REGEX "fatal: unknown task type id 1")
+ovni_test(NAME nosv-nested-tasks-bad SHOULD_FAIL
+ REGEX "fatal: cannot execute task 1: state is not created")
ovni_test(NAME nosv-task-types MP)
ovni_test(NAME nosv-pause MP)
ovni_test(NAME nanos6-nested-tasks)
-ovni_test(NAME nanos6-nested-tasks-bad)
+ovni_test(NAME nanos6-nested-tasks-bad SHOULD_FAIL
+ REGEX "fatal: cannot execute task 1: state is not created")
ovni_test(NAME nanos6-task-types MP)
ovni_test(NAME nanos6-blocking MP)
ovni_test(NAME nanos6-subsystems MP)
+ovni_test(NAME nanos6-ss-mismatch MP SHOULD_FAIL
+ REGEX "fatal: thread 0 has left 1 state(s) in the subsystem channel, top state=2")
if(BUILD_RT_TESTING)
add_subdirectory(rt)
diff --git a/test/common.h b/test/instr.h
similarity index 74%
rename from test/common.h
rename to test/instr.h
index 8dd274c..c0b34f6 100644
--- a/test/common.h
+++ b/test/instr.h
@@ -15,10 +15,12 @@
* along with this program. If not, see .
*/
-#ifndef OVNI_TEST_COMMON_H
-#define OVNI_TEST_COMMON_H
+#ifndef OVNI_TEST_INSTR_H
+#define OVNI_TEST_INSTR_H
-#include "../common.h"
+#define _GNU_SOURCE /* For gethostname() */
+
+#include "common.h"
#include "ovni.h"
#include
@@ -86,4 +88,39 @@ instr_thread_end(void)
ovni_flush();
}
-#endif /* OVNI_TEST_COMMON_H */
+static inline void
+instr_start(int rank, int nranks)
+{
+ char hostname[OVNI_MAX_HOSTNAME];
+ char rankname[OVNI_MAX_HOSTNAME + 64];
+
+ if(gethostname(hostname, HOST_NAME_MAX) != 0)
+ die("gethostname failed");
+
+ sprintf(rankname, "%s.%d", hostname, rank);
+
+ ovni_proc_init(1, rankname, getpid());
+ ovni_proc_set_rank(rank, nranks);
+ ovni_thread_init(gettid());
+
+ /* All ranks inform CPUs */
+ for(int i=0; i < nranks; i++)
+ ovni_add_cpu(i, i);
+
+ int curcpu = rank;
+
+ dbg("thread %d has cpu %d (ncpus=%d)\n",
+ gettid(), curcpu, nranks);
+
+ instr_thread_execute(curcpu, -1, 0);
+}
+
+static inline void
+instr_end(void)
+{
+ instr_thread_end();
+ ovni_thread_free();
+ ovni_proc_fini();
+}
+
+#endif /* OVNI_TEST_INSTR_H */
diff --git a/test/instr_nanos6.h b/test/instr_nanos6.h
new file mode 100644
index 0000000..231509e
--- /dev/null
+++ b/test/instr_nanos6.h
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2022 Barcelona Supercomputing Center (BSC)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef OVNI_TEST_INSTR_NANOS6_H
+#define OVNI_TEST_INSTR_NANOS6_H
+
+#include "test/instr.h"
+#include "compat.h"
+
+static inline void
+instr_nanos6_type_create(int32_t typeid)
+{
+ struct ovni_ev ev = {0};
+
+ ovni_ev_set_mcv(&ev, "6Yc");
+ ovni_ev_set_clock(&ev, ovni_clock_now());
+
+ char buf[256];
+ char *p = buf;
+
+ size_t nbytes = 0;
+ memcpy(buf, &typeid, sizeof(typeid));
+ p += sizeof(typeid);
+ nbytes += sizeof(typeid);
+ sprintf(p, "testtype%d", typeid);
+ nbytes += strlen(p) + 1;
+
+ ovni_ev_jumbo_emit(&ev, (uint8_t *) buf, nbytes);
+}
+
+INSTR_2ARG(instr_nanos6_task_create, "6Tc", int32_t, id, uint32_t, typeid)
+INSTR_0ARG(instr_nanos6_task_create_end, "6TC")
+INSTR_1ARG(instr_nanos6_task_execute, "6Tx", int32_t, id)
+
+static inline void
+instr_nanos6_task_create_and_execute(int32_t id, uint32_t typeid)
+{
+ instr_nanos6_task_create(id, typeid);
+ instr_nanos6_task_create_end();
+ instr_nanos6_task_execute(id);
+}
+
+INSTR_2ARG(instr_nanos6_task_block, "6Tb", int32_t, id, int32_t, reason)
+INSTR_2ARG(instr_nanos6_task_unblock, "6Tu", int32_t, id, int32_t, reason)
+
+static inline void
+instr_nanos6_block_enter(int32_t id)
+{
+ instr_nanos6_task_block(id, 0);
+}
+
+static inline void
+instr_nanos6_block_exit(int32_t id)
+{
+ instr_nanos6_task_unblock(id, 0);
+}
+
+static inline void
+instr_nanos6_task_wait_enter(int32_t id)
+{
+ instr_nanos6_task_block(id, 1);
+}
+
+static inline void
+instr_nanos6_task_wait_exit(int32_t id)
+{
+ instr_nanos6_task_unblock(id, 1);
+}
+
+static inline void
+instr_nanos6_waitfor_enter(int32_t id)
+{
+ instr_nanos6_task_block(id, 2);
+}
+
+static inline void
+instr_nanos6_waitfor_exit(int32_t id)
+{
+ instr_nanos6_task_unblock(id, 2);
+}
+
+INSTR_1ARG(instr_nanos6_task_end, "6Te", int32_t, id)
+
+INSTR_0ARG(instr_nanos6_sched_receive_task, "6Sr")
+INSTR_0ARG(instr_nanos6_sched_assign_task, "6Ss")
+INSTR_0ARG(instr_nanos6_sched_self_assign_task, "6S@")
+INSTR_0ARG(instr_nanos6_sched_hungry, "6Sh")
+INSTR_0ARG(instr_nanos6_sched_fill, "6Sf")
+INSTR_0ARG(instr_nanos6_sched_server_enter, "6S[")
+INSTR_0ARG(instr_nanos6_sched_server_exit, "6S]")
+INSTR_0ARG(instr_nanos6_sched_submit_enter, "6Su")
+INSTR_0ARG(instr_nanos6_sched_submit_exit, "6SU")
+INSTR_0ARG(instr_nanos6_enter_submit_task, "6U[")
+INSTR_0ARG(instr_nanos6_exit_submit_task, "6U]")
+INSTR_0ARG(instr_nanos6_register_accesses_enter, "6Dr")
+INSTR_0ARG(instr_nanos6_register_accesses_exit, "6DR")
+INSTR_0ARG(instr_nanos6_unregister_accesses_enter, "6Du")
+INSTR_0ARG(instr_nanos6_unregister_accesses_exit, "6DU")
+INSTR_0ARG(instr_nanos6_exit_create_task, "6TC")
+INSTR_0ARG(instr_nanos6_spawn_function_enter, "6Hs")
+INSTR_0ARG(instr_nanos6_spawn_function_exit, "6HS")
+
+#endif /* OVNI_TEST_INSTR_NANOS6_H */
diff --git a/test/instr_nosv.h b/test/instr_nosv.h
new file mode 100644
index 0000000..10fe994
--- /dev/null
+++ b/test/instr_nosv.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2022 Barcelona Supercomputing Center (BSC)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef OVNI_TEST_INSTR_NOSV_H
+#define OVNI_TEST_INSTR_NOSV_H
+
+#include "test/instr.h"
+#include "compat.h"
+
+static inline void
+instr_nosv_type_create(int32_t typeid)
+{
+ struct ovni_ev ev = {0};
+
+ ovni_ev_set_mcv(&ev, "VYc");
+ ovni_ev_set_clock(&ev, ovni_clock_now());
+
+ char buf[256];
+ char *p = buf;
+
+ size_t nbytes = 0;
+ memcpy(buf, &typeid, sizeof(typeid));
+ p += sizeof(typeid);
+ nbytes += sizeof(typeid);
+ sprintf(p, "testtype%d", typeid);
+ nbytes += strlen(p) + 1;
+
+ ovni_ev_jumbo_emit(&ev, (uint8_t *) buf, nbytes);
+}
+
+INSTR_2ARG(instr_nosv_task_create, "VTc", int32_t, id, uint32_t, typeid)
+INSTR_1ARG(instr_nosv_task_execute, "VTx", int32_t, id)
+INSTR_1ARG(instr_nosv_task_pause, "VTp", int32_t, id)
+INSTR_1ARG(instr_nosv_task_resume, "VTr", int32_t, id)
+INSTR_1ARG(instr_nosv_task_end, "VTe", int32_t, id)
+
+
+#endif /* OVNI_TEST_INSTR_NOSV_H */
diff --git a/test/nanos6-blocking.c b/test/nanos6-blocking.c
index 8bf25b4..5ca229b 100644
--- a/test/nanos6-blocking.c
+++ b/test/nanos6-blocking.c
@@ -15,10 +15,7 @@
* along with this program. If not, see .
*/
-#define _GNU_SOURCE
-
-#include "test/common.h"
-#include "test/nanos6.h"
+#include "test/instr_nanos6.h"
int
main(void)
@@ -30,18 +27,17 @@ main(void)
int us = 500;
uint32_t typeid = 1;
- type_create(typeid);
+ instr_nanos6_type_create(typeid);
- task_begin(1, typeid);
+ instr_nanos6_task_create_and_execute(1, typeid);
usleep(us);
- block_enter(1);
+ instr_nanos6_block_enter(1);
usleep(us);
- block_exit(1);
+ instr_nanos6_block_exit(1);
usleep(us);
- task_end(1);
+ instr_nanos6_task_end(1);
instr_end();
return 0;
}
-
diff --git a/test/nanos6-nested-tasks-bad.c b/test/nanos6-nested-tasks-bad.c
index 563ce78..6d814c6 100644
--- a/test/nanos6-nested-tasks-bad.c
+++ b/test/nanos6-nested-tasks-bad.c
@@ -15,23 +15,24 @@
* along with this program. If not, see .
*/
-#define _GNU_SOURCE
-
-#include "test/common.h"
-#include "test/nanos6.h"
+#include "test/instr_nanos6.h"
int
main(void)
{
instr_start(0, 1);
- /* Create two nested tasks with the same task_id: this should
- * fail */
- task_begin(1, 500);
- task_begin(1, 500);
+ uint32_t typeid = 666;
+ instr_nanos6_type_create(typeid);
+
+ uint32_t taskid = 1;
+ instr_nanos6_task_create(taskid, typeid);
+ instr_nanos6_task_create_end();
+ instr_nanos6_task_execute(taskid);
+ /* Run another nested task with same id (should fail) */
+ instr_nanos6_task_execute(taskid);
instr_end();
return 0;
}
-
diff --git a/test/nanos6-nested-tasks.c b/test/nanos6-nested-tasks.c
index 59b3bd7..9b5d13a 100644
--- a/test/nanos6-nested-tasks.c
+++ b/test/nanos6-nested-tasks.c
@@ -15,10 +15,7 @@
* along with this program. If not, see .
*/
-#define _GNU_SOURCE
-
-#include "test/common.h"
-#include "test/nanos6.h"
+#include "test/instr_nanos6.h"
int
main(void)
@@ -28,18 +25,18 @@ main(void)
int ntasks = 100;
uint32_t typeid = 1;
- type_create(typeid);
+ instr_nanos6_type_create(typeid);
/* Create and run the tasks, one nested into another */
for(int i = 0; i < ntasks; i++)
{
- task_begin(i + 1, typeid);
+ instr_nanos6_task_create_and_execute(i + 1, typeid);
usleep(500);
}
/* End the tasks in the opposite order */
for(int i = ntasks - 1; i >= 0; i--)
- task_end(i + 1);
+ instr_nanos6_task_end(i + 1);
instr_end();
diff --git a/test/nanos6-ss-mismatch.c b/test/nanos6-ss-mismatch.c
new file mode 100644
index 0000000..d10678f
--- /dev/null
+++ b/test/nanos6-ss-mismatch.c
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2022 Barcelona Supercomputing Center (BSC)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include "instr_nanos6.h"
+
+int
+main(void)
+{
+ int rank = atoi(getenv("OVNI_RANK"));
+ int nranks = atoi(getenv("OVNI_NRANKS"));
+ instr_start(rank, nranks);
+
+ instr_nanos6_sched_hungry();
+ /* The thread is left in the hungry state (should fail) */
+
+ instr_end();
+
+ return 0;
+}
diff --git a/test/nanos6-subsystems.c b/test/nanos6-subsystems.c
index d44ed39..c23bf58 100644
--- a/test/nanos6-subsystems.c
+++ b/test/nanos6-subsystems.c
@@ -15,10 +15,7 @@
* along with this program. If not, see .
*/
-#define _GNU_SOURCE
-
-#include "test/common.h"
-#include "test/nanos6.h"
+#include "instr_nanos6.h"
int
main(void)
@@ -32,58 +29,36 @@ main(void)
int32_t typeid = 1;
int32_t taskid = 1;
- type_create(typeid);
- task_begin(taskid, typeid);
+ instr_nanos6_type_create(typeid);
+ instr_nanos6_task_create_and_execute(taskid, typeid);
- sched_receive_task();
- usleep(us);
- sched_assign_task();
- usleep(us);
- sched_self_assign_task();
- usleep(us);
- sched_hungry();
- usleep(us);
- sched_fill();
- usleep(us);
- sched_server_enter();
- usleep(us);
- sched_server_exit();
- usleep(us);
- sched_submit_enter();
- usleep(us);
- sched_submit_exit();
- usleep(us);
- enter_submit_task();
- usleep(us);
- exit_submit_task();
- usleep(us);
- block_enter(taskid);
- usleep(us);
- block_exit(taskid);
- usleep(us);
- waitfor_enter(taskid);
- usleep(us);
- waitfor_exit(taskid);
- usleep(us);
- register_accesses_enter();
- usleep(us);
- register_accesses_exit();
- usleep(us);
- unregister_accesses_enter();
- usleep(us);
- unregister_accesses_exit();
- usleep(us);
- task_wait_enter(taskid);
- usleep(us);
- task_wait_exit(taskid);
- usleep(us);
- spawn_function_enter();
- usleep(us);
- spawn_function_exit();
- usleep(us);
+ instr_nanos6_sched_receive_task(); usleep(us);
+ instr_nanos6_sched_assign_task(); usleep(us);
+ instr_nanos6_sched_self_assign_task(); usleep(us);
+ instr_nanos6_sched_hungry(); usleep(us);
+ instr_nanos6_sched_fill(); usleep(us);
+ instr_nanos6_sched_server_enter(); usleep(us);
+ instr_nanos6_sched_server_exit(); usleep(us);
+ instr_nanos6_sched_submit_enter(); usleep(us);
+ instr_nanos6_sched_submit_exit(); usleep(us);
+ instr_nanos6_enter_submit_task(); usleep(us);
+ instr_nanos6_exit_submit_task(); usleep(us);
+ instr_nanos6_block_enter(taskid); usleep(us);
+ instr_nanos6_block_exit(taskid); usleep(us);
+ instr_nanos6_waitfor_enter(taskid); usleep(us);
+ instr_nanos6_waitfor_exit(taskid); usleep(us);
+ instr_nanos6_register_accesses_enter(); usleep(us);
+ instr_nanos6_register_accesses_exit(); usleep(us);
+ instr_nanos6_unregister_accesses_enter(); usleep(us);
+ instr_nanos6_unregister_accesses_exit(); usleep(us);
+ instr_nanos6_task_wait_enter(taskid); usleep(us);
+ instr_nanos6_task_wait_exit(taskid); usleep(us);
+ instr_nanos6_spawn_function_enter(); usleep(us);
+ instr_nanos6_spawn_function_exit(); usleep(us);
+
+ instr_nanos6_task_end(taskid);
instr_end();
return 0;
}
-
diff --git a/test/nanos6-task-types.c b/test/nanos6-task-types.c
index 0854ab1..918f57a 100644
--- a/test/nanos6-task-types.c
+++ b/test/nanos6-task-types.c
@@ -15,10 +15,7 @@
* along with this program. If not, see .
*/
-#define _GNU_SOURCE
-
-#include "test/common.h"
-#include "test/nanos6.h"
+#include "instr_nanos6.h"
int
main(void)
@@ -32,17 +29,16 @@ main(void)
int ntypes = 10;
for(int i = 0; i < ntypes; i++)
- type_create(i + 1);
+ instr_nanos6_type_create(i + 1);
for(int i = 0; i < ntasks; i++)
{
- task_begin(i + 1, (i % ntypes) + 1);
+ instr_nanos6_task_create_and_execute(i + 1, (i % ntypes) + 1);
usleep(500);
- task_end(i + 1);
+ instr_nanos6_task_end(i + 1);
}
instr_end();
return 0;
}
-
diff --git a/test/nanos6.h b/test/nanos6.h
deleted file mode 100644
index 69fe003..0000000
--- a/test/nanos6.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (c) 2022 Barcelona Supercomputing Center (BSC)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef OVNI_TEST_NANOS6_H
-#define OVNI_TEST_NANOS6_H
-
-#include "test/common.h"
-#include "compat.h"
-
-static inline void
-instr_start(int rank, int nranks)
-{
- char hostname[HOST_NAME_MAX];
- char rankname[HOST_NAME_MAX + 64];
-
- if(gethostname(hostname, HOST_NAME_MAX) != 0)
- die("gethostname failed");
-
- sprintf(rankname, "%s.%d", hostname, rank);
-
- ovni_proc_init(1, rankname, getpid());
- ovni_proc_set_rank(rank, nranks);
- ovni_thread_init(gettid());
-
- /* All ranks inform CPUs */
- for(int i=0; i < nranks; i++)
- ovni_add_cpu(i, i);
-
- int curcpu = rank;
-
- dbg("thread %d has cpu %d (ncpus=%d)\n",
- gettid(), curcpu, nranks);
-
- instr_thread_execute(curcpu, -1, 0);
-}
-
-static inline void
-instr_end(void)
-{
- instr_thread_end();
- ovni_thread_free();
- ovni_proc_fini();
-}
-
-static inline void
-type_create(int32_t typeid)
-{
- struct ovni_ev ev = {0};
-
- ovni_ev_set_mcv(&ev, "6Yc");
- ovni_ev_set_clock(&ev, ovni_clock_now());
-
- char buf[256];
- char *p = buf;
-
- size_t nbytes = 0;
- memcpy(buf, &typeid, sizeof(typeid));
- p += sizeof(typeid);
- nbytes += sizeof(typeid);
- sprintf(p, "testtype%d", typeid);
- nbytes += strlen(p) + 1;
-
- ovni_ev_jumbo_emit(&ev, (uint8_t *) buf, nbytes);
-}
-
-INSTR_2ARG(task_create, "6Tc", int32_t, id, uint32_t, typeid)
-INSTR_0ARG(task_create_end, "6TC")
-INSTR_1ARG(task_execute, "6Tx", int32_t, id)
-
-static inline void
-task_begin(int32_t id, uint32_t typeid)
-{
- task_create(id, typeid);
- task_create_end();
- task_execute(id);
-}
-
-INSTR_2ARG(task_block, "6Tb", int32_t, id, int32_t, reason)
-INSTR_2ARG(task_unblock, "6Tu", int32_t, id, int32_t, reason)
-
-static inline void block_enter(int32_t id)
-{
- task_block(id, 0);
-}
-
-static inline void block_exit(int32_t id)
-{
- task_unblock(id, 0);
-}
-
-static inline void task_wait_enter(int32_t id)
-{
- task_block(id, 1);
-}
-
-static inline void task_wait_exit(int32_t id)
-{
- task_unblock(id, 1);
-}
-
-static inline void waitfor_enter(int32_t id)
-{
- task_block(id, 2);
-}
-
-static inline void waitfor_exit(int32_t id)
-{
- task_unblock(id, 2);
-}
-
-INSTR_1ARG(task_end, "6Te", int32_t, id)
-
-INSTR_0ARG(sched_receive_task, "6Sr")
-INSTR_0ARG(sched_assign_task, "6Ss")
-INSTR_0ARG(sched_self_assign_task, "6S@")
-INSTR_0ARG(sched_hungry, "6Sh")
-INSTR_0ARG(sched_fill, "6Sf")
-INSTR_0ARG(sched_server_enter, "6S[")
-INSTR_0ARG(sched_server_exit, "6S]")
-INSTR_0ARG(sched_submit_enter, "6Su")
-INSTR_0ARG(sched_submit_exit, "6SU")
-INSTR_0ARG(enter_submit_task, "6U[")
-INSTR_0ARG(exit_submit_task, "6U]")
-INSTR_0ARG(register_accesses_enter, "6Dr")
-INSTR_0ARG(register_accesses_exit, "6DR")
-INSTR_0ARG(unregister_accesses_enter, "6Du")
-INSTR_0ARG(unregister_accesses_exit, "6DU")
-INSTR_0ARG(exit_create_task, "6TC")
-INSTR_0ARG(spawn_function_enter, "6Hs")
-INSTR_0ARG(spawn_function_exit, "6HS")
-
-#endif /* OVNI_TEST_NANOS6_H */
diff --git a/test/nosv-nested-tasks-bad.c b/test/nosv-nested-tasks-bad.c
index c507d15..ba95b58 100644
--- a/test/nosv-nested-tasks-bad.c
+++ b/test/nosv-nested-tasks-bad.c
@@ -15,136 +15,23 @@
* along with this program. If not, see .
*/
-#define _GNU_SOURCE
-
-#include "ovni.h"
-#include "compat.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-static void
-fail(const char *msg)
-{
- fprintf(stderr, "%s\n", msg);
- abort();
-}
-
-static inline void
-emit_ev(char *mcv)
-{
- struct ovni_ev ev = { 0 };
-
- ovni_ev_set_mcv(&ev, mcv);
- ovni_ev_set_clock(&ev, ovni_clock_now());
- ovni_ev_emit(&ev);
-}
-
-#define INSTR_3ARG(name, mcv, ta, a, tb, b, tc, c) \
- static inline void name(ta a, tb b, tc c) \
- { \
- struct ovni_ev ev = {0}; \
- ovni_ev_set_mcv(&ev, mcv); \
- ovni_ev_set_clock(&ev, ovni_clock_now()); \
- ovni_payload_add(&ev, (uint8_t *)&a, sizeof(a)); \
- ovni_payload_add(&ev, (uint8_t *)&b, sizeof(b)); \
- ovni_payload_add(&ev, (uint8_t *)&c, sizeof(c)); \
- ovni_ev_emit(&ev); \
- }
-
-INSTR_3ARG(instr_thread_execute, "OHx", int32_t, cpu, int32_t, creator_tid, uint64_t, tag)
-
-static inline void
-instr_thread_end(void)
-{
- struct ovni_ev ev = {0};
-
- ovni_ev_set_mcv(&ev, "OHe");
- ovni_ev_set_clock(&ev, ovni_clock_now());
- ovni_ev_emit(&ev);
-
- /* Flush the events to disk before killing the thread */
- ovni_flush();
-}
-
-static inline void
-instr_start(int rank, int nranks)
-{
- char hostname[HOST_NAME_MAX];
-
- if(gethostname(hostname, HOST_NAME_MAX) != 0)
- fail("gethostname failed");
-
- ovni_proc_init(1, hostname, getpid());
-
- ovni_proc_set_rank(rank, nranks);
-
- ovni_thread_init(gettid());
-
- /* Only the rank 0 inform about all CPUs */
- if(rank == 0)
- {
- /* Fake nranks cpus */
- for(int i=0; i < nranks; i++)
- ovni_add_cpu(i, i);
- }
-
- int curcpu = rank;
-
- fprintf(stderr, "thread %d has cpu %d (ncpus=%d)\n",
- gettid(), curcpu, nranks);
-
- instr_thread_execute(curcpu, -1, 0);
-}
-
-static inline void
-instr_end(void)
-{
- instr_thread_end();
- ovni_thread_free();
- ovni_proc_fini();
-}
-
-static void
-task_begin(int32_t id, int us)
-{
- int32_t typeid = 1;
- struct ovni_ev ev = {0};
-
- ovni_ev_set_mcv(&ev, "VTc");
- ovni_ev_set_clock(&ev, ovni_clock_now());
- ovni_payload_add(&ev, (uint8_t *) &id, sizeof(id));
- ovni_payload_add(&ev, (uint8_t *) &typeid, sizeof(id));
- ovni_ev_emit(&ev);
-
- memset(&ev, 0, sizeof(ev));
-
- ovni_ev_set_mcv(&ev, "VTx");
- ovni_ev_set_clock(&ev, ovni_clock_now());
- ovni_payload_add(&ev, (uint8_t *) &id, sizeof(id));
- ovni_ev_emit(&ev);
-
- usleep(us);
-}
+#include "instr_nosv.h"
int
main(void)
{
instr_start(0, 1);
- /* Create two nested tasks with the same task_id: this should
- * fail */
- task_begin(1, 500);
- task_begin(1, 500);
+ uint32_t typeid = 666;
+ instr_nosv_type_create(typeid);
+
+ uint32_t taskid = 1;
+ instr_nosv_task_create(taskid, typeid);
+ instr_nosv_task_execute(taskid);
+ /* Run another nested task with same id (should fail) */
+ instr_nosv_task_execute(taskid);
instr_end();
return 0;
}
-
diff --git a/test/nosv-nested-tasks.c b/test/nosv-nested-tasks.c
index 6f7a79d..8927839 100644
--- a/test/nosv-nested-tasks.c
+++ b/test/nosv-nested-tasks.c
@@ -15,155 +15,16 @@
* along with this program. If not, see .
*/
-#define _GNU_SOURCE
-
-#include "ovni.h"
-#include "compat.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
+#include "instr_nosv.h"
static void
-fail(const char *msg)
+create_and_run(int32_t id, uint32_t typeid, int us)
{
- fprintf(stderr, "%s\n", msg);
- abort();
-}
-
-static inline void
-emit_ev(char *mcv)
-{
- struct ovni_ev ev = { 0 };
-
- ovni_ev_set_mcv(&ev, mcv);
- ovni_ev_set_clock(&ev, ovni_clock_now());
- ovni_ev_emit(&ev);
-}
-
-#define INSTR_3ARG(name, mcv, ta, a, tb, b, tc, c) \
- static inline void name(ta a, tb b, tc c) \
- { \
- struct ovni_ev ev = {0}; \
- ovni_ev_set_mcv(&ev, mcv); \
- ovni_ev_set_clock(&ev, ovni_clock_now()); \
- ovni_payload_add(&ev, (uint8_t *)&a, sizeof(a)); \
- ovni_payload_add(&ev, (uint8_t *)&b, sizeof(b)); \
- ovni_payload_add(&ev, (uint8_t *)&c, sizeof(c)); \
- ovni_ev_emit(&ev); \
- }
-
-INSTR_3ARG(instr_thread_execute, "OHx", int32_t, cpu, int32_t, creator_tid, uint64_t, tag)
-
-static inline void
-instr_thread_end(void)
-{
- struct ovni_ev ev = {0};
-
- ovni_ev_set_mcv(&ev, "OHe");
- ovni_ev_set_clock(&ev, ovni_clock_now());
- ovni_ev_emit(&ev);
-
- /* Flush the events to disk before killing the thread */
- ovni_flush();
-}
-
-static inline void
-instr_start(int rank, int nranks)
-{
- char hostname[HOST_NAME_MAX];
-
- if(gethostname(hostname, HOST_NAME_MAX) != 0)
- fail("gethostname failed");
-
- ovni_proc_init(1, hostname, getpid());
-
- ovni_proc_set_rank(rank, nranks);
-
- ovni_thread_init(gettid());
-
- /* Only the rank 0 inform about all CPUs */
- if(rank == 0)
- {
- /* Fake nranks cpus */
- for(int i=0; i < nranks; i++)
- ovni_add_cpu(i, i);
- }
-
- int curcpu = rank;
-
- fprintf(stderr, "thread %d has cpu %d (ncpus=%d)\n",
- gettid(), curcpu, nranks);
-
- instr_thread_execute(curcpu, -1, 0);
-}
-
-static inline void
-instr_end(void)
-{
- instr_thread_end();
- ovni_thread_free();
- ovni_proc_fini();
-}
-
-static void
-type_create(int32_t typeid)
-{
- struct ovni_ev ev = {0};
-
- ovni_ev_set_mcv(&ev, "VYc");
- ovni_ev_set_clock(&ev, ovni_clock_now());
-
- char buf[256];
- char *p = buf;
-
- size_t nbytes = 0;
- memcpy(buf, &typeid, sizeof(typeid));
- p += sizeof(typeid);
- nbytes += sizeof(typeid);
- sprintf(p, "testtype%d", typeid);
- nbytes += strlen(p) + 1;
-
- ovni_ev_jumbo_emit(&ev, (uint8_t *) buf, nbytes);
-}
-
-static void
-task_begin(int32_t id, uint32_t typeid, int us)
-{
- struct ovni_ev ev = {0};
-
- ovni_ev_set_mcv(&ev, "VTc");
- ovni_ev_set_clock(&ev, ovni_clock_now());
- ovni_payload_add(&ev, (uint8_t *) &id, sizeof(id));
- ovni_payload_add(&ev, (uint8_t *) &typeid, sizeof(id));
- ovni_ev_emit(&ev);
-
- memset(&ev, 0, sizeof(ev));
-
- ovni_ev_set_mcv(&ev, "VTx");
- ovni_ev_set_clock(&ev, ovni_clock_now());
- ovni_payload_add(&ev, (uint8_t *) &id, sizeof(id));
- ovni_ev_emit(&ev);
-
+ instr_nosv_task_create(id, typeid);
+ instr_nosv_task_execute(id);
usleep(us);
}
-static void
-task_end(int32_t id)
-{
- struct ovni_ev ev = {0};
-
- ovni_ev_set_mcv(&ev, "VTe");
- ovni_ev_set_clock(&ev, ovni_clock_now());
- ovni_payload_add(&ev, (uint8_t *) &id, sizeof(id));
- ovni_ev_emit(&ev);
-}
-
int
main(void)
{
@@ -172,15 +33,15 @@ main(void)
int ntasks = 100;
uint32_t typeid = 1;
- type_create(typeid);
+ instr_nosv_type_create(typeid);
/* Create and run the tasks, one nested into another */
for(int i = 0; i < ntasks; i++)
- task_begin(i + 1, typeid, 500);
+ create_and_run(i + 1, typeid, 500);
/* End the tasks in the opposite order */
for(int i = ntasks - 1; i >= 0; i--)
- task_end(i + 1);
+ instr_nosv_task_end(i + 1);
instr_end();
diff --git a/test/nosv-pause.c b/test/nosv-pause.c
index e6631c2..70dd730 100644
--- a/test/nosv-pause.c
+++ b/test/nosv-pause.c
@@ -15,174 +15,7 @@
* along with this program. If not, see .
*/
-#define _GNU_SOURCE
-
-#include "ovni.h"
-#include "compat.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-static void
-fail(const char *msg)
-{
- fprintf(stderr, "%s\n", msg);
- abort();
-}
-
-static inline void
-emit_ev(char *mcv)
-{
- struct ovni_ev ev = { 0 };
-
- ovni_ev_set_mcv(&ev, mcv);
- ovni_ev_set_clock(&ev, ovni_clock_now());
- ovni_ev_emit(&ev);
-}
-
-#define INSTR_3ARG(name, mcv, ta, a, tb, b, tc, c) \
- static inline void name(ta a, tb b, tc c) \
- { \
- struct ovni_ev ev = {0}; \
- ovni_ev_set_mcv(&ev, mcv); \
- ovni_ev_set_clock(&ev, ovni_clock_now()); \
- ovni_payload_add(&ev, (uint8_t *)&a, sizeof(a)); \
- ovni_payload_add(&ev, (uint8_t *)&b, sizeof(b)); \
- ovni_payload_add(&ev, (uint8_t *)&c, sizeof(c)); \
- ovni_ev_emit(&ev); \
- }
-
-INSTR_3ARG(instr_thread_execute, "OHx", int32_t, cpu, int32_t, creator_tid, uint64_t, tag)
-
-static inline void
-instr_thread_end(void)
-{
- struct ovni_ev ev = {0};
-
- ovni_ev_set_mcv(&ev, "OHe");
- ovni_ev_set_clock(&ev, ovni_clock_now());
- ovni_ev_emit(&ev);
-
- /* Flush the events to disk before killing the thread */
- ovni_flush();
-}
-
-static inline void
-instr_start(int rank, int nranks)
-{
- char hostname[HOST_NAME_MAX];
-
- if(gethostname(hostname, HOST_NAME_MAX) != 0)
- fail("gethostname failed");
-
- ovni_proc_init(1, hostname, getpid());
-
- ovni_proc_set_rank(rank, nranks);
-
- ovni_thread_init(gettid());
-
- /* Only the rank 0 inform about all CPUs */
- if(rank == 0)
- {
- /* Fake nranks cpus */
- for(int i=0; i < nranks; i++)
- ovni_add_cpu(i, i);
- }
-
- int curcpu = rank;
-
- fprintf(stderr, "thread %d has cpu %d (ncpus=%d)\n",
- gettid(), curcpu, nranks);
-
- instr_thread_execute(curcpu, -1, 0);
-}
-
-static inline void
-instr_end(void)
-{
- instr_thread_end();
- ovni_thread_free();
- ovni_proc_fini();
-}
-
-static void
-type_create(int32_t typeid)
-{
- struct ovni_ev ev = {0};
-
- ovni_ev_set_mcv(&ev, "VYc");
- ovni_ev_set_clock(&ev, ovni_clock_now());
-
- char buf[256];
- char *p = buf;
-
- size_t nbytes = 0;
- memcpy(buf, &typeid, sizeof(typeid));
- p += sizeof(typeid);
- nbytes += sizeof(typeid);
- sprintf(p, "testtype%d", typeid);
- nbytes += strlen(p) + 1;
-
- ovni_ev_jumbo_emit(&ev, (uint8_t *) buf, nbytes);
-}
-
-static void
-task_begin(int32_t id, uint32_t typeid)
-{
- struct ovni_ev ev = {0};
-
- ovni_ev_set_mcv(&ev, "VTc");
- ovni_ev_set_clock(&ev, ovni_clock_now());
- ovni_payload_add(&ev, (uint8_t *) &id, sizeof(id));
- ovni_payload_add(&ev, (uint8_t *) &typeid, sizeof(id));
- ovni_ev_emit(&ev);
-
- memset(&ev, 0, sizeof(ev));
-
- ovni_ev_set_mcv(&ev, "VTx");
- ovni_ev_set_clock(&ev, ovni_clock_now());
- ovni_payload_add(&ev, (uint8_t *) &id, sizeof(id));
- ovni_ev_emit(&ev);
-}
-
-static void
-task_pause(int32_t id)
-{
- struct ovni_ev ev = {0};
-
- ovni_ev_set_mcv(&ev, "VTp");
- ovni_ev_set_clock(&ev, ovni_clock_now());
- ovni_payload_add(&ev, (uint8_t *) &id, sizeof(id));
- ovni_ev_emit(&ev);
-}
-
-static void
-task_resume(int32_t id)
-{
- struct ovni_ev ev = {0};
-
- ovni_ev_set_mcv(&ev, "VTr");
- ovni_ev_set_clock(&ev, ovni_clock_now());
- ovni_payload_add(&ev, (uint8_t *) &id, sizeof(id));
- ovni_ev_emit(&ev);
-}
-
-static void
-task_end(int32_t id)
-{
- struct ovni_ev ev = {0};
-
- ovni_ev_set_mcv(&ev, "VTe");
- ovni_ev_set_clock(&ev, ovni_clock_now());
- ovni_payload_add(&ev, (uint8_t *) &id, sizeof(id));
- ovni_ev_emit(&ev);
-}
+#include "instr_nosv.h"
int
main(void)
@@ -194,15 +27,15 @@ main(void)
int us = 500;
uint32_t typeid = 1;
- type_create(typeid);
-
- task_begin(1, typeid);
+ instr_nosv_type_create(typeid);
+ instr_nosv_task_create(1, typeid);
+ instr_nosv_task_execute(1);
usleep(us);
- task_pause(1);
+ instr_nosv_task_pause(1);
usleep(us);
- task_resume(1);
+ instr_nosv_task_resume(1);
usleep(us);
- task_end(1);
+ instr_nosv_task_end(1);
instr_end();
diff --git a/test/nosv-task-types.c b/test/nosv-task-types.c
index e910250..1ca7165 100644
--- a/test/nosv-task-types.c
+++ b/test/nosv-task-types.c
@@ -15,154 +15,7 @@
* along with this program. If not, see .
*/
-#define _GNU_SOURCE
-
-#include "ovni.h"
-#include "compat.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-static void
-fail(const char *msg)
-{
- fprintf(stderr, "%s\n", msg);
- abort();
-}
-
-static inline void
-emit_ev(char *mcv)
-{
- struct ovni_ev ev = { 0 };
-
- ovni_ev_set_mcv(&ev, mcv);
- ovni_ev_set_clock(&ev, ovni_clock_now());
- ovni_ev_emit(&ev);
-}
-
-#define INSTR_3ARG(name, mcv, ta, a, tb, b, tc, c) \
- static inline void name(ta a, tb b, tc c) \
- { \
- struct ovni_ev ev = {0}; \
- ovni_ev_set_mcv(&ev, mcv); \
- ovni_ev_set_clock(&ev, ovni_clock_now()); \
- ovni_payload_add(&ev, (uint8_t *)&a, sizeof(a)); \
- ovni_payload_add(&ev, (uint8_t *)&b, sizeof(b)); \
- ovni_payload_add(&ev, (uint8_t *)&c, sizeof(c)); \
- ovni_ev_emit(&ev); \
- }
-
-INSTR_3ARG(instr_thread_execute, "OHx", int32_t, cpu, int32_t, creator_tid, uint64_t, tag)
-
-static inline void
-instr_thread_end(void)
-{
- struct ovni_ev ev = {0};
-
- ovni_ev_set_mcv(&ev, "OHe");
- ovni_ev_set_clock(&ev, ovni_clock_now());
- ovni_ev_emit(&ev);
-
- /* Flush the events to disk before killing the thread */
- ovni_flush();
-}
-
-static inline void
-instr_start(int rank, int nranks)
-{
- char hostname[HOST_NAME_MAX];
-
- if(gethostname(hostname, HOST_NAME_MAX) != 0)
- fail("gethostname failed");
-
- ovni_proc_init(1, hostname, getpid());
-
- ovni_proc_set_rank(rank, nranks);
-
- ovni_thread_init(gettid());
-
- /* Only the rank 0 inform about all CPUs */
- if(rank == 0)
- {
- /* Fake nranks cpus */
- for(int i=0; i < nranks; i++)
- ovni_add_cpu(i, i);
- }
-
- int curcpu = rank;
-
- fprintf(stderr, "thread %d has cpu %d (ncpus=%d)\n",
- gettid(), curcpu, nranks);
-
- instr_thread_execute(curcpu, -1, 0);
-}
-
-static inline void
-instr_end(void)
-{
- instr_thread_end();
- ovni_thread_free();
- ovni_proc_fini();
-}
-
-static void
-type_create(int32_t typeid)
-{
- struct ovni_ev ev = {0};
-
- ovni_ev_set_mcv(&ev, "VYc");
- ovni_ev_set_clock(&ev, ovni_clock_now());
-
- char buf[256];
- char *p = buf;
-
- size_t nbytes = 0;
- memcpy(buf, &typeid, sizeof(typeid));
- p += sizeof(typeid);
- nbytes += sizeof(typeid);
- sprintf(p, "testtype%d", typeid);
- nbytes += strlen(p) + 1;
-
- ovni_ev_jumbo_emit(&ev, (uint8_t *) buf, nbytes);
-}
-
-static void
-task_begin(int32_t id, int32_t typeid, int us)
-{
- struct ovni_ev ev = {0};
-
- ovni_ev_set_mcv(&ev, "VTc");
- ovni_ev_set_clock(&ev, ovni_clock_now());
- ovni_payload_add(&ev, (uint8_t *) &id, sizeof(id));
- ovni_payload_add(&ev, (uint8_t *) &typeid, sizeof(typeid));
- ovni_ev_emit(&ev);
-
- memset(&ev, 0, sizeof(ev));
-
- ovni_ev_set_mcv(&ev, "VTx");
- ovni_ev_set_clock(&ev, ovni_clock_now());
- ovni_payload_add(&ev, (uint8_t *) &id, sizeof(id));
- ovni_ev_emit(&ev);
-
- usleep(us);
-}
-
-static void
-task_end(int32_t id)
-{
- struct ovni_ev ev = {0};
-
- ovni_ev_set_mcv(&ev, "VTe");
- ovni_ev_set_clock(&ev, ovni_clock_now());
- ovni_payload_add(&ev, (uint8_t *) &id, sizeof(id));
- ovni_ev_emit(&ev);
-}
+#include "instr_nosv.h"
int
main(void)
@@ -176,12 +29,14 @@ main(void)
int ntypes = 10;
for(int i=0; i