Skip to content

Latest commit

 

History

History
37 lines (32 loc) · 4.06 KB

program.md

File metadata and controls

37 lines (32 loc) · 4.06 KB

Autoresearch Program: Lattice Sort (latticesort) Library & Benchmark Architecture

Objective

Design, verify, and benchmark an adaptive integer and IEEE (Institute of Electrical and Electronics Engineers, international technical standards organization) 754 floating-point sorting library in safe Rust inspired by structural symmetry, dual-sentinel hash lattices, and cache-resident radix cascades.

The primary evaluation metric is Composite Geometric Mean Latency (geomean_ms) across 9 canonical distributions at $N = 1,000,000$ and $N = 10,000,000$ (lower is better), alongside multi-core throughput up to $N = 1,000,000,000$, while maintaining:

  1. 100% Exactness: Every output slice must match std::slice::sort_unstable (or f32::total_cmp / f64::total_cmp) element-for-element across unit tests, property boundary tests, and benchmark suites.
  2. Systems Safety & Style: Zero unsafe blocks, adherence to the Google Rust Style Guide, and zero warnings under cargo clippy --all-targets -- -D warnings.
  3. Adversarial Resilience: Every candidate optimization must pass the 9-attack Red-Team falsification suite without worst-case degradation.

Public API

Supported surface, re-exported from src/lib.rs:

  • lattice_sort_i32(&mut [i32]), lattice_sort_i64(&mut [i64]): Single-core adaptive sort for 32-bit and 64-bit signed integers.
  • lattice_sort_generic_32<T: LatticeKey32>, lattice_sort_generic_64<T: LatticeKey64>: Same pipelines for caller-defined bijective key types.
  • parallel_lattice_sort, parallel_lattice_sort_32, parallel_lattice_sort_64: Multi-core scoped parallel MSB (Most Significant Byte, highest-order byte of an integer word) + L2 (Level 2 Cache, processor secondary data cache) hybrid radix sort.
  • LatticeSortExt: Extension trait providing .lattice_sort() and .par_lattice_sort() on [i32], [u32], [i64], [u64], [f32], and [f64].
  • SentinelBag: Bounded exact multiset with a self-proving emptiness test.
  • PeriodicRun / PeriodicRunEncoder: Codec for exactly periodic streams.

The internal sorting modules kernel_i32, kernel_i64, and parallel are crate-private; harness stays public under #[doc(hidden)] for standalone benchmarks and may change between minor versions. rust-version is 1.88.

Repository Layout

  1. src/lib.rs: Crate root, module exports, and public documentation.
  2. src/kernel_i32.rs: Core 32-bit adaptive pipeline (lattice_sort_i32), including prefix peeling, peak/valley soliton wave merging, 1024-slot dual-sentinel hash aggregation, dense range count sort, fused 4-pass LSD (Least Significant Digit, lowest-order byte pass) radix sort, and 2-level MSB+L2 hybrid cascade.
  3. src/kernel_i64.rs: 64-bit adaptive 8-pass radix kernel (lattice_sort_i64) with constant-byte pass skipping.
  4. src/slice_ext.rs: Polymorphic trait LatticeSortExt with branchless sign-bit and IEEE 754 bijections.
  5. src/parallel.rs: Multi-core parallel sorting engine (parallel_lattice_sort) built on std::thread::scope.
  6. src/harness.rs: Deterministic 9-distribution benchmark evaluator (N = 1,000,000).
  7. tests/correctness.rs: Automated integration and boundary test suite executed by cargo test.
  8. benches/:
    • benches/latticesort.rs (cargo bench --bench latticesort): Primary 1M-element 9-distribution benchmark.
    • benches/adversarial.rs (cargo bench --bench adversarial): Red-Team 9-attack adversarial benchmark at $N = 1,000,000$.
    • benches/bench_10m.rs (cargo bench --bench bench_10m): 10M-element main and adversarial benchmark suite.
    • benches/bench_fronts_3_4.rs (cargo bench --bench bench_fronts_3_4): Polymorphic types (u32, i64, u64, f32, f64) and multi-core benchmark.
    • benches/bench_literature.rs (cargo bench --bench bench_literature): Head-to-head comparison against 6 sorting algorithms from Computer Science literature.
    • benches/bench_1b.rs (cargo bench --bench bench_1b): 1-Billion-element (4.00 GB) single-core and multi-core benchmark.
  9. results.tsv & RESEARCH_LOG.md: Complete chronological record of experiments exp00 through exp19.