The frozen -log(u) transform behind pf_weighted_permutation's exponential race.
A leaf module on purpose, and the reason is a tool rather than taste.
tools/check_exp_key.sh proves the transform gives the same bits under every IEEE-conforming
build, and it can only do that by compiling it standalone under several compilers and flag
sets. parquet_random gained a dependency on parquet_sorting -- and so, transitively, on
Arrow -- the moment the weighted permutation needed a sort, which put the transform out of that
check's reach. Splitting it out costs one file and keeps the check dependency-free, which
matters because that check is what found the FMA exposure to begin with.
Why this is not log() from the runtime. Everything parquet_random promises is a pure
function of its coordinates, frozen by pf_random_algorithm, and every other generic delivers
that with integer arithmetic alone -- Philox, the Lemire reduction and the Feistel permutation
are all integer, so two machines agree bit for bit and the golden vectors say so. log breaks
that property class, because libm is not part of any contract this project controls. Measured on
machine B over two million deterministic inputs: 1.33% of -log(u) values differ between
gfortran and ifx at their default flags, worst gap 126775 ulp; 0.083% still differ under
-fp-model=precise; and ifx disagrees with ITSELF across flag settings, so this is not only a
cross-vendor problem.
A weighted permutation is decided by the ORDER of e/w, so one differing key changes the answer
only when it crosses its neighbour -- rare at n = 10**6, approaching certain by n = 10**9.
That is a latent wrong answer with no symptom, which is the one failure mode this tier exists to
rule out.
The approximation costs nothing distributionally. The race needs E ~ Exp(1) iid; a
transform accurate to about two ulp perturbs each key by ~2e-16 relative, eleven orders of
magnitude below the Monte Carlo standard error of any test that could detect it. Approximation
error buys exact reproducibility, which is the trade this tier exists to make.
Depends on iso_fortran_env and nothing else. Keep it that way -- a dependency here is a
dependency the cross-build check cannot carry.
The rounding barrier: an identity that the optimiser may not fuse across.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | x |
the product to round |
the same value, rounded to real64
-log(u) for u in [2**-53, 1], using only IEEE + - * /. Not a general-purpose log.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | u |
a uniform in |
-log(u), in [0, 36.74]
exp_key under a public name. Test-only.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | u |
a uniform in |
-log(u)
Re-derives the frozen transform over 32 fixed inputs and compares against ek_contract_fp.
Forces the frozen-transform check to fail. Test-only.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| logical, | intent(in) | :: | ok |
|