Add nosv barrier API event
This commit is contained in:
parent
aaa7769448
commit
eb1fc0f7da
@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- The nOS-V model version is bumped to 2.1.0.
|
- The nOS-V model version is bumped to 2.1.0.
|
||||||
- Add support for `nosv_mutex_lock`, `nosv_mutex_trylock` and
|
- Add support for `nosv_mutex_lock`, `nosv_mutex_trylock` and
|
||||||
`nosv_mutex_unlock` events VA{lLtTuU}.
|
`nosv_mutex_unlock` events VA{lLtTuU}.
|
||||||
|
- Add support for the `nosv_barrier_event` event VA{bB}.
|
||||||
|
|
||||||
## [1.8.0] - 2024-03-18
|
## [1.8.0] - 2024-03-18
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ window_comm_lines_enabled true
|
|||||||
window_flags_enabled false
|
window_flags_enabled false
|
||||||
window_noncolor_mode true
|
window_noncolor_mode true
|
||||||
window_custom_color_enabled true
|
window_custom_color_enabled true
|
||||||
window_custom_color_palette {6.000000000000:94,0,0},{7.000000000000:153,114,0},{9.000000000000:124,213,228},{10.000000000000:242,239,141},{11.000000000000:0,70,0},{19.000000000000:195,96,151},{20.000000000000:255,162,255},{21.000000000000:203,255,3},{22.000000000000:7,255,12},{23.000000000000:21,224,189},{25.000000000000:0,99,162}
|
window_custom_color_palette {6.000000000000:94,0,0},{7.000000000000:153,114,0},{9.000000000000:124,213,228},{10.000000000000:242,239,141},{11.000000000000:0,70,0},{19.000000000000:195,96,151},{20.000000000000:255,162,255},{21.000000000000:203,255,3},{22.000000000000:7,255,12},{23.000000000000:21,224,189},{24.000000000000:255,103,0},{25.000000000000:0,99,162}
|
||||||
window_logical_filtered true
|
window_logical_filtered true
|
||||||
window_physical_filtered false
|
window_physical_filtered false
|
||||||
window_comm_fromto true
|
window_comm_fromto true
|
||||||
|
@ -17,7 +17,7 @@ window_comm_lines_enabled true
|
|||||||
window_flags_enabled false
|
window_flags_enabled false
|
||||||
window_noncolor_mode true
|
window_noncolor_mode true
|
||||||
window_custom_color_enabled true
|
window_custom_color_enabled true
|
||||||
window_custom_color_palette {6.000000000000:94,0,0},{7.000000000000:153,114,0},{9.000000000000:124,213,228},{10.000000000000:242,239,141},{11.000000000000:0,70,0},{19.000000000000:195,96,151},{20.000000000000:255,162,255},{21.000000000000:203,255,3},{22.000000000000:7,255,12},{23.000000000000:21,224,189},{25.000000000000:0,99,162}
|
window_custom_color_palette {6.000000000000:94,0,0},{7.000000000000:153,114,0},{9.000000000000:124,213,228},{10.000000000000:242,239,141},{11.000000000000:0,70,0},{19.000000000000:195,96,151},{20.000000000000:255,162,255},{21.000000000000:203,255,3},{22.000000000000:7,255,12},{23.000000000000:21,224,189},{24.000000000000:255,103,0},{25.000000000000:0,99,162}
|
||||||
window_logical_filtered true
|
window_logical_filtered true
|
||||||
window_physical_filtered false
|
window_physical_filtered false
|
||||||
window_comm_fromto true
|
window_comm_fromto true
|
||||||
|
@ -705,6 +705,10 @@ List of events for the model *nosv* with identifier **`V`** at version `2.1.0`:
|
|||||||
<dd>enters nosv_mutex_unlock()</dd>
|
<dd>enters nosv_mutex_unlock()</dd>
|
||||||
<dt><a id="VAU" href="#VAU"><pre>VAU</pre></a></dt>
|
<dt><a id="VAU" href="#VAU"><pre>VAU</pre></a></dt>
|
||||||
<dd>leaves nosv_mutex_unlock()</dd>
|
<dd>leaves nosv_mutex_unlock()</dd>
|
||||||
|
<dt><a id="VAb" href="#VAb"><pre>VAb</pre></a></dt>
|
||||||
|
<dd>enters nosv_barrier_wait()</dd>
|
||||||
|
<dt><a id="VAB" href="#VAB"><pre>VAB</pre></a></dt>
|
||||||
|
<dd>leaves nosv_barrier_wait()</dd>
|
||||||
<dt><a id="VHa" href="#VHa"><pre>VHa</pre></a></dt>
|
<dt><a id="VHa" href="#VHa"><pre>VHa</pre></a></dt>
|
||||||
<dd>enters nosv_attach()</dd>
|
<dd>enters nosv_attach()</dd>
|
||||||
<dt><a id="VHA" href="#VHA"><pre>VHA</pre></a></dt>
|
<dt><a id="VHA" href="#VHA"><pre>VHA</pre></a></dt>
|
||||||
|
@ -41,6 +41,7 @@ Track changes in emulator model versions.
|
|||||||
|
|
||||||
- nosv 2.1.0
|
- nosv 2.1.0
|
||||||
- Add support for `nosv_mutex_lock`, `nosv_mutex_trylock` and `nosv_mutex_unlock` events VA{lLtTuU}.
|
- Add support for `nosv_mutex_lock`, `nosv_mutex_trylock` and `nosv_mutex_unlock` events VA{lLtTuU}.
|
||||||
|
- Add support for `nosv_barrier_wait` event VA{bB}.
|
||||||
- nosv 2.0.0
|
- nosv 2.0.0
|
||||||
- Add support for parallel tasks, adding a new `bodyid` argument in `VT*` events.
|
- Add support for parallel tasks, adding a new `bodyid` argument in `VT*` events.
|
||||||
- Remove support for old attach events `VH{aA}`.
|
- Remove support for old attach events `VH{aA}`.
|
||||||
|
@ -65,6 +65,8 @@ static const int ss_table[256][256][3] = {
|
|||||||
['T'] = { CHSS, POP, ST_API_MUTEX_TRYLOCK },
|
['T'] = { CHSS, POP, ST_API_MUTEX_TRYLOCK },
|
||||||
['u'] = { CHSS, PUSH, ST_API_MUTEX_UNLOCK },
|
['u'] = { CHSS, PUSH, ST_API_MUTEX_UNLOCK },
|
||||||
['U'] = { CHSS, POP, ST_API_MUTEX_UNLOCK },
|
['U'] = { CHSS, POP, ST_API_MUTEX_UNLOCK },
|
||||||
|
['b'] = { CHSS, PUSH, ST_API_BARRIER_WAIT },
|
||||||
|
['B'] = { CHSS, POP, ST_API_BARRIER_WAIT },
|
||||||
},
|
},
|
||||||
/* FIXME: Move thread type to another channel, like nanos6 */
|
/* FIXME: Move thread type to another channel, like nanos6 */
|
||||||
['H'] = {
|
['H'] = {
|
||||||
|
@ -40,6 +40,7 @@ enum nosv_ss_values {
|
|||||||
ST_API_MUTEX_LOCK,
|
ST_API_MUTEX_LOCK,
|
||||||
ST_API_MUTEX_TRYLOCK,
|
ST_API_MUTEX_TRYLOCK,
|
||||||
ST_API_MUTEX_UNLOCK,
|
ST_API_MUTEX_UNLOCK,
|
||||||
|
ST_API_BARRIER_WAIT,
|
||||||
ST_WORKER,
|
ST_WORKER,
|
||||||
ST_DELEGATE,
|
ST_DELEGATE,
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ static struct ev_decl model_evlist[] = {
|
|||||||
PAIR_E("VAl", "VAL", "nosv_mutex_lock()")
|
PAIR_E("VAl", "VAL", "nosv_mutex_lock()")
|
||||||
PAIR_E("VAt", "VAT", "nosv_mutex_trylock()")
|
PAIR_E("VAt", "VAT", "nosv_mutex_trylock()")
|
||||||
PAIR_E("VAu", "VAU", "nosv_mutex_unlock()")
|
PAIR_E("VAu", "VAU", "nosv_mutex_unlock()")
|
||||||
|
PAIR_E("VAb", "VAB", "nosv_barrier_wait()")
|
||||||
|
|
||||||
/* FIXME: VHA and VHa are not subsystems */
|
/* FIXME: VHA and VHa are not subsystems */
|
||||||
{ "VHa", "enters nosv_attach()" },
|
{ "VHa", "enters nosv_attach()" },
|
||||||
@ -150,6 +151,7 @@ static const struct pcf_value_label nosv_ss_values[] = {
|
|||||||
{ ST_API_MUTEX_LOCK, "API: Mutex lock" },
|
{ ST_API_MUTEX_LOCK, "API: Mutex lock" },
|
||||||
{ ST_API_MUTEX_TRYLOCK,"API: Mutex trylock" },
|
{ ST_API_MUTEX_TRYLOCK,"API: Mutex trylock" },
|
||||||
{ ST_API_MUTEX_UNLOCK, "API: Mutex unlock" },
|
{ ST_API_MUTEX_UNLOCK, "API: Mutex unlock" },
|
||||||
|
{ ST_API_BARRIER_WAIT, "API: Barrier wait" },
|
||||||
{ ST_WORKER, "Thread: Worker" },
|
{ ST_WORKER, "Thread: Worker" },
|
||||||
{ ST_DELEGATE, "Thread: Delegate" },
|
{ ST_DELEGATE, "Thread: Delegate" },
|
||||||
{ EV_SCHED_SEND, "EV Scheduler: Send task" },
|
{ EV_SCHED_SEND, "EV Scheduler: Send task" },
|
||||||
|
@ -21,6 +21,7 @@ test_emu(require-missing.c
|
|||||||
test_emu(parallel-tasks.c)
|
test_emu(parallel-tasks.c)
|
||||||
test_emu(nest-to-parallel.c)
|
test_emu(nest-to-parallel.c)
|
||||||
test_emu(mutex.c)
|
test_emu(mutex.c)
|
||||||
|
test_emu(barrier.c)
|
||||||
|
|
||||||
test_emu(bad-nest-same-task.c SHOULD_FAIL
|
test_emu(bad-nest-same-task.c SHOULD_FAIL
|
||||||
REGEX "body_execute: refusing to run body(id=1,taskid=1) in Paused state, needs to resume intead")
|
REGEX "body_execute: refusing to run body(id=1,taskid=1) in Paused state, needs to resume intead")
|
||||||
|
24
test/emu/nosv/barrier.c
Normal file
24
test/emu/nosv/barrier.c
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/* Copyright (c) 2024 Barcelona Supercomputing Center (BSC)
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||||
|
|
||||||
|
#include "compat.h"
|
||||||
|
#include "instr.h"
|
||||||
|
#include "instr_nosv.h"
|
||||||
|
|
||||||
|
/* Test the nosv_barrier_wait() API events, introduced in the nOS-V model 2.1.0 */
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
instr_start(0, 1);
|
||||||
|
instr_nosv_init();
|
||||||
|
|
||||||
|
instr_nosv_barrier_wait_enter();
|
||||||
|
sleep_us(100);
|
||||||
|
instr_nosv_barrier_wait_exit();
|
||||||
|
|
||||||
|
instr_end();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -50,6 +50,8 @@ INSTR_0ARG(instr_nosv_attach_enter, "VAa")
|
|||||||
INSTR_0ARG(instr_nosv_attach_exit, "VAA")
|
INSTR_0ARG(instr_nosv_attach_exit, "VAA")
|
||||||
INSTR_0ARG(instr_nosv_detach_enter, "VAe")
|
INSTR_0ARG(instr_nosv_detach_enter, "VAe")
|
||||||
INSTR_0ARG(instr_nosv_detach_exit, "VAE")
|
INSTR_0ARG(instr_nosv_detach_exit, "VAE")
|
||||||
|
INSTR_0ARG(instr_nosv_barrier_wait_enter, "VAb")
|
||||||
|
INSTR_0ARG(instr_nosv_barrier_wait_exit, "VAB")
|
||||||
INSTR_0ARG(instr_nosv_mutex_lock_enter, "VAl")
|
INSTR_0ARG(instr_nosv_mutex_lock_enter, "VAl")
|
||||||
INSTR_0ARG(instr_nosv_mutex_lock_exit, "VAL")
|
INSTR_0ARG(instr_nosv_mutex_lock_exit, "VAL")
|
||||||
INSTR_0ARG(instr_nosv_mutex_trylock_enter, "VAt")
|
INSTR_0ARG(instr_nosv_mutex_trylock_enter, "VAt")
|
||||||
|
@ -43,6 +43,7 @@ nosv_test(init-nested.c SORT)
|
|||||||
nosv_test(parallel-tasks.c SORT)
|
nosv_test(parallel-tasks.c SORT)
|
||||||
nosv_test(inline.c SORT)
|
nosv_test(inline.c SORT)
|
||||||
nosv_test(mutex.c SORT)
|
nosv_test(mutex.c SORT)
|
||||||
|
nosv_test(barrier.c SORT)
|
||||||
|
|
||||||
# Test multiple instrumentation levels
|
# Test multiple instrumentation levels
|
||||||
nosv_test(several-tasks.c SORT NAME several-tasks-level-0 LEVEL 0)
|
nosv_test(several-tasks.c SORT NAME several-tasks-level-0 LEVEL 0)
|
||||||
|
66
test/rt/nosv/barrier.c
Normal file
66
test/rt/nosv/barrier.c
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/* Copyright (c) 2024 Barcelona Supercomputing Center (BSC)
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
|
|
||||||
|
#include <nosv.h>
|
||||||
|
#include <nosv/affinity.h>
|
||||||
|
#include <stdatomic.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
#include "compat.h"
|
||||||
|
|
||||||
|
#define NTASKS 200
|
||||||
|
atomic_int ncompleted = 0;
|
||||||
|
|
||||||
|
nosv_task_t tasks[NTASKS];
|
||||||
|
nosv_barrier_t barrier;
|
||||||
|
|
||||||
|
static void
|
||||||
|
task_body(nosv_task_t task)
|
||||||
|
{
|
||||||
|
UNUSED(task);
|
||||||
|
if (nosv_barrier_wait(barrier) != 0)
|
||||||
|
die("nosv_barrier_wait failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
task_done(nosv_task_t task)
|
||||||
|
{
|
||||||
|
UNUSED(task);
|
||||||
|
atomic_fetch_add(&ncompleted, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
nosv_init();
|
||||||
|
|
||||||
|
nosv_task_type_t task_type;
|
||||||
|
nosv_type_init(&task_type, task_body, NULL, task_done, "task", NULL, NULL, 0);
|
||||||
|
|
||||||
|
if (nosv_barrier_init(&barrier, NOSV_BARRIER_NONE, NTASKS) != 0)
|
||||||
|
die("nosv_barrier_init failed");
|
||||||
|
|
||||||
|
for (int i = 0; i < NTASKS; i++)
|
||||||
|
nosv_create(&tasks[i], task_type, 0, 0);
|
||||||
|
|
||||||
|
for (int i = 0; i < NTASKS; i++)
|
||||||
|
nosv_submit(tasks[i], 0);
|
||||||
|
|
||||||
|
while (atomic_load(&ncompleted) != NTASKS)
|
||||||
|
sleep_us(1000);
|
||||||
|
|
||||||
|
for (int i = 0; i < NTASKS; i++)
|
||||||
|
nosv_destroy(tasks[i], 0);
|
||||||
|
|
||||||
|
if (nosv_barrier_destroy(barrier) != 0)
|
||||||
|
die("nosv_barrier_destroy failed");
|
||||||
|
|
||||||
|
nosv_type_destroy(task_type, 0);
|
||||||
|
|
||||||
|
nosv_shutdown();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user