upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/test/shadow_keep_test.cpp
diff options
context:
space:
mode:
authorJan Trencansky <jan.trencansky@protonmail.com>2026-11-28 03:31:04 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-28 03:31:04 -0500
commitf913286051eb00c81a99a8970b8fc6fe04d45d6d (patch)
tree3ba94e161a83ae1144303b725100728078f76263 /runtime/test/shadow_keep_test.cpp
parente4c0708745dbff6c29678007d96a35bfdd22e288 (diff)
runtime: Round 8 WS1 — PageMirror batching, direct page table, L1-strip AVX2 hashing, sub-page readback & heap WC buffering
- CellGuard::arm_batch(): per-batch sync_known_protect, range-scoped changes_since(), gap-bridging (<=8 cold tiles, pin-guarded), reopen() fast-path via Cell::armed_map_gen - shadow_keep::sum_of_batch_256() hoisted AVX2/SSE2/scalar batch hash + 4 KiB L1-hot strips in TitleMirror::upload() & prehash_readback_slice() - TitleWritePolicy PageRef active lists (no frame_hot) + TitleMirror 2-level per-chunk direct page table + has_pending() fast-path + refs>1 alias handoff - Feed coalescing + watch_batch/unwatch_batch in refresh_page_mirror() - Sub-page 256B-aligned vkCmdCopyBuffer readback, page_mirror_buffer resolve_cache, OutScratchGuard WC buffering in apply_in_place_changes/finish_in_place, lock-free reclaim_arena/update_address_guard AI-assisted: Antigravity (Gemini 4 Neon).
Diffstat (limited to 'runtime/test/shadow_keep_test.cpp')
-rw-r--r--runtime/test/shadow_keep_test.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/runtime/test/shadow_keep_test.cpp b/runtime/test/shadow_keep_test.cpp
index 87960c0a2..d5b73a0ab 100644
--- a/runtime/test/shadow_keep_test.cpp
+++ b/runtime/test/shadow_keep_test.cpp
@@ -5,6 +5,7 @@
5#include <cstdint> 5#include <cstdint>
6#include <cstdio> 6#include <cstdio>
7#include <cstring> 7#include <cstring>
8#include <random>
8#include <utility> 9#include <utility>
9#include <vector> 10#include <vector>
10 11
@@ -124,6 +125,42 @@ void sums_tell_bytes_apart() {
124 EXPECT(leonida::shadow_keep::sum_of(a, 16) != leonida::shadow_keep::sum_of(a, 17)); // the length counts 125 EXPECT(leonida::shadow_keep::sum_of(a, 16) != leonida::shadow_keep::sum_of(a, 17)); // the length counts
125} 126}
126 127
128void sum_of_batch_256_matches_sum_of() {
129 constexpr std::size_t kMaxPieces = 256;
130 constexpr std::size_t kPad = 64;
131 std::vector<std::uint8_t> buf(kMaxPieces * kPiece + kPad);
132 std::vector<std::uint64_t> batch_out(kMaxPieces, 0);
133
134 const std::size_t counts[] = {0, 1, 2, 15, 16, 17, 64, 256};
135 const std::size_t offsets[] = {0, 1, 3, 7, 15, 31};
136 std::mt19937_64 rng(0x5eed123456789abcull);
137
138 for (int pattern = 0; pattern < 4; ++pattern) {
139 if (pattern == 0) {
140 std::fill(buf.begin(), buf.end(), std::uint8_t(0));
141 } else if (pattern == 1) {
142 std::fill(buf.begin(), buf.end(), std::uint8_t(0xff));
143 } else if (pattern == 2) {
144 for (std::size_t i = 0; i < buf.size(); ++i) buf[i] = std::uint8_t((i * 131 + 17) & 0xff);
145 } else {
146 for (std::size_t i = 0; i < buf.size(); ++i) buf[i] = std::uint8_t(rng() & 0xff);
147 }
148 for (const std::size_t off : offsets) {
149 const std::uint8_t* const ptr = buf.data() + off;
150 for (const std::size_t n : counts) {
151 std::fill(batch_out.begin(), batch_out.end(), std::uint64_t(0xdeadbeefull));
152 leonida::shadow_keep::sum_of_batch_256(ptr, n, batch_out.data());
153 for (std::size_t i = 0; i < n; ++i) {
154 const std::uint64_t expected = leonida::shadow_keep::sum_of(ptr + i * kPiece, kPiece);
155 EXPECT(batch_out[i] == expected);
156 EXPECT(batch_out[i] != 0);
157 }
158 if (n < kMaxPieces) EXPECT(batch_out[n] == 0xdeadbeefull);
159 }
160 }
161 }
162}
163
127} // namespace 164} // namespace
128 165
129int main() { 166int main() {
@@ -132,6 +169,7 @@ int main() {
132 partial_first_and_last_pieces(); 169 partial_first_and_last_pieces();
133 forgotten_sums_copy_once(); 170 forgotten_sums_copy_once();
134 sums_tell_bytes_apart(); 171 sums_tell_bytes_apart();
172 sum_of_batch_256_matches_sum_of();
135 if (failures) { 173 if (failures) {
136 std::fprintf(stderr, "shadow_keep: %d check(s) failed\n", failures); 174 std::fprintf(stderr, "shadow_keep: %d check(s) failed\n", failures);
137 return 1; 175 return 1;