SuperDex Physics C++ API
Loading...
Searching...
No Matches
arm_simd_float_4_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 "arm_simd_inl.h" // for IntelliSense
20
21#if MOCHI_USE_SIMD && MOCHI_ARCH_ARM_NEON
22
23namespace superdex {
24
25/***********************************************************************************************
26 Simd<float, 4>
27*/
28template <>
29class Simd<float, 4> {
30 public:
31 MOCHI_NATIVE_SIMD_IMPL_BOILERPLATE(float, 4, float32x4_t);
32
33 MOCHI_FORCE_INLINE Simd(float a, float b, float c = 0.0f, float d = 0.0f) : raw{a, b, c, d} {}
34 template <class U, MOCHI_REQUIRES_NON_BOOL_SCALAR(U, Scalar)>
35 MOCHI_FORCE_INLINE Simd(U a) : raw{vdupq_n_f32(a)} {}
36
37 template <int i>
38 [[nodiscard]] MOCHI_FORCE_INLINE static Scalar Get(Simd v) {
39 static_assert(i >= 0 && i < 4, "Index out of range");
40 return vgetq_lane_f32(v.raw, i);
41 }
42
43 [[nodiscard]] MOCHI_FORCE_INLINE Scalar operator[](int i) const {
44 MOCHI_ASSERT_VERBOSE(i >= 0 && i < kSize, "Index out of range");
45 return raw[i];
46 }
47
48 [[nodiscard]] MOCHI_FORCE_INLINE static Simd Set(Simd v, int i, Scalar value) {
49 MOCHI_ASSERT_VERBOSE(i >= 0 && i < kSize, "Index out of range");
50 auto result = v;
51 result.raw[i] = value;
52 return result;
53 }
54
55 template <int i>
56 [[nodiscard]] MOCHI_FORCE_INLINE static Simd Set(Simd v, Scalar value) {
57 static_assert(i >= 0 && i < kSize, "Index out of range");
58 return Set(v, i, value);
59 }
60
61 [[nodiscard]] MOCHI_FORCE_INLINE static Simd AsPoint(Simd a) {
62 return vsetq_lane_f32(1.0f, a.raw, 3);
63 }
64
65 [[nodiscard]] MOCHI_FORCE_INLINE static Simd AsDirection(Simd a) {
66 return vsetq_lane_f32(0.0f, a.raw, 3);
67 }
68
69 template <int x, int y, int z, int w>
70 [[nodiscard]] MOCHI_FORCE_INLINE static Simd Blend(Simd a, Simd b) {
71 static_assert(
72 x >= 0 && x <= 1 && y >= 0 && y <= 1 && z >= 0 && z <= 1 && w >= 0 && w <= 1,
73 "invalid blend index");
74 int constexpr kCount = x + y + z + w;
75 if constexpr (kCount == 0) {
76 return a;
77 } else if constexpr (kCount == 4) {
78 return b;
79 } else if constexpr (kCount == 1) {
80 // Replace one lane of a with the corresponding lane of b.
81 int constexpr kLane = x ? 0 : (y ? 1 : (z ? 2 : 3));
82 return vcopyq_laneq_f32(a.raw, kLane, b.raw, kLane);
83 } else if constexpr (kCount == 3) {
84 // Replace one lane of b with the corresponding lane of a.
85 int constexpr kLane = !x ? 0 : (!y ? 1 : (!z ? 2 : 3));
86 return vcopyq_laneq_f32(b.raw, kLane, a.raw, kLane);
87 } else if constexpr (x == 1 && y == 1) { // <1,1,0,0>: low half from b, high from a
88 return vcombine_f32(vget_low_f32(b.raw), vget_high_f32(a.raw));
89 } else if constexpr (z == 1 && w == 1) { // <0,0,1,1>: low half from a, high from b
90 return vcombine_f32(vget_low_f32(a.raw), vget_high_f32(b.raw));
91 } else {
92 // Remaining patterns: <1,0,1,0>, <0,1,0,1>, <1,0,0,1>, <0,1,1,0>.
93 // mask lane = -1 -> select from a; mask lane = 0 -> select from b.
94 auto mask = int32x4_t{x ? 0 : -1, y ? 0 : -1, z ? 0 : -1, w ? 0 : -1};
95 return Select(vreinterpretq_f32_s32(mask), a, b);
96 }
97 }
98
99 template <int N>
100 [[nodiscard]] MOCHI_FORCE_INLINE static bool AllTrue(Simd v) {
101 static_assert(N >= 1 && N <= 4, "Invalid number of components");
102 uint64_t mask =
103 vget_lane_u64(vreinterpret_u64_u16(vqmovn_u32(vreinterpretq_u32_f32(v.raw))), 0);
104 if constexpr (N == kSize) {
105 return mask == 0xFFFFFFFFFFFFFFFFULL;
106 } else {
107 int constexpr kNumBits = N * 16; // 64-bit mask has 16 bits per lane
108 auto constexpr kMustBeSet = (uint64_t(1) << kNumBits) - 1;
109 return (mask & kMustBeSet) == kMustBeSet;
110 }
111 }
112
113 template <int N>
114 [[nodiscard]] MOCHI_FORCE_INLINE static bool AnyTrue(Simd v) {
115 static_assert(N >= 1 && N <= 4, "Invalid number of components");
116 uint64_t mask =
117 vget_lane_u64(vreinterpret_u64_u16(vqmovn_u32(vreinterpretq_u32_f32(v.raw))), 0);
118 if constexpr (N == kSize) {
119 return mask != 0;
120 } else {
121 int constexpr kNumBits = N * 16; // 64-bit mask has 16 bits per lane
122 auto constexpr kMayBeSet = (uint64_t(1) << kNumBits) - 1;
123 return (mask & kMayBeSet) != 0;
124 }
125 }
126
127 [[nodiscard]] MOCHI_FORCE_INLINE static Simd Broadcast(float const* p) {
128 return Simd{*p};
129 }
130
131 template <int i>
132 [[nodiscard]] MOCHI_FORCE_INLINE static Simd Broadcast(Simd v) {
133 return vdupq_laneq_f32(v.raw, i);
134 }
135
136 template <int N = kSize>
137 [[nodiscard]] MOCHI_FORCE_INLINE static Simd Load([[maybe_unused]] float const* ptr) {
138 static_assert(N >= 0 && N <= 4);
139 if constexpr (N == 0) {
140 return Simd::Zero();
141 } else if constexpr (N == 1) {
142 return Simd{ptr[0], 0, 0, 0};
143 } else if constexpr (N == 2) {
144 return Simd{ptr[0], ptr[1], 0, 0};
145 } else if constexpr (N == 3) {
146 return Simd{ptr[0], ptr[1], ptr[2], 0};
147 } else {
148 return vld1q_f32(ptr);
149 }
150 }
151
152 [[nodiscard]] MOCHI_FORCE_INLINE static Simd Load(Scalar const* ptr, int n) {
153 MOCHI_ASSERT_VERBOSE(n >= 0 && n <= kSize, "Invalid size parameter");
154 // clang-format off
155 switch (n) {
156 case 1: return Load<1>(ptr);
157 case 2: return Load<2>(ptr);
158 case 3: return Load<3>(ptr);
159 case 4: return Load<4>(ptr);
160 MOCHI_UNLIKELY default: return Zero();
161 } // clang-format on
162 }
163
164 [[nodiscard]] MOCHI_FORCE_INLINE static Simd LoadIndexed(
165 float const* ptr,
166 Simd<int, 4> const& indices) {
167 return Simd<float, 4>{
168 ptr[indices.raw[0]], ptr[indices.raw[1]], ptr[indices.raw[2]], ptr[indices.raw[3]]};
169 }
170
171 template <int kTupleCount = kSize>
172 MOCHI_FORCE_INLINE static void
173 LoadTransposed(float const* ptr, Simd& out0, Simd& out1, Simd& out2) {
174 static_assert(kTupleCount >= 1 && kTupleCount <= kSize, "Unsupported kTupleCount");
175 if constexpr (kTupleCount == 1) {
176 out0.raw = float32x4_t{ptr[0], 0.0f, 0.0f, 0.0f};
177 out1.raw = float32x4_t{ptr[1], 0.0f, 0.0f, 0.0f};
178 out2.raw = float32x4_t{ptr[2], 0.0f, 0.0f, 0.0f};
179 } else if constexpr (kTupleCount == 2) {
180 out0.raw = float32x4_t{ptr[0], ptr[3], 0.0f, 0.0f};
181 out1.raw = float32x4_t{ptr[1], ptr[4], 0.0f, 0.0f};
182 out2.raw = float32x4_t{ptr[2], ptr[5], 0.0f, 0.0f};
183 } else if constexpr (kTupleCount == 3) {
184 out0.raw = float32x4_t{ptr[0], ptr[3], ptr[6], 0.0f};
185 out1.raw = float32x4_t{ptr[1], ptr[4], ptr[7], 0.0f};
186 out2.raw = float32x4_t{ptr[2], ptr[5], ptr[8], 0.0f};
187 } else { // kTupleCount == 4 (kSize)
188 float32x4x3_t result = vld3q_f32(ptr);
189 out0.raw = result.val[0];
190 out1.raw = result.val[1];
191 out2.raw = result.val[2];
192 }
193 }
194
195 // Branchless: each lane loads one tuple from a selected address, inactive lanes from zeros.
196 MOCHI_FORCE_INLINE static void
197 LoadTransposed(Scalar const* ptr, Simd& out0, Simd& out1, Simd& out2, int count) {
198 MOCHI_ASSERT_VERBOSE(count >= 0 && count <= kSize, "Invalid tuple count");
199 float const* const zero = arm_simd::kZeroTuple<float>;
200 float32x4x3_t r = vld3q_dup_f32(count > 0 ? ptr : zero);
201 r = vld3q_lane_f32(count > 1 ? ptr + 3 : zero, r, 1);
202 r = vld3q_lane_f32(count > 2 ? ptr + 6 : zero, r, 2);
203 r = vld3q_lane_f32(count > 3 ? ptr + 9 : zero, r, 3);
204 out0.raw = r.val[0];
205 out1.raw = r.val[1];
206 out2.raw = r.val[2];
207 }
208
209 [[nodiscard]] MOCHI_FORCE_INLINE static Simd Select(Simd mask, Simd a, Simd b) {
210 return vbslq_f32(vreinterpretq_u32_f32(mask.raw), a.raw, b.raw);
211 }
212
213 template <int i>
214 [[nodiscard]] MOCHI_FORCE_INLINE static Simd SetBasisVector() {
215 static_assert(i >= 0 && i <= 3, "Invalid component index");
216 auto zeros = vdupq_n_f32(0);
217 return vsetq_lane_f32(1.0f, zeros, i);
218 }
219
220 template <int x = 0, int y = 1, int z = 2, int w = 3>
221 [[nodiscard]] MOCHI_FORCE_INLINE static Simd Shuffle(Simd a, Simd b) {
222 static_assert(
223 x >= 0 && x < 4 && y >= 0 && y < 4 && z >= 0 && z < 4 && w >= 0 && w < 4, "Invalid index");
224 return Simd{a.raw[x], a.raw[y], b.raw[z], b.raw[w]};
225 }
226
227 template <int x = 0, int y = 1, int z = 2, int w = 3>
228 [[nodiscard]] MOCHI_FORCE_INLINE static Simd Shuffle(Simd v) {
229 return Shuffle<x, y, z, w>(v, v);
230 }
231
232 [[nodiscard]] MOCHI_FORCE_INLINE static Simd SignBitMask() {
233 return vreinterpretq_f32_s32(vdupq_n_s32((int32_t)0x80000000));
234 }
235
236 template <int N = kSize>
237 MOCHI_FORCE_INLINE static void Store([[maybe_unused]] float* ptr, [[maybe_unused]] Simd v) {
238 static_assert(N >= 0 && N <= kSize);
239 if constexpr (N == 0) {
240 } else if constexpr (N < kSize) {
241 memcpy(ptr, &v, sizeof(float) * N);
242 } else {
243 vst1q_f32(ptr, v.raw);
244 }
245 }
246
247 MOCHI_FORCE_INLINE static void Store(Scalar* ptr, Simd v, int n) {
248 MOCHI_ASSERT_VERBOSE(n >= 0 && n <= kSize, "Invalid size parameter");
249 // clang-format off
250 switch (n) {
251 case 1: Store<1>(ptr, v); break;
252 case 2: Store<2>(ptr, v); break;
253 case 3: Store<3>(ptr, v); break;
254 case 4: Store<4>(ptr, v); break;
255 MOCHI_UNLIKELY default: break;
256 } // clang-format on
257 }
258
259 MOCHI_FORCE_INLINE static int StoreSelected(float* ptr, Simd condition, Simd values) {
260 uint32x4_t shifted = vshrq_n_u32(vreinterpretq_u32_f32(condition.raw), 31);
261 uint32x4_t const multipliers = {1, 2, 4, 8};
262 uint32x4_t weighted = vmulq_u32(shifted, multipliers);
263 uint32_t count = vaddvq_u32(shifted);
264 uint32_t mask = vaddvq_u32(weighted);
265 uint8x16_t pattern = vld1q_u8(arm_simd::kStoreSelectedShuffleTableS4[mask]);
266 uint8x16_t packed = vqtbl1q_u8(vreinterpretq_u8_f32(values.raw), pattern);
267 vst1q_f32(ptr, vreinterpretq_f32_u8(packed));
268 return static_cast<int>(count);
269 }
270
271 template <int kTupleCount = kSize>
272 MOCHI_FORCE_INLINE static void StoreTransposed(float* ptr, Simd a, Simd b, Simd c) {
273 static_assert(kTupleCount >= 1 && kTupleCount <= kSize, "Invalid kTupleCount");
274 if constexpr (kTupleCount == 1) {
275 ptr[0] = a.raw[0];
276 ptr[1] = b.raw[0];
277 ptr[2] = c.raw[0];
278 } else if constexpr (kTupleCount == 2) {
279 Simd::Store(ptr, Simd{a[0], b[0], c[0], a[1]});
280 ptr[4] = b.raw[1];
281 ptr[5] = c.raw[1];
282 } else if constexpr (kTupleCount == 3) {
283 Simd::Store(ptr + 0, Simd{a[0], b[0], c[0], a[1]});
284 Simd::Store(ptr + 4, Simd{b[1], c[1], a[2], b[2]});
285 ptr[8] = c.raw[2];
286 } else {
287 vst3q_f32(ptr, float32x4x3_t({a.raw, b.raw, c.raw}));
288 }
289 }
290
291 // Inactive lanes write tuple 0, which lane 0 stores last.
292 MOCHI_FORCE_INLINE static void StoreTransposed(Scalar* ptr, Simd a, Simd b, Simd c, int count) {
293 MOCHI_ASSERT_VERBOSE(count >= 0 && count <= kSize, "Invalid tuple count");
294 if (count == 0) {
295 return;
296 }
297 float32x4x3_t const v = {a.raw, b.raw, c.raw};
298 vst3q_lane_f32(count > 3 ? ptr + 9 : ptr, v, 3);
299 vst3q_lane_f32(count > 2 ? ptr + 6 : ptr, v, 2);
300 vst3q_lane_f32(count > 1 ? ptr + 3 : ptr, v, 1);
301 vst3q_lane_f32(ptr, v, 0);
302 }
303
304 [[nodiscard]] MOCHI_FORCE_INLINE static Simd Sqrt(Simd v) {
305 return vsqrtq_f32(v.raw);
306 }
307
308 [[nodiscard]] MOCHI_FORCE_INLINE static Simd RcpApprox(Simd v) {
309 return vrecpeq_f32(v.raw);
310 }
311
312 [[nodiscard]] MOCHI_FORCE_INLINE static Simd RcpSqrtApprox(Simd v) {
313 return vrsqrteq_f32(v.raw);
314 }
315
316 [[nodiscard]] MOCHI_FORCE_INLINE static Simd Abs(Simd v) {
317 return vabsq_f32(v.raw);
318 }
319
320 [[nodiscard]] MOCHI_FORCE_INLINE static Simd Min(Simd a, Simd b) {
321 return vminq_f32(a.raw, b.raw);
322 }
323
324 [[nodiscard]] MOCHI_FORCE_INLINE static Simd Max(Simd a, Simd b) {
325 return vmaxq_f32(a.raw, b.raw);
326 }
327
328 [[nodiscard]] MOCHI_FORCE_INLINE static Simd Floor(Simd a) {
329 return vrndmq_f32(a.raw);
330 }
331
332 [[nodiscard]] MOCHI_FORCE_INLINE static Simd FastRound(Simd v) {
333 return vrndaq_f32(v.raw);
334 }
335
336 [[nodiscard]] MOCHI_FORCE_INLINE static Simd MulAdd(Simd a, Simd b, Simd c) {
337 return vfmaq_f32(c.raw, b.raw, a.raw);
338 }
339
340 [[nodiscard]] MOCHI_FORCE_INLINE static Simd MulSub(Simd a, Simd b, Simd c) {
341 return MulAdd(a, b, -c);
342 }
343
344 [[nodiscard]] MOCHI_FORCE_INLINE static Simd NegMulAdd(Simd a, Simd b, Simd c) {
345 return vfmsq_f32(c.raw, b.raw, a.raw);
346 }
347
348 [[nodiscard]] MOCHI_FORCE_INLINE static Simd NegMulSub(Simd a, Simd b, Simd c) {
349 return NegMulAdd(a, b, -c);
350 }
351
352 template <int N = 4>
353 [[nodiscard]] MOCHI_FORCE_INLINE static Scalar HMin(Simd a) {
354 static_assert(N >= 2 && N <= 4, "Unsupported N");
355 if constexpr (N == 2) {
356 return superdex::Min(a.raw[0], a.raw[1]);
357 } else if constexpr (N == 3) {
358 return vminvq_f32(vsetq_lane_f32(std::numeric_limits<Scalar>::infinity(), a.raw, 3));
359 } else {
360 return vminvq_f32(a.raw);
361 }
362 }
363
364 template <int N = 4>
365 [[nodiscard]] MOCHI_FORCE_INLINE static Scalar HMax(Simd a) {
366 static_assert(N >= 2 && N <= 4, "Unsupported N");
367 if constexpr (N == 2) {
368 return superdex::Max(a.raw[0], a.raw[1]);
369 } else if constexpr (N == 3) {
370 // HMax({x, y, z, -infinity})
371 return vmaxvq_f32(vsetq_lane_f32(-std::numeric_limits<Scalar>::infinity(), a.raw, 3));
372 } else {
373 return vmaxvq_f32(a.raw);
374 }
375 }
376
377 template <int N>
378 [[nodiscard]] MOCHI_FORCE_INLINE static Scalar HSum(Simd a) {
379 static_assert(N >= 2 && N <= 4, "Unsupported N");
380 if constexpr (N == 2) {
381 return a.raw[0] + a.raw[1];
382 } else if constexpr (N == 3) {
383 return a.raw[0] + a.raw[1] + a.raw[2];
384 } else if constexpr (N == 4) {
385 return vaddvq_f32(a.raw);
386 }
387 }
388
389 [[nodiscard]] MOCHI_FORCE_INLINE static Simd HSumEach(Simd a, Simd b, Simd c, Simd d) {
390 return vpaddq_f32(vpaddq_f32(a.raw, b.raw), vpaddq_f32(c.raw, d.raw));
391 }
392
393 template <int N>
394 [[nodiscard]] MOCHI_FORCE_INLINE static Scalar HProd(Simd a) {
395 static_assert(N >= 2 && N <= 4, "Unsupported N");
396 if constexpr (N == 2) {
397 return a.raw[0] * a.raw[1];
398 } else if constexpr (N == 3) {
399 return a.raw[0] * a.raw[1] * a.raw[2];
400 } else if constexpr (N == 4) {
401 return a.raw[0] * a.raw[1] * a.raw[2] * a.raw[3];
402 }
403 }
404
405 template <int N>
406 [[nodiscard]] MOCHI_FORCE_INLINE static Simd Dot(Simd a, Simd b) {
407 static_assert(N >= 2 && N <= 4, "Unsupported N");
408 return Simd{HSum<N>(a * b)};
409 }
410
411 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator<(Simd rhs) const {
412 return vreinterpretq_f32_u32(vcltq_f32(this->raw, rhs.raw));
413 }
414
415 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator>(Simd rhs) const {
416 return vreinterpretq_f32_u32(vcgtq_f32(this->raw, rhs.raw));
417 }
418
419 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator<=(Simd rhs) const {
420 return vreinterpretq_f32_u32(vcleq_f32(this->raw, rhs.raw));
421 }
422
423 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator>=(Simd rhs) const {
424 return vreinterpretq_f32_u32(vcgeq_f32(this->raw, rhs.raw));
425 }
426
427 [[nodiscard]] MOCHI_FORCE_INLINE static Simd Equal(Simd a, Simd b) {
428 return vreinterpretq_f32_u32(vceqq_f32(a.raw, b.raw));
429 }
430
431 [[nodiscard]] MOCHI_FORCE_INLINE static Simd NotEqual(Simd a, Simd b) {
432 return ~Equal(a, b);
433 }
434
435 [[nodiscard]] MOCHI_FORCE_INLINE static Simd Zero() {
436 return vdupq_n_f32(0);
437 }
438
439 [[nodiscard]] MOCHI_FORCE_INLINE bool operator==(Simd rhs) const {
440 return AllTrue<kSize>(Equal(*this, rhs));
441 }
442
443 [[nodiscard]] MOCHI_FORCE_INLINE bool operator!=(Simd rhs) const {
444 return !(*this == rhs);
445 }
446
447 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator~() const {
448 return vreinterpretq_f32_u32(vmvnq_u32(vreinterpretq_u32_f32(raw)));
449 }
450
451 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator-() const {
452 return vnegq_f32(raw);
453 }
454
455 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator+(Simd rhs) const {
456 return vaddq_f32(raw, rhs.raw);
457 }
458
459 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator-(Simd rhs) const {
460 return vsubq_f32(raw, rhs.raw);
461 }
462
463 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator*(Simd rhs) const {
464 return vmulq_f32(raw, rhs.raw);
465 }
466
467 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator/(Simd rhs) const {
468 return vdivq_f32(raw, rhs.raw);
469 }
470
471 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator&(Simd rhs) const {
472 return vreinterpretq_f32_u32(
473 vandq_u32(vreinterpretq_u32_f32(raw), vreinterpretq_u32_f32(rhs.raw)));
474 }
475
476 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator|(Simd rhs) const {
477 return vreinterpretq_f32_u32(
478 vorrq_u32(vreinterpretq_u32_f32(raw), vreinterpretq_u32_f32(rhs.raw)));
479 }
480
481 [[nodiscard]] MOCHI_FORCE_INLINE Simd operator^(Simd rhs) const {
482 return vreinterpretq_f32_u32(
483 veorq_u32(vreinterpretq_u32_f32(raw), vreinterpretq_u32_f32(rhs.raw)));
484 }
485};
486
487} // namespace superdex
488
489#endif // MOCHI_USE_SIMD && MOCHI_ARCH_ARM_NEON
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
Scalar operator[](int i) 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:704
constexpr T NegMulAdd(T a, T b, T c)
Simd< T, 2 > Shuffle(Simd< T, 2 > a)
Definition simd_inl.h:286
Simd< T, 2 > HSumEach(Simd< T, 2 > a, Simd< T, 2 > b)
Returns {HSum(a), HSum(b)}.
Definition simd_inl.h:400
V LoadIndexed(typename V::Scalar const *ptr, Simd< I, V::kSize > indices)
Definition simd_inl.h:201
constexpr T const & Min(T const &a, T const &b)
constexpr auto Equal(T const &a, T const &b)
T HSum(Simd< T, N > a)
Definition simd_inl.h:390
T HMin(Simd< T, N > a)
Definition simd_inl.h:430
bool AllTrue(T const &a)
Definition basic_utils.h:60
constexpr T NegMulSub(T a, T b, T c)
Simd< T, N > Set(Simd< T, N > a, T value)
Definition simd_inl.h:326
constexpr auto NotEqual(T const &a, T const &b)
T HMax(Simd< T, N > a)
Definition simd_inl.h:440
V Broadcast(typename V::Scalar a)
Definition simd_inl.h:116
constexpr T Abs(T a)
Definition basic_utils.h:50
constexpr T MulSub(T a, T b, T c)
Simd< T, N > Blend(Simd< T, N > a, Simd< T, N > b)
Definition simd_inl.h:301
bool AnyTrue(T const &a)
Definition basic_utils.h:66
constexpr T Select(bool condition, T a, T b)
constexpr T Sqrt(T a)
T Get(Simd< T, N > v)
Definition simd_inl.h:316
constexpr T Floor(T a)
T HProd(Simd< T, N > a)
Definition simd_inl.h:420
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:208
Simd< T, N > FastRound(Simd< T, N > a)
Definition simd_inl.h:465
void StoreTransposed(T *ptr, Simd< T, N > a, Simd< T, N > b, Simd< T, N > c)
Definition simd_inl.h:252
void Store(T *ptr, Simd< T, N > a)
Definition simd_inl.h:220
Simd< T, N > RcpSqrtApprox(Simd< T, N > a)
Definition simd_inl.h:370
constexpr T RcpApprox(T a)
constexpr T MulAdd(T a, T b, T c)
int StoreSelected(T *ptr, Simd< MaskT, N > condition, Simd< T, N > values)
Definition simd_inl.h:232
V Load(typename V::Scalar const *ptr)
Definition simd_inl.h:185
#define MOCHI_NATIVE_SIMD_IMPL_BOILERPLATE(T, N, NativeT)