Emit the rank too when switching Nanos6 tasks
The task type and rank are allowed to emit PRV duplicates.
This commit is contained in:
parent
31b2ef5ffe
commit
30761c266b
@ -177,6 +177,7 @@ chan_task_switch(struct emu *emu,
|
||||
struct task *prev, struct task *next)
|
||||
{
|
||||
struct nanos6_thread *th = EXT(emu->thread, '6');
|
||||
struct proc *proc = emu->proc;
|
||||
|
||||
if (!prev || !next) {
|
||||
err("cannot switch to or from a NULL task");
|
||||
@ -203,19 +204,21 @@ chan_task_switch(struct emu *emu,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* No need to change the rank as we will switch to tasks from
|
||||
* same thread */
|
||||
if (chan_set(&th->m.ch[CH_TASKID], value_int64(next->id)) != 0) {
|
||||
err("chan_set taskid failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* TODO: test when switching to another task with the same type. We
|
||||
* should emit the same type state value as previous task. */
|
||||
if (chan_set(&th->m.ch[CH_TYPE], value_int64(next->type->gid)) != 0) {
|
||||
err("chan_set type failed");
|
||||
return -1;
|
||||
}
|
||||
if (proc->rank >= 0) {
|
||||
struct value vrank = value_int64(proc->rank + 1);
|
||||
if (chan_set(&th->m.ch[CH_RANK], vrank) != 0) {
|
||||
err("chan_set rank failed");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -30,6 +30,12 @@ static const int chan_stack[CH_MAX] = {
|
||||
[CH_THREAD] = 1,
|
||||
};
|
||||
|
||||
static const int chan_dup[CH_MAX] = {
|
||||
[CH_TYPE] = 1,
|
||||
[CH_RANK] = 1,
|
||||
};
|
||||
|
||||
|
||||
/* ----------------- pvt ------------------ */
|
||||
|
||||
static const int pvt_type[] = {
|
||||
@ -96,9 +102,9 @@ static const struct pcf_value_label (*pcf_labels[CH_MAX])[] = {
|
||||
|
||||
static const long prv_flags[CH_MAX] = {
|
||||
[CH_TASKID] = PRV_SKIPDUP,
|
||||
[CH_TYPE] = PRV_SKIPDUP,
|
||||
[CH_TYPE] = PRV_EMITDUP, /* Switch to task of same type */
|
||||
[CH_SUBSYSTEM] = PRV_SKIPDUP,
|
||||
[CH_RANK] = PRV_SKIPDUP,
|
||||
[CH_RANK] = PRV_EMITDUP, /* Switch to task of same rank */
|
||||
[CH_THREAD] = PRV_SKIPDUP,
|
||||
};
|
||||
|
||||
@ -134,6 +140,7 @@ static const struct model_chan_spec th_chan = {
|
||||
.prefix = model_name,
|
||||
.ch_names = chan_name,
|
||||
.ch_stack = chan_stack,
|
||||
.ch_dup = chan_dup,
|
||||
.pvt = &pvt_spec,
|
||||
.track = th_track,
|
||||
};
|
||||
@ -143,6 +150,7 @@ static const struct model_chan_spec cpu_chan = {
|
||||
.prefix = model_name,
|
||||
.ch_names = chan_name,
|
||||
.ch_stack = chan_stack,
|
||||
.ch_dup = chan_dup,
|
||||
.pvt = &pvt_spec,
|
||||
.track = cpu_track,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user