Move thread type events to another channel

This commit is contained in:
Rodrigo Arias 2022-09-05 20:18:42 +02:00
parent dfc4ba2224
commit 982bc39490
4 changed files with 79 additions and 38 deletions

45
emu.h
View File

@ -103,31 +103,32 @@ enum nodes_state {
/* The values of nanos6_ss_state are synced to the previous /* The values of nanos6_ss_state are synced to the previous
* CTF implementation. */ * CTF implementation. */
enum nanos6_ss_state { enum nanos6_ss_state {
ST_NANOS6_NULL = 0, /* IDLE */ ST_NANOS6_TASK_BODY = 1,
ST_NANOS6_TASK_BODY = 3, /* TASK */ ST_NANOS6_TASK_CREATING,
ST_NANOS6_TASK_CREATING = 8, /* TASK_CREATE */ ST_NANOS6_TASK_SUBMIT,
ST_NANOS6_TASK_SUBMIT = 10, /* TASK_SUBMIT */ ST_NANOS6_TASK_SPAWNING,
ST_NANOS6_TASK_SPAWNING = 18, /* SPAWN_FUNCTION */ ST_NANOS6_SCHED_ADDING,
ST_NANOS6_SCHED_HUNGRY = 2, /* BUSY_WAIT */ ST_NANOS6_SCHED_SERVING,
ST_NANOS6_SCHED_ADDING = 6, /* SCHEDULER_ADD_TASK */ ST_NANOS6_DEP_REG,
ST_NANOS6_SCHED_SERVING = 20, /* SCHEDULER_LOCK_SERVING */ ST_NANOS6_DEP_UNREG,
ST_NANOS6_DEP_REG = 4, /* DEPENDENCY_REGISTER */ ST_NANOS6_BLK_TASKWAIT,
ST_NANOS6_DEP_UNREG = 5, /* DEPENDENCY_UNREGISTER */ ST_NANOS6_BLK_WAITFOR,
ST_NANOS6_BLK_TASKWAIT = 12, /* TASK_WAIT */ ST_NANOS6_BLK_BLOCKING,
ST_NANOS6_BLK_WAITFOR = 13, /* WAIT_FOR */ ST_NANOS6_BLK_UNBLOCKING,
ST_NANOS6_BLK_BLOCKING = 16, /* BLOCKING_API_BLOCK */ ST_NANOS6_HANDLING_TASK,
ST_NANOS6_BLK_UNBLOCKING = 17, /* BLOCKING_API_UNBLOCK */ ST_NANOS6_WORKER_LOOP,
EV_NANOS6_SCHED_RECV = 50, /* Value 51 is broken in old Paraver */
EV_NANOS6_SCHED_SEND = 51, EV_NANOS6_SCHED_RECV = 60,
EV_NANOS6_SCHED_SELF = 52, EV_NANOS6_SCHED_SEND = 61,
EV_NANOS6_SCHED_SELF = 62,
}; };
enum nanos6_thread_state { enum nanos6_thread_type {
ST_NANOS6_TH_EXTERNAL = 1, ST_NANOS6_TH_LEADER = 1,
ST_NANOS6_TH_WORKER, ST_NANOS6_TH_MAIN = 2,
ST_NANOS6_TH_LEADER, ST_NANOS6_TH_WORKER = 3,
ST_NANOS6_TH_MAIN ST_NANOS6_TH_EXTERNAL = 4,
}; };
enum kernel_cs_state { enum kernel_cs_state {

View File

@ -50,7 +50,7 @@ hook_init_nanos6(struct ovni_emu *emu)
chan_th_init(th, uth, CHAN_NANOS6_TYPE, CHAN_TRACK_TH_RUNNING, 0, 0, 1, row, prv_th, clock); chan_th_init(th, uth, CHAN_NANOS6_TYPE, CHAN_TRACK_TH_RUNNING, 0, 0, 1, row, prv_th, clock);
chan_th_init(th, uth, CHAN_NANOS6_SUBSYSTEM, CHAN_TRACK_TH_ACTIVE, 0, 0, 1, row, prv_th, clock); chan_th_init(th, uth, CHAN_NANOS6_SUBSYSTEM, CHAN_TRACK_TH_ACTIVE, 0, 0, 1, row, prv_th, clock);
chan_th_init(th, uth, CHAN_NANOS6_RANK, CHAN_TRACK_TH_RUNNING, 0, 0, 1, row, prv_th, clock); chan_th_init(th, uth, CHAN_NANOS6_RANK, CHAN_TRACK_TH_RUNNING, 0, 0, 1, row, prv_th, clock);
chan_th_init(th, uth, CHAN_NANOS6_THREAD, CHAN_TRACK_TH_RUNNING, 0, 0, 1, row, prv_th, clock); chan_th_init(th, uth, CHAN_NANOS6_THREAD, CHAN_TRACK_NONE, 0, 1, 1, row, prv_th, clock);
} }
/* Init the Nanos6 channels in all cpus */ /* Init the Nanos6 channels in all cpus */
@ -292,7 +292,7 @@ pre_task(struct ovni_emu *emu)
update_task(emu); update_task(emu);
break; break;
default: default:
die("unexpected event value %c\n", die("unexpected Nanos6 task event value %c\n",
emu->cur_ev->header.value); emu->cur_ev->header.value);
} }
} }
@ -360,6 +360,26 @@ pre_blocking(struct ovni_emu *emu)
} }
} }
static void
pre_worker(struct ovni_emu *emu)
{
struct ovni_ethread *th;
struct ovni_chan *chan_th;
th = emu->cur_thread;
chan_th = &th->chan[CHAN_NANOS6_SUBSYSTEM];
switch(emu->cur_ev->header.value)
{
case '[': chan_push(chan_th, ST_NANOS6_WORKER_LOOP); break;
case ']': chan_pop (chan_th, ST_NANOS6_WORKER_LOOP); break;
case 't': chan_push(chan_th, ST_NANOS6_HANDLING_TASK); break;
case 'T': chan_pop (chan_th, ST_NANOS6_HANDLING_TASK); break;
default: break;
}
}
static void static void
pre_sched(struct ovni_emu *emu) pre_sched(struct ovni_emu *emu)
{ {
@ -371,14 +391,16 @@ pre_sched(struct ovni_emu *emu)
switch(emu->cur_ev->header.value) switch(emu->cur_ev->header.value)
{ {
case 'h': chan_push(chan_th, ST_NANOS6_SCHED_HUNGRY); break;
case 'f': chan_pop(chan_th, ST_NANOS6_SCHED_HUNGRY); break;
case '[': chan_push(chan_th, ST_NANOS6_SCHED_SERVING); break; case '[': chan_push(chan_th, ST_NANOS6_SCHED_SERVING); break;
case ']': chan_pop (chan_th, ST_NANOS6_SCHED_SERVING); break; case ']': chan_pop (chan_th, ST_NANOS6_SCHED_SERVING); break;
case 'a': chan_push(chan_th, ST_NANOS6_SCHED_ADDING); break;
case 'A': chan_pop (chan_th, ST_NANOS6_SCHED_ADDING); break;
case '@': chan_ev (chan_th, EV_NANOS6_SCHED_SELF); break; case '@': chan_ev (chan_th, EV_NANOS6_SCHED_SELF); break;
case 'r': chan_ev (chan_th, EV_NANOS6_SCHED_RECV); break; case 'r': chan_ev (chan_th, EV_NANOS6_SCHED_RECV); break;
case 's': chan_ev (chan_th, EV_NANOS6_SCHED_SEND); break; case 's': chan_ev (chan_th, EV_NANOS6_SCHED_SEND); break;
default: break; default:
die("unknown Nanos6 scheduler event %c\n",
emu->cur_ev->header.value);
} }
} }
@ -421,9 +443,8 @@ pre_ss(struct ovni_emu *emu, int st)
case '[': chan_push(chan_th, st); break; case '[': chan_push(chan_th, st); break;
case ']': chan_pop(chan_th, st); break; case ']': chan_pop(chan_th, st); break;
default: default:
err("unexpected value '%c' (expecting '[' or ']')\n", die("unexpected value '%c' (expecting '[' or ']')\n",
emu->cur_ev->header.value); emu->cur_ev->header.value);
abort();
} }
} }
@ -438,8 +459,9 @@ check_affinity(struct ovni_emu *emu)
if(cpu->nrunning_threads > 1) if(cpu->nrunning_threads > 1)
{ {
die("cpu %s has more than one thread running\n", err("cpu %s has more than one thread running\n", cpu->name);
cpu->name); if(emu->enable_linter)
abort();
} }
} }
@ -460,11 +482,14 @@ hook_pre_nanos6(struct ovni_emu *emu)
case 'Y': pre_type(emu); break; case 'Y': pre_type(emu); break;
case 'S': pre_sched(emu); break; case 'S': pre_sched(emu); break;
case 'U': pre_ss(emu, ST_NANOS6_TASK_SUBMIT); break; case 'U': pre_ss(emu, ST_NANOS6_TASK_SUBMIT); break;
case 'F': pre_ss(emu, ST_NANOS6_TASK_SPAWNING); break;
case 'H': pre_thread(emu); break; case 'H': pre_thread(emu); break;
case 'D': pre_deps(emu); break; case 'D': pre_deps(emu); break;
case 'B': pre_blocking(emu); break; case 'B': pre_blocking(emu); break;
case 'W': pre_worker(emu); break;
default: default:
break; die("unknown Nanos6 event category %c\n",
emu->cur_ev->header.category);
} }
check_affinity(emu); check_affinity(emu);

18
pcf.c
View File

@ -179,7 +179,6 @@ struct pcf_value_label nanos6_ss_values[] = {
{ ST_NANOS6_TASK_CREATING, "Task: Creating" }, { ST_NANOS6_TASK_CREATING, "Task: Creating" },
{ ST_NANOS6_TASK_SUBMIT, "Task: Submitting" }, { ST_NANOS6_TASK_SUBMIT, "Task: Submitting" },
{ ST_NANOS6_TASK_SPAWNING, "Task: Spawning function" }, { ST_NANOS6_TASK_SPAWNING, "Task: Spawning function" },
{ ST_NANOS6_SCHED_HUNGRY, "Scheduler: Waiting for ready tasks" },
{ ST_NANOS6_SCHED_SERVING, "Scheduler: Serving tasks" }, { ST_NANOS6_SCHED_SERVING, "Scheduler: Serving tasks" },
{ ST_NANOS6_SCHED_ADDING, "Scheduler: Adding ready tasks" }, { ST_NANOS6_SCHED_ADDING, "Scheduler: Adding ready tasks" },
{ ST_NANOS6_DEP_REG, "Dependency: Registering" }, { ST_NANOS6_DEP_REG, "Dependency: Registering" },
@ -188,12 +187,24 @@ struct pcf_value_label nanos6_ss_values[] = {
{ ST_NANOS6_BLK_BLOCKING, "Blocking: Blocking current task" }, { ST_NANOS6_BLK_BLOCKING, "Blocking: Blocking current task" },
{ ST_NANOS6_BLK_UNBLOCKING, "Blocking: Unblocking remote task" }, { ST_NANOS6_BLK_UNBLOCKING, "Blocking: Unblocking remote task" },
{ ST_NANOS6_BLK_WAITFOR, "Blocking: Wait For" }, { ST_NANOS6_BLK_WAITFOR, "Blocking: Wait For" },
{ ST_NANOS6_HANDLING_TASK, "Worker: Handling task" },
{ ST_NANOS6_WORKER_LOOP, "Worker: Looking for work" },
{ EV_NANOS6_SCHED_SEND, "EV Scheduler: Send task" }, { EV_NANOS6_SCHED_SEND, "EV Scheduler: Send task" },
{ EV_NANOS6_SCHED_RECV, "EV Scheduler: Recv task" }, { EV_NANOS6_SCHED_RECV, "EV Scheduler: Recv task" },
{ EV_NANOS6_SCHED_SELF, "EV Scheduler: Self-assign task" }, { EV_NANOS6_SCHED_SELF, "EV Scheduler: Self-assign task" },
{ -1, NULL }, { -1, NULL },
}; };
struct pcf_value_label nanos6_thread_type[] = {
{ ST_NULL, "No type" },
{ ST_TOO_MANY_TH, "Unknown: multiple threads running" },
{ ST_NANOS6_TH_EXTERNAL, "External" },
{ ST_NANOS6_TH_WORKER, "Worker" },
{ ST_NANOS6_TH_LEADER, "Leader" },
{ ST_NANOS6_TH_MAIN, "Main" },
{ -1, NULL },
};
struct pcf_value_label (*pcf_chan_value_labels[CHAN_MAX])[] = { struct pcf_value_label (*pcf_chan_value_labels[CHAN_MAX])[] = {
[CHAN_OVNI_PID] = &default_values, [CHAN_OVNI_PID] = &default_values,
[CHAN_OVNI_TID] = &default_values, [CHAN_OVNI_TID] = &default_values,
@ -217,6 +228,7 @@ struct pcf_value_label (*pcf_chan_value_labels[CHAN_MAX])[] = {
[CHAN_NANOS6_TYPE] = &default_values, [CHAN_NANOS6_TYPE] = &default_values,
[CHAN_NANOS6_SUBSYSTEM] = &nanos6_ss_values, [CHAN_NANOS6_SUBSYSTEM] = &nanos6_ss_values,
[CHAN_NANOS6_RANK] = &default_values, [CHAN_NANOS6_RANK] = &default_values,
[CHAN_NANOS6_THREAD] = &nanos6_thread_type,
[CHAN_KERNEL_CS] = &kernel_cs_values, [CHAN_KERNEL_CS] = &kernel_cs_values,
}; };
@ -246,6 +258,7 @@ char *pcf_chan_name[CHAN_MAX] = {
[CHAN_NANOS6_TYPE] = "Nanos6 task type", [CHAN_NANOS6_TYPE] = "Nanos6 task type",
[CHAN_NANOS6_SUBSYSTEM] = "Nanos6 subsystem", [CHAN_NANOS6_SUBSYSTEM] = "Nanos6 subsystem",
[CHAN_NANOS6_RANK] = "Nanos6 task MPI rank", [CHAN_NANOS6_RANK] = "Nanos6 task MPI rank",
[CHAN_NANOS6_THREAD] = "Nanos6 thread type",
[CHAN_KERNEL_CS] = "Context switches", [CHAN_KERNEL_CS] = "Context switches",
}; };
@ -283,8 +296,9 @@ int pcf_chan_suffix[CHAN_MAX][CHAN_MAXTYPE] = {
[CHAN_NANOS6_TYPE] = { RUN_TH, RUN_TH }, [CHAN_NANOS6_TYPE] = { RUN_TH, RUN_TH },
[CHAN_NANOS6_SUBSYSTEM] = { ACT_TH, RUN_TH }, [CHAN_NANOS6_SUBSYSTEM] = { ACT_TH, RUN_TH },
[CHAN_NANOS6_RANK] = { RUN_TH, RUN_TH }, [CHAN_NANOS6_RANK] = { RUN_TH, RUN_TH },
[CHAN_NANOS6_THREAD] = { ACT_TH, NONE },
[CHAN_KERNEL_CS] = { CUR_TH, ACT_TH }, [CHAN_KERNEL_CS] = { RUN_TH, ACT_TH },
}; };
/* ----------------------------------------------- */ /* ----------------------------------------------- */

View File

@ -21,6 +21,7 @@
#define _GNU_SOURCE /* For gethostname() */ #define _GNU_SOURCE /* For gethostname() */
#include "common.h" #include "common.h"
#include "compat.h"
#include "ovni.h" #include "ovni.h"
#include <inttypes.h> #include <inttypes.h>