Add commented-out prints of solution candidates for debugging
This commit is contained in:
parent
b73803e9bd
commit
be16706e32
|
@ -44,6 +44,7 @@ extern "C" {
|
|||
///
|
||||
/// This function uses unsafe code for FFI into the tromp solver.
|
||||
#[allow(unsafe_code)]
|
||||
#[allow(clippy::print_stdout)]
|
||||
unsafe fn worker(eq: *mut CEqui, p: verify::Params, curr_state: &State) -> Vec<Vec<u32>> {
|
||||
// SAFETY: caller must supply a valid `eq` instance.
|
||||
//
|
||||
|
@ -70,6 +71,7 @@ unsafe fn worker(eq: *mut CEqui, p: verify::Params, curr_state: &State) -> Vec<V
|
|||
let nsols = equi_nsols(eq);
|
||||
let sols = equi_sols(eq);
|
||||
let solution_len = 1 << p.k;
|
||||
//println!("{nsols} solutions of length {solution_len} at {sols:?}");
|
||||
|
||||
// SAFETY:
|
||||
// - caller must supply a `p` instance that matches the hard-coded values in the C code.
|
||||
|
@ -77,6 +79,13 @@ unsafe fn worker(eq: *mut CEqui, p: verify::Params, curr_state: &State) -> Vec<V
|
|||
// - this slice is a shared ref to the memory in a valid `eq` instance supplied by the caller.
|
||||
let solutions: &[u32] = slice::from_raw_parts(sols, nsols * solution_len);
|
||||
|
||||
/*
|
||||
println!(
|
||||
"{nsols} solutions of length {solution_len} as a slice of length {:?}",
|
||||
solutions.len()
|
||||
);
|
||||
*/
|
||||
|
||||
let mut chunks = solutions.chunks_exact(solution_len);
|
||||
|
||||
// SAFETY:
|
||||
|
@ -98,6 +107,17 @@ unsafe fn worker(eq: *mut CEqui, p: verify::Params, curr_state: &State) -> Vec<V
|
|||
solutions
|
||||
};
|
||||
|
||||
/*
|
||||
println!(
|
||||
"{} solutions as cloned vectors of length {:?}",
|
||||
solutions.len(),
|
||||
solutions
|
||||
.iter()
|
||||
.map(|solution| solution.len())
|
||||
.collect::<Vec<_>>()
|
||||
);
|
||||
*/
|
||||
|
||||
solutions
|
||||
}
|
||||
|
||||
|
|
|
@ -355,8 +355,15 @@ typedef struct equi equi;
|
|||
listindices1(eq, WK, t, prf); // assume WK odd
|
||||
qsort(prf, PROOFSIZE, sizeof(u32), &compu32);
|
||||
for (u32 i=1; i<PROOFSIZE; i++)
|
||||
if (prf[i] <= prf[i-1])
|
||||
if (prf[i] <= prf[i-1]) {
|
||||
/*
|
||||
printf(
|
||||
"failed dup indexes check: wanted: proof[%d] > proof[%d], actual: %d <= %d\n",
|
||||
i, i-1, prf[i], prf[i-1]
|
||||
);
|
||||
*/
|
||||
return;
|
||||
}
|
||||
#ifdef EQUIHASH_TROMP_ATOMIC
|
||||
u32 soli = std::atomic_fetch_add_explicit(&eq->nsols, 1U, std::memory_order_relaxed);
|
||||
#else
|
||||
|
@ -678,7 +685,7 @@ nc++, candidate(eq, tree_from_bid(bucketid, s0, s1));
|
|||
}
|
||||
}
|
||||
}
|
||||
//printf(" %d candidates ", nc);
|
||||
//printf(" %d candidates\n", nc);
|
||||
}
|
||||
|
||||
size_t equi_nsols(const equi *eq) {
|
||||
|
|
Loading…
Reference in New Issue