mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-04 07:18:50 +00:00
Made by tools/layout/move_0216.py (the commit before this one) on db8e0be9c, the final code head of 0.2.16:
- 75 git mv (renames, so `git log --follow` and blame keep working; packaging/acceptance_matrix.md shows as delete + add because its links
changed too) and 3 removals: SETUP.bat, UPDATE.bat and update.sh (setup.py --update pulls the code now);
- 1,425 path edits in 307 files: root-relative paths in CI, Docker, .gitignore and the release scripts; Markdown links; Python and
Node joins from a root that moved with its folder; explicit edits for code that computes a root or names a moved path; tables of
repository paths inside tests.
engine/ holds what CMake builds (src, include, cmake, metal, sycl, spark, third_party, the C++ tests and benches). app/ is the desktop
app and its host (was apps/). terminal/ is the Terminal in the layout of the installed one (strata.py, setup.py, strata_cli,
strata_control, serve, bin, data, ref, crates, the Python tools and tests). docs/ has the documentation, docs/lang/ the translated
READMEs, docs/history and docs/bench-results. tools/ has the repository's own checks, packaging, docker, research and nix.
tests/core/test_tqp_ref.py is a pytest file and stays with the Python tests (terminal/tests/core/).
AGENTS.md, README.md, LICENSE, setup.sh and START-HERE.bat stay at the root.
No behaviour change: the same command lines, the same sources. For this head a replay of the script gave the same numbers and the path
scan (tools/layout/checks/path_scan.py) reports no hit; the suites and the builds run on this commit next.
79 lines
3.3 KiB
C++
79 lines
3.3 KiB
C++
// The batch window's row layout (include/strata/core/batch_rows.hpp): plain one-row slots, a slot's contiguous group of
|
|
// proposed rows (--batch-mtp), and the hand-off capacity of a layer split's stages. Header-only, CPU.
|
|
#include "strata/core/batch_rows.hpp"
|
|
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
|
|
namespace {
|
|
int failures = 0;
|
|
void check(bool ok, const char* what) {
|
|
if (!ok) {
|
|
std::fprintf(stderr, "FAIL: %s\n", what);
|
|
++failures;
|
|
}
|
|
}
|
|
const char* run(const int* rows, const long long* p, int S, int n_slots, int max_t, int hbase, bool handoff) {
|
|
int64_t pos[8];
|
|
for (int t = 0; t < S; ++t) pos[t] = p[t];
|
|
return strata::core::batch_rows_error(rows, S, pos, n_slots, max_t, hbase, handoff, 8);
|
|
}
|
|
} // namespace
|
|
|
|
int main() {
|
|
using strata::core::batch_rows_error;
|
|
// plain batch: one row per slot, any positions
|
|
{
|
|
const int rows[] = {0, 1, 2};
|
|
const long long pos[] = {10, 500, 3};
|
|
check(run(rows, pos, 3, 3, 8, 0, false) == nullptr, "one row per slot");
|
|
check(run(rows, pos, 3, 3, 8, 0, true) == nullptr, "one row per slot through the hand-off");
|
|
}
|
|
// --batch-mtp: a slot's two rows at consecutive positions; also on a layer split (S > slots)
|
|
{
|
|
const int rows[] = {1, 1, 0, 0};
|
|
const long long pos[] = {40, 41, 7, 8};
|
|
check(run(rows, pos, 4, 2, 8, 0, false) == nullptr, "two rows per slot, one stage");
|
|
check(run(rows, pos, 4, 2, 8, 0, true) == nullptr, "two rows per slot across a layer split (S > slots)");
|
|
}
|
|
// eight rows = four slots of two: the whole hand-off
|
|
{
|
|
const int rows[] = {0, 0, 1, 1, 2, 2, 3, 3};
|
|
const long long pos[] = {1, 2, 5, 6, 9, 10, 20, 21};
|
|
check(run(rows, pos, 8, 4, 8, 0, true) == nullptr, "eight rows fill the hand-off");
|
|
check(run(rows, pos, 8, 4, 8, 1, true) != nullptr, "a group past the hand-off's end");
|
|
check(run(rows, pos, 8, 4, 8, 1, false) == nullptr, "no hand-off: the base does not bound the rows");
|
|
}
|
|
// refused layouts
|
|
{
|
|
const int rows[] = {0, 1, 0};
|
|
const long long pos[] = {5, 9, 6};
|
|
check(run(rows, pos, 3, 2, 8, 0, false) != nullptr, "a slot's rows must be contiguous");
|
|
}
|
|
{
|
|
const int rows[] = {0, 0};
|
|
const long long pos[] = {5, 7};
|
|
check(run(rows, pos, 2, 1, 8, 0, false) != nullptr, "a slot's rows need consecutive positions");
|
|
}
|
|
{
|
|
const int rows[] = {0, 2};
|
|
const long long pos[] = {5, 7};
|
|
check(run(rows, pos, 2, 2, 8, 0, false) != nullptr, "a slot past the slots held");
|
|
const int neg[] = {-1};
|
|
const long long p1[] = {1};
|
|
check(run(neg, p1, 1, 2, 8, 0, false) != nullptr, "a negative slot");
|
|
}
|
|
{
|
|
const int rows[] = {0, 0, 0};
|
|
const long long pos[] = {1, 2, 3};
|
|
check(run(rows, pos, 3, 1, 2, 0, false) != nullptr, "more rows than the window holds");
|
|
check(run(rows, pos, 0, 1, 8, 0, false) != nullptr, "an empty window");
|
|
check(run(rows, pos, 3, 1, 8, -1, false) != nullptr, "a negative hand-off base");
|
|
check(run(rows, pos, 3, 1, 8, 0, false) == nullptr, "three rows of one slot are a group");
|
|
}
|
|
if (failures != 0) return EXIT_FAILURE;
|
|
std::printf("batch_rows_test: ok\n");
|
|
return EXIT_SUCCESS;
|
|
}
|