IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
IsEqualRegImpl.h
Go to the documentation of this file.
1 // IsEqualRegImpl.h:
3 // -------------------
4 //
14 
15 #ifndef __IPSDKUTIL_INSTRUCTIONSET_COMPARISON_DETAIL_AVX_ISEQUALREGIMPL_H__
16 #define __IPSDKUTIL_INSTRUCTIONSET_COMPARISON_DETAIL_AVX_ISEQUALREGIMPL_H__
17 
21 
22 namespace ipsdk {
23 namespace simd {
24 namespace detail {
25 
28 
29 template <typename T>
30 IPSDK_FORCEINLINE
31 typename RegMaskType<eInstructionSet::eIS_Avx, T>::Type
32 IsEqualReg<eInstructionSet::eIS_Avx, T,
33  typename boost::enable_if<
34  typename boost::mpl::and_<
35  typename boost::is_integral<T>::type,
36  typename boost::mpl::equal_to<boost::mpl::int_<sizeof(T)>, boost::mpl::int_<4> >::type
37  >::type
38  >::type
39 >::act(
40  const typename AvxType<T>::Type& in1,
41  const typename AvxType<T>::Type& in2)
42 {
43  typename RegMaskType<eInstructionSet::eIS_Avx, T>::Type out;
44  act(in1, in2, out);
45  return out;
46 }
47 
48 template <typename T>
49 IPSDK_FORCEINLINE
50 void
51 IsEqualReg<eInstructionSet::eIS_Avx, T,
52  typename boost::enable_if<
53  typename boost::mpl::and_<
54  typename boost::is_integral<T>::type,
55  typename boost::mpl::equal_to<boost::mpl::int_<sizeof(T)>, boost::mpl::int_<4> >::type
56  >::type
57  >::type
58 >::act(
59  const typename AvxType<T>::Type& in1,
60  const typename AvxType<T>::Type& in2,
61  typename RegMaskType<eInstructionSet::eIS_Avx, T>::Type& out)
62 {
63  __m128i in11, in12;
64  __m128i in21, in22;
65  COPY_IMM_TO_XMM(in1, in11, in12);
66  COPY_IMM_TO_XMM(in2, in21, in22);
67  __m128i out1 = _mm_cmpeq_epi32(in11, in21);
68  __m128i out2 = _mm_cmpeq_epi32(in12, in22);
69  COPY_XMM_TO_IMM(out1, out2, out);
70 }
71 
72 IPSDK_FORCEINLINE
73 RegMaskType<eInstructionSet::eIS_Avx, ipReal32>::Type
74 IsEqualReg<eInstructionSet::eIS_Avx, ipReal32>::act(
75  const AvxType<ipReal32>::Type& in1,
76  const AvxType<ipReal32>::Type& in2)
77 {
78  return _mm256_cmp_ps(in1, in2, _CMP_EQ_OQ);
79 }
80 
81 IPSDK_FORCEINLINE
82 void
83 IsEqualReg<eInstructionSet::eIS_Avx, ipReal32>::act(
84  const AvxType<ipReal32>::Type& in1,
85  const AvxType<ipReal32>::Type& in2,
86  RegMaskType<eInstructionSet::eIS_Avx, ipReal32>::Type& out)
87 {
88  out = _mm256_cmp_ps(in1, in2, _CMP_EQ_OQ);
89 }
90 
91 IPSDK_FORCEINLINE
92 RegMaskType<eInstructionSet::eIS_Avx, ipReal64>::Type
93 IsEqualReg<eInstructionSet::eIS_Avx, ipReal64>::act(
94  const AvxType<ipReal64>::Type& in1,
95  const AvxType<ipReal64>::Type& in2)
96 {
97  return _mm256_cmp_pd(in1, in2, _CMP_EQ_OQ);
98 }
99 
100 IPSDK_FORCEINLINE
101 void
102 IsEqualReg<eInstructionSet::eIS_Avx, ipReal64>::act(
103  const AvxType<ipReal64>::Type& in1,
104  const AvxType<ipReal64>::Type& in2,
105  RegMaskType<eInstructionSet::eIS_Avx, ipReal64>::Type& out)
106 {
107  out = _mm256_cmp_pd(in1, in2, _CMP_EQ_OQ);
108 }
109 
112 
113 } // end of namespace detail
114 } // end of namespace simd
115 } // end of namespace ipsdk
116 
117 #endif // __IPSDKUTIL_INSTRUCTIONSET_COMPARISON_DETAIL_AVX_ISEQUALREGIMPL_H__
Functions to convert from 128 (resp. 256) bits registers to 256 (resp. 128) bits registers.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
IsEqualReg<eInstructionSet::domain instructionSet, typename T, typename Enable=void> structure...
Predefined types for Avx instruction set management.
Advanced Vector Extensions.
Definition: InstructionSetTypes.h:44