IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
AlignedArithmetic.h
1 // AlignedArithmetic.h:
3 // --------------------
4 //
15 
16 #ifndef __IPSDKUTIL_ALIGNEDARITHMETIC_H__
17 #define __IPSDKUTIL_ALIGNEDARITHMETIC_H__
18 
19 #include <IPSDKUtil/InstructionSet/Pack.h>
25 
26 namespace ipsdk {
27 
30 
35 template <ipsdk::eInstructionSet::domain IS,
36  typename BufType>
37 static IPSDK_FORCEINLINE void
38 alignedAdd(const BufType* pInputBuf,
39  const ipUInt64 size,
40  BufType* pInOutBuf)
41 {
42  simd::Pack<IS, BufType> inputPack, inOutPack;
43  for(ipUInt64 k=0; k<size; k+=simd::NbEltsPerOp<IS>::Value) {
44 
45  simd::load<IS>(inputPack, pInputBuf + k);
46  simd::load<IS>(inOutPack, pInOutBuf + k);
47  simd::add<IS>(inOutPack, inputPack, inOutPack);
48  simd::unload<IS>(inOutPack, pInOutBuf + k);
49  }
50 }
51 
56 template <ipsdk::eInstructionSet::domain IS,
57  typename BufType>
58 static IPSDK_FORCEINLINE void
59 alignedSub(const BufType* pInputBuf,
60  const ipUInt64 size,
61  BufType* pInOutBuf)
62 {
63  simd::Pack<IS, BufType> inputPack, inOutPack;
64  for(ipUInt64 k=0; k<size; k+=simd::NbEltsPerOp<IS>::Value) {
65 
66  simd::load<IS>(inputPack, pInputBuf + k);
67  simd::load<IS>(inOutPack, pInOutBuf + k);
68  simd::sub<IS>(inOutPack, inputPack, inOutPack);
69  simd::unload<IS>(inOutPack, pInOutBuf + k);
70  }
71 }
72 
76 template <ipsdk::eInstructionSet::domain IS,
77  typename BufInType,
78  typename BufOutType>
79 static IPSDK_FORCEINLINE void
80 alignedRound(const BufInType* pInputBuf,
81  const ipUInt64 size,
82  BufOutType* pOutputBuf)
83 {
84  simd::Pack<IS, BufInType> inputPack;
85  simd::Pack<IS, BufOutType> outputPack;
86  for(ipUInt64 k=0; k<size; k+=simd::NbEltsPerOp<IS>::Value) {
87 
88  simd::load<IS>(inputPack, pInputBuf + k);
89  simd::round<IS>(inputPack, outputPack);
90  simd::unload<IS>(outputPack, pOutputBuf + k);
91  }
92 }
93 
94 
97 
98 } // end of namespace ipsdk
99 
100 #endif // __IPSDKUTIL_ALIGNEDARITHMETIC_H__
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
uint64_t ipUInt64
Base types definition.
Definition: BaseTypes.h:55
round function; returns the round values of the elements of a pack
load function; loads a buffer into a pack
sub function; returns the result of an arithmetic substraction on all the elements of 2 input pack op...
unload function; unloads a pack into a memory buffer
add function; returns the result of an arithmetic add operation on all the elements of 2 input pack o...