From 8d78abd07fe249dbf55838351d018d8c9324a0e3 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Thu, 21 Nov 2024 09:58:48 +0100 Subject: [PATCH] WIP: Allow breakdown for OpenMP without nOS-V --- src/emu/nosv/breakdown.c | 29 ++++++++++++++++++++++------- src/emu/nosv/breakdown.h | 1 + 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/emu/nosv/breakdown.c b/src/emu/nosv/breakdown.c index 40a3e7c..209067a 100644 --- a/src/emu/nosv/breakdown.c +++ b/src/emu/nosv/breakdown.c @@ -80,6 +80,20 @@ model_nosv_breakdown_create(struct emu *emu) struct nosv_emu *memu = EXT(emu, 'V'); struct nosv_breakdown_emu *bemu = &memu->breakdown; + /* Ensure all threads have breakdown enabled */ + bemu->enabled = 1; + for (struct thread *th = emu->system.threads; th; th = th->gnext) { + if (check_thread_metadata(th) != 0) { + err("bad nosv metadata in thread: %s", th->id); + bemu->enabled = 0; + } + } + + if (!bemu->enabled) { + warn("cannot enable breakdown for nOS-V model"); + return 0; + } + /* Count phy cpus */ struct system *sys = &emu->system; int64_t nphycpus = (int64_t) (sys->ncpus - sys->nlooms); @@ -111,13 +125,6 @@ model_nosv_breakdown_create(struct emu *emu) } } - for (struct thread *th = emu->system.threads; th; th = th->gnext) { - if (check_thread_metadata(th) != 0) { - err("bad nosv metadata in thread: %s", th->id); - return -1; - } - } - return 0; } @@ -241,6 +248,10 @@ model_nosv_breakdown_connect(struct emu *emu) struct nosv_emu *memu = EXT(emu, 'V'); struct nosv_breakdown_emu *bemu = &memu->breakdown; + + if (!bemu->enabled) + return 0; + struct bay *bay = &emu->bay; struct system *sys = &emu->system; @@ -290,6 +301,10 @@ model_nosv_breakdown_finish(struct emu *emu, struct nosv_emu *memu = EXT(emu, 'V'); struct nosv_breakdown_emu *bemu = &memu->breakdown; + + if (!bemu->enabled) + return 0; + struct pcf *pcf = pvt_get_pcf(bemu->pvt); long typeid = PRV_NOSV_BREAKDOWN; char label[] = "CPU: nOS-V Runtime/Idle/Task breakdown"; diff --git a/src/emu/nosv/breakdown.h b/src/emu/nosv/breakdown.h index 376947b..4b74ace 100644 --- a/src/emu/nosv/breakdown.h +++ b/src/emu/nosv/breakdown.h @@ -51,6 +51,7 @@ struct nosv_breakdown_emu { int64_t nphycpus; struct sort sort; struct pvt *pvt; + int enabled; }; #endif /* BREAKDOWN_H */