SuperDex Physics C++ API
Loading...
Searching...
No Matches
x64_simd_double_2_inl.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include "x64_simd_inl.h" // for IntelliSense
20
21#if MOCHI_USE_SIMD && MOCHI_ARCH_X64_AVX2
22
23namespace superdex {
24
25/***********************************************************************************************
26 Simd<double, 2>
27*/
28template <>
29class Simd<double, 2> {
30 public:
31 MOCHI_NATIVE_SIMD_IMPL_BOILERPLATE(double, 2, __m128d);
32 Simd(double a, double b) : raw(_mm_set_pd(b, a)) {} // SSE2
33
34 template <class U, MOCHI_REQUIRES_NON_BOOL_SCALAR(U, Scalar)>
35 Simd(U a) : raw(_mm_set_pd1(a)) {} // SSE2
36
37 template <int i>
38 [[nodiscard]] static MOCHI_FORCE_INLINE double Get(Simd v) {
39 static_assert(i >= 0 && i < 2, "Index out of range");
40 if constexpr (i == 0) {
41 return _mm_cvtsd_f64(v.raw); // AVX
42 } else if constexpr (i == 1) {
43 return _mm_cvtsd_f64(_mm_shuffle_pd(v.raw, v.raw, 0x01)); // AVX, AVX
44 }
45 }
46
47 [[nodiscard]] static MOCHI_FORCE_INLINE double Get(Simd v, int i) {
48 MOCHI_ASSERT_VERBOSE(i >= 0 && i < 2, "Index out of range");
49#if MOCHI_COMPILER_MSVC
50 return v.raw.m128d_f64[i];
51#else
52 switch (i) { // clang-format off
53 case 0: return Get<0>(v);
54 case 1: return Get<1>(v);
55 MOCHI_UNLIKELY default: return 0.0;
56 } // clang-format on
57#endif
58 }
59
60 [[nodiscard]] static MOCHI_FORCE_INLINE Simd Set(Simd v, int i, Scalar value) {
61 MOCHI_ASSERT_VERBOSE(i >= 0 && i < 2, "Index out of range");
62#if MOCHI_COMPILER_MSVC
63 auto result = v;
64 result.raw.m128d_f64[i] = value;
65 return result;
66#else
67 static constexpr __m128i kMasks[] = {{-1LL, 0LL}, {0LL, -1LL}};
68 return _mm_blendv_pd(v.raw, _mm_set_pd1(value), _mm_castsi128_pd(kMasks[i])); // SSE4.1
69#endif
70 }
71
72 template <int i>
73 [[nodiscard]] static MOCHI_FORCE_INLINE Simd Set(Simd v, Scalar value) {
74 static_assert(i >= 0 && i < 2, "Index out of range");
75 if constexpr (i == 0) {
76 return _mm_shuffle_pd(_mm_set1_pd(value), v.raw, 0x02); // SSE2
77 } else {
78 return _mm_shuffle_pd(v.raw, _mm_set1_pd(value), 0x02); // SSE2
79 }
80 }
81
82 template <int N>
83 [[nodiscard]] static MOCHI_FORCE_INLINE bool AllTrue(Simd v) {
84 static_assert(N >= 1 && N <= kSize, "Unsupported N");
85 auto mask = GetMSBitMask(v); // One bit for each byte in the vector
86 if constexpr (N == kSize) {
87 return mask == 0x0000FFFF;
88 } else {
89 return (mask & 0x000000FF) == 0x000000FF;
90 }
91 }
92
93 template <int N>
94 [[nodiscard]] static MOCHI_FORCE_INLINE bool AnyTrue(Simd v) {
95 static_assert(N >= 1 && N <= kSize, "Unsupported N");
96 int mask = GetMSBitMask(v); // One bit for each byte in the vector
97 if constexpr (N == kSize) {
98 return mask != 0;
99 } else {
100 return (mask & 0x000000FF) != 0;
101 }
102 }
103
104 template <int x, int y>
105 [[nodiscard]] static MOCHI_FORCE_INLINE Simd Blend(Simd a, Simd b) {
106 static_assert(x >= 0 && x < 2 && y >= 0 && y < 2, "invalid blend index");
107 if constexpr (x == 0 && y == 0) {
108 return a;
109 } else if constexpr (x == 1 && y == 1) {
110 return b;
111 } else {
112 return _mm_blend_pd(a.raw, b.raw, x | (y << 1)); // SSE4.1
113 }
114 }
115
116 [[nodiscard]] static MOCHI_FORCE_INLINE Simd Broadcast(Scalar const* p) {
117 return Simd{*p};
118 }
119
120 template <int i>
121 [[nodiscard]] static MOCHI_FORCE_INLINE Simd Broadcast(Simd v) {
122 return Shuffle<i, i>(v);
123 }
124
125 [[nodiscard]] static Simd LoadIndexed(Scalar const* ptr, Simd<int64_t, 2> const& indices) {
126 return _mm_i64gather_pd(ptr, indices.raw, sizeof(double)); // AVX2
127 }
128
129 template <int N = kSize>
130 [[nodiscard]] static MOCHI_FORCE_INLINE Simd Load([[maybe_unused]] Scalar const* ptr) {
131 static_assert(N >= 0 && N <= kSize);
132 if constexpr (N == 0) {
133 return Simd::Zero();
134 } else if constexpr (N == 1) {
135 return Simd{*ptr, 0.0};
136 } else {
137 return _mm_loadu_pd(ptr); // SSE2
138 }
139 }
140
141 static_assert(sizeof(long long) == 8);
142
143#if MOCHI_COMPILER_MSVC
144 // MSVC defines __m128i as a union. Byte arrays are required to initialize it this way.
145 // clang-format off
146 static constexpr __m128i kLoadMasks[] = {
147 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
148 {-1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0},
149 {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}};
150 // clang-format on
151#else
152 // GCC and Clang define __m128i as 'long long' with special attributes.
153 static constexpr __m128i kLoadMasks[] = {{0LL, 0LL}, {-1LL, 0LL}, {-1LL, -1LL}};
154#endif
155
156 [[nodiscard]] static MOCHI_FORCE_INLINE Simd Load(Scalar const* ptr, int n) {
157 MOCHI_ASSERT_VERBOSE(n >= 0 && n <= kSize, "Invalid size parameter");
158 return _mm_maskload_pd(ptr, kLoadMasks[n]); // AVX
159 }
160
161 template <int kTupleCount = kSize>
162 MOCHI_FORCE_INLINE static void
163 LoadTransposed(Scalar const* ptr, Simd& out0, Simd& out1, Simd& out2) {
164 static_assert(kTupleCount >= 1 && kTupleCount <= kSize, "Invalid kTupleCount");
165 constexpr int kCount1 = Clamp(kTupleCount * 3 - 2, 0, 2);
166 constexpr int kCount2 = Clamp(kTupleCount * 3 - 4, 0, 2);
167 auto a = Simd::Load<2>(ptr).raw; // [0,1]
168 auto b = Simd::Load<kCount1>(kCount1 == 0 ? ptr : ptr + 2).raw; // [2,3]
169 auto c = Simd::Load<kCount2>(kCount2 == 0 ? ptr : ptr + 4).raw; // [4,5]
170 out0.raw = _mm_shuffle_pd(a, b, 0b0010); // [0,3]
171 out1.raw = _mm_shuffle_pd(a, c, 0b0001); // [1,4]
172 out2.raw = _mm_shuffle_pd(b, c, 0b0010); // [2,5]
173 }
174
175 template <int N = kSize>
176 static MOCHI_FORCE_INLINE void Store([[maybe_unused]] Scalar* ptr, [[maybe_unused]] Simd v) {
177 static_assert(N >= 0 && N <= kSize);
178 if constexpr (N == 0) {
179 } else if constexpr (N < kSize) {
180 // About 3X faster than a masked store on AMD. About the same on Intel.
181 memcpy(ptr, &v, sizeof(Scalar) * N);
182 } else {
183 _mm_storeu_pd(ptr, v.raw); // SSE2
184 }
185 }
186
187 static MOCHI_FORCE_INLINE void Store(Scalar* ptr, Simd v, int n) {
188 MOCHI_ASSERT_VERBOSE(n >= 0 && n <= kSize, "Invalid size parameter");
189 // Faster than masked store on AMD.
190 switch (n) { // clang-format off
191 case 1: Store<1>(ptr, v); break;
192 case 2: Store<2>(ptr, v); break;
193 MOCHI_UNLIKELY default: break;
194 } // clang-format on
195 }
196
197 MOCHI_FORCE_INLINE static int StoreSelected(Scalar* ptr, Simd condition, Simd values) {
198 auto mask = _mm_movemask_pd(condition.raw);
199 auto swapped = _mm_shuffle_pd(values.raw, values.raw, 1); // swap halves
200 auto blendMask =
201 _mm_castsi128_pd(_mm_set1_epi32((mask & 1) - 1)); // swap first bit of mask is zero
202 _mm_storeu_pd(ptr, _mm_blendv_pd(values.raw, swapped, blendMask));
203 return _mm_popcnt_u32(mask);
204 }
205
206 template <int kTupleCount = kSize>
207 MOCHI_FORCE_INLINE static void StoreTransposed(Scalar* ptr, Simd a, Simd b, Simd c) {
208 static_assert(kTupleCount >= 1 && kTupleCount <= kSize, "Invalid kTupleCount");
209 // a = [0,3], b = [1,4], c = [2,5]
210 Simd::Store<2>(ptr, _mm_shuffle_pd(a.raw, b.raw, 0b00)); // [0,1]
211 constexpr int kCount1 = Clamp(kTupleCount * 3 - 2, 0, 2);
212 constexpr int kCount2 = Clamp(kTupleCount * 3 - 4, 0, 2);
213 if constexpr (kCount1 > 0) {
214 Simd::Store<kCount1>(ptr + 2, _mm_shuffle_pd(c.raw, a.raw, 0b10)); // [2,3]
215 }
216 if constexpr (kCount2 > 0) {
217 Simd::Store<kCount2>(ptr + 4, _mm_shuffle_pd(b.raw, c.raw, 0b11)); // [4,5]
218 }
219 }
220
221 [[nodiscard]] static MOCHI_FORCE_INLINE Simd Select(Simd mask, Simd a, Simd b) {
222 return _mm_blendv_pd(b.raw, a.raw, mask.raw); // SSE4.1
223 }
224
225 // return Simd{v[x], v[y]}
226 template <int x = 0, int y = 1>
227 [[nodiscard]] static MOCHI_FORCE_INLINE Simd Shuffle(Simd v) {
228 static_assert(x >= 0 && x < 2, "Invalid index");
229 static_assert(y >= 0 && y < 2, "Invalid index");
230 if constexpr (x == 0 && y == 1) {
231 return v;
232 } else {
233 return _mm_shuffle_pd(v.raw, v.raw, x | (y << 1)); // SSE2
234 }
235 }
236
237 [[nodiscard]] static MOCHI_FORCE_INLINE Simd Sqrt(Simd v) {
238 return _mm_sqrt_pd(v.raw); // SSE2
239 }
240
241 [[nodiscard]] static MOCHI_FORCE_INLINE Simd RcpApprox(Simd v) {
242 return Simd{1.0} / v;
243 }
244
245 [[nodiscard]] static MOCHI_FORCE_INLINE Simd RcpSqrtApprox(Simd v) {
246 return Simd{1.0} / Sqrt(v);
247 }
248
249 // Broadcast the value -0.0. Use this in bitwise operations to affect just the sign bit.
250 [[nodiscard]] static MOCHI_FORCE_INLINE Simd SignBitMask() {
251 return _mm_castsi128_pd(_mm_set1_epi64x(0x8000000000000000LL)); // SSE2, SSE2
252 }
253
254 [[nodiscard]] static MOCHI_FORCE_INLINE Simd Abs(Simd v) {
255 return _mm_andnot_pd(SignBitMask().raw, v.raw); // SSE2
256 }
257
258 [[nodiscard]] static MOCHI_FORCE_INLINE Simd Min(Simd a, Simd b) {
259 return _mm_min_pd(a.raw, b.raw); // SSE2
260 }
261
262 [[nodiscard]] static MOCHI_FORCE_INLINE Simd Max(Simd a, Simd b) {
263 return _mm_max_pd(a.raw, b.raw); // SSE2
264 }
265
266 [[nodiscard]] static MOCHI_FORCE_INLINE Simd Floor(Simd a) {
267 return _mm_floor_pd(a.raw); // SSE4.1
268 }
269
270 [[nodiscard]] static MOCHI_FORCE_INLINE Simd FastRound(Simd v) {
271 return _mm_round_pd(v.raw, _MM_FROUND_TO_NEAREST_INT); // SSE4.1
272 }
273
274#if MOCHI_ARCH_X64_SVML
275 [[nodiscard]] static MOCHI_FORCE_INLINE Simd Cos(Simd a) {
276 return _mm_cos_pd(a.raw); // SSE
277 }
278
279 [[nodiscard]] static MOCHI_FORCE_INLINE Simd Sin(Simd a) {
280 return _mm_sin_pd(a.raw); // SSE
281 }
282
283 [[nodiscard]] static MOCHI_FORCE_INLINE Simd Tan(Simd a) {
284 return _mm_tan_pd(a.raw); // SSE
285 }
286
287 [[nodiscard]] static MOCHI_FORCE_INLINE Simd ACos(Simd a) {
288 return _mm_acos_pd(a.raw); // SSE
289 }
290
291 [[nodiscard]] static MOCHI_FORCE_INLINE Simd ASin(Simd a) {
292 return _mm_asin_pd(a.raw); // SSE
293 }
294
295 [[nodiscard]] static MOCHI_FORCE_INLINE Simd ATan(Simd a) {
296 return _mm_atan_pd(a.raw); // SSE
297 }
298
299 [[nodiscard]] static MOCHI_FORCE_INLINE Simd Exp(Simd a) {
300 return _mm_exp_pd(a.raw); // SSE
301 }
302
303 [[nodiscard]] static MOCHI_FORCE_INLINE Simd Ln(Simd a) {
304 return _mm_log_pd(a.raw); // SSE
305 }
306
307 [[nodiscard]] static MOCHI_FORCE_INLINE Simd Tanh(Simd a) {
308 return _mm_tanh_pd(a.raw); // SSE
309 }
310#endif // MOCHI_ARCH_X64_SVML
311
312 [[nodiscard]] static MOCHI_FORCE_INLINE Simd MulAdd(Simd a, Simd b, Simd c) {
313#if MOCHI_ARCH_X64_FMA
314 return {_mm_fmadd_pd(a.raw, b.raw, c.raw)}; // FMA
315#else
316 return (a * b) + c;
317#endif
318 }
319
320 [[nodiscard]] static MOCHI_FORCE_INLINE Simd MulSub(Simd a, Simd b, Simd c) {
321#if MOCHI_ARCH_X64_FMA
322 return _mm_fmsub_pd(a.raw, b.raw, c.raw); // FMA
323#else
324 return (a * b) - c;
325#endif
326 }
327
328 [[nodiscard]] static MOCHI_FORCE_INLINE Simd NegMulAdd(Simd a, Simd b, Simd c) {
329#if MOCHI_ARCH_X64_FMA
330 return _mm_fnmadd_pd(a.raw, b.raw, c.raw); // FMA
331#else
332 return -(a * b) + c;
333#endif
334 }
335
336 [[nodiscard]] static MOCHI_FORCE_INLINE Simd NegMulSub(Simd a, Simd b, Simd c) {
337#if MOCHI_ARCH_X64_FMA
338 return _mm_fnmsub_pd(a.raw, b.raw, c.raw); // FMA
339#else
340 return -(a * b) - c;
341#endif
342 }
343
344 template <int N = 2>
345 [[nodiscard]] static MOCHI_FORCE_INLINE Scalar HMin(Simd a) {
346 static_assert(N == 2, "Unsupported N");
347 return Get<0>(Min(a, Broadcast<1>(a)));
348 }
349
350 template <int N = 2>
351 [[nodiscard]] static MOCHI_FORCE_INLINE Scalar HMax(Simd a) {
352 static_assert(N == 2, "Unsupported N");
353 return Get<0>(Max(a, Broadcast<1>(a)));
354 }
355
356 template <int N>
357 [[nodiscard]] static MOCHI_FORCE_INLINE Scalar HSum(Simd a) {
358 static_assert(N == 2, "Unsupported N");
359 return Get<0>(a) + Get<1>(a);
360 }
361
362 template <int N>
363 [[nodiscard]] static MOCHI_FORCE_INLINE Scalar HProd(Simd a) {
364 static_assert(N == 2, "Unsupported N");
365 return Get<0>(Broadcast<0>(a) * Broadcast<1>(a));
366 }
367
368 template <int N>
369 [[nodiscard]] static MOCHI_FORCE_INLINE Simd Dot(Simd a, Simd b) {
370 static_assert(N == 2, "Unsupported N");
371#if MOCHI_COMPILER_CLANG
372 return _mm_dp_pd(a.raw, b.raw, -1); // SSE4.1
373#else
374 return _mm_dp_pd(a.raw, b.raw, 0xFF); // SSE4.1
375#endif
376 }
377
378 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator<(Simd rhs) const {
379 return _mm_cmplt_pd(this->raw, rhs.raw); // SSE
380 }
381
382 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator>(Simd rhs) const {
383 return _mm_cmpgt_pd(this->raw, rhs.raw); // SSE2
384 }
385
386 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator<=(Simd rhs) const {
387 return _mm_cmple_pd(this->raw, rhs.raw); // SSE2
388 }
389
390 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator>=(Simd rhs) const {
391 return _mm_cmpge_pd(this->raw, rhs.raw); // SSE2
392 }
393
394 [[nodiscard]] static MOCHI_FORCE_INLINE Simd Equal(Simd a, Simd b) {
395 return _mm_cmpeq_pd(a.raw, b.raw); // SSE2
396 }
397
398 [[nodiscard]] static MOCHI_FORCE_INLINE Simd NotEqual(Simd a, Simd b) {
399 return _mm_cmpneq_pd(a.raw, b.raw); // SSE2
400 }
401
402 [[nodiscard]] static MOCHI_FORCE_INLINE Simd Zero() {
403 return _mm_setzero_pd(); // SSE2
404 }
405
406 [[nodiscard]] MOCHI_FORCE_INLINE bool operator==(Simd rhs) const {
407 auto mask = GetMSBitMask(Equal(raw, rhs.raw));
408 return mask == 0xFFFF; // All values equal
409 }
410
411 [[nodiscard]] MOCHI_FORCE_INLINE bool operator!=(Simd rhs) const {
412 auto mask = GetMSBitMask(NotEqual(raw, rhs.raw));
413 return mask != 0; // Any values not equal
414 }
415
416 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator~() const {
417 // _mm_cmpeq_epi32 appears to be the fastest way to fill an SSE register with ones.
418 __m128i dummy{};
419 __m128d ones = _mm_castsi128_pd(_mm_cmpeq_epi32(dummy, dummy)); // SSE2, SSE2
420 return _mm_xor_pd(raw, ones); // SSE2
421 }
422
423 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator-() const {
424 return _mm_xor_pd(raw, SignBitMask().raw); // SSE2, SSE2
425 }
426
427 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator+(Simd rhs) const {
428 return _mm_add_pd(raw, rhs.raw); // SSE2
429 }
430
431 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator-(Simd rhs) const {
432 return _mm_sub_pd(raw, rhs.raw); // SSE2
433 }
434
435 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator*(Simd rhs) const {
436 return _mm_mul_pd(raw, rhs.raw); // SSE2
437 }
438
439 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator/(Simd rhs) const {
440 return _mm_div_pd(raw, rhs.raw); // SSE2
441 }
442
443 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator&(Simd rhs) const {
444 return _mm_and_pd(raw, rhs.raw); // SSE2
445 }
446
447 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator|(Simd rhs) const {
448 return _mm_or_pd(raw, rhs.raw); // SSE2
449 }
450
451 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator^(Simd rhs) const {
452 return _mm_xor_pd(raw, rhs.raw); // SSE2
453 }
454
455 private:
456 // Integer mask with with the most significant bit of each byte in the vector
457 [[nodiscard]] static MOCHI_FORCE_INLINE int GetMSBitMask(Simd a) {
458 return _mm_movemask_epi8(_mm_castpd_si128(a.raw)); // SSE2, SSE2
459 }
460};
461
462} // namespace superdex
463
464#endif // MOCHI_USE_SIMD && MOCHI_ARCH_X64_AVX2
Simd operator&(Simd rhs) const
bool operator==(Simd rhs) const
NativeType raw
Definition simd.h:174
Simd operator>(Simd rhs) const
Simd operator*(Simd rhs) const
Simd operator^(Simd rhs) const
Simd operator-() const
Simd operator>=(Simd rhs) const
Simd operator<(Simd rhs) const
bool operator!=(Simd rhs) const
Simd operator|(Simd rhs) const
static constexpr int kSize
Definition simd.h:96
Simd operator+(Simd rhs) const
Simd operator~() const
Simd operator/(Simd rhs) const
Simd operator<=(Simd rhs) const
#define MOCHI_ASSERT_VERBOSE(condition_without_side_effects,...)
Definition debug.h:102
#define MOCHI_UNLIKELY
#define MOCHI_FORCE_INLINE
T Dot(Simd< T, N > a, Simd< T, N > b)
Definition simd.h:666
constexpr T ACos(T a)
Simd< T, 2 > Shuffle(Simd< T, 2 > a)
Definition simd_inl.h:270
V LoadIndexed(typename V::Scalar const *ptr, Simd< I, V::kSize > indices)
Definition simd_inl.h:200
constexpr T const & Min(T const &a, T const &b)
constexpr auto Equal(T const &a, T const &b)
constexpr T Sin(T a)
T HSum(Simd< T, N > a)
Definition simd_inl.h:379
T HMin(Simd< T, N > a)
Definition simd_inl.h:391
bool AllTrue(T const &a)
Definition basic_utils.h:60
constexpr auto MulAdd(A a, B b, C c)
Simd< T, N > Tanh(Simd< T, N > a)
Definition simd_inl.h:688
Simd< T, N > Set(Simd< T, N > a, T value)
Definition simd_inl.h:315
constexpr auto NotEqual(T const &a, T const &b)
constexpr T Exp(T a)
constexpr T Cos(T a)
T HMax(Simd< T, N > a)
Definition simd_inl.h:397
V Broadcast(typename V::Scalar a)
Definition simd_inl.h:115
constexpr T Abs(T a)
Definition basic_utils.h:50
constexpr auto MulSub(A a, B b, C c)
Simd< T, N > Blend(Simd< T, N > a, Simd< T, N > b)
Definition simd_inl.h:285
constexpr T Tan(T a)
bool AnyTrue(T const &a)
Definition basic_utils.h:66
constexpr T Select(bool condition, T a, T b)
constexpr T Sqrt(T a)
constexpr T ATan(T a)
Simd< T, N > Ln(Simd< T, N > a)
Definition simd_inl.h:678
constexpr auto NegMulAdd(A a, B b, C c)
T Get(Simd< T, N > v)
Definition simd_inl.h:300
constexpr T Floor(T a)
constexpr T ASin(T a)
constexpr ValT Clamp(ValT value, MinT min, MaxT max)
T HProd(Simd< T, N > a)
Definition simd_inl.h:385
constexpr T const & Max(T const &a, T const &b)
void LoadTransposed(T const *ptr, Simd< T, N > &out0, Simd< T, N > &out1, Simd< T, N > &out2)
Definition simd_inl.h:207
Simd< T, N > FastRound(Simd< T, N > a)
Definition simd_inl.h:416
void StoreTransposed(T *ptr, Simd< T, N > a, Simd< T, N > b, Simd< T, N > c)
Definition simd_inl.h:245
void Store(T *ptr, Simd< T, N > a)
Definition simd_inl.h:213
Simd< T, N > RcpSqrtApprox(Simd< T, N > a)
Definition simd_inl.h:359
constexpr T RcpApprox(T a)
constexpr auto NegMulSub(A a, B b, C c)
int StoreSelected(T *ptr, Simd< MaskT, N > condition, Simd< T, N > values)
Definition simd_inl.h:225
V Load(typename V::Scalar const *ptr)
Definition simd_inl.h:184
#define MOCHI_NATIVE_SIMD_IMPL_BOILERPLATE(T, N, NativeT)