aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsalis.py56
-rw-r--r--ui/curses/ui.j2.c6
2 files changed, 36 insertions, 26 deletions
diff --git a/salis.py b/salis.py
index 76290ee..f80e447 100755
--- a/salis.py
+++ b/salis.py
@@ -8,6 +8,7 @@
# JIT compilation allows quick switching between all available executable configurations.
import os
+import random
import shutil
import subprocess
import sys
@@ -40,6 +41,11 @@ new = parsers.add_parser("new", formatter_class=fclass, help="create new simul
archs = os.listdir("./arch")
uis = os.listdir("./ui")
+def iseed(i):
+ ival = int(i, 0)
+ if ival < -1: raise ArgumentTypeError("invalid seed value")
+ return ival
+
def ipos(i):
ival = int(i, 0)
if ival < 0: raise ArgumentTypeError("value must be positive integer")
@@ -55,31 +61,32 @@ option_keys = ["short", "long", "metavar", "description", "default", "required",
# fmt: off
option_conf = [
["A", "anc", "ANC", "ancestor file name without extension, to be compiled on "
- "all cores (ANC points to 'ancs/<ARCH>/<ANC>.asm')", None, True, str, [bench, new]],
- ["a", "arch", archs, "VM architecture", "dummy", False, str, [bench, new]],
- ["b", "steps", "N", "number of steps to run in benchmark", 0x1000000, False, ipos, [bench]],
- ["C", "clones", "N", "number of ancestor clones on each core", 1, False, inat, [bench, new]],
- ["c", "cores", "N", "number of simulator cores", 2, False, inat, [bench, new]],
+ "all cores (ANC points to 'ancs/<ARCH>/<ANC>.asm')", None, True, str, [bench, new]],
+ ["a", "arch", archs, "VM architecture", "dummy", False, str, [bench, new]],
+ ["b", "steps", "N", "number of steps to run in benchmark", 0x1000000, False, ipos, [bench]],
+ ["C", "clones", "N", "number of ancestor clones on each core", 1, False, inat, [bench, new]],
+ ["c", "cores", "N", "number of simulator cores", 2, False, inat, [bench, new]],
["d", "data-push-pow", "POW", "data aggregation interval exponent (interval == 2^POW >= "
"thread sync interval); a value of 0 disables data "
- "aggregation (requires 'sqlite')", 28, False, ipos, [new]],
- ["f", "force", None, "overwrite existing simulation of given name", False, False, bool, [new]],
- ["F", "muta-flip", None, "cosmic rays flip bits instead of randomizing whole bytes", False, False, bool, [bench, new]],
- ["M", "muta-pow", "POW", "mutator range exponent (range == 2^POW)", 32, False, ipos, [bench, new]],
- ["m", "mvec-pow", "POW", "memory vector size exponent (size == 2^POW)", 20, False, ipos, [bench, new]],
- ["n", "name", "NAME", "name of new or loaded simulation", "def.sim", False, str, [load, new]],
- ["o", "optimized", None, "builds salis binary with optimizations", False, False, bool, [bench, load, new]],
+ "aggregation (requires 'sqlite')", 28, False, ipos, [new]],
+ ["f", "force", None, "overwrite existing simulation of given name", False, False, bool, [new]],
+ ["F", "muta-flip", None, "cosmic rays flip bits instead of randomizing whole bytes", False, False, bool, [bench, new]],
+ ["M", "muta-pow", "POW", "mutator range exponent (range == 2^POW)", 32, False, ipos, [bench, new]],
+ ["m", "mvec-pow", "POW", "memory vector size exponent (size == 2^POW)", 20, False, ipos, [bench, new]],
+ ["n", "name", "NAME", "name of new or loaded simulation", "def.sim", False, str, [load, new]],
+ ["o", "optimized", None, "builds salis binary with optimizations", False, False, bool, [bench, load, new]],
["p", "pre-cmd", "CMD", "shell command to wrap call to executable (e.g. gdb, "
- "valgrind, etc.)", None, False, str, [bench, load, new]],
- ["s", "seed", "SEED", "seed value for new simulation", 0, False, ipos, [bench, new]],
- ["S", "print-source", None, "print generated C source to stdout and exit", False, False, bool, [bench, load, new]],
- ["T", "delete-temp-dir", None, "delete temporary directory on exit", True, False, bool, [bench, load, new]],
+ "valgrind, etc.)", None, False, str, [bench, load, new]],
+ ["s", "seed", "SEED", "seed value for new simulation; a value of 0 disables "
+ "cosmic rays; a value of -1 creates a random seed", 0, False, iseed, [bench, new]],
+ ["S", "print-source", None, "print generated C source to stdout and exit", False, False, bool, [bench, load, new]],
+ ["T", "delete-temp-dir", None, "delete temporary directory on exit", True, False, bool, [bench, load, new]],
["t", "thread-gap", "N", "memory gap between cores in bytes (may help reduce cache "
- "misses?)", 0x100, False, inat, [bench, load, new]],
- ["u", "ui", uis, "user interface", "curses", False, str, [load, new]],
- ["x", "compress", None, "compress save files (requires 'zlib')", True, False, bool, [new]],
- ["y", "sync-pow", "POW", "core sync interval exponent (interval == 2^POW)", 20, False, ipos, [bench, new]],
- ["z", "auto-save-pow", "POW", "auto-save interval exponent (interval == 2^POW)", 36, False, ipos, [new]],
+ "misses?)", 0x100, False, inat, [bench, load, new]],
+ ["u", "ui", uis, "user interface", "curses", False, str, [load, new]],
+ ["x", "compress", None, "compress save files (requires 'zlib')", True, False, bool, [new]],
+ ["y", "sync-pow", "POW", "core sync interval exponent (interval == 2^POW)", 20, False, ipos, [bench, new]],
+ ["z", "auto-save-pow", "POW", "auto-save interval exponent (interval == 2^POW)", 36, False, ipos, [new]],
]
# fmt: on
@@ -225,13 +232,16 @@ inst_mask = "0x7f"
ipc_flag = "0x80"
mall_flag = "0x80"
muta_range = ul_pow(args.muta_pow)
-muta_seed = ul_val(args.seed)
mvec_size = ul_pow(args.mvec_pow)
sync_interval = ul_pow(args.sync_pow)
thread_gap = ul_val(args.thread_gap)
uint64_half = ul_val(0x8000000000000000)
-args.seed = ul_val(args.seed)
+if args.seed == -1:
+ args.seed = ul_val(random.getrandbits(64))
+ info("Using random seed", args.seed)
+else:
+ args.seed = ul_val(args.seed)
if args.command in ["bench"]:
includes.append("stdio.h")
diff --git a/ui/curses/ui.j2.c b/ui/curses/ui.j2.c
index 9ebd387..861321f 100644
--- a/ui/curses/ui.j2.c
+++ b/ui/curses/ui.j2.c
@@ -844,7 +844,7 @@ void ui_print_log_line(unsigned lptr, int line) {
{{ pane_width }},
PAIR_NORMAL,
A_NORMAL,
- "%d-%02d-%02d %02d:%02d:%02d",
+ ": %d-%02d-%02d %02d:%02d:%02d",
tm.tm_year + 1900,
tm.tm_mon + 1,
tm.tm_mday,
@@ -856,7 +856,7 @@ void ui_print_log_line(unsigned lptr, int line) {
// Level
ui_field(
line,
- {{ pane_width }} + 20,
+ {{ pane_width }} + 22,
g_log_warns[lptr] ? PAIR_WARN : PAIR_HEADER,
A_NORMAL,
g_log_warns[lptr] ? "WARN:" : "INFO:"
@@ -865,7 +865,7 @@ void ui_print_log_line(unsigned lptr, int line) {
// Message
ui_field(
line,
- {{ pane_width }} + 26,
+ {{ pane_width }} + 28,
PAIR_NORMAL,
A_NORMAL,
g_logs[lptr]