Make mark thread channels show only when running

Implements support for tracking the running thread using the track API.
This commit is contained in:
Rodrigo Arias 2024-06-19 13:15:16 +02:00
parent 9da7234684
commit d9180d950b
3 changed files with 42 additions and 7 deletions

View File

@ -12,6 +12,7 @@
#include "pv/prv.h"
#include "pv/pvt.h"
#include "thread.h"
#include "track.h"
#include "uthash.h"
#include <errno.h>
@ -299,14 +300,15 @@ create_thread_chan(struct ovni_mark_emu *m, struct bay *bay, struct thread *th)
t->nchannels = m->ntypes;
const char *fmt = "thread%ld.mark%ld";
struct mark_type *type;
for (type = m->types; type; type = type->hh.next) {
/* TODO: We may use a vector of thread channels in every type to
* avoid the double hash access in events */
long i = type->index;
struct chan *ch = &t->channels[i];
chan_init(ch, type->ctype, "thread%ld.mark%ld",
th->gindex, type->type);
chan_init(ch, type->ctype, fmt, th->gindex, type->type);
if (bay_register(bay, ch) != 0) {
err("bay_register failed");
@ -314,6 +316,24 @@ create_thread_chan(struct ovni_mark_emu *m, struct bay *bay, struct thread *th)
}
}
/* Setup tracking */
t->track = calloc(m->ntypes, sizeof(struct track));
if (t->track == NULL) {
err("calloc failed:");
return -1;
}
for (type = m->types; type; type = type->hh.next) {
long i = type->index;
struct track *track = &t->track[i];
/* For now only tracking to running thread is supported */
if (track_init(track, bay, TRACK_TYPE_TH, TRACK_TH_RUN,
fmt, th->gindex, type->type) != 0) {
err("track_init failed");
return -1;
}
}
return 0;
}
@ -351,15 +371,29 @@ connect_thread_prv(struct emu *emu, struct thread *sth, struct prv *prv)
struct ovni_thread *oth = EXT(sth, 'O');
struct ovni_mark_thread *mth = &oth->mark;
for (struct mark_type *type = memu->types; type; type = type->hh.next) {
/* TODO: We may use a vector of thread channels in every type to
* avoid the double hash access in events */
long i = type->index;
struct chan *ch = &mth->channels[i];
struct track *track = &mth->track[i];
struct chan *sel = &sth->chan[TH_CHAN_STATE];
/* Connect the input and sel channel to the mux */
if (track_connect_thread(track, ch, sel, 1) != 0) {
err("track_connect_thread failed");
return -1;
}
/* Then connect the output of the tracking module to the prv
* trace for the current thread */
struct chan *out = track_get_output(track);
long row = sth->gindex;
long flags = PRV_ZERO; /* Allow zero value */
/* Allow zero value and skip duplicated nulls */
long flags = PRV_ZERO | PRV_SKIPDUPNULL;
long prvtype = type->prvtype;
if (prv_register(prv, row, prvtype, &emu->bay, ch, flags)) {
if (prv_register(prv, row, prvtype, &emu->bay, out, flags)) {
err("prv_register failed");
return -1;
}

View File

@ -14,6 +14,7 @@ struct ovni_mark_emu {
};
struct ovni_mark_thread {
struct track *track;
struct chan *channels;
long nchannels;
};

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC)
/* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC)
* SPDX-License-Identifier: GPL-3.0-or-later */
#ifndef TRACK_H
@ -27,8 +27,8 @@ struct track {
int mode;
char name[MAX_CHAN_NAME];
struct bay *bay;
struct chan ch;
struct chan *out;
struct chan ch; /*< Scratch channel as output when mux is used */
struct chan *out; /*< Output channel (ch or the input channel) */
struct mux mux;
};