File tree Expand file tree Collapse file tree 10 files changed +84
-160
lines changed
Expand file tree Collapse file tree 10 files changed +84
-160
lines changed Original file line number Diff line number Diff line change 1515
1616#include " xsimd_base.hpp"
1717#include " xsimd_neon_bool.hpp"
18+ #include " xsimd_neon_int_base.hpp"
1819#include " xsimd_neon_utils.hpp"
1920
2021namespace xsimd
@@ -224,6 +225,7 @@ namespace xsimd
224225
225226 template <>
226227 struct batch_kernel <int16_t , 8 >
228+ : neon_int_kernel_base<batch<int16_t , 8 >>
227229 {
228230 using batch_type = batch<int16_t , 8 >;
229231 using value_type = int16_t ;
@@ -323,26 +325,6 @@ namespace xsimd
323325 return vabsq_s16 (rhs);
324326 }
325327
326- static batch_type fma (const batch_type& x, const batch_type& y, const batch_type& z)
327- {
328- return x * y + z;
329- }
330-
331- static batch_type fms (const batch_type& x, const batch_type& y, const batch_type& z)
332- {
333- return x * y - z;
334- }
335-
336- static batch_type fnma (const batch_type& x, const batch_type& y, const batch_type& z)
337- {
338- return -x * y + z;
339- }
340-
341- static batch_type fnms (const batch_type& x, const batch_type& y, const batch_type& z)
342- {
343- return -x * y - z;
344- }
345-
346328 static value_type hadd (const batch_type& rhs)
347329 {
348330#if XSIMD_ARM_INSTR_SET >= XSIMD_ARM8_64_NEON_VERSION
Original file line number Diff line number Diff line change 1515
1616#include " xsimd_base.hpp"
1717#include " xsimd_neon_bool.hpp"
18+ #include " xsimd_neon_int_base.hpp"
1819#include " xsimd_neon_utils.hpp"
1920
2021namespace xsimd
@@ -304,6 +305,7 @@ namespace xsimd
304305 {
305306 template <>
306307 struct batch_kernel <int32_t , 4 >
308+ : neon_int_kernel_base<batch<int32_t , 4 >>
307309 {
308310 using batch_type = batch<int32_t , 4 >;
309311 using value_type = int32_t ;
@@ -407,26 +409,6 @@ namespace xsimd
407409 return vabsq_s32 (rhs);
408410 }
409411
410- static batch_type fma (const batch_type& x, const batch_type& y, const batch_type& z)
411- {
412- return x * y + z;
413- }
414-
415- static batch_type fms (const batch_type& x, const batch_type& y, const batch_type& z)
416- {
417- return x * y - z;
418- }
419-
420- static batch_type fnma (const batch_type& x, const batch_type& y, const batch_type& z)
421- {
422- return -x * y + z;
423- }
424-
425- static batch_type fnms (const batch_type& x, const batch_type& y, const batch_type& z)
426- {
427- return -x * y - z;
428- }
429-
430412 static value_type hadd (const batch_type& rhs)
431413 {
432414#if XSIMD_ARM_INSTR_SET >= XSIMD_ARM8_64_NEON_VERSION
Original file line number Diff line number Diff line change 1212#define XSIMD_NEON_INT64_HPP
1313
1414#include " xsimd_base.hpp"
15+ #include " xsimd_neon_int_base.hpp"
1516
1617namespace xsimd
1718{
@@ -303,6 +304,7 @@ namespace xsimd
303304 {
304305 template <>
305306 struct batch_kernel <int64_t , 2 >
307+ : neon_int_kernel_base<batch<int64_t , 2 >>
306308 {
307309 using batch_type = batch<int64_t , 2 >;
308310 using value_type = int64_t ;
@@ -424,26 +426,6 @@ namespace xsimd
424426#endif
425427 }
426428
427- static batch_type fma (const batch_type& x, const batch_type& y, const batch_type& z)
428- {
429- return x * y + z;
430- }
431-
432- static batch_type fms (const batch_type& x, const batch_type& y, const batch_type& z)
433- {
434- return x * y - z;
435- }
436-
437- static batch_type fnma (const batch_type& x, const batch_type& y, const batch_type& z)
438- {
439- return -x * y + z;
440- }
441-
442- static batch_type fnms (const batch_type& x, const batch_type& y, const batch_type& z)
443- {
444- return -x * y - z;
445- }
446-
447429 static value_type hadd (const batch_type& rhs)
448430 {
449431#if XSIMD_ARM_INSTR_SET >= XSIMD_ARM8_64_NEON_VERSION
Original file line number Diff line number Diff line change 1515
1616#include " xsimd_base.hpp"
1717#include " xsimd_neon_bool.hpp"
18+ #include " xsimd_neon_int_base.hpp"
1819#include " xsimd_neon_utils.hpp"
1920
2021namespace xsimd
@@ -224,6 +225,7 @@ namespace xsimd
224225
225226 template <>
226227 struct batch_kernel <int8_t , 16 >
228+ : neon_int_kernel_base<batch<int8_t , 16 >>
227229 {
228230 using batch_type = batch<int8_t , 16 >;
229231 using value_type = int8_t ;
@@ -323,26 +325,6 @@ namespace xsimd
323325 return vabsq_s8 (rhs);
324326 }
325327
326- static batch_type fma (const batch_type& x, const batch_type& y, const batch_type& z)
327- {
328- return x * y + z;
329- }
330-
331- static batch_type fms (const batch_type& x, const batch_type& y, const batch_type& z)
332- {
333- return x * y - z;
334- }
335-
336- static batch_type fnma (const batch_type& x, const batch_type& y, const batch_type& z)
337- {
338- return -x * y + z;
339- }
340-
341- static batch_type fnms (const batch_type& x, const batch_type& y, const batch_type& z)
342- {
343- return -x * y - z;
344- }
345-
346328 // Not implemented yet
347329 static value_type hadd (const batch_type& rhs)
348330 {
Original file line number Diff line number Diff line change 1+ /* **************************************************************************
2+ * Copyright (c) Johan Mabille, Sylvain Corlay, Wolf Vollprecht and *
3+ * Martin Renou *
4+ * Copyright (c) QuantStack *
5+ * *
6+ * Distributed under the terms of the BSD 3-Clause License. *
7+ * *
8+ * The full license is in the file LICENSE, distributed with this software. *
9+ ****************************************************************************/
10+
11+ #ifndef XSIMD_NEON_INT_BASE_HPP
12+ #define XSIMD_NEON_INT_BASE_HPP
13+
14+ namespace xsimd
15+ {
16+ namespace detail
17+ {
18+ template <class B >
19+ struct neon_int_kernel_base
20+ {
21+ using batch_type = B;
22+
23+ static batch_type fmin (const batch_type& lhs, const batch_type& rhs)
24+ {
25+ return min (lhs, rhs);
26+ }
27+
28+ static batch_type fmax (const batch_type& lhs, const batch_type& rhs)
29+ {
30+ return max (lhs, rhs);
31+ }
32+
33+ static batch_type fabs (const batch_type& rhs)
34+ {
35+ return abs (rhs);
36+ }
37+ static batch_type fma (const batch_type& x, const batch_type& y, const batch_type& z)
38+ {
39+ return x * y + z;
40+ }
41+
42+ static batch_type fms (const batch_type& x, const batch_type& y, const batch_type& z)
43+ {
44+ return x * y - z;
45+ }
46+
47+ static batch_type fnma (const batch_type& x, const batch_type& y, const batch_type& z)
48+ {
49+ return -x * y + z;
50+ }
51+
52+ static batch_type fnms (const batch_type& x, const batch_type& y, const batch_type& z)
53+ {
54+ return -x * y - z;
55+ }
56+ };
57+ }
58+ }
59+
60+ #endif
61+
Original file line number Diff line number Diff line change 1515
1616#include " xsimd_base.hpp"
1717#include " xsimd_neon_bool.hpp"
18+ #include " xsimd_neon_int_base.hpp"
1819#include " xsimd_neon_utils.hpp"
1920
2021namespace xsimd
@@ -197,6 +198,7 @@ namespace xsimd
197198 {
198199 template <>
199200 struct batch_kernel <uint16_t , 8 >
201+ : neon_int_kernel_base<batch<uint16_t , 8 >>
200202 {
201203 using batch_type = batch<uint16_t , 8 >;
202204 using value_type = uint16_t ;
@@ -296,26 +298,6 @@ namespace xsimd
296298 return rhs;
297299 }
298300
299- static batch_type fma (const batch_type& x, const batch_type& y, const batch_type& z)
300- {
301- return x * y + z;
302- }
303-
304- static batch_type fms (const batch_type& x, const batch_type& y, const batch_type& z)
305- {
306- return x * y - z;
307- }
308-
309- static batch_type fnma (const batch_type& x, const batch_type& y, const batch_type& z)
310- {
311- return -x * y + z;
312- }
313-
314- static batch_type fnms (const batch_type& x, const batch_type& y, const batch_type& z)
315- {
316- return -x * y - z;
317- }
318-
319301 // Not implemented yet
320302 static value_type hadd (const batch_type& rhs)
321303 {
Original file line number Diff line number Diff line change 1515
1616#include " xsimd_base.hpp"
1717#include " xsimd_neon_bool.hpp"
18+ #include " xsimd_neon_int_base.hpp"
1819#include " xsimd_neon_utils.hpp"
1920
2021namespace xsimd
@@ -295,6 +296,7 @@ namespace xsimd
295296 {
296297 template <>
297298 struct batch_kernel <uint32_t , 4 >
299+ : neon_int_kernel_base<batch<uint32_t , 4 >>
298300 {
299301 using batch_type = batch<uint32_t , 4 >;
300302 using value_type = uint32_t ;
@@ -398,26 +400,6 @@ namespace xsimd
398400 return rhs;
399401 }
400402
401- static batch_type fma (const batch_type& x, const batch_type& y, const batch_type& z)
402- {
403- return x * y + z;
404- }
405-
406- static batch_type fms (const batch_type& x, const batch_type& y, const batch_type& z)
407- {
408- return x * y - z;
409- }
410-
411- static batch_type fnma (const batch_type& x, const batch_type& y, const batch_type& z)
412- {
413- return -x * y + z;
414- }
415-
416- static batch_type fnms (const batch_type& x, const batch_type& y, const batch_type& z)
417- {
418- return -x * y - z;
419- }
420-
421403 static value_type hadd (const batch_type& rhs)
422404 {
423405#if XSIMD_ARM_INSTR_SET >= XSIMD_ARM8_64_NEON_VERSION
Original file line number Diff line number Diff line change 1212#define XSIMD_NEON_UINT64_HPP
1313
1414#include " xsimd_base.hpp"
15+ #include " xsimd_neon_int_base.hpp"
1516
1617namespace xsimd
1718{
@@ -299,6 +300,7 @@ namespace xsimd
299300 {
300301 template <>
301302 struct batch_kernel <uint64_t , 2 >
303+ : neon_int_kernel_base<batch<uint64_t , 2 >>
302304 {
303305 using batch_type = batch<uint64_t , 2 >;
304306 using value_type = uint64_t ;
@@ -452,26 +454,6 @@ namespace xsimd
452454 return rhs;
453455 }
454456
455- static batch_type fma (const batch_type& x, const batch_type& y, const batch_type& z)
456- {
457- return x * y + z;
458- }
459-
460- static batch_type fms (const batch_type& x, const batch_type& y, const batch_type& z)
461- {
462- return x * y - z;
463- }
464-
465- static batch_type fnma (const batch_type& x, const batch_type& y, const batch_type& z)
466- {
467- return -x * y + z;
468- }
469-
470- static batch_type fnms (const batch_type& x, const batch_type& y, const batch_type& z)
471- {
472- return -x * y - z;
473- }
474-
475457 static value_type hadd (const batch_type& rhs)
476458 {
477459#if XSIMD_ARM_INSTR_SET >= XSIMD_ARM8_64_NEON_VERSION
You can’t perform that action at this time.
0 commit comments