3#include "native/isa_import.h"
4#include "native/arm/neon.h"
5#include "native/arm/fp16fml.h"
6#include "native/detail/constexpr_float.h"
7#include "native/arm/float_control.h"
9#if NATIVE_HOST_NEON || defined(NATIVE_DOXYGEN)
10namespace native::detail {
11 template<isa<arm> Arch,
bool Subtract,
bool High,
int Lane,std::
size_t N,std::
size_t M>
12 constexpr simd<float,N,Arch> fp16fml_value(simd<float,N,Arch> acc,
13 simd<fp16,2*N,Arch> a,simd<fp16,M,Arch> b,arm_float_control control={})
noexcept {
14 namespace cf=constexpr_float;
15 std::array<std::uint32_t,N> c{};
16 std::array<std::uint16_t,2*N> av{};
17 std::array<std::uint16_t,M> bv{};
18 acc.store_bits(c.data());a.store_bits(av.data());b.store_bits(bv.data());
19 auto widen=[&](std::uint16_t x) {
20 if(control.flush_half_inputs() && !(x&0x7c00)) x&=0x8000;
21 return cf::is_nan<cf::binary16>(x)?cf::resize_nan<cf::binary32,cf::binary16>(x,
false)
22 :cf::convert_bits<cf::binary32,cf::binary16>(x);
24 for(std::size_t i=0;i<N;++i) {
25 auto index=i+(High?N:0);
27 if constexpr(Subtract) x=control.negate<cf::binary16>(x);
28 c[i]=cf::fma_bits<cf::binary32>(widen(x),widen(bv[Lane<0?index:Lane]),c[i],control.rounding_mode(),control.policy<cf::binary32>());
30 return simd<float,N,Arch>::load_bits(c.data());
50 template<isa<arm> Arch>
requires(Arch.has(arm_feature::fp16fml))
51 [[nodiscard]] hint_inline hint_target(
"fp16fml")
53 simd<
float, 2, Arch> acc,
56 if consteval {
return detail::fp16fml_value<Arch,
false,
false,-1>(acc,a,b); }
else {
57 auto result = detail::fmlal<Arch>(
58 vget_low_f32(detail::arm_neon::to_register<float32x4_t>(acc)),
59 __builtin_bit_cast(float16x4_t, a.to_native()),
60 __builtin_bit_cast(float16x4_t, b.to_native()));
61 return detail::arm_neon::from_register<simd<float, 2, Arch>>(vcombine_f32(result, vdup_n_f32(0.f)));
66 template<isa<arm> Arch>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)))
67 [[nodiscard]]
consteval
72 return detail::fp16fml_value<Arch,
false,
false,-1>(acc,a,b);
76 template<isa<arm> Arch>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)))
77 [[nodiscard]]
constexpr
82 return detail::fp16fml_value<Arch,
false,
false,-1>(acc,a,b, detail::arm_float_control::current());
86 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(arm_feature::fp16fml) && Lane < 4)
87 [[nodiscard]] hint_inline hint_target(
"fp16fml")
92 if consteval {
return detail::fp16fml_value<Arch,false,false,Lane>(acc,a,b); }
else {
93 auto result = detail::fmlal_lane<Arch, Lane>(
94 vget_low_f32(detail::arm_neon::to_register<float32x4_t>(acc)),
95 __builtin_bit_cast(float16x4_t, a.to_native()),
96 __builtin_bit_cast(float16x4_t, b.to_native()));
97 return detail::arm_neon::from_register<simd<float, 2, Arch>>(vcombine_f32(result, vdup_n_f32(0.f)));
102 template<isa<arm> Arch,
unsigned Lane>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 4)
103 [[nodiscard]]
consteval
108 return detail::fp16fml_value<Arch,false,false,Lane>(acc,a,b);
112 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 4)
113 [[nodiscard]]
constexpr
118 return detail::fp16fml_value<Arch,false,false,Lane>(acc,a,b, detail::arm_float_control::current());
122 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(arm_feature::fp16fml) && Lane < 8)
123 [[nodiscard]] hint_inline hint_target(
"fp16fml")
128 if consteval {
return detail::fp16fml_value<Arch,false,false,Lane>(acc,a,b); }
else {
129 auto result = detail::fmlal_lane<Arch, Lane>(
130 vget_low_f32(detail::arm_neon::to_register<float32x4_t>(acc)),
131 __builtin_bit_cast(float16x4_t, a.to_native()),
132 __builtin_bit_cast(float16x8_t, b.to_native()));
133 return detail::arm_neon::from_register<simd<float, 2, Arch>>(vcombine_f32(result, vdup_n_f32(0.f)));
138 template<isa<arm> Arch,
unsigned Lane>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 8)
139 [[nodiscard]]
consteval
144 return detail::fp16fml_value<Arch,false,false,Lane>(acc,a,b);
148 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 8)
149 [[nodiscard]]
constexpr
154 return detail::fp16fml_value<Arch,false,false,Lane>(acc,a,b, detail::arm_float_control::current());
158 template<isa<arm> Arch>
requires(Arch.has(arm_feature::fp16fml))
159 [[nodiscard]] hint_inline hint_target(
"fp16fml")
164 if consteval {
return detail::fp16fml_value<Arch,
false,
false,-1>(acc,a,b); }
else {
165 auto result = detail::fmlal<Arch>(
166 detail::arm_neon::to_register<float32x4_t>(acc),
167 __builtin_bit_cast(float16x8_t, a.to_native()),
168 __builtin_bit_cast(float16x8_t, b.to_native()));
174 template<isa<arm> Arch>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)))
175 [[nodiscard]]
consteval
180 return detail::fp16fml_value<Arch,
false,
false,-1>(acc,a,b);
184 template<isa<arm> Arch>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)))
185 [[nodiscard]]
constexpr
190 return detail::fp16fml_value<Arch,
false,
false,-1>(acc,a,b, detail::arm_float_control::current());
194 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(arm_feature::fp16fml) && Lane < 4)
195 [[nodiscard]] hint_inline hint_target(
"fp16fml")
200 if consteval {
return detail::fp16fml_value<Arch,false,false,Lane>(acc,a,b); }
else {
201 auto result = detail::fmlal_lane<Arch, Lane>(
202 detail::arm_neon::to_register<float32x4_t>(acc),
203 __builtin_bit_cast(float16x8_t, a.to_native()),
204 __builtin_bit_cast(float16x4_t, b.to_native()));
210 template<isa<arm> Arch,
unsigned Lane>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 4)
211 [[nodiscard]]
consteval
216 return detail::fp16fml_value<Arch,false,false,Lane>(acc,a,b);
220 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 4)
221 [[nodiscard]]
constexpr
226 return detail::fp16fml_value<Arch,false,false,Lane>(acc,a,b, detail::arm_float_control::current());
230 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(arm_feature::fp16fml) && Lane < 8)
231 [[nodiscard]] hint_inline hint_target(
"fp16fml")
236 if consteval {
return detail::fp16fml_value<Arch,false,false,Lane>(acc,a,b); }
else {
237 auto result = detail::fmlal_lane<Arch, Lane>(
238 detail::arm_neon::to_register<float32x4_t>(acc),
239 __builtin_bit_cast(float16x8_t, a.to_native()),
240 __builtin_bit_cast(float16x8_t, b.to_native()));
246 template<isa<arm> Arch,
unsigned Lane>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 8)
247 [[nodiscard]]
consteval
252 return detail::fp16fml_value<Arch,false,false,Lane>(acc,a,b);
256 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 8)
257 [[nodiscard]]
constexpr
262 return detail::fp16fml_value<Arch,false,false,Lane>(acc,a,b, detail::arm_float_control::current());
266 template<isa<arm> Arch>
requires(Arch.has(arm_feature::fp16fml))
267 [[nodiscard]] hint_inline hint_target(
"fp16fml")
272 if consteval {
return detail::fp16fml_value<Arch,
false,
true,-1>(acc,a,b); }
else {
273 auto result = detail::fmlal2<Arch>(
274 vget_low_f32(detail::arm_neon::to_register<float32x4_t>(acc)),
275 __builtin_bit_cast(float16x4_t, a.to_native()),
276 __builtin_bit_cast(float16x4_t, b.to_native()));
277 return detail::arm_neon::from_register<simd<float, 2, Arch>>(vcombine_f32(result, vdup_n_f32(0.f)));
282 template<isa<arm> Arch>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)))
283 [[nodiscard]]
consteval
288 return detail::fp16fml_value<Arch,
false,
true,-1>(acc,a,b);
292 template<isa<arm> Arch>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)))
293 [[nodiscard]]
constexpr
298 return detail::fp16fml_value<Arch,
false,
true,-1>(acc,a,b, detail::arm_float_control::current());
302 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(arm_feature::fp16fml) && Lane < 4)
303 [[nodiscard]] hint_inline hint_target(
"fp16fml")
308 if consteval {
return detail::fp16fml_value<Arch,false,true,Lane>(acc,a,b); }
else {
309 auto result = detail::fmlal2_lane<Arch, Lane>(
310 vget_low_f32(detail::arm_neon::to_register<float32x4_t>(acc)),
311 __builtin_bit_cast(float16x4_t, a.to_native()),
312 __builtin_bit_cast(float16x4_t, b.to_native()));
313 return detail::arm_neon::from_register<simd<float, 2, Arch>>(vcombine_f32(result, vdup_n_f32(0.f)));
318 template<isa<arm> Arch,
unsigned Lane>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 4)
319 [[nodiscard]]
consteval
324 return detail::fp16fml_value<Arch,false,true,Lane>(acc,a,b);
328 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 4)
329 [[nodiscard]]
constexpr
334 return detail::fp16fml_value<Arch,false,true,Lane>(acc,a,b, detail::arm_float_control::current());
338 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(arm_feature::fp16fml) && Lane < 8)
339 [[nodiscard]] hint_inline hint_target(
"fp16fml")
344 if consteval {
return detail::fp16fml_value<Arch,false,true,Lane>(acc,a,b); }
else {
345 auto result = detail::fmlal2_lane<Arch, Lane>(
346 vget_low_f32(detail::arm_neon::to_register<float32x4_t>(acc)),
347 __builtin_bit_cast(float16x4_t, a.to_native()),
348 __builtin_bit_cast(float16x8_t, b.to_native()));
349 return detail::arm_neon::from_register<simd<float, 2, Arch>>(vcombine_f32(result, vdup_n_f32(0.f)));
354 template<isa<arm> Arch,
unsigned Lane>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 8)
355 [[nodiscard]]
consteval
360 return detail::fp16fml_value<Arch,false,true,Lane>(acc,a,b);
364 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 8)
365 [[nodiscard]]
constexpr
370 return detail::fp16fml_value<Arch,false,true,Lane>(acc,a,b, detail::arm_float_control::current());
374 template<isa<arm> Arch>
requires(Arch.has(arm_feature::fp16fml))
375 [[nodiscard]] hint_inline hint_target(
"fp16fml")
380 if consteval {
return detail::fp16fml_value<Arch,
false,
true,-1>(acc,a,b); }
else {
381 auto result = detail::fmlal2<Arch>(
382 detail::arm_neon::to_register<float32x4_t>(acc),
383 __builtin_bit_cast(float16x8_t, a.to_native()),
384 __builtin_bit_cast(float16x8_t, b.to_native()));
390 template<isa<arm> Arch>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)))
391 [[nodiscard]]
consteval
396 return detail::fp16fml_value<Arch,
false,
true,-1>(acc,a,b);
400 template<isa<arm> Arch>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)))
401 [[nodiscard]]
constexpr
406 return detail::fp16fml_value<Arch,
false,
true,-1>(acc,a,b, detail::arm_float_control::current());
410 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(arm_feature::fp16fml) && Lane < 4)
411 [[nodiscard]] hint_inline hint_target(
"fp16fml")
416 if consteval {
return detail::fp16fml_value<Arch,false,true,Lane>(acc,a,b); }
else {
417 auto result = detail::fmlal2_lane<Arch, Lane>(
418 detail::arm_neon::to_register<float32x4_t>(acc),
419 __builtin_bit_cast(float16x8_t, a.to_native()),
420 __builtin_bit_cast(float16x4_t, b.to_native()));
426 template<isa<arm> Arch,
unsigned Lane>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 4)
427 [[nodiscard]]
consteval
432 return detail::fp16fml_value<Arch,false,true,Lane>(acc,a,b);
436 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 4)
437 [[nodiscard]]
constexpr
442 return detail::fp16fml_value<Arch,false,true,Lane>(acc,a,b, detail::arm_float_control::current());
446 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(arm_feature::fp16fml) && Lane < 8)
447 [[nodiscard]] hint_inline hint_target(
"fp16fml")
452 if consteval {
return detail::fp16fml_value<Arch,false,true,Lane>(acc,a,b); }
else {
453 auto result = detail::fmlal2_lane<Arch, Lane>(
454 detail::arm_neon::to_register<float32x4_t>(acc),
455 __builtin_bit_cast(float16x8_t, a.to_native()),
456 __builtin_bit_cast(float16x8_t, b.to_native()));
462 template<isa<arm> Arch,
unsigned Lane>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 8)
463 [[nodiscard]]
consteval
468 return detail::fp16fml_value<Arch,false,true,Lane>(acc,a,b);
472 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 8)
473 [[nodiscard]]
constexpr
478 return detail::fp16fml_value<Arch,false,true,Lane>(acc,a,b, detail::arm_float_control::current());
482 template<isa<arm> Arch>
requires(Arch.has(arm_feature::fp16fml))
483 [[nodiscard]] hint_inline hint_target(
"fp16fml")
488 if consteval {
return detail::fp16fml_value<Arch,
true,
false,-1>(acc,a,b); }
else {
489 auto result = detail::fmlsl<Arch>(
490 vget_low_f32(detail::arm_neon::to_register<float32x4_t>(acc)),
491 __builtin_bit_cast(float16x4_t, a.to_native()),
492 __builtin_bit_cast(float16x4_t, b.to_native()));
493 return detail::arm_neon::from_register<simd<float, 2, Arch>>(vcombine_f32(result, vdup_n_f32(0.f)));
498 template<isa<arm> Arch>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)))
499 [[nodiscard]]
consteval
504 return detail::fp16fml_value<Arch,
true,
false,-1>(acc,a,b);
508 template<isa<arm> Arch>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)))
509 [[nodiscard]]
constexpr
514 return detail::fp16fml_value<Arch,
true,
false,-1>(acc,a,b, detail::arm_float_control::current());
518 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(arm_feature::fp16fml) && Lane < 4)
519 [[nodiscard]] hint_inline hint_target(
"fp16fml")
524 if consteval {
return detail::fp16fml_value<Arch,true,false,Lane>(acc,a,b); }
else {
525 auto result = detail::fmlsl_lane<Arch, Lane>(
526 vget_low_f32(detail::arm_neon::to_register<float32x4_t>(acc)),
527 __builtin_bit_cast(float16x4_t, a.to_native()),
528 __builtin_bit_cast(float16x4_t, b.to_native()));
529 return detail::arm_neon::from_register<simd<float, 2, Arch>>(vcombine_f32(result, vdup_n_f32(0.f)));
534 template<isa<arm> Arch,
unsigned Lane>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 4)
535 [[nodiscard]]
consteval
540 return detail::fp16fml_value<Arch,true,false,Lane>(acc,a,b);
544 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 4)
545 [[nodiscard]]
constexpr
550 return detail::fp16fml_value<Arch,true,false,Lane>(acc,a,b, detail::arm_float_control::current());
554 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(arm_feature::fp16fml) && Lane < 8)
555 [[nodiscard]] hint_inline hint_target(
"fp16fml")
560 if consteval {
return detail::fp16fml_value<Arch,true,false,Lane>(acc,a,b); }
else {
561 auto result = detail::fmlsl_lane<Arch, Lane>(
562 vget_low_f32(detail::arm_neon::to_register<float32x4_t>(acc)),
563 __builtin_bit_cast(float16x4_t, a.to_native()),
564 __builtin_bit_cast(float16x8_t, b.to_native()));
565 return detail::arm_neon::from_register<simd<float, 2, Arch>>(vcombine_f32(result, vdup_n_f32(0.f)));
570 template<isa<arm> Arch,
unsigned Lane>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 8)
571 [[nodiscard]]
consteval
576 return detail::fp16fml_value<Arch,true,false,Lane>(acc,a,b);
580 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 8)
581 [[nodiscard]]
constexpr
586 return detail::fp16fml_value<Arch,true,false,Lane>(acc,a,b, detail::arm_float_control::current());
590 template<isa<arm> Arch>
requires(Arch.has(arm_feature::fp16fml))
591 [[nodiscard]] hint_inline hint_target(
"fp16fml")
596 if consteval {
return detail::fp16fml_value<Arch,
true,
false,-1>(acc,a,b); }
else {
597 auto result = detail::fmlsl<Arch>(
598 detail::arm_neon::to_register<float32x4_t>(acc),
599 __builtin_bit_cast(float16x8_t, a.to_native()),
600 __builtin_bit_cast(float16x8_t, b.to_native()));
606 template<isa<arm> Arch>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)))
607 [[nodiscard]]
consteval
612 return detail::fp16fml_value<Arch,
true,
false,-1>(acc,a,b);
616 template<isa<arm> Arch>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)))
617 [[nodiscard]]
constexpr
622 return detail::fp16fml_value<Arch,
true,
false,-1>(acc,a,b, detail::arm_float_control::current());
626 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(arm_feature::fp16fml) && Lane < 4)
627 [[nodiscard]] hint_inline hint_target(
"fp16fml")
632 if consteval {
return detail::fp16fml_value<Arch,true,false,Lane>(acc,a,b); }
else {
633 auto result = detail::fmlsl_lane<Arch, Lane>(
634 detail::arm_neon::to_register<float32x4_t>(acc),
635 __builtin_bit_cast(float16x8_t, a.to_native()),
636 __builtin_bit_cast(float16x4_t, b.to_native()));
642 template<isa<arm> Arch,
unsigned Lane>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 4)
643 [[nodiscard]]
consteval
648 return detail::fp16fml_value<Arch,true,false,Lane>(acc,a,b);
652 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 4)
653 [[nodiscard]]
constexpr
658 return detail::fp16fml_value<Arch,true,false,Lane>(acc,a,b, detail::arm_float_control::current());
662 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(arm_feature::fp16fml) && Lane < 8)
663 [[nodiscard]] hint_inline hint_target(
"fp16fml")
668 if consteval {
return detail::fp16fml_value<Arch,true,false,Lane>(acc,a,b); }
else {
669 auto result = detail::fmlsl_lane<Arch, Lane>(
670 detail::arm_neon::to_register<float32x4_t>(acc),
671 __builtin_bit_cast(float16x8_t, a.to_native()),
672 __builtin_bit_cast(float16x8_t, b.to_native()));
678 template<isa<arm> Arch,
unsigned Lane>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 8)
679 [[nodiscard]]
consteval
684 return detail::fp16fml_value<Arch,true,false,Lane>(acc,a,b);
688 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 8)
689 [[nodiscard]]
constexpr
694 return detail::fp16fml_value<Arch,true,false,Lane>(acc,a,b, detail::arm_float_control::current());
698 template<isa<arm> Arch>
requires(Arch.has(arm_feature::fp16fml))
699 [[nodiscard]] hint_inline hint_target(
"fp16fml")
704 if consteval {
return detail::fp16fml_value<Arch,
true,
true,-1>(acc,a,b); }
else {
705 auto result = detail::fmlsl2<Arch>(
706 vget_low_f32(detail::arm_neon::to_register<float32x4_t>(acc)),
707 __builtin_bit_cast(float16x4_t, a.to_native()),
708 __builtin_bit_cast(float16x4_t, b.to_native()));
709 return detail::arm_neon::from_register<simd<float, 2, Arch>>(vcombine_f32(result, vdup_n_f32(0.f)));
714 template<isa<arm> Arch>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)))
715 [[nodiscard]]
consteval
720 return detail::fp16fml_value<Arch,
true,
true,-1>(acc,a,b);
724 template<isa<arm> Arch>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)))
725 [[nodiscard]]
constexpr
730 return detail::fp16fml_value<Arch,
true,
true,-1>(acc,a,b, detail::arm_float_control::current());
734 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(arm_feature::fp16fml) && Lane < 4)
735 [[nodiscard]] hint_inline hint_target(
"fp16fml")
740 if consteval {
return detail::fp16fml_value<Arch,true,true,Lane>(acc,a,b); }
else {
741 auto result = detail::fmlsl2_lane<Arch, Lane>(
742 vget_low_f32(detail::arm_neon::to_register<float32x4_t>(acc)),
743 __builtin_bit_cast(float16x4_t, a.to_native()),
744 __builtin_bit_cast(float16x4_t, b.to_native()));
745 return detail::arm_neon::from_register<simd<float, 2, Arch>>(vcombine_f32(result, vdup_n_f32(0.f)));
750 template<isa<arm> Arch,
unsigned Lane>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 4)
751 [[nodiscard]]
consteval
756 return detail::fp16fml_value<Arch,true,true,Lane>(acc,a,b);
760 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 4)
761 [[nodiscard]]
constexpr
766 return detail::fp16fml_value<Arch,true,true,Lane>(acc,a,b, detail::arm_float_control::current());
770 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(arm_feature::fp16fml) && Lane < 8)
771 [[nodiscard]] hint_inline hint_target(
"fp16fml")
776 if consteval {
return detail::fp16fml_value<Arch,true,true,Lane>(acc,a,b); }
else {
777 auto result = detail::fmlsl2_lane<Arch, Lane>(
778 vget_low_f32(detail::arm_neon::to_register<float32x4_t>(acc)),
779 __builtin_bit_cast(float16x4_t, a.to_native()),
780 __builtin_bit_cast(float16x8_t, b.to_native()));
781 return detail::arm_neon::from_register<simd<float, 2, Arch>>(vcombine_f32(result, vdup_n_f32(0.f)));
786 template<isa<arm> Arch,
unsigned Lane>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 8)
787 [[nodiscard]]
consteval
792 return detail::fp16fml_value<Arch,true,true,Lane>(acc,a,b);
796 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 2, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 8)
797 [[nodiscard]]
constexpr
802 return detail::fp16fml_value<Arch,true,true,Lane>(acc,a,b, detail::arm_float_control::current());
806 template<isa<arm> Arch>
requires(Arch.has(arm_feature::fp16fml))
807 [[nodiscard]] hint_inline hint_target(
"fp16fml")
812 if consteval {
return detail::fp16fml_value<Arch,
true,
true,-1>(acc,a,b); }
else {
813 auto result = detail::fmlsl2<Arch>(
814 detail::arm_neon::to_register<float32x4_t>(acc),
815 __builtin_bit_cast(float16x8_t, a.to_native()),
816 __builtin_bit_cast(float16x8_t, b.to_native()));
822 template<isa<arm> Arch>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)))
823 [[nodiscard]]
consteval
828 return detail::fp16fml_value<Arch,
true,
true,-1>(acc,a,b);
832 template<isa<arm> Arch>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)))
833 [[nodiscard]]
constexpr
838 return detail::fp16fml_value<Arch,
true,
true,-1>(acc,a,b, detail::arm_float_control::current());
842 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(arm_feature::fp16fml) && Lane < 4)
843 [[nodiscard]] hint_inline hint_target(
"fp16fml")
848 if consteval {
return detail::fp16fml_value<Arch,true,true,Lane>(acc,a,b); }
else {
849 auto result = detail::fmlsl2_lane<Arch, Lane>(
850 detail::arm_neon::to_register<float32x4_t>(acc),
851 __builtin_bit_cast(float16x8_t, a.to_native()),
852 __builtin_bit_cast(float16x4_t, b.to_native()));
858 template<isa<arm> Arch,
unsigned Lane>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 4)
859 [[nodiscard]]
consteval
864 return detail::fp16fml_value<Arch,true,true,Lane>(acc,a,b);
868 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } &&
requires {
sizeof(
simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 4)
869 [[nodiscard]]
constexpr
874 return detail::fp16fml_value<Arch,true,true,Lane>(acc,a,b, detail::arm_float_control::current());
878 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(arm_feature::fp16fml) && Lane < 8)
879 [[nodiscard]] hint_inline hint_target(
"fp16fml")
884 if consteval {
return detail::fp16fml_value<Arch,true,true,Lane>(acc,a,b); }
else {
885 auto result = detail::fmlsl2_lane<Arch, Lane>(
886 detail::arm_neon::to_register<float32x4_t>(acc),
887 __builtin_bit_cast(float16x8_t, a.to_native()),
888 __builtin_bit_cast(float16x8_t, b.to_native()));
894 template<isa<arm> Arch,
unsigned Lane>
requires(!Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 8)
895 [[nodiscard]]
consteval
900 return detail::fp16fml_value<Arch,true,true,Lane>(acc,a,b);
904 template<isa<arm> Arch,
unsigned Lane>
requires(Arch.has(polyfill) &&
requires {
sizeof(simd<float, 4, Arch>); } &&
requires {
sizeof(
simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::fp16fml)) && Lane < 8)
905 [[nodiscard]]
constexpr
910 return detail::fp16fml_value<Arch,true,true,Lane>(acc,a,b, detail::arm_float_control::current());
914 template<isa<arm> Arch,
class A,
class B,
class C>
915 void fmlal(A, B, C) =
delete;
916 template<isa<arm> Arch,
unsigned Lane,
class A,
class B,
class C>
917 void fmlal_lane(A, B, C) =
delete;
918 template<isa<arm> Arch,
class A,
class B,
class C>
919 void fmlal2(A, B, C) =
delete;
920 template<isa<arm> Arch,
unsigned Lane,
class A,
class B,
class C>
921 void fmlal2_lane(A, B, C) =
delete;
922 template<isa<arm> Arch,
class A,
class B,
class C>
923 void fmlsl(A, B, C) =
delete;
924 template<isa<arm> Arch,
unsigned Lane,
class A,
class B,
class C>
925 void fmlsl_lane(A, B, C) =
delete;
926 template<isa<arm> Arch,
class A,
class B,
class C>
927 void fmlsl2(A, B, C) =
delete;
928 template<isa<arm> Arch,
unsigned Lane,
class A,
class B,
class C>
929 void fmlsl2_lane(A, B, C) =
delete;
939#if NATIVE_HOST_NEON || defined(NATIVE_DOXYGEN)
constexpr simd< float, 2, Arch > fmlal(simd< float, 2, Arch > acc, simd< fp16, 4, Arch > a, simd< fp16, 4, Arch > b) noexcept
Add products from the low 2 half lanes of a and b.
constexpr simd< float, 2, Arch > fmlsl(simd< float, 2, Arch > acc, simd< fp16, 4, Arch > a, simd< fp16, 4, Arch > b) noexcept
Subtract products from the low 2 half lanes of a and b.
constexpr simd< float, 2, Arch > fmlsl2_lane(simd< float, 2, Arch > acc, simd< fp16, 4, Arch > a, simd< fp16, 4, Arch > b) noexcept
FMLSL2 with b[Lane] broadcast; selects the high 2 lanes of a.
constexpr simd< float, 2, Arch > fmlal_lane(simd< float, 2, Arch > acc, simd< fp16, 4, Arch > a, simd< fp16, 4, Arch > b) noexcept
FMLAL with b[Lane] broadcast; selects the low 2 lanes of a.
constexpr simd< float, 2, Arch > fmlal2(simd< float, 2, Arch > acc, simd< fp16, 4, Arch > a, simd< fp16, 4, Arch > b) noexcept
Add products from the high 2 half lanes of a and b.
constexpr simd< float, 2, Arch > fmlsl2(simd< float, 2, Arch > acc, simd< fp16, 4, Arch > a, simd< fp16, 4, Arch > b) noexcept
Subtract products from the high 2 half lanes of a and b.
constexpr simd< float, 2, Arch > fmlal2_lane(simd< float, 2, Arch > acc, simd< fp16, 4, Arch > a, simd< fp16, 4, Arch > b) noexcept
FMLAL2 with b[Lane] broadcast; selects the high 2 lanes of a.
constexpr simd< float, 2, Arch > fmlsl_lane(simd< float, 2, Arch > acc, simd< fp16, 4, Arch > a, simd< fp16, 4, Arch > b) noexcept
FMLSL with b[Lane] broadcast; selects the low 2 lanes of a.
Architecture-tagged vectors, register packs and supporting value types. Native arithmetic follows its...
Omitted architecture arguments use the native.simd provider's baseline.