IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
AbsReg.h
1 // AbsReg.h:
3 // -----------------
4 //
16 
17 #ifndef __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_ABSREG_H__
18 #define __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_ABSREG_H__
19 
27 
28 #include <boost/mpl/not_equal_to.hpp>
29 #include <boost/type_traits/is_float.hpp>
30 
31 namespace ipsdk {
32 namespace simd {
33 namespace detail {
34 
37 
44 template <eInstructionSet::domain IS,
45  typename T, typename Enable=void>
46 struct AbsReg;
47 
48 template <eInstructionSet::domain IS, typename T>
49 struct AbsReg<
50  IS,
51  T,
52  typename boost::enable_if<
53  typename boost::mpl::and_<
54  typename boost::is_integral<T>::type,
55  typename boost::mpl::not_<boost::is_signed<T> >::type
56  >::type
57  >::type
58 >
59 {
60  static
61  IPSDK_FORCEINLINE
62  typename RegType<IS, T>::Type
63  act(const typename RegType<IS, T>::Type& in)
64  {
65  return in;
66  }
67 
68  static
69  IPSDK_FORCEINLINE
70  void
71  act(const typename RegType<IS, T>::Type& in, typename RegType<IS, T>::Type& out)
72  {
73  out = in;
74  }
75 };
76 
77 template <eInstructionSet::domain IS, typename T>
78 struct AbsReg<
79  IS,
80  T,
81  typename boost::enable_if<
82  typename boost::mpl::and_<
83  typename boost::mpl::not_equal_to<
84  boost::mpl::int_<IS>,
85  boost::mpl::int_<eInstructionSet::eIS_Avx512>
86  >::type,
87  typename boost::mpl::and_<
88  typename boost::is_integral<T>::type,
89  typename boost::is_signed<T>::type
90  >::type
91  >::type
92  >::type
93 >
94 {
95  static
96  IPSDK_FORCEINLINE
97  typename RegType<IS, T>::Type
98  act(const typename RegType<IS, T>::Type& in)
99  {
100  typename RegType<IS, T>::Type out;
101  act(in, out);
102  return out;
103  }
104 
105  static
106  IPSDK_FORCEINLINE
107  void
108  act(const typename RegType<IS, T>::Type& in, typename RegType<IS, T>::Type& out)
109  {
110  typename RegType<IS, T>::Type minusIn;
111  UnaryMinusReg<IS, T>::act(in, minusIn);
112  MaxReg<IS, T>::act(in, minusIn, out);
113  }
114 };
115 
116 template <eInstructionSet::domain IS>
117 struct AbsReg<
118  IS,
119  ipReal32,
120  typename boost::enable_if<
121  typename boost::mpl::not_equal_to<
122  boost::mpl::int_<IS>,
123  boost::mpl::int_<eInstructionSet::eIS_Avx512>
124  >::type
125  >::type
126 >
127 
128 {
129  static
130  IPSDK_FORCEINLINE
132  act(const typename RegType<IS, ipReal32>::Type& in)
133  {
134  typename RegType<IS, ipReal32>::Type out;
135  act(in, out);
136  return out;
137  }
138 
139  static
140  IPSDK_FORCEINLINE
141  void
142  act(const typename RegType<IS, ipReal32>::Type& in, typename RegType<IS, ipReal32>::Type& out)
143  {
144  typename RegType<IS, ipReal32>::Type mzero, notmzero;
145  AssignReg<IS, ipReal32>::act(mzero, -.0f);
146  BitwiseNotReg<IS, ipReal32>::act(mzero, notmzero);
147  BitwiseAndReg<IS, ipReal32>::act(in, notmzero, out);
148  }
149 };
150 
151 template <eInstructionSet::domain IS>
152 struct AbsReg<
153  IS,
154  ipReal64,
155  typename boost::enable_if<
156  typename boost::mpl::not_equal_to<
157  boost::mpl::int_<IS>,
158  boost::mpl::int_<eInstructionSet::eIS_Avx512>
159  >::type
160  >::type
161 >
162 {
163  static
164  IPSDK_FORCEINLINE
166  act(const typename RegType<IS, ipReal64>::Type& in)
167  {
168  typename RegType<IS, ipReal64>::Type out;
169  act(in, out);
170  return out;
171  }
172 
173  static
174  IPSDK_FORCEINLINE
175  void
176  act(const typename RegType<IS, ipReal64>::Type& in, typename RegType<IS, ipReal64>::Type& out)
177  {
178  typename RegType<IS, ipReal64>::Type mzero, notmzero;
179  AssignReg<IS, ipReal64>::act(mzero, -.0);
180  BitwiseNotReg<IS, ipReal64>::act(mzero, notmzero);
181  BitwiseAndReg<IS, ipReal64>::act(in, notmzero, out);
182  }
183 };
184 
187 
188 } // end of namespace detail
189 } // end of namespace simd
190 } // end of namespace ipsdk
191 
192 #ifdef IPSDK_WITH_AVX512
194 #endif
195 
196 #endif // __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_ABSREG_H__
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
Definition: BitwiseNotRegDecl.h:30
template structure which is specialized to implement the maximum computation on 2 scalars or 2 regist...
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
Definition: DataItemNodeHdrMacrosDetails.h:48
RegType class.
Definition: MaxRegDecl.h:29
Definition of import/export macro for library.
Definition: UnaryMinusReg.h:40
specialization of ipsdk::simd::detail::AbsReg structure for AVX512 instruction set ...
template structure which is specialized to implement the computation of abs function on a scalar or a...
Definition: AbsReg.h:46
Definition: RegType.h:29
Definition: BitwiseAndReg.h:30
Definition: AssignRegDecl.h:31
float ipReal32
Base types definition.
Definition: BaseTypes.h:56