Prevent zero values in the mark API

These values cannot be differentiated from a null value, due to a
Paraver limitation.
This commit is contained in:
Rodrigo Arias 2024-06-20 11:32:20 +02:00
parent 670edb6ddc
commit c803a7566f
4 changed files with 24 additions and 6 deletions

View File

@ -40,7 +40,13 @@ void ovni_mark_label(int32_t type, int64_t value, const char *label);
### Emit events ### Emit events
All mark channels begin with the default value *null*, which is not shown in 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 If you have used a single channel (without `OVNI_MARK_STACK`), then you must use
the following call to emit events at runtime: the following call to emit events at runtime:

View File

@ -624,6 +624,11 @@ mark_event(struct emu *emu)
return -1; return -1;
} }
if (value == 0) {
err("mark value cannot be zero, type %ld", type);
return -1;
}
long index = mc->index; long index = mc->index;
struct ovni_thread *oth = EXT(emu->thread, 'O'); struct ovni_thread *oth = EXT(emu->thread, 'O');
struct ovni_mark_thread *mth = &oth->mark; struct ovni_mark_thread *mth = &oth->mark;

View File

@ -1136,6 +1136,9 @@ ovni_mark_label(int32_t type, int64_t value, const char *label)
void void
ovni_mark_push(int32_t type, int64_t value) 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}; struct ovni_ev ev = {0};
ovni_ev_set_clock(&ev, ovni_clock_now()); ovni_ev_set_clock(&ev, ovni_clock_now());
ovni_ev_set_mcv(&ev, "OM["); ovni_ev_set_mcv(&ev, "OM[");
@ -1147,6 +1150,9 @@ ovni_mark_push(int32_t type, int64_t value)
void void
ovni_mark_pop(int32_t type, int64_t value) 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}; struct ovni_ev ev = {0};
ovni_ev_set_clock(&ev, ovni_clock_now()); ovni_ev_set_clock(&ev, ovni_clock_now());
ovni_ev_set_mcv(&ev, "OM]"); ovni_ev_set_mcv(&ev, "OM]");
@ -1158,6 +1164,9 @@ ovni_mark_pop(int32_t type, int64_t value)
void void
ovni_mark_set(int32_t type, int64_t value) 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}; struct ovni_ev ev = {0};
ovni_ev_set_clock(&ev, ovni_clock_now()); ovni_ev_set_clock(&ev, ovni_clock_now());
ovni_ev_set_mcv(&ev, "OM="); ovni_ev_set_mcv(&ev, "OM=");

View File

@ -46,9 +46,7 @@ main(void)
ovni_mark_label(MARK_COLORS, COL_GRAY, "Gray"); ovni_mark_label(MARK_COLORS, COL_GRAY, "Gray");
ovni_mark_label(MARK_COLORS, COL_RED, "Red"); ovni_mark_label(MARK_COLORS, COL_RED, "Red");
for (int i = 0; i < 100; i++) { for (int i = 1; i <= 100; i++) {
ovni_mark_set(MARK_PROGRESS, i);
int which = 1 + (rand() % 3); int which = 1 + (rand() % 3);
/* Simulate a thread goes to sleep */ /* Simulate a thread goes to sleep */
@ -61,9 +59,9 @@ main(void)
if (rank == 0 && i == 75) if (rank == 0 && i == 75)
instr_thread_resume(); instr_thread_resume();
}
ovni_mark_set(MARK_PROGRESS, 100); ovni_mark_set(MARK_PROGRESS, i);
}
instr_end(); instr_end();