1 | /* Copyright (C) 2011-2014 Povilas Kanapickas <povilas@radix.lt> |
2 | |
3 | Distributed under the Boost Software License, Version 1.0. |
4 | (See accompanying file LICENSE_1_0.txt or copy at |
5 | http://www.boost.org/LICENSE_1_0.txt) |
6 | */ |
7 | |
8 | #ifndef LIBSIMDPP_SIMDPP_DETAIL_INSN_F_MAX_H |
9 | #define LIBSIMDPP_SIMDPP_DETAIL_INSN_F_MAX_H |
10 | |
11 | #ifndef LIBSIMDPP_SIMD_H |
12 | #error "This file must be included through simd.h" |
13 | #endif |
14 | |
15 | #include <simdpp/types.h> |
16 | #include <simdpp/detail/null/math.h> |
17 | #include <simdpp/detail/vector_array_macros.h> |
18 | |
19 | namespace simdpp { |
20 | namespace SIMDPP_ARCH_NAMESPACE { |
21 | namespace detail { |
22 | namespace insn { |
23 | |
24 | |
25 | static SIMDPP_INL |
26 | float32x4 i_max(const float32x4& a, const float32x4& b) |
27 | { |
28 | #if SIMDPP_USE_NULL || SIMDPP_USE_NEON_NO_FLT_SP |
29 | return detail::null::max(a, b); |
30 | #elif SIMDPP_USE_SSE2 |
31 | return _mm_max_ps(a.native(), b.native()); |
32 | #elif SIMDPP_USE_NEON |
33 | return vmaxq_f32(a.native(), b.native()); |
34 | #elif SIMDPP_USE_ALTIVEC |
35 | return vec_max(a.native(), b.native()); |
36 | #elif SIMDPP_USE_MSA |
37 | return __msa_fmax_w(a.native(), b.native()); |
38 | #endif |
39 | } |
40 | |
41 | #if SIMDPP_USE_AVX |
42 | static SIMDPP_INL |
43 | float32x8 i_max(const float32x8& a, const float32x8& b) |
44 | { |
45 | return _mm256_max_ps(a.native(), b.native()); |
46 | } |
47 | #endif |
48 | |
49 | #if SIMDPP_USE_AVX512F |
50 | static SIMDPP_INL |
51 | float32<16> i_max(const float32<16>& a, const float32<16>& b) |
52 | { |
53 | return _mm512_max_ps(a.native(), b.native()); |
54 | } |
55 | #endif |
56 | |
57 | template<unsigned N> SIMDPP_INL |
58 | float32<N> i_max(const float32<N>& a, const float32<N>& b) |
59 | { |
60 | SIMDPP_VEC_ARRAY_IMPL2(float32<N>, i_max, a, b); |
61 | } |
62 | |
63 | // ----------------------------------------------------------------------------- |
64 | |
65 | static SIMDPP_INL |
66 | float64x2 i_max(const float64x2& a, const float64x2& b) |
67 | { |
68 | #if SIMDPP_USE_SSE2 |
69 | return _mm_max_pd(a.native(), b.native()); |
70 | #elif SIMDPP_USE_NEON64 |
71 | return vmaxq_f64(a.native(), b.native()); |
72 | #elif SIMDPP_USE_VSX_206 |
73 | return vec_max(a.native(), b.native()); |
74 | #elif SIMDPP_USE_MSA |
75 | return __msa_fmax_d(a.native(), b.native()); |
76 | #elif SIMDPP_USE_NULL || SIMDPP_USE_NEON32 || SIMDPP_USE_ALTIVEC |
77 | return detail::null::max(a, b); |
78 | #endif |
79 | } |
80 | |
81 | #if SIMDPP_USE_AVX |
82 | static SIMDPP_INL |
83 | float64x4 i_max(const float64x4& a, const float64x4& b) |
84 | { |
85 | return _mm256_max_pd(a.native(), b.native()); |
86 | } |
87 | #endif |
88 | |
89 | #if SIMDPP_USE_AVX512F |
90 | static SIMDPP_INL |
91 | float64<8> i_max(const float64<8>& a, const float64<8>& b) |
92 | { |
93 | return _mm512_max_pd(a.native(), b.native()); |
94 | } |
95 | #endif |
96 | |
97 | template<unsigned N> SIMDPP_INL |
98 | float64<N> i_max(const float64<N>& a, const float64<N>& b) |
99 | { |
100 | SIMDPP_VEC_ARRAY_IMPL2(float64<N>, i_max, a, b); |
101 | } |
102 | |
103 | } // namespace insn |
104 | } // namespace detail |
105 | } // namespace SIMDPP_ARCH_NAMESPACE |
106 | } // namespace simdpp |
107 | |
108 | #endif |
109 | |
110 | |