Use enum for tracking modes
This commit is contained in:
parent
e3880d178e
commit
553e51741a
@ -1,19 +1,19 @@
|
|||||||
#include "nanos6_priv.h"
|
#include "nanos6_priv.h"
|
||||||
|
|
||||||
static const char *th_track[] = {
|
const enum nanos6_track th_track[] = {
|
||||||
[CH_TASKID] = "running",
|
[CH_TASKID] = RUN_TH,
|
||||||
[CH_TYPE] = "running",
|
[CH_TYPE] = RUN_TH,
|
||||||
[CH_SUBSYSTEM] = "active",
|
[CH_SUBSYSTEM] = ACT_TH,
|
||||||
[CH_RANK] = "running",
|
[CH_RANK] = RUN_TH,
|
||||||
[CH_THREAD] = "none",
|
[CH_THREAD] = NONE,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *cpu_track[] = {
|
const enum nanos6_track cpu_track[] = {
|
||||||
[CH_TASKID] = "running",
|
[CH_TASKID] = RUN_TH,
|
||||||
[CH_TYPE] = "running",
|
[CH_TYPE] = RUN_TH,
|
||||||
[CH_SUBSYSTEM] = "running",
|
[CH_SUBSYSTEM] = RUN_TH,
|
||||||
[CH_RANK] = "running",
|
[CH_RANK] = RUN_TH,
|
||||||
[CH_THREAD] = "running",
|
[CH_THREAD] = RUN_TH,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int th_type[] = {
|
static const int th_type[] = {
|
||||||
@ -67,14 +67,12 @@ connect_thread_mux(struct emu *emu, struct thread *thread)
|
|||||||
|
|
||||||
/* The tracking only sets the ch_out, but we keep both tracking
|
/* The tracking only sets the ch_out, but we keep both tracking
|
||||||
* updated as the CPU tracking channels may use them. */
|
* updated as the CPU tracking channels may use them. */
|
||||||
const char *tracking = th_track[i];
|
if (th_track[i] == RUN_TH)
|
||||||
if (strcmp(tracking, "running") == 0) {
|
|
||||||
th->ch_out[i] = &th->ch_run[i];
|
th->ch_out[i] = &th->ch_run[i];
|
||||||
} else if (strcmp(tracking, "active") == 0) {
|
else if (th_track[i] == ACT_TH)
|
||||||
th->ch_out[i] = &th->ch_act[i];
|
th->ch_out[i] = &th->ch_act[i];
|
||||||
} else {
|
else
|
||||||
th->ch_out[i] = &th->ch[i];
|
th->ch_out[i] = &th->ch[i];
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,15 +103,13 @@ add_inputs_cpu_mux(struct emu *emu, struct mux *mux, int i)
|
|||||||
struct nanos6_thread *th = extend_get(&t->ext, '6');
|
struct nanos6_thread *th = extend_get(&t->ext, '6');
|
||||||
|
|
||||||
/* Choose input thread channel based on tracking mode */
|
/* Choose input thread channel based on tracking mode */
|
||||||
const char *tracking = cpu_track[i];
|
struct chan *inp = NULL;
|
||||||
struct chan *inp;
|
if (cpu_track[i] == RUN_TH)
|
||||||
if (strcmp(tracking, "running") == 0) {
|
|
||||||
inp = &th->ch_run[i];
|
inp = &th->ch_run[i];
|
||||||
} else if (strcmp(tracking, "active") == 0) {
|
else if (cpu_track[i] == ACT_TH)
|
||||||
inp = &th->ch_act[i];
|
inp = &th->ch_act[i];
|
||||||
} else {
|
else
|
||||||
die("cpu tracking must be 'running' or 'active'");
|
die("cpu tracking must be 'running' or 'active'");
|
||||||
}
|
|
||||||
|
|
||||||
if (mux_add_input(mux, value_int64(t->gindex), inp) != 0) {
|
if (mux_add_input(mux, value_int64(t->gindex), inp) != 0) {
|
||||||
err("mux_add_input failed");
|
err("mux_add_input failed");
|
||||||
@ -131,17 +127,15 @@ connect_cpu_mux(struct emu *emu, struct cpu *scpu)
|
|||||||
for (int i = 0; i < CH_MAX; i++) {
|
for (int i = 0; i < CH_MAX; i++) {
|
||||||
struct mux *mux = &cpu->mux[i];
|
struct mux *mux = &cpu->mux[i];
|
||||||
struct chan *out = &cpu->ch[i];
|
struct chan *out = &cpu->ch[i];
|
||||||
const char *tracking = cpu_track[i];
|
|
||||||
|
|
||||||
/* Choose select CPU channel based on tracking mode */
|
/* Choose select CPU channel based on tracking mode */
|
||||||
struct chan *sel;
|
struct chan *sel = NULL;
|
||||||
if (strcmp(tracking, "running") == 0) {
|
if (cpu_track[i] == RUN_TH)
|
||||||
sel = &scpu->chan[CPU_CHAN_THRUN];
|
sel = &scpu->chan[CPU_CHAN_THRUN];
|
||||||
} else if (strcmp(tracking, "active") == 0) {
|
else if (cpu_track[i] == ACT_TH)
|
||||||
sel = &scpu->chan[CPU_CHAN_THACT];
|
sel = &scpu->chan[CPU_CHAN_THACT];
|
||||||
} else {
|
else
|
||||||
die("cpu tracking must be 'running' or 'active'");
|
die("cpu tracking must be 'running' or 'active'");
|
||||||
}
|
|
||||||
|
|
||||||
if (mux_init(mux, &emu->bay, sel, out, NULL) != 0) {
|
if (mux_init(mux, &emu->bay, sel, out, NULL) != 0) {
|
||||||
err("mux_init failed");
|
err("mux_init failed");
|
||||||
@ -205,6 +199,11 @@ connect_cpu_prv(struct emu *emu, struct cpu *scpu, struct prv *prv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//static int
|
||||||
|
//populate_cpu_pcf(struct emu *emu, struct pcf *pcf)
|
||||||
|
//{
|
||||||
|
//}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
connect_cpus(struct emu *emu)
|
connect_cpus(struct emu *emu)
|
||||||
{
|
{
|
||||||
@ -233,6 +232,9 @@ connect_cpus(struct emu *emu)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// struct pcf *pcf = pvt_get_pcf(pvt);
|
||||||
|
// populate_cpu_pcf(pcf, emu);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,16 @@ enum nanos6_chan_type {
|
|||||||
CH_MAX,
|
CH_MAX,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum nanos6_track {
|
||||||
|
NONE = 0,
|
||||||
|
RUN_TH,
|
||||||
|
ACT_TH,
|
||||||
|
TRACK_MAX,
|
||||||
|
};
|
||||||
|
|
||||||
|
extern const enum nanos6_track th_track[CH_MAX];
|
||||||
|
extern const enum nanos6_track cpu_track[CH_MAX];
|
||||||
|
|
||||||
enum nanos6_ss_state {
|
enum nanos6_ss_state {
|
||||||
ST_TASK_BODY = 1,
|
ST_TASK_BODY = 1,
|
||||||
ST_TASK_CREATING,
|
ST_TASK_CREATING,
|
||||||
|
Loading…
Reference in New Issue
Block a user