@@ -23,222 +23,188 @@ from Advanced Micro Devices, Inc.
2323*/
2424#include " abs_v.hpp"
2525
26- namespace us {
27- namespace L1 {
26+ namespace us {
27+ namespace L1 {
2828
29+ template <typename T_IN, typename T_OUT, unsigned int T_LEN, unsigned int T_INCREMENT, unsigned int T_SIMD_DEPTH>
30+ void m_AbsV (adf::input_buffer<int32>& input_vector, adf::output_buffer<int32>& output) {
31+ aie::vector<int32, T_SIMD_DEPTH> op = aie::zeros<int32, T_SIMD_DEPTH>();
32+ aie::vector<int32, T_SIMD_DEPTH> res = aie::zeros<int32, T_SIMD_DEPTH>();
2933
30- template < typename T_IN, typename T_OUT, unsigned int T_LEN, unsigned int T_INCREMENT, unsigned int T_SIMD_DEPTH >
31- void m_AbsV (adf::input_buffer< int32 >& input_vector, adf::output_buffer< int32 >& output){
32-
33- aie::vector< int32, T_SIMD_DEPTH > op = aie::zeros< int32, T_SIMD_DEPTH >();
34- aie::vector< int32, T_SIMD_DEPTH > res = aie::zeros< int32, T_SIMD_DEPTH >();
34+ auto iter_in = aie::begin_vector<T_SIMD_DEPTH>(input_vector);
35+ auto iter_out = aie::begin_vector<T_SIMD_DEPTH>(output);
3536
36- auto iter_in = aie::begin_vector< T_SIMD_DEPTH >(input_vector);
37- auto iter_out = aie::begin_vector< T_SIMD_DEPTH >(output) ;
37+ for ( unsigned int i = 0 ; i < T_LEN; i += T_INCREMENT) chess_prepare_for_pipelining {
38+ op = *iter_in ;
3839
39- for (unsigned int i = 0 ; i < T_LEN; i += T_INCREMENT)
40- chess_prepare_for_pipelining {
41- op = *iter_in;
40+ res = aie::abs (op);
4241
43- res = aie::abs (op) ;
42+ *iter_out = res ;
4443
45- *iter_out = res;
46-
47- iter_out++;
48- iter_in++;
49- }
50-
44+ iter_out++;
45+ iter_in++;
46+ }
5147}
5248
53- template < typename T_IN, typename T_OUT, unsigned int T_LEN, unsigned int T_INCREMENT, unsigned int T_SIMD_DEPTH >
54- void m_AbsV (adf::input_buffer< int16 >& input_vector, adf::output_buffer< int16 >& output){
55-
56- aie::vector< int16, T_SIMD_DEPTH > op = aie::zeros< int16, T_SIMD_DEPTH >();
57- aie::vector< int16, T_SIMD_DEPTH > res = aie::zeros< int16, T_SIMD_DEPTH >();
49+ template <typename T_IN, typename T_OUT, unsigned int T_LEN, unsigned int T_INCREMENT, unsigned int T_SIMD_DEPTH>
50+ void m_AbsV (adf::input_buffer<int16>& input_vector, adf::output_buffer<int16>& output) {
51+ aie::vector<int16, T_SIMD_DEPTH> op = aie::zeros<int16, T_SIMD_DEPTH>();
52+ aie::vector<int16, T_SIMD_DEPTH> res = aie::zeros<int16, T_SIMD_DEPTH>();
5853
59- auto iter_in = aie::begin_vector< T_SIMD_DEPTH >(input_vector);
60- auto iter_out = aie::begin_vector< T_SIMD_DEPTH >(output);
54+ auto iter_in = aie::begin_vector<T_SIMD_DEPTH>(input_vector);
55+ auto iter_out = aie::begin_vector<T_SIMD_DEPTH>(output);
6156
62- for (unsigned int i = 0 ; i < T_LEN; i += T_INCREMENT)
63- chess_prepare_for_pipelining {
64- op = *iter_in;
57+ for (unsigned int i = 0 ; i < T_LEN; i += T_INCREMENT) chess_prepare_for_pipelining {
58+ op = *iter_in;
6559
66- res = aie::abs (op);
60+ res = aie::abs (op);
6761
68- *iter_out = res;
62+ *iter_out = res;
6963
70- iter_out++;
71- iter_in++;
72- }
73-
64+ iter_out++;
65+ iter_in++;
66+ }
7467}
7568
76- template < typename T_IN, typename T_OUT, unsigned int T_LEN, unsigned int T_INCREMENT, unsigned int T_SIMD_DEPTH >
77- void m_AbsV (adf::input_buffer< float >& input_vector, adf::output_buffer< float >& output){
78-
79- aie::vector< float , T_SIMD_DEPTH > op = aie::zeros< float , T_SIMD_DEPTH >();
80- aie::vector< float , T_SIMD_DEPTH > res = aie::zeros< float , T_SIMD_DEPTH >();
69+ template <typename T_IN, typename T_OUT, unsigned int T_LEN, unsigned int T_INCREMENT, unsigned int T_SIMD_DEPTH>
70+ void m_AbsV (adf::input_buffer<float >& input_vector, adf::output_buffer<float >& output) {
71+ aie::vector<float , T_SIMD_DEPTH> op = aie::zeros<float , T_SIMD_DEPTH>();
72+ aie::vector<float , T_SIMD_DEPTH> res = aie::zeros<float , T_SIMD_DEPTH>();
8173
82- auto iter_in = aie::begin_vector< T_SIMD_DEPTH >(input_vector);
83- auto iter_out = aie::begin_vector< T_SIMD_DEPTH >(output);
74+ auto iter_in = aie::begin_vector<T_SIMD_DEPTH>(input_vector);
75+ auto iter_out = aie::begin_vector<T_SIMD_DEPTH>(output);
8476
85- for (unsigned int i = 0 ; i < T_LEN; i += T_INCREMENT)
86- chess_prepare_for_pipelining {
87- op = *iter_in;
77+ for (unsigned int i = 0 ; i < T_LEN; i += T_INCREMENT) chess_prepare_for_pipelining {
78+ op = *iter_in;
8879
89- res = aie::mul_square (op);
90- res = aie::sqrt (res);
91- *iter_out = res;
80+ res = aie::mul_square (op);
81+ res = aie::sqrt (res);
82+ *iter_out = res;
9283
93- iter_out++;
94- iter_in++;
95- }
84+ iter_out++;
85+ iter_in++;
86+ }
9687}
9788
89+ template <typename T_IN, typename T_OUT, unsigned int T_LEN, unsigned int T_INCREMENT, unsigned int T_SIMD_DEPTH>
90+ void m_AbsV (adf::input_buffer<cint16>& input_vector, adf::output_buffer<int32>& output) {
91+ aie::vector<cint16, T_SIMD_DEPTH> op = aie::zeros<cint16, T_SIMD_DEPTH>();
92+ aie::vector<int32, T_SIMD_DEPTH> res = aie::zeros<int32, T_SIMD_DEPTH>();
9893
99- template < typename T_IN, typename T_OUT, unsigned int T_LEN, unsigned int T_INCREMENT, unsigned int T_SIMD_DEPTH >
100- void m_AbsV (adf::input_buffer< cint16 >& input_vector, adf::output_buffer< int32 >& output){
101-
102- aie::vector< cint16, T_SIMD_DEPTH > op = aie::zeros< cint16, T_SIMD_DEPTH >();
103- aie::vector< int32, T_SIMD_DEPTH > res = aie::zeros< int32, T_SIMD_DEPTH >();
94+ auto iter_in = aie::begin_vector<T_SIMD_DEPTH>(input_vector);
95+ auto iter_out = aie::begin_vector<T_SIMD_DEPTH>(output);
10496
105- auto iter_in = aie::begin_vector< T_SIMD_DEPTH >(input_vector);
106- auto iter_out = aie::begin_vector< T_SIMD_DEPTH >(output) ;
97+ for ( unsigned int i = 0 ; i < T_LEN; i += T_INCREMENT) chess_prepare_for_pipelining {
98+ op = *iter_in ;
10799
108- for (unsigned int i = 0 ; i < T_LEN; i += T_INCREMENT)
109- chess_prepare_for_pipelining {
110- op = *iter_in;
100+ res = aie::abs_square (op);
111101
112- res = aie::abs_square (op);
113-
114- *iter_out = res;
115-
116- iter_out++;
117- iter_in++;
118- }
102+ *iter_out = res;
119103
104+ iter_out++;
105+ iter_in++;
106+ }
120107}
121108
122- template < typename T_IN, typename T_OUT, unsigned int T_LEN, unsigned int T_INCREMENT, unsigned int T_SIMD_DEPTH >
123- void AbsV (adf::input_buffer< T_IN >& input_vector, adf::output_buffer< T_OUT >& output){
124-
109+ template <typename T_IN, typename T_OUT, unsigned int T_LEN, unsigned int T_INCREMENT, unsigned int T_SIMD_DEPTH>
110+ void AbsV (adf::input_buffer<T_IN>& input_vector, adf::output_buffer<T_OUT>& output) {
125111 static_assert (std::is_same<T_IN, int32_t >::value || std::is_same<T_IN, int16_t >::value ||
126- std::is_same<T_IN, float >::value || std::is_same<T_IN, cint16>::value
127- ," T_IN must be int32, float or cint16" );
128-
129- m_AbsV< T_IN, T_OUT, T_LEN, T_INCREMENT, T_SIMD_DEPTH >(input_vector, output);
130-
112+ std::is_same<T_IN, float >::value || std::is_same<T_IN, cint16>::value,
113+ " T_IN must be int32, float or cint16" );
131114
115+ m_AbsV<T_IN, T_OUT, T_LEN, T_INCREMENT, T_SIMD_DEPTH>(input_vector, output);
132116}
133117
118+ template <typename T_IN, typename T_OUT, unsigned int T_LEN, unsigned int T_INCREMENT, unsigned int T_SIMD_DEPTH>
119+ void m_AbsV (int32* input_vector, int32* output) {
120+ aie::vector<int32, T_SIMD_DEPTH> op = aie::zeros<int32, T_SIMD_DEPTH>();
121+ aie::vector<int32, T_SIMD_DEPTH> res = aie::zeros<int32, T_SIMD_DEPTH>();
134122
123+ auto iter_in = aie::begin_vector<T_SIMD_DEPTH>(input_vector);
124+ auto iter_out = aie::begin_vector<T_SIMD_DEPTH>(output);
135125
136- template < typename T_IN, typename T_OUT, unsigned int T_LEN, unsigned int T_INCREMENT, unsigned int T_SIMD_DEPTH >
137- void m_AbsV (int32 *input_vector, int32 *output){
138-
139- aie::vector< int32, T_SIMD_DEPTH > op = aie::zeros< int32, T_SIMD_DEPTH >();
140- aie::vector< int32, T_SIMD_DEPTH > res = aie::zeros< int32, T_SIMD_DEPTH >();
141-
142- auto iter_in = aie::begin_vector< T_SIMD_DEPTH >(input_vector);
143- auto iter_out = aie::begin_vector< T_SIMD_DEPTH >(output);
144-
145- for (unsigned int i = 0 ; i < T_LEN; i += T_INCREMENT)
146- chess_prepare_for_pipelining {
147- op = *iter_in;
126+ for (unsigned int i = 0 ; i < T_LEN; i += T_INCREMENT) chess_prepare_for_pipelining {
127+ op = *iter_in;
148128
149- res = aie::abs (op);
129+ res = aie::abs (op);
150130
151- *iter_out = res;
152-
153- iter_out++;
154- iter_in++;
155- }
131+ *iter_out = res;
156132
133+ iter_out++;
134+ iter_in++;
135+ }
157136}
158137
159- template < typename T_IN, typename T_OUT, unsigned int T_LEN, unsigned int T_INCREMENT, unsigned int T_SIMD_DEPTH >
160- void m_AbsV (int16 *input_vector, int16 *output){
161-
162- aie::vector< int16, T_SIMD_DEPTH > op = aie::zeros< int16, T_SIMD_DEPTH >();
163- aie::vector< int16, T_SIMD_DEPTH > res = aie::zeros< int16, T_SIMD_DEPTH >();
164-
165- auto iter_in = aie::begin_vector< T_SIMD_DEPTH >(input_vector);
166- auto iter_out = aie::begin_vector< T_SIMD_DEPTH >(output);
138+ template <typename T_IN, typename T_OUT, unsigned int T_LEN, unsigned int T_INCREMENT, unsigned int T_SIMD_DEPTH>
139+ void m_AbsV (int16* input_vector, int16* output) {
140+ aie::vector<int16, T_SIMD_DEPTH> op = aie::zeros<int16, T_SIMD_DEPTH>();
141+ aie::vector<int16, T_SIMD_DEPTH> res = aie::zeros<int16, T_SIMD_DEPTH>();
167142
168- for (unsigned int i = 0 ; i < T_LEN; i += T_INCREMENT)
169- chess_prepare_for_pipelining {
170- op = *iter_in;
143+ auto iter_in = aie::begin_vector<T_SIMD_DEPTH>(input_vector);
144+ auto iter_out = aie::begin_vector<T_SIMD_DEPTH>(output);
171145
172- res = aie::abs (op);
146+ for (unsigned int i = 0 ; i < T_LEN; i += T_INCREMENT) chess_prepare_for_pipelining {
147+ op = *iter_in;
173148
174- *iter_out = res;
149+ res = aie::abs (op) ;
175150
176- iter_out++;
177- iter_in++;
178- }
151+ *iter_out = res;
179152
153+ iter_out++;
154+ iter_in++;
155+ }
180156}
181157
182- template < typename T_IN, typename T_OUT, unsigned int T_LEN, unsigned int T_INCREMENT, unsigned int T_SIMD_DEPTH >
183- void m_AbsV (cint16* input_vector, int32* output){
158+ template <typename T_IN, typename T_OUT, unsigned int T_LEN, unsigned int T_INCREMENT, unsigned int T_SIMD_DEPTH>
159+ void m_AbsV (cint16* input_vector, int32* output) {
160+ aie::vector<cint16, T_SIMD_DEPTH> op = aie::zeros<cint16, T_SIMD_DEPTH>();
161+ aie::vector<int32, T_SIMD_DEPTH> res = aie::zeros<int32, T_SIMD_DEPTH>();
184162
185- aie::vector< cint16, T_SIMD_DEPTH > op = aie::zeros< cint16, T_SIMD_DEPTH >( );
186- aie::vector< int32, T_SIMD_DEPTH > res = aie::zeros< int32, T_SIMD_DEPTH >( );
163+ auto iter_in = aie::begin_vector< T_SIMD_DEPTH>(input_vector );
164+ auto iter_out = aie::begin_vector< T_SIMD_DEPTH>(output );
187165
188- auto iter_in = aie::begin_vector< T_SIMD_DEPTH >(input_vector);
189- auto iter_out = aie::begin_vector< T_SIMD_DEPTH >(output) ;
166+ for ( unsigned int i = 0 ; i < T_LEN; i += T_INCREMENT) chess_prepare_for_pipelining {
167+ op = *iter_in ;
190168
191- for (unsigned int i = 0 ; i < T_LEN; i += T_INCREMENT)
192- chess_prepare_for_pipelining {
193- op = *iter_in;
169+ res = aie::abs_square (op);
194170
195- res = aie::abs_square (op);
196-
197- *iter_out = res;
198-
199- iter_out++;
200- iter_in++;
201- }
171+ *iter_out = res;
202172
173+ iter_out++;
174+ iter_in++;
175+ }
203176}
204177
205- template < typename T_IN, typename T_OUT, unsigned int T_LEN, unsigned int T_INCREMENT, unsigned int T_SIMD_DEPTH >
206- void m_AbsV (float * input_vector, float * output){
207-
208- aie::vector< float , T_SIMD_DEPTH > op = aie::zeros< float , T_SIMD_DEPTH >();
209- aie::vector< float , T_SIMD_DEPTH > res = aie::zeros< float , T_SIMD_DEPTH >();
178+ template <typename T_IN, typename T_OUT, unsigned int T_LEN, unsigned int T_INCREMENT, unsigned int T_SIMD_DEPTH>
179+ void m_AbsV (float * input_vector, float * output) {
180+ aie::vector<float , T_SIMD_DEPTH> op = aie::zeros<float , T_SIMD_DEPTH>();
181+ aie::vector<float , T_SIMD_DEPTH> res = aie::zeros<float , T_SIMD_DEPTH>();
210182
211- auto iter_in = aie::begin_vector< T_SIMD_DEPTH >(input_vector);
212- auto iter_out = aie::begin_vector< T_SIMD_DEPTH >(output);
183+ auto iter_in = aie::begin_vector<T_SIMD_DEPTH>(input_vector);
184+ auto iter_out = aie::begin_vector<T_SIMD_DEPTH>(output);
213185
214- for (unsigned int i = 0 ; i < T_LEN; i += T_INCREMENT)
215- chess_prepare_for_pipelining {
216- op = *iter_in;
186+ for (unsigned int i = 0 ; i < T_LEN; i += T_INCREMENT) chess_prepare_for_pipelining {
187+ op = *iter_in;
217188
218- res = aie::mul_square (op);
219- res = aie::sqrt (res);
189+ res = aie::mul_square (op);
190+ res = aie::sqrt (res);
220191
221- *iter_out = res;
222-
223- iter_out++;
224- iter_in++;
225- }
192+ *iter_out = res;
226193
194+ iter_out++;
195+ iter_in++;
196+ }
227197}
228198
229- template < typename T_IN, typename T_OUT, unsigned int T_LEN, unsigned int T_INCREMENT, unsigned int T_SIMD_DEPTH >
230- void AbsVInternalBuffer (adf::input_buffer< T_IN >& input_vector, adf::output_buffer< T_OUT >& output){
231-
199+ template <typename T_IN, typename T_OUT, unsigned int T_LEN, unsigned int T_INCREMENT, unsigned int T_SIMD_DEPTH>
200+ void AbsVInternalBuffer (adf::input_buffer<T_IN>& input_vector, adf::output_buffer<T_OUT>& output) {
232201 static_assert (std::is_same<T_IN, int32_t >::value || std::is_same<T_IN, int16_t >::value ||
233- std::is_same<T_IN, float >::value || std::is_same<T_IN, cint16>::value
234- ," T_IN must be int32, float or cint16" );
235-
236- T_IN* buffer_in = (T_IN*)input_vector.data ();
237- T_OUT* buffer_out = (T_OUT*)output.data ();
238- m_AbsV< T_IN, T_OUT, T_LEN, T_INCREMENT, T_SIMD_DEPTH >(buffer_in, buffer_out);
202+ std::is_same<T_IN, float >::value || std::is_same<T_IN, cint16>::value,
203+ " T_IN must be int32, float or cint16" );
239204
205+ T_IN* buffer_in = (T_IN*)input_vector.data ();
206+ T_OUT* buffer_out = (T_OUT*)output.data ();
207+ m_AbsV<T_IN, T_OUT, T_LEN, T_INCREMENT, T_SIMD_DEPTH>(buffer_in, buffer_out);
240208}
241-
242209}
243-
244210}
0 commit comments