IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
BitwiseNotRegImpl.h
Go to the documentation of this file.
1 // BitwiseNotRegImpl.h:
3 // -------------------
4 //
14 
15 #ifndef __IPSDKUTIL_INSTRUCTIONSET_LOGICAL_DETAIL_AVX2_BITWISENOTREGIMPL_H__
16 #define __IPSDKUTIL_INSTRUCTIONSET_LOGICAL_DETAIL_AVX2_BITWISENOTREGIMPL_H__
17 
20 
21 namespace ipsdk {
22 namespace simd {
23 namespace detail {
24 
27 
28 template <typename T>
29 IPSDK_FORCEINLINE
30 typename AvxType<T>::Type
31 BitwiseNotReg<eInstructionSet::eIS_Avx2, T,
32  typename boost::enable_if_c<boost::is_integral<T>::value>::type>::act(
33  const typename AvxType<T>::Type& in)
34 {
35  const typename AvxType<T>::Type allbits =
36  AssignReg<eInstructionSet::eIS_Avx2, ipUInt8>::act(0xFF);
37  return _mm256_xor_si256(in, allbits);
38 }
39 
40 template <typename T>
41 IPSDK_FORCEINLINE
42 void
43 BitwiseNotReg<eInstructionSet::eIS_Avx2, T,
44  typename boost::enable_if_c<boost::is_integral<T>::value>::type>::act(
45  const typename AvxType<T>::Type& in,
46  typename AvxType<T>::Type& out)
47 {
48  typename AvxType<T>::Type allbits;
49  AssignReg<eInstructionSet::eIS_Avx2, ipUInt8>::act(allbits, 0xFF);
50  out = _mm256_xor_si256(in, allbits);
51 }
52 
53 IPSDK_FORCEINLINE
54 AvxType<ipReal32>::Type
55 BitwiseNotReg<eInstructionSet::eIS_Avx2, ipReal32>::act(
56  const AvxType<ipReal32>::Type& in)
57 {
58  AvxType<ipUInt8>::Type allbits;
59  AssignReg<eInstructionSet::eIS_Avx2, ipUInt8>::act(allbits, 0xFF);
60  return _mm256_castsi256_ps(_mm256_xor_si256(_mm256_castps_si256(in), allbits));
61 }
62 
63 
64 IPSDK_FORCEINLINE
65 void
66 BitwiseNotReg<eInstructionSet::eIS_Avx2, ipReal32>::act(
67  const AvxType<ipReal32>::Type& in,
68  AvxType<ipReal32>::Type& out)
69 {
70  AvxType<ipUInt8>::Type allbits;
71  AssignReg<eInstructionSet::eIS_Avx2, ipUInt8>::act(allbits, 0xFF);
72  out = _mm256_castsi256_ps(_mm256_xor_si256(_mm256_castps_si256(in), allbits));
73 }
74 
75 IPSDK_FORCEINLINE
76 AvxType<ipReal64>::Type
77 BitwiseNotReg<eInstructionSet::eIS_Avx2, ipReal64>::act(
78  const AvxType<ipReal64>::Type& in)
79 {
80  AvxType<ipUInt8>::Type allbits;
81  AssignReg<eInstructionSet::eIS_Avx2, ipUInt8>::act(allbits, 0xFF);
82  return _mm256_castsi256_pd(_mm256_xor_si256(_mm256_castpd_si256(in), allbits));
83 }
84 
85 
86 IPSDK_FORCEINLINE
87 void
88 BitwiseNotReg<eInstructionSet::eIS_Avx2, ipReal64>::act(
89  const AvxType<ipReal64>::Type& in,
90  AvxType<ipReal64>::Type& out)
91 {
92  AvxType<ipUInt8>::Type allbits;
93  AssignReg<eInstructionSet::eIS_Avx2, ipUInt8>::act(allbits, 0xFF);
94  out = _mm256_castsi256_pd(_mm256_xor_si256(_mm256_castpd_si256(in), allbits));
95 }
96 
99 
100 } // end of namespace detail
101 } // end of namespace simd
102 } // end of namespace ipsdk
103 
105 
106 #endif // __IPSDKUTIL_INSTRUCTIONSET_LOGICAL_DETAIL_AVX2_BITWISENOTREGIMPL_H__
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
Advanced Vector Extensions 2.
Definition: InstructionSetTypes.h:48