From c803a7566f25b6c636cab05214e04d85e2355485 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Thu, 20 Jun 2024 11:32:20 +0200 Subject: [PATCH] Prevent zero values in the mark API These values cannot be differentiated from a null value, due to a Paraver limitation. --- doc/user/runtime/mark.md | 8 +++++++- src/emu/ovni/mark.c | 5 +++++ src/rt/ovni.c | 9 +++++++++ test/emu/ovni/libovni-mark.c | 8 +++----- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/doc/user/runtime/mark.md b/doc/user/runtime/mark.md index e595864..8018acc 100644 --- a/doc/user/runtime/mark.md +++ b/doc/user/runtime/mark.md @@ -40,7 +40,13 @@ void ovni_mark_label(int32_t type, int64_t value, const char *label); ### Emit events All mark channels begin with the default value *null*, which is not shown in -Paraver and will be displayed as the usual empty space. +Paraver and will be displayed as the usual empty space. The value of the channel +can be changed over time with the following functions. + +!!! warning + + The value 0 is forbidden, as it is used by Paraver to represent the + "empty" state. If you have used a single channel (without `OVNI_MARK_STACK`), then you must use the following call to emit events at runtime: diff --git a/src/emu/ovni/mark.c b/src/emu/ovni/mark.c index 179f84a..e887ae5 100644 --- a/src/emu/ovni/mark.c +++ b/src/emu/ovni/mark.c @@ -624,6 +624,11 @@ mark_event(struct emu *emu) return -1; } + if (value == 0) { + err("mark value cannot be zero, type %ld", type); + return -1; + } + long index = mc->index; struct ovni_thread *oth = EXT(emu->thread, 'O'); struct ovni_mark_thread *mth = &oth->mark; diff --git a/src/rt/ovni.c b/src/rt/ovni.c index d36c87f..0f43241 100644 --- a/src/rt/ovni.c +++ b/src/rt/ovni.c @@ -1136,6 +1136,9 @@ ovni_mark_label(int32_t type, int64_t value, const char *label) void ovni_mark_push(int32_t type, int64_t value) { + if (value == 0) + die("value cannot be 0, type %ld", (long) type); + struct ovni_ev ev = {0}; ovni_ev_set_clock(&ev, ovni_clock_now()); ovni_ev_set_mcv(&ev, "OM["); @@ -1147,6 +1150,9 @@ ovni_mark_push(int32_t type, int64_t value) void ovni_mark_pop(int32_t type, int64_t value) { + if (value == 0) + die("value cannot be 0, type %ld", (long) type); + struct ovni_ev ev = {0}; ovni_ev_set_clock(&ev, ovni_clock_now()); ovni_ev_set_mcv(&ev, "OM]"); @@ -1158,6 +1164,9 @@ ovni_mark_pop(int32_t type, int64_t value) void ovni_mark_set(int32_t type, int64_t value) { + if (value == 0) + die("value cannot be 0, type %ld", (long) type); + struct ovni_ev ev = {0}; ovni_ev_set_clock(&ev, ovni_clock_now()); ovni_ev_set_mcv(&ev, "OM="); diff --git a/test/emu/ovni/libovni-mark.c b/test/emu/ovni/libovni-mark.c index 56af5a2..21a6694 100644 --- a/test/emu/ovni/libovni-mark.c +++ b/test/emu/ovni/libovni-mark.c @@ -46,9 +46,7 @@ main(void) ovni_mark_label(MARK_COLORS, COL_GRAY, "Gray"); ovni_mark_label(MARK_COLORS, COL_RED, "Red"); - for (int i = 0; i < 100; i++) { - ovni_mark_set(MARK_PROGRESS, i); - + for (int i = 1; i <= 100; i++) { int which = 1 + (rand() % 3); /* Simulate a thread goes to sleep */ @@ -61,9 +59,9 @@ main(void) if (rank == 0 && i == 75) instr_thread_resume(); - } - ovni_mark_set(MARK_PROGRESS, 100); + ovni_mark_set(MARK_PROGRESS, i); + } instr_end();