aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2026-07-07 23:30:52 +0200
committerPaul Oliver <contact@pauloliver.dev>2026-07-20 04:00:10 +0200
commita61a742245d429b8d085208e249bb3bc80e44fb6 (patch)
treebfa44c45de28f9890e15c5ef98ae8d1cec6e36a9
parent55928b51596de4cd1b7a2783529ecda3ff3087ce (diff)
data-tests (WIP)more_tests
-rw-r--r--arch/null/arch.c4
-rw-r--r--arch/v1/arch.c3
-rw-r--r--core/salis.c118
-rw-r--r--core/server.c2
-rwxr-xr-xsalis.py15
-rw-r--r--test/anc/v1/datat.asm12
-rw-r--r--test/test_build.py30
-rw-r--r--test/test_data_v1.py89
-rw-r--r--test/test_general.py12
-rw-r--r--test/test_run.py30
-rw-r--r--test/test_v1.py28
-rw-r--r--test/ui/push/ui.c101
-rw-r--r--test/ui/push/vars.py2
13 files changed, 345 insertions, 101 deletions
diff --git a/arch/null/arch.c b/arch/null/arch.c
index 7dd521e..2abbe2f 100644
--- a/arch/null/arch.c
+++ b/arch/null/arch.c
@@ -152,6 +152,10 @@ void arch_push_data_header(void) {
}
#endif
+void arch_prepare_data_line(void) {
+ assert(g_sim_db);
+}
+
void arch_push_data_line(FILE *eva_file) {
assert(g_sim_db);
assert(eva_file);
diff --git a/arch/v1/arch.c b/arch/v1/arch.c
index 1501b42..20f9801 100644
--- a/arch/v1/arch.c
+++ b/arch/v1/arch.c
@@ -900,6 +900,9 @@ void arch_push_data_header(void) {
}
#endif
+void arch_prepare_data_line(void) {
+}
+
void arch_push_data_line(FILE *eva_file) {
assert(g_sim_db);
assert(eva_file);
diff --git a/core/salis.c b/core/salis.c
index b7c904b..6f7ffe5 100644
--- a/core/salis.c
+++ b/core/salis.c
@@ -72,12 +72,17 @@ struct Core {
uint64_t *ivav;
uint8_t *iviv;
+ uint64_t amb0; // average size of main memory blocks (rounded)
+ uint64_t amb1; // average size of child memory blocks (rounded)
+
uint64_t emb0; // executions within mb0 counter
uint64_t emb1; // executions within mb1 counter
uint64_t eliv; // executions within not-owned live code counter (parasites)
uint64_t edea; // executions within dead code counter
-#define EVENT_ARRAY(core, index, ev) uint64_t ev##a[MVEC_SIZE];
+#define EVENT_ARRAY(core, index, ev) \
+ uint64_t ev##_blob_size; \
+ uint64_t ev##a[MVEC_SIZE];
EVENT_ARRAYS(core)
#undef EVENT_ARRAY
@@ -147,6 +152,7 @@ const char *arch_mnemonic(uint8_t inst);
#if defined(COMMAND_NEW)
void arch_push_data_header(void);
#endif
+void arch_prepare_data_line(void);
void arch_push_data_line(FILE *eva_file);
// ----------------------------------------------------------------------------
@@ -738,8 +744,8 @@ void salis_push_data_header(void) {
"pnum_" #i " int not null, " \
"pfst_" #i " int not null, " \
"plst_" #i " int not null, " \
- "amb0_" #i " real not null, " \
- "amb1_" #i " real not null, " \
+ "amb0_" #i " int not null, " \
+ "amb1_" #i " int not null, " \
"emb0_" #i " int not null, " \
"emb1_" #i " int not null, " \
"eliv_" #i " int not null, " \
@@ -756,29 +762,46 @@ void salis_push_data_header(void) {
}
#endif
-void salis_push_data_line(void) {
- assert(g_sim_db);
+void salis_prepare_data_line(void) {
+ log_info("Preparing data-line for next push");
// Measure average membory block sizes
- double amb0[CORES] = { 0 };
- double amb1[CORES] = { 0 };
-
for (int i = 0; i < CORES; ++i) {
struct Core *core = &g_cores[i];
+ double amb0 = 0.;
+ double amb1 = 0.;
for (uint64_t j = core->pfst; j <= core->plst; ++j) {
- amb0[i] += (double)arch_proc_mb0_size(core, j);
- amb1[i] += (double)arch_proc_mb1_size(core, j);
+ amb0 += (double)arch_proc_mb0_size(core, j);
+ amb1 += (double)arch_proc_mb1_size(core, j);
}
- amb0[i] /= core->pnum;
- amb1[i] /= core->pnum;
+ core->amb0 = (uint64_t)(amb0 / (double)core->pnum);
+ core->amb1 = (uint64_t)(amb1 / (double)core->pnum);
}
+}
+
+void salis_push_data_line(void) {
+ assert(g_sim_db);
// Compress event arrays
// Compression (deflation) is CPU intensive so it's done in parallel
memset(&g_eva_deflate_params, 0, sizeof(struct DeflateParams) * CORES * EVENT_ARRAYS_COUNT);
- uint64_t blob_sizes[CORES][EVENT_ARRAYS_COUNT];
+
+ int rem = snprintf(
+ g_eva_pbuf,
+ EVA_SAVE_NAME_LEN,
+ "%s/evas-%016lx",
+ SIM_EVAS,
+ g_steps
+ );
+
+ assert(rem >= 0);
+ assert(rem < EVA_SAVE_NAME_LEN);
+ (void)rem;
+
+ log_info("Saving event-array data to file: %s", g_eva_pbuf);
+ FILE *eva_file = fopen(g_eva_pbuf, "wb");
for (int i = 0; i < CORES; ++i) {
for (int j = 0; j < EVENT_ARRAYS_COUNT; ++j) {
@@ -801,27 +824,22 @@ void salis_push_data_line(void) {
}
}
- int rem = snprintf(
- g_eva_pbuf,
- EVA_SAVE_NAME_LEN,
- "%s/evas-%016lx",
- SIM_EDIR,
- g_steps
- );
-
- assert(rem >= 0);
- assert(rem < EVA_SAVE_NAME_LEN);
- (void)rem;
-
- log_info("Saving event-array data to file: %s", g_eva_pbuf);
- FILE *eva_file = fopen(g_eva_pbuf, "wb");
-
for (int i = 0; i < CORES; ++i) {
for (int j = 0; j < EVENT_ARRAYS_COUNT; ++j) {
+ uint64_t *blob_size = NULL;
+
+ switch (j) {
+#define EVENT_ARRAY(core, index, ev) \
+ case index: blob_size = &g_cores[i].ev##_blob_size; break;
+ EVENT_ARRAYS(core)
+#undef EVENT_ARRAY
+ default: assert(false);
+ }
+
thrd_join(g_eva_thrds[i][j], NULL);
struct DeflateParams *params = &g_eva_deflate_params[i][j];
- blob_sizes[i][j] = params->strm.total_out;
- fwrite(params->out, sizeof(char), blob_sizes[i][j], eva_file);
+ *blob_size = params->strm.total_out;
+ if (eva_file) fwrite(params->out, sizeof(char), *blob_size, eva_file);
comp_deflate_end(params);
free(params->out);
}
@@ -859,8 +877,8 @@ void salis_push_data_line(void) {
"%ld, " \
"%ld, " \
"%ld, " \
- "%f, " \
- "%f, " \
+ "%ld, " \
+ "%ld, " \
"%ld, " \
"%ld, " \
"%ld, " \
@@ -872,15 +890,15 @@ void salis_push_data_line(void) {
"%ld"
");",
#define EVENT_ARRAY(core, index, ev) \
- blob_sizes[core][index],
+ g_cores[core].ev##_blob_size,
#define FOR_CORE(i) \
g_cores[i].cycl, \
g_cores[i].mall, \
g_cores[i].pnum, \
g_cores[i].pfst, \
g_cores[i].plst, \
- amb0[i], \
- amb1[i], \
+ g_cores[i].amb0, \
+ g_cores[i].amb1, \
g_cores[i].emb0, \
g_cores[i].emb1, \
g_cores[i].eliv, \
@@ -896,12 +914,16 @@ void salis_push_data_line(void) {
for (int i = 0; i < CORES; ++i) {
struct Core *core = &g_cores[i];
+ core->amb0 = 0;
+ core->amb1 = 0;
+
core->emb0 = 0;
core->emb1 = 0;
core->eliv = 0;
core->edea = 0;
#define EVENT_ARRAY(core, index, ev) \
+ core->ev##_blob_size = 0; \
memset(core->ev##a, 0, EVENT_ARRAYS_SIZE);
EVENT_ARRAYS(core)
#undef EVENT_ARRAY
@@ -920,14 +942,10 @@ void salis_init(void) {
core_init(&g_cores[i], &seed);
}
-#if defined(COMMAND_NEW)
- salis_auto_save();
-#endif
-
// Initialize database
sql_open();
salis_push_data_header();
- salis_push_data_line();
+ salis_prepare_data_line();
}
#endif
@@ -1036,6 +1054,18 @@ void salis_sync(void) {
void salis_loop(uint64_t ns, uint64_t dt) {
assert(dt);
+ if (ns) {
+#if defined(COMMAND_NEW) || defined(COMMAND_LOAD)
+ if (g_steps % AUTOSAVE_INTERVAL == 0) {
+ salis_auto_save();
+ }
+#endif
+
+ if (g_steps % DATA_PUSH_INTERVAL == 0) {
+ salis_push_data_line();
+ }
+ }
+
if (ns < dt) {
salis_run_thread(ns);
return;
@@ -1044,14 +1074,8 @@ void salis_loop(uint64_t ns, uint64_t dt) {
salis_run_thread(dt);
salis_sync();
-#if defined(COMMAND_NEW) || defined(COMMAND_LOAD)
- if (g_steps % AUTOSAVE_INTERVAL == 0) {
- salis_auto_save();
- }
-#endif
-
if (g_steps % DATA_PUSH_INTERVAL == 0) {
- salis_push_data_line();
+ salis_prepare_data_line();
}
salis_loop(ns - dt, SYNC_INTERVAL);
diff --git a/core/server.c b/core/server.c
index aceaee4..615020e 100644
--- a/core/server.c
+++ b/core/server.c
@@ -167,7 +167,7 @@ void sql_callback_add_data(sqlite3_stmt *sql_stmt, void *data) {
g_eva_pbuf,
EVA_SAVE_NAME_LEN,
"%s/evas-%016lx",
- SIM_EDIR,
+ SIM_EVAS,
col_value
);
diff --git a/salis.py b/salis.py
index de4f75d..ba17643 100755
--- a/salis.py
+++ b/salis.py
@@ -220,7 +220,7 @@ ns = SimpleNamespace()
def gen_sim_paths():
ns.sim_dir = os.path.join(args.home, args.name)
- ns.sim_edir = os.path.join(ns.sim_dir, "evas")
+ ns.sim_evas = os.path.join(ns.sim_dir, "evas")
ns.sim_opts = os.path.join(ns.sim_dir, "opts.json")
ns.sim_path = os.path.join(ns.sim_dir, args.name)
@@ -262,10 +262,10 @@ if args.command == "new":
log.info(f"Using random seed: {hex(args.seed)}")
log.info(f"Creating new simulation directory at: {ns.sim_dir}")
- log.info(f"Creating new event-array storage directory at: {ns.sim_edir}")
+ log.info(f"Creating new event-array storage directory at: {ns.sim_evas}")
log.info(f"Creating configuration file at: {ns.sim_opts}")
os.mkdir(ns.sim_dir)
- os.mkdir(ns.sim_edir)
+ os.mkdir(ns.sim_evas)
opts = {fmt_h2u(name[1]): getattr(args, fmt_h2u(name[1])) for (name, sub_parsers, _), kwargs in options.items() if new in sub_parsers and load not in sub_parsers}
@@ -369,7 +369,8 @@ def pop_data_push_vars():
ns.b.links.add("-lz")
def pop_sim_path_vars():
- ns.b.defines.add(f"-DSIM_EDIR=\"{ns.sim_edir}\"")
+ ns.b.defines.add(f"-DSIM_DIR=\"{ns.sim_dir}\"")
+ ns.b.defines.add(f"-DSIM_EVAS=\"{ns.sim_evas}\"")
ns.b.defines.add(f"-DSIM_OPTS=\"{ns.sim_opts}\"")
ns.b.defines.add(f"-DSIM_PATH=\"{ns.sim_path}\"")
@@ -420,7 +421,7 @@ if args.command == "new":
pop_general()
ns.b.defines.add(f"-DAUTOSAVE_NAME_LEN={len(ns.sim_path) + 18}")
- ns.b.defines.add(f"-DEVA_SAVE_NAME_LEN={len(ns.sim_edir) + 23}")
+ ns.b.defines.add(f"-DEVA_SAVE_NAME_LEN={len(ns.sim_evas) + 23}")
ns.b.defines.add(f"-DTHREAD_GAP={args.thread_gap}")
# Populate for load
@@ -432,7 +433,7 @@ if args.command == "load":
pop_general()
ns.b.defines.add(f"-DAUTOSAVE_NAME_LEN={len(ns.sim_path) + 18}")
- ns.b.defines.add(f"-DEVA_SAVE_NAME_LEN={len(ns.sim_edir) + 23}")
+ ns.b.defines.add(f"-DEVA_SAVE_NAME_LEN={len(ns.sim_evas) + 23}")
ns.b.defines.add(f"-DTHREAD_GAP={args.thread_gap}")
# Populate for server
@@ -443,7 +444,7 @@ if args.command == "server":
pop_net_vars()
pop_general()
- ns.b.defines.add(f"-DEVA_SAVE_NAME_LEN={len(ns.sim_edir) + 23}")
+ ns.b.defines.add(f"-DEVA_SAVE_NAME_LEN={len(ns.sim_evas) + 23}")
# Populate for client
if args.command == "client":
diff --git a/test/anc/v1/datat.asm b/test/anc/v1/datat.asm
new file mode 100644
index 0000000..d727627
--- /dev/null
+++ b/test/anc/v1/datat.asm
@@ -0,0 +1,12 @@
+incn
+shfl
+shfl
+allf
+load
+wrte
+bswp
+bswp
+splt
+loka
+jmpb
+keya
diff --git a/test/test_build.py b/test/test_build.py
index ec23390..96da14e 100644
--- a/test/test_build.py
+++ b/test/test_build.py
@@ -3,12 +3,12 @@ import signal
from test_general import SalisTest
-class TestBuild(SalisTest):
- NAME = "test-build.sim"
+SIM_NAME = "test-build.sim"
+class TestBuild(SalisTest):
def cmds_new(self, anc, arch):
return (
- f"./salis.py new -a{anc} -b -f -g{compiler} -H{self.tempdir.name} -n{TestBuild.NAME} {optimized} -s{seed} -u{ui} -v{arch}"
+ f"./salis.py new -a{anc} -b -f -g{compiler} -H{self.tempdir.name} -n{SIM_NAME} {optimized} -s{seed} -u{ui} -v{arch}"
for compiler in ["clang", "gcc"]
for optimized in ["", "-o"]
for seed in [-1, 0, 1234]
@@ -23,7 +23,7 @@ class TestBuild(SalisTest):
def cmds_load(self):
return (
- f"./salis.py load -b -g{compiler} -H{self.tempdir.name} -n{TestBuild.NAME} {optimized} -u{ui}"
+ f"./salis.py load -b -g{compiler} -H{self.tempdir.name} -n{SIM_NAME} {optimized} -u{ui}"
for compiler in ["clang", "gcc"]
for optimized in ["", "-o"]
for ui in ["curses", "daemon"]
@@ -31,7 +31,7 @@ class TestBuild(SalisTest):
def cmds_server(self):
return (
- f"./salis.py server -b -g{compiler} -H{self.tempdir.name} -n{TestBuild.NAME} {optimized}"
+ f"./salis.py server -b -g{compiler} -H{self.tempdir.name} -n{SIM_NAME} {optimized}"
for compiler in ["clang", "gcc"]
for optimized in ["", "-o"]
)
@@ -44,44 +44,44 @@ class TestBuild(SalisTest):
for optimized in ["", "-o"]
)
- def file_list(self):
+ def files_on_build(self):
return [
- os.path.join(self.tempdir.name, TestBuild.NAME, "opts.json"),
+ os.path.join(self.tempdir.name, SIM_NAME, "opts.json"),
]
def test_null_new(self):
for cmd in self.cmds_new_null():
SalisTest.run_subprocess(cmd)
- self.assert_file_list_exists(self.file_list())
+ self.assert_file_list_exists(self.files_on_build())
def test_v1_new(self):
for cmd in self.cmds_new_v1():
SalisTest.run_subprocess(cmd)
- self.assert_file_list_exists(self.file_list())
+ self.assert_file_list_exists(self.files_on_build())
def test_null_load(self):
SalisTest.run_subprocess(next(self.cmds_new_null()))
- self.assert_file_list_exists(self.file_list())
+ self.assert_file_list_exists(self.files_on_build())
for cmd in self.cmds_load():
SalisTest.run_subprocess(cmd)
- self.assert_file_list_exists(self.file_list())
+ self.assert_file_list_exists(self.files_on_build())
def test_v1_load(self):
SalisTest.run_subprocess(next(self.cmds_new_v1()))
- self.assert_file_list_exists(self.file_list())
+ self.assert_file_list_exists(self.files_on_build())
for cmd in self.cmds_load():
SalisTest.run_subprocess(cmd)
- self.assert_file_list_exists(self.file_list())
+ self.assert_file_list_exists(self.files_on_build())
def test_server(self):
SalisTest.run_subprocess(next(self.cmds_new_null()))
- self.assert_file_list_exists(self.file_list())
+ self.assert_file_list_exists(self.files_on_build())
for cmd in self.cmds_server():
SalisTest.run_subprocess(cmd)
- self.assert_file_list_exists(self.file_list())
+ self.assert_file_list_exists(self.files_on_build())
@SalisTest.run_ui_test(anc="0123", anc_path="anc", name="def.sim", ui="null", ui_path="test/ui", vm_arch="null")
def test_client(self):
diff --git a/test/test_data_v1.py b/test/test_data_v1.py
new file mode 100644
index 0000000..ed933e8
--- /dev/null
+++ b/test/test_data_v1.py
@@ -0,0 +1,89 @@
+import json
+import os
+import signal
+import socket
+import subprocess
+
+from test_general import SalisTest
+
+ANC_SIZE = 12
+
+SERVER_HOST = "localhost"
+SERVER_PORT = 8080
+
+SIM_NAME = "def.sim"
+SIM_OPTS = {
+ "anc": "datat",
+ "anc_path": "test/anc",
+ "clones": 2,
+ "cores": 1,
+ "data_push_pow": 12,
+ "force": False,
+ "muta_pow": 32,
+ "mvec_pow": 8,
+ "seed": "0x0",
+ "vm_arch": "v1",
+ "sync_pow": 10,
+ "auto_save_pow": 36,
+}
+
+class TestDataV1(SalisTest):
+ def request_from_server(self, request):
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as client:
+ client.connect((SERVER_HOST, SERVER_PORT))
+ client.sendall(json.dumps(request).encode())
+ client.shutdown(socket.SHUT_WR)
+ return json.load(client.makefile(mode="r"))
+
+ @SalisTest.run_ui_test(**SIM_OPTS, name=SIM_NAME, ui="push", ui_path="test/ui")
+ def test_data_flow(self):
+ with SalisTest.run_pipe(f"./salis.py server -H{self.tempdir.name}") as server_proc:
+ for line in server_proc.stdout:
+ if "Listening..." in line:
+ break
+
+ try:
+ self.assert_equal(self.request_from_server({"request": "name"})["name"], "def.sim")
+ self.assert_equal(self.request_from_server({"request": "hash"})["hash"], subprocess.check_output("git rev-parse HEAD".split()).decode().strip())
+ self.assert_equal(self.request_from_server({"request": "opts"}), SIM_OPTS)
+
+ data = self.request_from_server({
+ "request": "data",
+ "x-axis": "rowid",
+ "x-current": 0,
+ "x-high": 2,
+ "nth": 1,
+ "entries": 2,
+ "hm-left": 0,
+ "hm-pixel-count": 2 ** SIM_OPTS["mvec_pow"],
+ "hm-pixel-pow": 0,
+ })
+
+ with open(os.path.join(self.tempdir.name, SIM_NAME, "outputs.json"), "r") as f:
+ outputs = json.load(f)
+
+ # Check scalar values
+ #self.assert_equal(data["rowid"], [1, 2])
+ #self.assert_equal(data["cycl_0"], [0, 923])
+ #self.assert_equal(data["mall_0"], [ANC_SIZE * 2, (ANC_SIZE * 2) + 12])
+ #self.assert_equal(data["pnum_0"], [2, 5])
+ #self.assert_equal(data["pfst_0"], [0, 0])
+ #self.assert_equal(data["plst_0"], [1, 4])
+ #self.assert_equal(data["amb0_0"], [ANC_SIZE, ((ANC_SIZE * 2) + (4 * 3)) // 5])
+ #self.assert_equal(data["amb1_0"], [0, 0])
+ #self.assert_equal(data["emb0_0"], [0, 1872])
+ #self.assert_equal(data["emb1_0"], [0, 2])
+ #self.assert_equal(data["eliv_0"], [0, 1894])
+ #self.assert_equal(data["edea_0"], [0, 328])
+ #self.assert_equal(data["wmb0_0"], [0, 1])
+ #self.assert_equal(data["wmb1_0"], [0, 0])
+ #self.assert_equal(data["wdea_0"], [0, 0])
+
+ #self.assert_equal(data["step"], [0, 2 ** SIM_OPTS["data_push_pow"]])
+
+ print("\ndata ---->\n", json.dumps(data, sort_keys=True))
+ print("\noutputs ---->\n", json.dumps(outputs, sort_keys=True))
+
+ #self.assertDictEqual(data, outputs, "mismatch between server-data and ui outputs")
+ finally:
+ server_proc.send_signal(signal.SIGINT)
diff --git a/test/test_general.py b/test/test_general.py
index 43f3635..5c91ed8 100644
--- a/test/test_general.py
+++ b/test/test_general.py
@@ -7,11 +7,12 @@ from tempfile import TemporaryDirectory
class SalisTest(unittest.TestCase):
def setUp(self):
self.tempdir = TemporaryDirectory(prefix="salis_test_")
+ self.maxDiff = None
def tearDown(self):
self.tempdir.cleanup()
- def file_list_new(self, name):
+ def files_on_new(self, name):
return [
os.path.join(self.tempdir.name, name, name),
os.path.join(self.tempdir.name, name, f"{name}.sqlite3"),
@@ -20,6 +21,9 @@ class SalisTest(unittest.TestCase):
os.path.join(self.tempdir.name, name, "evas", f"evas-{0:016x}"),
]
+ def assert_equal(self, v1, v2):
+ assert v1 == v2, f"{v1} != {v2}"
+
def assert_file_list_exists(self, files):
for file in files:
assert os.path.isfile(file), f"{file} does not exist"
@@ -33,12 +37,12 @@ class SalisTest(unittest.TestCase):
return subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, text=True)
@staticmethod
- def run_ui_test(anc, anc_path, ui, ui_path, vm_arch, clones=1, cores=1, name="def.sim"):
+ def run_ui_test(anc, anc_path, ui, ui_path, vm_arch, clones=1, cores=1, mvec_pow=20, name="def.sim", data_push_pow=28, sync_pow=20, **kwargs):
def test_decorator(test_case):
def test_wrapper(self):
- cmd = f"./salis.py new -a{anc} -A{anc_path} -C{clones} -c{cores} -H{self.tempdir.name} -n{name} -u{ui} -U{ui_path} -v{vm_arch}"
+ cmd = f"./salis.py new -a{anc} -A{anc_path} -C{clones} -c{cores} -d{data_push_pow} -H{self.tempdir.name} -m{mvec_pow} -n{name} -u{ui} -U{ui_path} -v{vm_arch} -y{sync_pow}"
subprocess.run(cmd.split(), check=True, stdout=subprocess.DEVNULL)
- self.assert_file_list_exists(self.file_list_new(name))
+ self.assert_file_list_exists(self.files_on_new(name))
test_case(self)
return test_wrapper
diff --git a/test/test_run.py b/test/test_run.py
index 17bdca8..d164bb4 100644
--- a/test/test_run.py
+++ b/test/test_run.py
@@ -2,15 +2,15 @@ import os
from test_general import SalisTest
-class TestRun(SalisTest):
- NAME = "test-run.sim"
- PUSH_POW = 8
+SIM_NAME = "test-run.sim"
+PUSH_POW = 8
+class TestRun(SalisTest):
def cmds(self, anc, arch):
return (
(
- f"./salis.py new -a{anc} -d{TestRun.PUSH_POW} -f -g{compiler} -H{self.tempdir.name} -n{TestRun.NAME} {optimized} -s{seed} -upush -Utest/ui/ -v{arch} -y{TestRun.PUSH_POW}",
- f"./salis.py load -g{compiler} -H{self.tempdir.name} -n{TestRun.NAME} {optimized} -upush -Utest/ui/",
+ f"./salis.py new -a{anc} -d{PUSH_POW} -f -g{compiler} -H{self.tempdir.name} -n{SIM_NAME} {optimized} -s{seed} -upush -Utest/ui/ -v{arch} -y{PUSH_POW}",
+ f"./salis.py load -g{compiler} -H{self.tempdir.name} -n{SIM_NAME} {optimized} -upush -Utest/ui/",
)
for compiler in ["clang", "gcc"]
for optimized in ["", "-o"]
@@ -23,28 +23,28 @@ class TestRun(SalisTest):
def cmds_v1(self):
return self.cmds("55a", "v1")
- def file_list_0(self):
+ def files_on_first_push(self):
return [
- *self.file_list_new(TestRun.NAME),
- os.path.join(self.tempdir.name, TestRun.NAME, "evas", f"evas-{2 ** TestRun.PUSH_POW:016x}"),
+ *self.files_on_new(SIM_NAME),
+ os.path.join(self.tempdir.name, SIM_NAME, "evas", f"evas-{2 ** PUSH_POW:016x}"),
]
- def file_list_1(self):
+ def files_on_second_push(self):
return [
- *self.file_list_0(),
- os.path.join(self.tempdir.name, TestRun.NAME, "evas", f"evas-{2 * (2 ** TestRun.PUSH_POW):016x}"),
+ *self.files_on_first_push(),
+ os.path.join(self.tempdir.name, SIM_NAME, "evas", f"evas-{2 * (2 ** PUSH_POW):016x}"),
]
def test_null(self):
for cmd in self.cmds_null():
SalisTest.run_subprocess(cmd[0])
- self.assert_file_list_exists(self.file_list_0())
+ self.assert_file_list_exists(self.files_on_first_push())
SalisTest.run_subprocess(cmd[1])
- self.assert_file_list_exists(self.file_list_1())
+ self.assert_file_list_exists(self.files_on_second_push())
def test_v1(self):
for cmd in self.cmds_v1():
SalisTest.run_subprocess(cmd[0])
- self.assert_file_list_exists(self.file_list_0())
+ self.assert_file_list_exists(self.files_on_first_push())
SalisTest.run_subprocess(cmd[1])
- self.assert_file_list_exists(self.file_list_1())
+ self.assert_file_list_exists(self.files_on_second_push())
diff --git a/test/test_v1.py b/test/test_v1.py
index 783dc38..a54d390 100644
--- a/test/test_v1.py
+++ b/test/test_v1.py
@@ -1,46 +1,52 @@
from test_general import SalisTest
+SIM_OPTS = {
+ "anc_path": "test/anc",
+ "ui_path": "test/ui/v1",
+ "vm_arch": "v1",
+}
+
class TestV1(SalisTest):
- @SalisTest.run_ui_test(anc="noops", anc_path="test/anc", ui="noops", ui_path="test/ui/v1", vm_arch="v1")
+ @SalisTest.run_ui_test(**SIM_OPTS, anc="noops", ui="noops")
def test_noops(self):
pass
- @SalisTest.run_ui_test(anc="jumps", anc_path="test/anc", ui="jumps", ui_path="test/ui/v1", vm_arch="v1")
+ @SalisTest.run_ui_test(**SIM_OPTS, anc="jumps", ui="jumps")
def test_jumps(self):
pass
- @SalisTest.run_ui_test(anc="addrs", anc_path="test/anc", ui="addrs", ui_path="test/ui/v1", vm_arch="v1")
+ @SalisTest.run_ui_test(**SIM_OPTS, anc="addrs", ui="addrs")
def test_addrs(self):
pass
- @SalisTest.run_ui_test(anc="ifnzs", anc_path="test/anc", ui="ifnzs", ui_path="test/ui/v1", vm_arch="v1")
+ @SalisTest.run_ui_test(**SIM_OPTS, anc="ifnzs", ui="ifnzs")
def test_ifnzs(self):
pass
- @SalisTest.run_ui_test(anc="allos", anc_path="test/anc", ui="allos", ui_path="test/ui/v1", vm_arch="v1", clones=2)
+ @SalisTest.run_ui_test(**SIM_OPTS, anc="allos", ui="allos", clones=2)
def test_allos(self):
pass
- @SalisTest.run_ui_test(anc="mbops", anc_path="test/anc", ui="mbops", ui_path="test/ui/v1", vm_arch="v1")
+ @SalisTest.run_ui_test(**SIM_OPTS, anc="mbops", ui="mbops")
def test_mbops(self):
pass
- @SalisTest.run_ui_test(anc="3rops", anc_path="test/anc", ui="3rops", ui_path="test/ui/v1", vm_arch="v1")
+ @SalisTest.run_ui_test(**SIM_OPTS, anc="3rops", ui="3rops")
def test_3rops(self):
pass
- @SalisTest.run_ui_test(anc="1rops", anc_path="test/anc", ui="1rops", ui_path="test/ui/v1", vm_arch="v1")
+ @SalisTest.run_ui_test(**SIM_OPTS, anc="1rops", ui="1rops")
def test_1rops(self):
pass
- @SalisTest.run_ui_test(anc="stack", anc_path="test/anc", ui="stack", ui_path="test/ui/v1", vm_arch="v1")
+ @SalisTest.run_ui_test(**SIM_OPTS, anc="stack", ui="stack")
def test_stack(self):
pass
- @SalisTest.run_ui_test(anc="ioops", anc_path="test/anc", ui="ioops", ui_path="test/ui/v1", vm_arch="v1")
+ @SalisTest.run_ui_test(**SIM_OPTS, anc="ioops", ui="ioops")
def test_ioops(self):
pass
- @SalisTest.run_ui_test(anc="2rops", anc_path="test/anc", ui="2rops", ui_path="test/ui/v1", vm_arch="v1")
+ @SalisTest.run_ui_test(**SIM_OPTS, anc="2rops", ui="2rops")
def test_2rops(self):
pass
diff --git a/test/ui/push/ui.c b/test/ui/push/ui.c
index e345658..281f15b 100644
--- a/test/ui/push/ui.c
+++ b/test/ui/push/ui.c
@@ -1,10 +1,111 @@
+#include <json-c/json.h>
+
+#if CORES != 1
+#error
+#endif
+
+struct json_object *g_outputs;
+uint64_t g_rowid;
+
+void append_output(void) {
+ json_object_array_add(json_object_object_get(g_outputs, "rowid"), json_object_new_int64(++g_rowid));
+ json_object_array_add(json_object_object_get(g_outputs, "cycl_0"), json_object_new_int64(g_cores->cycl));
+ json_object_array_add(json_object_object_get(g_outputs, "mall_0"), json_object_new_int64(g_cores->mall));
+ json_object_array_add(json_object_object_get(g_outputs, "pnum_0"), json_object_new_int64(g_cores->pnum));
+ json_object_array_add(json_object_object_get(g_outputs, "pfst_0"), json_object_new_int64(g_cores->pfst));
+ json_object_array_add(json_object_object_get(g_outputs, "plst_0"), json_object_new_int64(g_cores->plst));
+ json_object_array_add(json_object_object_get(g_outputs, "amb0_0"), json_object_new_int64(g_cores->amb0));
+ json_object_array_add(json_object_object_get(g_outputs, "amb1_0"), json_object_new_int64(g_cores->amb1));
+ json_object_array_add(json_object_object_get(g_outputs, "emb0_0"), json_object_new_int64(g_cores->emb0));
+ json_object_array_add(json_object_object_get(g_outputs, "emb1_0"), json_object_new_int64(g_cores->emb1));
+ json_object_array_add(json_object_object_get(g_outputs, "eliv_0"), json_object_new_int64(g_cores->eliv));
+ json_object_array_add(json_object_object_get(g_outputs, "edea_0"), json_object_new_int64(g_cores->edea));
+ json_object_array_add(json_object_object_get(g_outputs, "wmb0_0"), json_object_new_int64(g_cores->wmb0));
+ json_object_array_add(json_object_object_get(g_outputs, "wmb1_0"), json_object_new_int64(g_cores->wmb1));
+ json_object_array_add(json_object_object_get(g_outputs, "wdea_0"), json_object_new_int64(g_cores->wdea));
+
+#define EVENT_ARRAY(core, index, ev) \
+ json_object_array_add(json_object_object_get(g_outputs, #ev EVENT_ARRAYS_SIZE_COL_MARKER #core), json_object_new_int64(g_cores[core].ev##_blob_size)); \
+ for (uint64_t i = 0; i < MVEC_SIZE; i++) { \
+ json_object_array_add(json_object_object_get(g_outputs, #ev "_" #core), json_object_new_int64(g_cores->ev##a[i])); \
+ }
+ EVENT_ARRAYS(0)
+#undef EVENT_ARRAY
+
+#define ARCH_EVENT_ARRAY(core, index, ev) \
+ json_object_array_add(json_object_object_get(g_outputs, #ev EVENT_ARRAYS_SIZE_COL_MARKER #core), json_object_new_int64(g_cores[core].ev##_blob_size)); \
+ for (uint64_t i = 0; i < MVEC_SIZE; i++) { \
+ json_object_array_add(json_object_object_get(g_outputs, #ev "_" #core), json_object_new_int64(g_cores->ev##a[i])); \
+ }
+ ARCH_EVENT_ARRAYS(0)
+#undef ARCH_EVENT_ARRAY
+
+#define INST(core, pref, index, label, mnemonic, symbol) \
+ json_object_array_add(json_object_object_get(g_outputs, #label "_" #pref "_" #core), json_object_new_int64(g_cores->i##pref[index]));
+#define INST_EVENT_ARRAY(core, index, iv) \
+ INST_SET(core, iv)
+ INST_EVENT_ARRAYS(0)
+#undef INST_EVENT_ARRAY
+#undef INST
+
+ json_object_array_add(json_object_object_get(g_outputs, "step"), json_object_new_int64(g_steps));
+}
+
int main(void) {
#if defined(COMMAND_NEW)
salis_init();
#elif defined(COMMAND_LOAD)
salis_load();
#endif
+
+ g_outputs = json_object_new_object();
+
+ json_object_object_add(g_outputs, "rowid", json_object_new_array());
+ json_object_object_add(g_outputs, "cycl_0", json_object_new_array());
+ json_object_object_add(g_outputs, "mall_0", json_object_new_array());
+ json_object_object_add(g_outputs, "pnum_0", json_object_new_array());
+ json_object_object_add(g_outputs, "pfst_0", json_object_new_array());
+ json_object_object_add(g_outputs, "plst_0", json_object_new_array());
+ json_object_object_add(g_outputs, "amb0_0", json_object_new_array());
+ json_object_object_add(g_outputs, "amb1_0", json_object_new_array());
+ json_object_object_add(g_outputs, "emb0_0", json_object_new_array());
+ json_object_object_add(g_outputs, "emb1_0", json_object_new_array());
+ json_object_object_add(g_outputs, "eliv_0", json_object_new_array());
+ json_object_object_add(g_outputs, "edea_0", json_object_new_array());
+ json_object_object_add(g_outputs, "wmb0_0", json_object_new_array());
+ json_object_object_add(g_outputs, "wmb1_0", json_object_new_array());
+ json_object_object_add(g_outputs, "wdea_0", json_object_new_array());
+
+#define EVENT_ARRAY(core, index, ev) \
+ json_object_object_add(g_outputs, #ev EVENT_ARRAYS_SIZE_COL_MARKER #core, json_object_new_array()); \
+ json_object_object_add(g_outputs, #ev "_" #core, json_object_new_array());
+ EVENT_ARRAYS(0)
+#undef EVENT_ARRAY
+
+#define ARCH_EVENT_ARRAY(core, index, ev) \
+ json_object_object_add(g_outputs, #ev EVENT_ARRAYS_SIZE_COL_MARKER #core, json_object_new_array()); \
+ json_object_object_add(g_outputs, #ev "_" #core, json_object_new_array());
+ ARCH_EVENT_ARRAYS(0)
+#undef ARCH_EVENT_ARRAY
+
+#define INST(core, pref, index, label, mnemonic, symbol) \
+ json_object_object_add(g_outputs, #label "_" #pref "_" #core, json_object_new_array());
+#define INST_EVENT_ARRAY(core, index, iv) \
+ INST_SET(core, iv)
+ INST_EVENT_ARRAYS(0)
+#undef INST_EVENT_ARRAY
+#undef INST
+
+ json_object_object_add(g_outputs, "step", json_object_new_array());
+
+ append_output();
salis_step(DATA_PUSH_INTERVAL);
+ append_output();
+ salis_step(1);
+
+ json_object_to_file(SIM_DIR "/outputs.json", g_outputs);
+ json_object_put(g_outputs);
+
salis_save(SIM_PATH);
salis_free();
return 0;
diff --git a/test/ui/push/vars.py b/test/ui/push/vars.py
index 9c2a9f3..ca0e801 100644
--- a/test/ui/push/vars.py
+++ b/test/ui/push/vars.py
@@ -1,3 +1,3 @@
flags = set()
defines = set()
-links = set()
+links = {"-ljson-c"}