2021-10-26 18:42:41 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021 Barcelona Supercomputing Center (BSC)
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2021-07-28 11:56:35 +02:00
|
|
|
#ifndef OVNI_EMU_H
|
|
|
|
#define OVNI_EMU_H
|
|
|
|
|
2021-11-18 11:55:28 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2021-07-28 11:56:35 +02:00
|
|
|
#include "ovni.h"
|
2021-07-29 17:46:25 +02:00
|
|
|
#include "uthash.h"
|
2021-08-03 17:48:37 +02:00
|
|
|
#include "parson.h"
|
2021-10-18 12:47:51 +02:00
|
|
|
#include "heap.h"
|
2021-11-18 11:55:28 +01:00
|
|
|
#include "common.h"
|
2021-10-18 12:47:51 +02:00
|
|
|
|
2021-07-28 11:56:35 +02:00
|
|
|
/* Emulated thread runtime status */
|
|
|
|
enum ethread_state {
|
|
|
|
TH_ST_UNKNOWN,
|
|
|
|
TH_ST_RUNNING,
|
|
|
|
TH_ST_PAUSED,
|
|
|
|
TH_ST_DEAD,
|
2021-10-11 11:12:26 +02:00
|
|
|
TH_ST_COOLING,
|
|
|
|
TH_ST_WARMING,
|
2021-07-28 11:56:35 +02:00
|
|
|
};
|
|
|
|
|
2021-07-29 17:46:25 +02:00
|
|
|
enum nosv_task_state {
|
|
|
|
TASK_ST_CREATED,
|
|
|
|
TASK_ST_RUNNING,
|
|
|
|
TASK_ST_PAUSED,
|
|
|
|
TASK_ST_DEAD,
|
|
|
|
};
|
|
|
|
|
2021-10-20 18:33:54 +02:00
|
|
|
enum ovni_state {
|
|
|
|
ST_OVNI_FLUSHING = 1,
|
|
|
|
};
|
|
|
|
|
2021-10-19 10:07:01 +02:00
|
|
|
enum error_values {
|
|
|
|
ST_BAD = 666,
|
2021-10-18 12:47:51 +02:00
|
|
|
ST_TOO_MANY_TH = 777,
|
|
|
|
};
|
|
|
|
|
2021-10-14 07:30:27 +02:00
|
|
|
enum nosv_ss_values {
|
2021-09-23 10:41:53 +02:00
|
|
|
ST_NULL = 0,
|
2021-10-14 07:30:27 +02:00
|
|
|
ST_NOSV_SCHED_HUNGRY = 6,
|
2021-10-25 12:35:05 +02:00
|
|
|
ST_NOSV_SCHED_SERVING,
|
|
|
|
ST_NOSV_SCHED_SUBMITTING,
|
|
|
|
ST_NOSV_MEM_ALLOCATING,
|
|
|
|
ST_NOSV_MEM_FREEING,
|
|
|
|
ST_NOSV_TASK_RUNNING,
|
|
|
|
ST_NOSV_API_SUBMIT,
|
|
|
|
ST_NOSV_API_PAUSE,
|
|
|
|
ST_NOSV_API_YIELD,
|
|
|
|
ST_NOSV_API_WAITFOR,
|
|
|
|
ST_NOSV_API_SCHEDPOINT,
|
2021-10-29 18:27:49 +02:00
|
|
|
ST_NOSV_ATTACH,
|
|
|
|
ST_NOSV_WORKER,
|
|
|
|
ST_NOSV_DELEGATE,
|
2021-10-14 07:30:27 +02:00
|
|
|
|
2021-10-25 12:35:05 +02:00
|
|
|
EV_NOSV_SCHED_RECV,
|
|
|
|
EV_NOSV_SCHED_SEND,
|
|
|
|
EV_NOSV_SCHED_SELF,
|
2021-09-23 10:41:53 +02:00
|
|
|
};
|
|
|
|
|
2021-11-12 11:36:27 +01:00
|
|
|
enum tampi_state {
|
2021-10-11 17:29:45 +02:00
|
|
|
ST_TAMPI_SEND = 1,
|
|
|
|
ST_TAMPI_RECV = 2,
|
|
|
|
ST_TAMPI_ISEND = 3,
|
|
|
|
ST_TAMPI_IRECV = 4,
|
|
|
|
ST_TAMPI_WAIT = 5,
|
|
|
|
ST_TAMPI_WAITALL = 6,
|
|
|
|
};
|
|
|
|
|
2021-11-12 11:36:27 +01:00
|
|
|
enum openmp_state {
|
2021-10-11 12:29:12 +02:00
|
|
|
ST_OPENMP_TASK = 1,
|
|
|
|
ST_OPENMP_PARALLEL = 2,
|
|
|
|
};
|
|
|
|
|
2021-11-12 11:36:27 +01:00
|
|
|
enum nanos6_state {
|
2021-11-12 16:15:33 +01:00
|
|
|
ST_NANOS6_REGISTER = 1,
|
|
|
|
ST_NANOS6_UNREGISTER = 2,
|
2021-11-12 11:06:34 +01:00
|
|
|
ST_NANOS6_IF0_WAIT = 3,
|
|
|
|
ST_NANOS6_IF0_INLINE = 4,
|
|
|
|
ST_NANOS6_TASKWAIT = 5,
|
2021-11-12 16:15:33 +01:00
|
|
|
ST_NANOS6_CREATE = 6,
|
|
|
|
ST_NANOS6_SUBMIT = 7,
|
2021-11-12 11:06:34 +01:00
|
|
|
ST_NANOS6_SPAWN = 8,
|
2021-10-25 16:57:31 +02:00
|
|
|
};
|
|
|
|
|
2021-07-29 17:46:25 +02:00
|
|
|
struct ovni_ethread;
|
2021-08-02 10:08:58 +02:00
|
|
|
struct ovni_eproc;
|
2021-07-29 17:46:25 +02:00
|
|
|
|
|
|
|
struct nosv_task {
|
|
|
|
int id;
|
2021-07-29 18:13:41 +02:00
|
|
|
int type_id;
|
2021-07-29 17:46:25 +02:00
|
|
|
struct ovni_ethread *thread;
|
|
|
|
enum nosv_task_state state;
|
|
|
|
UT_hash_handle hh;
|
|
|
|
};
|
|
|
|
|
2021-07-29 18:13:41 +02:00
|
|
|
struct nosv_task_type {
|
|
|
|
int id;
|
2021-07-30 20:08:40 +02:00
|
|
|
const char *label;
|
2021-07-29 18:13:41 +02:00
|
|
|
UT_hash_handle hh;
|
|
|
|
};
|
|
|
|
|
2021-10-21 16:15:29 +02:00
|
|
|
#define MAX_CHAN_STACK 128
|
|
|
|
|
2021-10-21 16:41:52 +02:00
|
|
|
enum chan_track {
|
2021-10-18 12:47:51 +02:00
|
|
|
/* The channel is manually controlled. */
|
2021-10-21 16:41:52 +02:00
|
|
|
CHAN_TRACK_NONE = 0,
|
2021-10-18 12:47:51 +02:00
|
|
|
|
|
|
|
/* Enables the channel when the thread is running only. */
|
2021-10-21 16:41:52 +02:00
|
|
|
CHAN_TRACK_TH_RUNNING,
|
2021-10-18 12:47:51 +02:00
|
|
|
|
|
|
|
/* The thread active tracking mode a enables the channel when
|
|
|
|
* the thread is running, cooling or warming. Otherwise the
|
|
|
|
* channel is disabled. */
|
|
|
|
CHAN_TRACK_TH_ACTIVE,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum chan {
|
|
|
|
CHAN_OVNI_PID,
|
|
|
|
CHAN_OVNI_TID,
|
2021-10-19 10:13:57 +02:00
|
|
|
CHAN_OVNI_NRTHREADS,
|
2021-10-18 12:47:51 +02:00
|
|
|
CHAN_OVNI_STATE,
|
|
|
|
CHAN_OVNI_APPID,
|
|
|
|
CHAN_OVNI_CPU,
|
2021-10-20 18:33:54 +02:00
|
|
|
CHAN_OVNI_FLUSH,
|
2021-10-18 12:47:51 +02:00
|
|
|
|
|
|
|
CHAN_NOSV_TASKID,
|
|
|
|
CHAN_NOSV_TYPEID,
|
|
|
|
CHAN_NOSV_APPID,
|
|
|
|
CHAN_NOSV_SUBSYSTEM,
|
|
|
|
|
|
|
|
CHAN_TAMPI_MODE,
|
|
|
|
CHAN_OPENMP_MODE,
|
2021-11-12 11:36:27 +01:00
|
|
|
CHAN_NANOS6_SUBSYSTEM,
|
2021-10-18 12:47:51 +02:00
|
|
|
|
|
|
|
CHAN_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
enum chan_to_prv_type {
|
|
|
|
CHAN_ID = 0,
|
|
|
|
CHAN_TH = 1,
|
|
|
|
CHAN_CPU = 2,
|
|
|
|
};
|
|
|
|
|
2021-11-17 12:08:25 +01:00
|
|
|
enum chan_dirty {
|
|
|
|
CHAN_CLEAN = 0,
|
|
|
|
|
|
|
|
/* The channel is dirty because it has been enabled or disabled */
|
|
|
|
CHAN_DIRTY_ACTIVE = 1,
|
|
|
|
|
|
|
|
/* The channel is dirty because it changed the state */
|
|
|
|
CHAN_DIRTY_VALUE = 2,
|
|
|
|
};
|
|
|
|
|
2021-10-18 12:47:51 +02:00
|
|
|
/* Same order as `enum chan` */
|
|
|
|
static const int chan_to_prvtype[CHAN_MAX][3] = {
|
|
|
|
/* Channel TH CPU */
|
|
|
|
{ CHAN_OVNI_PID, 10, 60 },
|
|
|
|
{ CHAN_OVNI_TID, 11, 61 },
|
2021-10-19 10:13:57 +02:00
|
|
|
{ CHAN_OVNI_NRTHREADS, -1, 62 },
|
2021-10-18 12:47:51 +02:00
|
|
|
{ CHAN_OVNI_STATE, 13, -1 },
|
|
|
|
{ CHAN_OVNI_APPID, 14, 64 }, /* Not used */
|
|
|
|
{ CHAN_OVNI_CPU, 15, -1 },
|
2021-10-20 18:33:54 +02:00
|
|
|
{ CHAN_OVNI_FLUSH, 16, 66 },
|
2021-10-18 12:47:51 +02:00
|
|
|
|
|
|
|
{ CHAN_NOSV_TASKID, 20, 70 },
|
|
|
|
{ CHAN_NOSV_TYPEID, 21, 71 },
|
|
|
|
{ CHAN_NOSV_APPID, 22, 72 },
|
|
|
|
{ CHAN_NOSV_SUBSYSTEM, 23, 73 },
|
|
|
|
|
|
|
|
{ CHAN_TAMPI_MODE, 30, 80 },
|
|
|
|
|
|
|
|
{ CHAN_OPENMP_MODE, 40, 90 },
|
2021-10-25 16:57:31 +02:00
|
|
|
|
2021-11-12 11:36:27 +01:00
|
|
|
{ CHAN_NANOS6_SUBSYSTEM, 50, 100 },
|
2021-10-21 16:41:52 +02:00
|
|
|
};
|
|
|
|
|
2021-11-08 17:02:39 +01:00
|
|
|
#define CHAN_PRV_TH(id) chan_to_prvtype[id][CHAN_TH]
|
|
|
|
#define CHAN_PRV_CPU(id) chan_to_prvtype[id][CHAN_CPU]
|
|
|
|
|
2021-10-21 16:15:29 +02:00
|
|
|
struct ovni_chan {
|
2021-10-18 12:47:51 +02:00
|
|
|
/* Channel id */
|
|
|
|
enum chan id;
|
|
|
|
|
2021-10-21 16:15:29 +02:00
|
|
|
/* Number of states in the stack */
|
|
|
|
int n;
|
|
|
|
|
|
|
|
/* Stack of states */
|
|
|
|
int stack[MAX_CHAN_STACK];
|
|
|
|
|
|
|
|
/* 1 if enabled, 0 if not. */
|
|
|
|
int enabled;
|
|
|
|
|
|
|
|
/* What state should be shown in errors */
|
|
|
|
int badst;
|
|
|
|
|
2021-11-17 12:08:25 +01:00
|
|
|
/* Last state emitted (-1 otherwise) */
|
|
|
|
int lastst;
|
|
|
|
|
2021-10-21 16:15:29 +02:00
|
|
|
/* Punctual event: -1 if not used */
|
|
|
|
int ev;
|
|
|
|
|
|
|
|
/* Emit events of this type */
|
|
|
|
int type;
|
|
|
|
|
|
|
|
/* A pointer to a clock to sample the time */
|
|
|
|
int64_t *clock;
|
|
|
|
|
|
|
|
/* The time of the last state or event */
|
|
|
|
int64_t t;
|
|
|
|
|
|
|
|
/* Paraver row */
|
|
|
|
int row;
|
|
|
|
|
2021-11-17 12:08:25 +01:00
|
|
|
/* Type of dirty */
|
|
|
|
enum chan_dirty dirty;
|
2021-10-21 16:15:29 +02:00
|
|
|
|
|
|
|
/* Where should the events be written to? */
|
|
|
|
FILE *prv;
|
2021-10-21 16:39:36 +02:00
|
|
|
|
|
|
|
/* What should cause the channel to become disabled? */
|
|
|
|
enum chan_track track;
|
2021-10-21 16:15:29 +02:00
|
|
|
|
2021-10-18 12:47:51 +02:00
|
|
|
/* The thread associated with the channel if any */
|
|
|
|
struct ovni_ethread *thread;
|
2021-10-21 16:39:36 +02:00
|
|
|
|
2021-10-18 12:47:51 +02:00
|
|
|
/* The CPU associated with the channel if any */
|
|
|
|
struct ovni_cpu *cpu;
|
2021-10-11 17:29:45 +02:00
|
|
|
|
2021-10-18 12:47:51 +02:00
|
|
|
struct ovni_chan **update_list;
|
2021-10-11 12:29:12 +02:00
|
|
|
|
2021-10-18 12:47:51 +02:00
|
|
|
/* Used when the channel is a list */
|
|
|
|
struct ovni_chan *prev;
|
|
|
|
struct ovni_chan *next;
|
2021-10-21 16:08:03 +02:00
|
|
|
};
|
|
|
|
|
2021-10-11 12:42:37 +02:00
|
|
|
#define MAX_BURSTS 100
|
|
|
|
|
2021-07-28 11:56:35 +02:00
|
|
|
/* State of each emulated thread */
|
|
|
|
struct ovni_ethread {
|
|
|
|
/* Emulated thread tid */
|
|
|
|
pid_t tid;
|
|
|
|
|
2021-08-02 10:08:58 +02:00
|
|
|
int index;
|
|
|
|
int gindex;
|
|
|
|
|
|
|
|
/* The process associated with this thread */
|
|
|
|
struct ovni_eproc *proc;
|
|
|
|
|
2021-07-30 20:08:40 +02:00
|
|
|
/* Stream fd */
|
|
|
|
int stream_fd;
|
2021-07-28 11:56:35 +02:00
|
|
|
|
|
|
|
enum ethread_state state;
|
2021-10-18 12:47:51 +02:00
|
|
|
int is_running;
|
|
|
|
int is_active;
|
2021-07-28 11:56:35 +02:00
|
|
|
|
|
|
|
/* Thread stream */
|
|
|
|
struct ovni_stream *stream;
|
|
|
|
|
|
|
|
/* Current cpu */
|
|
|
|
struct ovni_cpu *cpu;
|
2021-07-29 17:46:25 +02:00
|
|
|
|
|
|
|
/* FIXME: Use a table with registrable pointers to custom data
|
|
|
|
* structures */
|
|
|
|
|
|
|
|
/* nosv task */
|
|
|
|
struct nosv_task *task;
|
2021-09-27 17:42:14 +02:00
|
|
|
|
2021-10-21 16:15:29 +02:00
|
|
|
/* Channels are used to output the emulator state in PRV */
|
|
|
|
struct ovni_chan chan[CHAN_MAX];
|
2021-10-11 12:42:37 +02:00
|
|
|
|
|
|
|
/* Burst times */
|
|
|
|
int nbursts;
|
|
|
|
int64_t burst_time[MAX_BURSTS];
|
2021-11-18 17:05:37 +01:00
|
|
|
|
|
|
|
/* These pointers keep a linked list of threads in each CPU */
|
|
|
|
struct ovni_ethread *prev;
|
|
|
|
struct ovni_ethread *next;
|
2021-07-28 11:56:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* State of each emulated process */
|
|
|
|
struct ovni_eproc {
|
2021-07-30 21:37:25 +02:00
|
|
|
int pid;
|
2021-08-02 10:08:58 +02:00
|
|
|
int index;
|
|
|
|
int gindex;
|
2021-08-03 18:42:56 +02:00
|
|
|
int appid;
|
2021-07-28 11:56:35 +02:00
|
|
|
|
2021-10-14 09:06:11 +02:00
|
|
|
/* The loom of the current process */
|
|
|
|
struct ovni_loom *loom;
|
|
|
|
|
2021-07-28 11:56:35 +02:00
|
|
|
/* Path of the process tracedir */
|
|
|
|
char dir[PATH_MAX];
|
|
|
|
|
|
|
|
/* Threads */
|
|
|
|
size_t nthreads;
|
2021-11-18 16:20:20 +01:00
|
|
|
struct ovni_ethread *thread;
|
2021-07-30 21:37:25 +02:00
|
|
|
|
2021-08-03 17:48:37 +02:00
|
|
|
JSON_Value *meta;
|
|
|
|
|
2021-07-30 21:37:25 +02:00
|
|
|
/* ------ Subsystem specific data --------*/
|
|
|
|
/* TODO: Use dynamic allocation */
|
|
|
|
|
|
|
|
struct nosv_task_type *types;
|
|
|
|
struct nosv_task *tasks;
|
|
|
|
|
2021-07-28 11:56:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------ emulation ---------------- */
|
|
|
|
|
|
|
|
enum ovni_cpu_type {
|
|
|
|
CPU_REAL,
|
|
|
|
CPU_VIRTUAL,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ovni_cpu_state {
|
|
|
|
CPU_ST_UNKNOWN,
|
|
|
|
CPU_ST_READY,
|
|
|
|
};
|
|
|
|
|
2021-10-11 11:12:26 +02:00
|
|
|
#define MAX_CPU_NAME 32
|
|
|
|
|
2021-07-28 11:56:35 +02:00
|
|
|
struct ovni_cpu {
|
2021-08-02 18:15:59 +02:00
|
|
|
/* Logical index: 0 to ncpus - 1 */
|
|
|
|
int i;
|
2021-07-28 11:56:35 +02:00
|
|
|
|
2021-08-02 18:15:59 +02:00
|
|
|
/* Physical id: as reported by lscpu(1) */
|
|
|
|
int phyid;
|
2021-07-28 11:56:35 +02:00
|
|
|
|
2021-08-02 21:13:03 +02:00
|
|
|
/* Global index for all CPUs */
|
|
|
|
int gindex;
|
|
|
|
|
2021-07-28 11:56:35 +02:00
|
|
|
enum ovni_cpu_state state;
|
|
|
|
|
2021-10-14 09:08:07 +02:00
|
|
|
/* The loom of the CPU */
|
|
|
|
struct ovni_loom *loom;
|
|
|
|
|
2021-10-21 16:42:46 +02:00
|
|
|
/* CPU channels */
|
|
|
|
struct ovni_chan chan[CHAN_MAX];
|
|
|
|
|
2021-10-19 10:09:33 +02:00
|
|
|
/* The threads assigned to this CPU */
|
2021-07-28 11:56:35 +02:00
|
|
|
size_t nthreads;
|
2021-11-18 17:05:37 +01:00
|
|
|
struct ovni_ethread *thread;
|
2021-10-11 11:12:26 +02:00
|
|
|
|
2021-10-19 10:09:33 +02:00
|
|
|
/* Running threads */
|
2021-10-18 12:47:51 +02:00
|
|
|
size_t nrunning_threads;
|
|
|
|
struct ovni_ethread *th_running;
|
|
|
|
|
2021-10-19 10:09:33 +02:00
|
|
|
/* Active threads (not paused or dead) */
|
2021-10-18 12:47:51 +02:00
|
|
|
size_t nactive_threads;
|
|
|
|
struct ovni_ethread *th_active;
|
|
|
|
|
2021-10-11 11:12:26 +02:00
|
|
|
/* Cpu name as shown in paraver row */
|
|
|
|
char name[MAX_CPU_NAME];
|
2021-11-29 11:02:54 +01:00
|
|
|
|
|
|
|
/* Is this a virtual CPU? */
|
|
|
|
int virtual;
|
2021-07-28 11:56:35 +02:00
|
|
|
};
|
|
|
|
|
2021-08-02 21:13:03 +02:00
|
|
|
/* ----------------------- trace ------------------------ */
|
|
|
|
|
|
|
|
/* State of each loom on post-process */
|
|
|
|
struct ovni_loom {
|
|
|
|
size_t nprocs;
|
2021-08-10 10:16:41 +02:00
|
|
|
char hostname[OVNI_MAX_HOSTNAME];
|
2021-07-28 11:56:35 +02:00
|
|
|
|
2021-10-18 12:47:51 +02:00
|
|
|
size_t max_ncpus;
|
|
|
|
size_t max_phyid;
|
|
|
|
size_t ncpus;
|
|
|
|
size_t offset_ncpus;
|
2021-11-18 18:27:28 +01:00
|
|
|
struct ovni_cpu *cpu;
|
2021-07-28 11:56:35 +02:00
|
|
|
|
2021-08-03 19:56:31 +02:00
|
|
|
int64_t clock_offset;
|
|
|
|
|
2021-07-28 11:56:35 +02:00
|
|
|
/* Virtual CPU */
|
|
|
|
struct ovni_cpu vcpu;
|
|
|
|
|
2021-11-18 15:53:10 +01:00
|
|
|
struct ovni_eproc *proc;
|
2021-08-02 21:13:03 +02:00
|
|
|
};
|
|
|
|
|
2021-09-27 17:42:14 +02:00
|
|
|
#define MAX_VIRTUAL_EVENTS 16
|
|
|
|
|
2021-08-02 21:13:03 +02:00
|
|
|
struct ovni_trace {
|
2021-10-18 12:47:51 +02:00
|
|
|
size_t nlooms;
|
2021-11-18 14:05:19 +01:00
|
|
|
struct ovni_loom *loom;
|
2021-09-27 17:42:14 +02:00
|
|
|
|
2021-10-18 12:47:51 +02:00
|
|
|
size_t nstreams;
|
2021-08-02 21:13:03 +02:00
|
|
|
struct ovni_stream *stream;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ovni_stream {
|
|
|
|
uint8_t *buf;
|
|
|
|
size_t size;
|
|
|
|
size_t offset;
|
|
|
|
|
|
|
|
int tid;
|
|
|
|
int thread;
|
|
|
|
int proc;
|
|
|
|
int loom;
|
|
|
|
int loaded;
|
|
|
|
int active;
|
2021-10-18 12:47:51 +02:00
|
|
|
|
|
|
|
double progress;
|
|
|
|
|
2021-08-02 21:13:03 +02:00
|
|
|
struct ovni_ev *cur_ev;
|
2021-10-18 12:47:51 +02:00
|
|
|
int64_t lastclock;
|
2021-08-03 19:56:31 +02:00
|
|
|
int64_t clock_offset;
|
2021-10-18 12:47:51 +02:00
|
|
|
|
|
|
|
heap_node_t hh;
|
2021-08-02 21:13:03 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ovni_emu {
|
|
|
|
struct ovni_trace trace;
|
|
|
|
|
2021-07-28 11:56:35 +02:00
|
|
|
struct ovni_stream *cur_stream;
|
|
|
|
struct ovni_ev *cur_ev;
|
|
|
|
|
|
|
|
struct ovni_loom *cur_loom;
|
|
|
|
struct ovni_eproc *cur_proc;
|
|
|
|
struct ovni_ethread *cur_thread;
|
|
|
|
|
2021-10-21 16:34:04 +02:00
|
|
|
/* Indexed by gindex */
|
|
|
|
struct ovni_ethread **global_thread;
|
|
|
|
struct ovni_cpu **global_cpu;
|
|
|
|
|
2021-08-02 21:13:03 +02:00
|
|
|
struct nosv_task *cur_task;
|
|
|
|
|
2021-10-18 12:47:51 +02:00
|
|
|
/* Global processed size and offset of all streams */
|
|
|
|
size_t global_size;
|
|
|
|
size_t global_offset;
|
|
|
|
double start_emulation_time;
|
|
|
|
|
2021-08-03 19:56:31 +02:00
|
|
|
int64_t firstclock;
|
|
|
|
int64_t lastclock;
|
2021-07-29 17:46:25 +02:00
|
|
|
int64_t delta_time;
|
|
|
|
|
2021-10-18 12:47:51 +02:00
|
|
|
/* Counters for statistics */
|
|
|
|
int64_t nev_processed;
|
|
|
|
|
2021-11-08 17:06:17 +01:00
|
|
|
/* Be strict */
|
|
|
|
int enable_linter;
|
|
|
|
|
2021-08-03 18:42:56 +02:00
|
|
|
FILE *prv_thread;
|
|
|
|
FILE *prv_cpu;
|
2021-08-03 20:47:02 +02:00
|
|
|
FILE *pcf_thread;
|
|
|
|
FILE *pcf_cpu;
|
2021-08-03 18:42:56 +02:00
|
|
|
|
2021-08-03 19:56:31 +02:00
|
|
|
char *clock_offset_file;
|
|
|
|
char *tracedir;
|
|
|
|
|
2021-08-02 10:08:58 +02:00
|
|
|
/* Total counters */
|
2021-10-18 12:47:51 +02:00
|
|
|
size_t total_nthreads;
|
|
|
|
size_t total_proc;
|
|
|
|
size_t total_ncpus;
|
|
|
|
|
|
|
|
/* Keep a list of dirty channels for the CPUs and threads */
|
|
|
|
struct ovni_chan *cpu_chan;
|
|
|
|
struct ovni_chan *th_chan;
|
|
|
|
|
|
|
|
heap_head_t sorted_stream;
|
2021-07-28 11:56:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Emulator function declaration */
|
|
|
|
|
2021-10-21 16:46:42 +02:00
|
|
|
void hook_init_ovni(struct ovni_emu *emu);
|
2021-07-28 19:12:20 +02:00
|
|
|
void hook_pre_ovni(struct ovni_emu *emu);
|
2021-07-28 11:56:35 +02:00
|
|
|
|
2021-10-21 16:46:42 +02:00
|
|
|
void hook_init_nosv(struct ovni_emu *emu);
|
2021-07-29 17:46:25 +02:00
|
|
|
void hook_pre_nosv(struct ovni_emu *emu);
|
|
|
|
|
2021-10-11 17:29:45 +02:00
|
|
|
void hook_init_tampi(struct ovni_emu *emu);
|
|
|
|
void hook_pre_tampi(struct ovni_emu *emu);
|
|
|
|
|
2021-10-11 12:29:12 +02:00
|
|
|
void hook_init_openmp(struct ovni_emu *emu);
|
|
|
|
void hook_pre_openmp(struct ovni_emu *emu);
|
|
|
|
|
2021-11-12 11:06:34 +01:00
|
|
|
void hook_init_nanos6(struct ovni_emu *emu);
|
|
|
|
void hook_pre_nanos6(struct ovni_emu *emu);
|
2021-10-25 16:57:31 +02:00
|
|
|
|
2021-08-02 21:13:03 +02:00
|
|
|
struct ovni_cpu *emu_get_cpu(struct ovni_loom *loom, int cpuid);
|
2021-07-28 11:56:35 +02:00
|
|
|
|
2021-09-20 15:42:45 +02:00
|
|
|
struct ovni_ethread *emu_get_thread(struct ovni_eproc *proc, int tid);
|
2021-07-28 11:56:35 +02:00
|
|
|
|
2021-10-18 12:47:51 +02:00
|
|
|
void emu_cpu_update_chan(struct ovni_cpu *cpu, struct ovni_chan *cpu_chan);
|
2021-07-30 21:37:25 +02:00
|
|
|
|
2021-07-28 11:56:35 +02:00
|
|
|
#endif /* OVNI_EMU_H */
|