1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! Feature-gated unchecked slice access for voting hot loops.
//!
//! The center-voting passes read the gradient at `y*w + x` (always in bounds by
//! construction) and scatter-add into an accumulator at an index that a
//! preceding `px/py` range test has already proven `< w*h`. The `[]` operator
//! re-checks that bound on every access, which shows up in the profile for the
//! scatter-heavy inner loop.
//!
//! With the `unsafe-opt` feature these helpers skip the redundant check; without
//! it they are plain checked indexing with **identical** numerical output. Every
//! call site documents why its index is in bounds, and a `debug_assert!` guards
//! the invariant in debug/test builds.
use Scalar;
/// Load `s[i]`.
///
/// # Safety contract (only relevant under `unsafe-opt`)
///
/// The caller must guarantee `i < s.len()`.
pub
/// Scatter-add `s[i] += v`.
///
/// # Safety contract (only relevant under `unsafe-opt`)
///
/// The caller must guarantee `i < s.len()`.
pub