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 05:38:11 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-28 05:38:11 -0500
commit70ea06a50bc5323359492c34861b48a8d3c96db2 (patch)
tree48b8b39d9f536f07da186b9c0b721e302cc2bccc /runtime/test/shadow_keep_test.cpp
parent8f7826117905a4d2149199e1f734a871f10183bd (diff)
runtime: Round 10 WS2 — shared Cell::known_* cache, TitleHeap changed() scoping, 64-tile bridging, fused AVX2 copy_and_sum_256 & filter/collect cuts
- Move title_memory_map::changed() into TitleHeap::hooks.commit/decommit and !from_mirror_heap in free_title_block() - Share Cell::known_* across CellGuard & TitleTextureCells (no PAGE_READONLY no-guard cache; MEM_RESERVE intra-pass in TitleTextureCells, cross-pass in CellGuard; seed on xmem::map_view) - Persist TitleTextureCells VQ cache across outer batches; bridge across run_already_armed_ tiles with uniform restore[0..15] up to kMaxBridgeGap=64 - Persist 1024-entry local_mirror per ConsoleHeap*, flush Phase A/B disjointly, handle !base V#s in Phase A, skip redundant WC BAR writes for waiting T#s - Fused SEH-safe AVX2/SSE2 guarded::copy_and_sum_256(), kMaxWorkers=8, single-reader title_write_watch::ask() fast path preserving mark() entries AI-assisted: Antigravity (Gemini 4 Neon).
Diffstat (limited to 'runtime/test/shadow_keep_test.cpp')
-rw-r--r--runtime/test/shadow_keep_test.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/runtime/test/shadow_keep_test.cpp b/runtime/test/shadow_keep_test.cpp
index d5b73a0ab..5d8c0cdba 100644
--- a/runtime/test/shadow_keep_test.cpp
+++ b/runtime/test/shadow_keep_test.cpp
@@ -161,6 +161,49 @@ void sum_of_batch_256_matches_sum_of() {
161 } 161 }
162} 162}
163 163
164void copy_and_sum_256_matches_sum_of() {
165 constexpr std::size_t kMaxPieces = 256;
166 constexpr std::size_t kPad = 64;
167 std::vector<std::uint8_t> src(kMaxPieces * kPiece + kPad);
168 std::vector<std::uint8_t> dst(kMaxPieces * kPiece + kPad);
169 std::vector<std::uint64_t> fused_out(kMaxPieces, 0);
170
171 const std::size_t counts[] = {0, 1, 2, 15, 16, 17, 64, 256};
172 const std::size_t offsets[] = {0, 1, 3, 7, 15, 31};
173 std::mt19937_64 rng(0xf05ed123456789abull);
174
175 for (int pattern = 0; pattern < 4; ++pattern) {
176 if (pattern == 0) {
177 std::fill(src.begin(), src.end(), std::uint8_t(0));
178 } else if (pattern == 1) {
179 std::fill(src.begin(), src.end(), std::uint8_t(0xff));
180 } else if (pattern == 2) {
181 for (std::size_t i = 0; i < src.size(); ++i) src[i] = std::uint8_t((i * 131 + 17) & 0xff);
182 } else {
183 for (std::size_t i = 0; i < src.size(); ++i) src[i] = std::uint8_t(rng() & 0xff);
184 }
185 for (const std::size_t src_off : offsets) {
186 const std::size_t dst_off = (src_off * 3) % 32;
187 const std::uint8_t* const sptr = src.data() + src_off;
188 std::uint8_t* const dptr = dst.data() + dst_off;
189 for (const std::size_t n : counts) {
190 std::fill(dst.begin(), dst.end(), std::uint8_t(0xCC));
191 std::fill(fused_out.begin(), fused_out.end(), std::uint64_t(0xdeadbeefull));
192 leonida::shadow_keep::copy_and_sum_256(dptr, sptr, n, fused_out.data());
193 if (dst_off > 0) EXPECT(dst[dst_off - 1] == 0xCC);
194 if (n > 0) EXPECT(std::memcmp(dptr, sptr, n * kPiece) == 0);
195 EXPECT(dst[dst_off + n * kPiece] == 0xCC);
196 for (std::size_t i = 0; i < n; ++i) {
197 const std::uint64_t expected = leonida::shadow_keep::sum_of(sptr + i * kPiece, kPiece);
198 EXPECT(fused_out[i] == expected);
199 EXPECT(fused_out[i] != 0);
200 }
201 if (n < kMaxPieces) EXPECT(fused_out[n] == 0xdeadbeefull);
202 }
203 }
204 }
205}
206
164} // namespace 207} // namespace
165 208
166int main() { 209int main() {
@@ -170,6 +213,7 @@ int main() {
170 forgotten_sums_copy_once(); 213 forgotten_sums_copy_once();
171 sums_tell_bytes_apart(); 214 sums_tell_bytes_apart();
172 sum_of_batch_256_matches_sum_of(); 215 sum_of_batch_256_matches_sum_of();
216 copy_and_sum_256_matches_sum_of();
173 if (failures) { 217 if (failures) {
174 std::fprintf(stderr, "shadow_keep: %d check(s) failed\n", failures); 218 std::fprintf(stderr, "shadow_keep: %d check(s) failed\n", failures);
175 return 1; 219 return 1;