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
//! Reproducible results: pinning the autotuned choices that change the numbers.
//!
//! Some kernels offer several equivalent implementations and let CubeCL's autotuner pick the
//! fastest per device. Most compute identical values, but a few sum in a different order (an IIR
//! filter's time blocks, a matrix product's routine), and the tuner can pick differently from run
//! to run. While a [`PinnedChoices`] guard lives, those kernels use fixed, documented choices on
//! the thread that holds it, so the same input on the same device gives the same output. Results
//! are not promised to match bit for bit across devices (different hardware rounds differently).
use Cell;
use PhantomData;
thread_local!
/// While alive, [`tuned_choices_pinned`] is `true` on this thread. Guards nest.
/// Pins result-changing autotuned choices on this thread until the guard is dropped.
/// Whether a [`PinnedChoices`] guard is alive on this thread.