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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
pub mod prng;
pub mod eval;
pub mod tt;
pub mod pleco_arc;
use core::piece_move::BitMove;
use board::Board;
pub trait Searcher {
fn name() -> &'static str where Self: Sized;
fn best_move(board: Board, depth: u16) -> BitMove
where
Self: Sized;
}
pub trait PreFetchable {
fn prefetch(&self, key: u64);
fn prefetch2(&self, key: u64) {
self.prefetch(key);
self.prefetch(key + 1);
}
}
#[inline(always)]
pub fn prefetch_write<T>(ptr: *const T) {
__prefetch_write::<T>(ptr);
}
#[cfg(feature = "nightly")]
#[inline(always)]
fn __prefetch_write<T>(ptr: *const T) {
use std::intrinsics::prefetch_write_data;
unsafe {
prefetch_write_data::<T>(ptr, 3);
}
}
#[cfg(
all(
not(feature = "nightly"),
any(target_arch = "x86", target_arch = "x86_64"),
target_feature = "sse"
)
)]
#[inline(always)]
fn __prefetch_write<T>(ptr: *const T) {
#[cfg(target_arch = "x86")]
use std::arch::x86::_mm_prefetch;
#[cfg(target_arch = "x86_64")]
use std::arch::x86_64::_mm_prefetch;
unsafe {
_mm_prefetch(ptr as *const i8, 3);
}
}
#[cfg(
all(
not(feature = "nightly"),
any(
all(
any(target_arch = "x86", target_arch = "x86_64"),
not(target_feature = "sse")
),
not(any(target_arch = "x86", target_arch = "x86_64"))
)
)
)]
#[inline(always)]
fn __prefetch_write<T>(ptr: *const T) {
}
pub mod hint {
#[cfg(feature = "nightly")]
use std::intrinsics;
#[inline(always)]
pub fn unlikely(cond: bool) -> bool {
#[cfg(feature = "nightly")]
unsafe {
intrinsics::unlikely(cond)
}
#[cfg(not(feature = "nightly"))]
cond
}
#[inline(always)]
pub fn likely(cond: bool) -> bool {
#[cfg(feature = "nightly")]
unsafe {
intrinsics::likely(cond)
}
#[cfg(not(feature = "nightly"))]
cond
}
}