34 #define ELEMENT_COUNT(x) c7x::element_count_of<x>::value
55 template <
typename T>
static inline void MATHLIB_log2_vector(
size_t length, T *restrict pSrc, T *restrict pDst)
59 size_t remNumBlocks = 0;
62 typedef typename c7x::make_full_vector<float>::type vec;
64 __SE_TEMPLATE_v1 se0Params = __gen_SE_TEMPLATE_v1();
65 __SA_TEMPLATE_v1 sa0Params = __gen_SA_TEMPLATE_v1();
70 numBlocks = length / c7x::element_count_of<vec>::value;
71 remNumBlocks = length % c7x::element_count_of<vec>::value;
83 vec C1, C2, C3, C4, C5, eMax, outVecMin, outVecMax;
84 c7x::double_vec ln2, base;
86 zero = (c7x::uint_vec) 0;
88 ln2 = (c7x::double_vec) 0.693147180559945;
89 base = (c7x::double_vec) 1.4426950408890;
90 C1 = (vec) -0.2302894f;
91 C2 = (vec) 0.1908169f;
92 C3 = (vec) -0.2505905f;
93 C4 = (vec) 0.3333164f;
94 C5 = (vec) -0.5000002f;
95 eMax = (vec) 3.402823466e+38f;
96 outVecMin = (vec) 0xFF800000u;
97 outVecMax = (vec) 1024.0f;
100 for (
size_t i = 0; i < numBlocks; i++) {
101 vec inVec = c7x::strm_eng<0, vec>::get_adv();
106 vec pol, r1, r2, r3, r4;
107 c7x::double_vec inVecVals_odd, inVecVals_even, inVecVals_oddReciprocal, inVecVals_evenReciprocal,
108 inVecReciprocalApprox_8_15, inVecReciprocalApprox_0_7, inVecVals_8_15, inVecVals_0_7, rVals_0_7, rVals_8_15,
109 TVals_8_15, TVals_0_7, NVals_odd, NVals_even, NVals_0_7, NVals_8_15, outVec_8_15, outVec_0_7;
110 c7x::uint_vec inVecReciprocal_32_63, inVecReciprocalClr_32_63, inVecReciprocalApprox_32_63, indexT;
119 inVecVals_odd = __high_float_to_double(inVec);
120 inVecVals_even = __low_float_to_double(inVec);
121 inVecVals_oddReciprocal = __recip(inVecVals_odd);
122 inVecVals_evenReciprocal = __recip(inVecVals_even);
126 inVecReciprocal_32_63 = c7x::reinterpret<c7x::uint_vec>(__permute_odd_odd_int(
127 MATHLIB_vperm_data_interweave_0_63, c7x::as_uchar_vec(inVecVals_oddReciprocal),
128 c7x::as_uchar_vec(inVecVals_evenReciprocal)));
131 inVecReciprocalClr_32_63 = inVecReciprocal_32_63 & 0xFFFE0000u;
134 inVecReciprocalApprox_8_15 = c7x::reinterpret<c7x::double_vec>(__permute_high_high(
135 MATHLIB_vperm_data_interweave_0_63, c7x::as_uchar_vec(inVecReciprocalClr_32_63),
136 c7x::as_uchar_vec(zero)));
137 inVecReciprocalApprox_0_7 = c7x::reinterpret<c7x::double_vec>(__permute_low_low(
138 MATHLIB_vperm_data_interweave_0_63, c7x::as_uchar_vec(inVecReciprocalClr_32_63),
139 c7x::as_uchar_vec(zero)));
142 inVecVals_0_7 = c7x::reinterpret<c7x::double_vec>(
143 __permute_low_low(MATHLIB_vperm_data_dp_interweave_0_63, c7x::as_uchar_vec(inVecVals_odd),
144 c7x::as_uchar_vec(inVecVals_even)));
145 inVecVals_8_15 = c7x::reinterpret<c7x::double_vec>(
146 __permute_high_high(MATHLIB_vperm_data_dp_interweave_0_63, c7x::as_uchar_vec(inVecVals_odd),
147 c7x::as_uchar_vec(inVecVals_even)));
150 rVals_0_7 = (inVecReciprocalApprox_0_7 * inVecVals_0_7) - 1.0;
151 rVals_8_15 = (inVecReciprocalApprox_8_15 * inVecVals_8_15) - 1.0;
154 r1 = c7x::reinterpret<vec>(__permute_even_even_int(
155 MATHLIB_vperm_data_0_63, c7x::as_uchar_vec(__double_to_float(rVals_8_15)),
156 c7x::as_uchar_vec(__double_to_float(rVals_0_7))));
162 pol = (C5 * r2) + ((C4 * r3) + ((((C2 * r1) + C3) + (C1 * r2)) * r4));
163 pol = pol * __double_to_float(base);
170 inVecReciprocalApprox_32_63 = c7x::reinterpret<c7x::uint_vec>(
171 __permute_odd_odd_int(MATHLIB_vperm_data_0_63, c7x::as_uchar_vec(inVecReciprocalApprox_8_15),
172 c7x::as_uchar_vec(inVecReciprocalApprox_0_7)));
174 N = c7x::convert<c7x::int_vec>(((inVecReciprocalApprox_32_63 << 1) >> 21) - 1023);
177 NVals_odd = __high_int_to_double(N);
178 NVals_even = __low_int_to_double(N);
179 NVals_0_7 = c7x::reinterpret<c7x::double_vec>(__permute_low_low(MATHLIB_vperm_data_dp_interweave_0_63,
180 c7x::as_uchar_vec(NVals_odd),
181 c7x::as_uchar_vec(NVals_even)));
182 NVals_8_15 = c7x::reinterpret<c7x::double_vec>(__permute_high_high(MATHLIB_vperm_data_dp_interweave_0_63,
183 c7x::as_uchar_vec(NVals_odd),
184 c7x::as_uchar_vec(NVals_even)));
197 TVals_8_15 = c7x::reinterpret<c7x::double_vec>(__permute_high_high(
198 MATHLIB_vperm_data_interweave_0_63, c7x::as_uchar_vec(upperBitsIndexT), c7x::as_uchar_vec(lowerBitsIndexT)));
199 TVals_0_7 = c7x::reinterpret<c7x::double_vec>(__permute_low_low(
200 MATHLIB_vperm_data_interweave_0_63, c7x::as_uchar_vec(upperBitsIndexT), c7x::as_uchar_vec(lowerBitsIndexT)));
203 TVals_8_15 = (TVals_8_15 - (ln2 * NVals_8_15)) * base;
204 TVals_0_7 = (TVals_0_7 - (ln2 * NVals_0_7)) * base;
212 outVec_0_7 = (rVals_0_7 * base) + TVals_0_7;
213 outVec_8_15 = (rVals_8_15 * base) + TVals_8_15;
216 outVec = c7x::reinterpret<vec>(__permute_even_even_int(
217 MATHLIB_vperm_data_0_63, c7x::as_uchar_vec(__double_to_float(outVec_8_15)),
218 c7x::as_uchar_vec(__double_to_float(outVec_0_7))));
219 outVec = outVec + pol;
228 __vpred cmp_min = __cmp_le_pred(inVec, c7x::convert<vec>(zero));
229 outVec = __select(cmp_min, outVecMin, outVec);
234 __vpred cmp_max = __cmp_lt_pred(eMax, inVec);
235 outVec = __select(cmp_max, outVecMax, outVec);
237 __vpred tmp = c7x::strm_agen<0, vec>::get_vpred();
238 vec *addr = c7x::strm_agen<0, vec>::get_adv(pDst);
239 __vstore_pred(tmp, addr, outVec);
template MATHLIB_STATUS MATHLIB_log2< float >(size_t length, float *restrict pSrc, float *restrict pDst)
MATHLIB_STATUS MATHLIB_log2_sp(size_t length, float *restrict pSrc, float *restrict pDst)
static void MATHLIB_log2_vector(size_t length, T *restrict pSrc, T *restrict pDst)
MATHLIB_STATUS MATHLIB_log2(size_t length, T *restrict pSrc, T *restrict pDst)
#define MATHLIB_LOGTABLE_OFFSET
static c7x::uint_vec MATHLIB_LUTReadLowerBits(vecType vecOffset)
This method reads bits 31-0 of LUT value at vecOffset.
static c7x::uint_vec MATHLIB_LUTReadUpperBits(vecType vecOffset)
This method reads bits 63-32 of LUT value at vecOffset.
static void MATHLIB_SE0SA0Close()
This method performs SE0 and SA0 close.
static void MATHLIB_SE0SA01DSequentialInit(__SE_TEMPLATE_v1 *se0Params, __SA_TEMPLATE_v1 *sa0Params, size_t length, T *pSrc, T *pDst)
static MATHLIB_STATUS MATHLIB_checkParams(size_t length, T *pSrc, T *pDst)
This method performs parameter checks for MATHLIB function.
static void MATHLIB_SE0SA0Open(__SE_TEMPLATE_v1 *se0Params, __SA_TEMPLATE_v1 *sa0Params, T *pSrc)
This method performs SE0 and SA0 open.
MATHLIB_STATUS_NAME
The enumeration of all status codes.