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
use crate::simd::SimdValue;
pub trait SimdPartialOrd: SimdValue {
fn simd_gt(self, other: Self) -> Self::SimdBool;
fn simd_lt(self, other: Self) -> Self::SimdBool;
fn simd_ge(self, other: Self) -> Self::SimdBool;
fn simd_le(self, other: Self) -> Self::SimdBool;
fn simd_eq(self, other: Self) -> Self::SimdBool;
fn simd_ne(self, other: Self) -> Self::SimdBool;
fn simd_max(self, other: Self) -> Self;
fn simd_min(self, other: Self) -> Self;
fn simd_clamp(self, min: Self, max: Self) -> Self;
fn simd_horizontal_min(self) -> Self::Element;
fn simd_horizontal_max(self) -> Self::Element;
}
impl<T: PartialOrd + SimdValue<Element = T, SimdBool = bool>> SimdPartialOrd for T {
#[inline(always)]
fn simd_gt(self, other: Self) -> Self::SimdBool {
self > other
}
#[inline(always)]
fn simd_lt(self, other: Self) -> Self::SimdBool {
self < other
}
#[inline(always)]
fn simd_ge(self, other: Self) -> Self::SimdBool {
self >= other
}
#[inline(always)]
fn simd_le(self, other: Self) -> Self::SimdBool {
self <= other
}
#[inline(always)]
fn simd_eq(self, other: Self) -> Self::SimdBool {
self == other
}
#[inline(always)]
fn simd_ne(self, other: Self) -> Self::SimdBool {
self != other
}
#[inline(always)]
fn simd_max(self, other: Self) -> Self {
if self >= other {
self
} else {
other
}
}
#[inline(always)]
fn simd_min(self, other: Self) -> Self {
if self <= other {
self
} else {
other
}
}
#[inline(always)]
fn simd_clamp(self, min: Self, max: Self) -> Self {
if self < min {
min
} else if self > max {
max
} else {
self
}
}
#[inline(always)]
fn simd_horizontal_min(self) -> Self::Element {
self
}
#[inline(always)]
fn simd_horizontal_max(self) -> Self::Element {
self
}
}