mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
core: Several improvements to Power/VSX
- changed behavior of vec_ctf, vec_ctu, vec_cts in gcc and clang to make them compatible with XLC - implemented most of missing conversion intrinsics in gcc and clang - implemented conversions intrinsics of odd-numbered elements - ignored gcc bug warning that caused by -Wunused-but-set-variable in rare cases - replaced right shift with algebraic right shift for signed vectors to shift in the sign bit. - added new universal intrinsics v_matmuladd, v_rotate_left/right - avoid using floating multiply-add in RNG
This commit is contained in:
@@ -74,6 +74,12 @@ namespace cv
|
||||
|
||||
#define RNG_NEXT(x) ((uint64)(unsigned)(x)*CV_RNG_COEFF + ((x) >> 32))
|
||||
|
||||
#ifdef __PPC64__
|
||||
#define PPC_MUL_ADD(ret, tmp, p0, p1) \
|
||||
asm volatile("fmuls %0,%1,%2\n\t fadds %0,%0,%3" : "=&f" (ret) \
|
||||
: "f" (tmp), "f" (p0), "f" (p1))
|
||||
#endif
|
||||
|
||||
/***************************************************************************************\
|
||||
* Pseudo-Random Number Generators (PRNGs) *
|
||||
\***************************************************************************************/
|
||||
@@ -248,6 +254,14 @@ static void randf_32f( float* arr, int len, uint64* state, const Vec2f* p, bool
|
||||
|
||||
volatile float32x4_t v0 = vmulq_f32(vld1q_f32(f), p0);
|
||||
vst1q_f32(arr+i, vaddq_f32(v0, p1));
|
||||
#elif defined __PPC64__
|
||||
// inline asm is required for numerical stability!
|
||||
// compilers tends to use floating multiply-add single(fmadds)
|
||||
// instead of separate multiply and add
|
||||
PPC_MUL_ADD(arr[i+0], f[0], p[i+0][0], p[i+0][1]);
|
||||
PPC_MUL_ADD(arr[i+1], f[1], p[i+1][0], p[i+1][1]);
|
||||
PPC_MUL_ADD(arr[i+2], f[2], p[i+2][0], p[i+2][1]);
|
||||
PPC_MUL_ADD(arr[i+3], f[3], p[i+3][0], p[i+3][1]);
|
||||
#else
|
||||
arr[i+0] = f[0]*p[i+0][0] + p[i+0][1];
|
||||
arr[i+1] = f[1]*p[i+1][0] + p[i+1][1];
|
||||
@@ -269,6 +283,8 @@ static void randf_32f( float* arr, int len, uint64* state, const Vec2f* p, bool
|
||||
vdup_n_f32((float)(int)temp), vdup_n_f32(p[i][0])),
|
||||
vdup_n_f32(p[i][1]));
|
||||
arr[i] = vget_lane_f32(t, 0);
|
||||
#elif defined __PPC64__
|
||||
PPC_MUL_ADD(arr[i], (float)(int)temp, p[i][0], p[i][1]);
|
||||
#else
|
||||
arr[i] = (int)temp*p[i][0] + p[i][1];
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user