summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2024-09-07 10:20:52 -0700
committerPaul Oliver <contact@pauloliver.dev>2024-09-07 10:20:52 -0700
commit7f56d951fe4ad6749e68ac860ea05f572b6d04ed (patch)
tree3346bdedd8cbaa93eb6ca1b75332bc73648d0ae8
parent9779eecbee025d757df43b03a0dc27c5148245a5 (diff)
Allow compiling ancestor at half of max address
Also makes code compatible with older versions of GCC.
-rwxr-xr-xsalis4
-rw-r--r--src/arch/salis-v1.c10
-rw-r--r--src/salis.c23
3 files changed, 34 insertions, 3 deletions
diff --git a/salis b/salis
index fe8191c..b02daa2 100755
--- a/salis
+++ b/salis
@@ -78,6 +78,7 @@ options=(
"c|cores|N|number of simulator cores||2|bench:new"
"F|muta-flip||cosmic rays flip bits instead of randomizing whole bytes||false|bench:new"
"f|force||overwrite existing simulation of given name||false|new"
+ "H|half||compile ancestor at the middle of the memory buffer||false|bench:new"
"h|help||${help_msg}|||bench:load:new"
"M|muta-pow|POW|mutator range exponent (range == 2^POW)||32|bench:new"
"m|mvec-pow|POW|memory vector size exponent (size == 2^POW)||20|bench:new"
@@ -283,7 +284,7 @@ fpow() {
printf '%#xul' $((1 << ${1}))
}
-bcmd="gcc src/salis.c -o ${salis_exe} ${gcc_flags} -Isrc -lncursesw"
+bcmd="gcc src/salis.c -o ${salis_exe} ${gcc_flags} -Isrc -lncursesw -pthread"
bcmd="${bcmd} `[[ ${opt_optimized} == true ]] && echo "-O3 -DNDEBUG" || echo "-ggdb"`"
bcmd="${bcmd} -DACTION=${!act_var}"
bcmd="${bcmd} -DARCHITECTURE=`fquote ${opt_arch}`"
@@ -323,6 +324,7 @@ bench|new)
done
bcmd="${bcmd} -DANC_LIST=`fquote "${anc_list::-1}"`"
+ bcmd="${bcmd} -DANC_HALF=`[[ ${opt_half} == true ]] && echo 1 || echo 0`"
;;
esac
diff --git a/src/arch/salis-v1.c b/src/arch/salis-v1.c
index 0e8f202..9268d50 100644
--- a/src/arch/salis-v1.c
+++ b/src/arch/salis-v1.c
@@ -200,7 +200,15 @@ void arch_on_proc_kill(Core *core) {
void arch_anc_init(Core *core, u64 size) {
assert(core);
- proc_fetch(core, 0)->mb0s = size;
+ Proc *panc = proc_fetch(core, 0);
+
+#if ANC_HALF == 1
+ panc->mb0a = U64_HALF;
+ panc->ip = U64_HALF;
+ panc->sp = U64_HALF;
+#endif
+
+ panc->mb0s = size;
}
#endif
diff --git a/src/salis.c b/src/salis.c
index c3de4f4..24f3966 100644
--- a/src/salis.c
+++ b/src/salis.c
@@ -27,6 +27,8 @@
#define INST_CAPS (0x80)
#define INST_MASK (0x7f)
+#define U64_HALF (0x8000000000000000)
+
typedef struct Core Core;
typedef struct Ipcm Ipcm;
typedef struct Proc Proc;
@@ -296,7 +298,12 @@ u64 core_assemble_ancestor(int cix, const char *anc) {
assert(f);
- u64 addr = 0;
+#if ANC_HALF == 1
+ u64 addr = U64_HALF;
+#else
+ u64 addr = 0;
+#endif
+
char line[ASM_LINE_LEN] = {0};
Core *core = &g_cores[cix];
@@ -352,6 +359,10 @@ void core_init(int cix, u64 *seed, const char *anc) {
u64 anc_size = core_assemble_ancestor(cix, anc);
+#if ANC_HALF == 1
+ anc_size -= U64_HALF;
+#endif
+
arch_anc_init(core, anc_size);
}
#endif
@@ -361,6 +372,8 @@ void core_load(FILE *f, Core *core) {
assert(f);
assert(core);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
fread(&core->mall, sizeof(u64), 1, f);
fread( core->muta, sizeof(u64), 4, f);
fread(&core->pnum, sizeof(u64), 1, f);
@@ -371,6 +384,7 @@ void core_load(FILE *f, Core *core) {
fread(&core->psli, sizeof(u64), 1, f);
fread(&core->ncyc, sizeof(u64), 1, f);
fread(&core->ivpt, sizeof(u64), 1, f);
+#pragma GCC diagnostic pop
core->iviv = calloc(SYNC_INTERVAL, sizeof(u8));
core->ivav = calloc(SYNC_INTERVAL, sizeof(u64));
@@ -380,10 +394,13 @@ void core_load(FILE *f, Core *core) {
assert(core->ivav);
assert(core->pvec);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
fread(core->iviv, sizeof(u8), SYNC_INTERVAL, f);
fread(core->ivav, sizeof(u64), SYNC_INTERVAL, f);
fread(core->pvec, sizeof(Proc), core->pcap, f);
fread(core->mvec, sizeof(u8), MVEC_SIZE, f);
+#pragma GCC diagnostic pop
}
#endif
@@ -521,8 +538,12 @@ void salis_load() {
core_load(f, &g_cores[i]);
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
fread(&g_steps, sizeof(u64), 1, f);
fread(&g_syncs, sizeof(u64), 1, f);
+#pragma GCC diagnostic pop
+
fclose(f);
}
#endif