Skip to main content

finalize_step_amf

Function finalize_step_amf 

Source
pub fn finalize_step_amf(
    ws: &mut Workspace,
    me: usize,
    pme1: usize,
    pme2_excl: usize,
    nvpiv: i32,
    degme: usize,
    elenme: i32,
    aggressive: bool,
) -> StepFlops
Expand description

AMF analogue of finalize_step. The Pass-1 element seeding, hash-bucket detection, and supervariable-merge structure mirror AMD; the per-iteration accumulator carries the AMF triple (deg, wf3, wf4) (Amestoy 1999 thesis), and the re-insertion computes the quantized RMF score and inserts at head[amf_bucket_of(wf[i], n)].

Six metric-specific sites compared to AMD (numbered per dev/research/amf-clean-room.md Section 6):

  1. Pass-1 also resets wf[e] = 0 on the first touch of each element (lazy cache sentinel).
  2. Pass-2 element walk caches wf[e] = dext * (2*deg(e) - dext - 1) on first encounter and accumulates wf4 += wf[e].
  3. Pass-2 variable walk accumulates wf3 += nv[j].
  4. Loose-degree special case zeroes wf3 = wf4 = 0; the kept degree[i] cannot have a meaningful WF-subtraction so the AMF score is reset.
  5. Supervariable merge takes wf[i] = max(wf[i], wf[j]).
  6. Re-insertion uses the saturated/regular RMF formula with dummy = i32::MAX - 1, quantizes via bucket(wf[i], n), and threads through head of length 2 * n + 2.

Reference: ana_orderings.F:4660-5025.