IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
RoundPack.h
Go to the documentation of this file.
1 // RoundPack.h:
3 // -----------------
4 //
18 
19 #ifndef __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_ROUNDPACK_H__
20 #define __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_ROUNDPACK_H__
21 
28 
29 namespace ipsdk {
30 namespace simd {
31 namespace detail {
32 
35 
40 template <eInstructionSet::domain instructionSet,
41  typename TIn, typename TOut, typename Enable=void>
42 struct RoundPack
43 {
44 };
45 
46 template <eInstructionSet::domain instructionSet,
47  typename TIn, typename TOut>
48 struct RoundPack<instructionSet, TIn, TOut,
49  typename boost::enable_if_c<!boost::is_integral<TIn>::value && boost::is_integral<TOut>::value>::type>
50 {
51  static
52  IPSDK_FORCEINLINE
55  {
57  assign<instructionSet>(zero, 0);
58  assign<instructionSet>(half, .5);
59  assign<instructionSet>(mHalf, -.5);
60 
63  isLess<instructionSet>(in, zero, ltz);
64  ifElse<instructionSet>(ltz, mHalf, half, addRes);
65  add<instructionSet>(in, addRes, addRes);
66  return cast<instructionSet, TOut>(addRes);
67  }
68 
69  static
70  IPSDK_FORCEINLINE
71  void
74  {
76  assign<instructionSet>(zero, 0);
77  assign<instructionSet>(half, .5);
78  assign<instructionSet>(mHalf, -.5);
79 
82  isLess<instructionSet>(in, zero, ltz);
83  ifElse<instructionSet>(ltz, mHalf, half, addRes);
84  add<instructionSet>(in, addRes, addRes);
85  cast<instructionSet>(addRes, out);
86  }
87 };
88 
89 template <eInstructionSet::domain instructionSet,
90  typename TIn, typename TOut>
91 struct RoundPack<instructionSet, TIn, TOut,
92  typename boost::enable_if_c<!boost::is_integral<TIn>::value && !boost::is_integral<TOut>::value>::type>
93 {
94  static
95  IPSDK_FORCEINLINE
98  {
99  return cast<instructionSet, TOut>(in);
100  }
101 
102  static
103  IPSDK_FORCEINLINE
104  void
107  {
108  cast<instructionSet>(in, out);
109  }
110 };
111 
114 
115 } // end of namespace detail
116 } // end of namespace simd
117 } // end of namespace ipsdk
118 
119 #endif // __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_ROUNDPACK_H__
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
structure containing set of masks for vectorized operations
Definition: BaseMaskPackDecl.h:29
Definition: RoundPack.h:42
Definition: DataItemNodeHdrMacrosDetails.h:48
function assigning a given value of type T to a given Pack<instructionSet, T>
Predefined types associated to instruction set management.
Definition: PackTypes.h:56
Definition of import/export macro for library.
add function; returns the result of an arithmetic add operation on all the elements of 2 input pack o...
structure containing intrinsic registers used to store vectorized data
Definition: BasePackDecl.h:29