ref: 4b943729b9f24bb74b253030e772ae12ddc01f49
parent: 95f5c83ba4c59a8ad2f7544a8ef20bfbb9caed02
author: Paul Brossier <piem@piem.org>
date: Sun Oct 1 11:30:10 EDT 2017
src/aubio_priv.h: define ipp aliases for single/double precision, use them in cvec and fvec
--- a/src/aubio_priv.h
+++ b/src/aubio_priv.h
@@ -127,6 +127,31 @@
#include <ippcore.h>
#include <ippvm.h>
#include <ipps.h>
+#ifndef HAVE_AUBIO_DOUBLE
+#define aubio_ippsSet ippsSet_32f
+#define aubio_ippsZero ippsZero_32f
+#define aubio_ippsCopy ippsCopy_32f
+#define aubio_ippsMul ippsMul_32f
+#define aubio_ippsMulC ippsMulC_32f
+#define aubio_ippsAddC ippsAddC_32f
+#define aubio_ippsLn ippsLn_32f_A21
+#define aubio_ippsMean ippsMean_32f
+#define aubio_ippsSum ippsSum_32f
+#define aubio_ippsMax ippsMax_32f
+#define aubio_ippsMin ippsMin_32f
+#else /* HAVE_AUBIO_DOUBLE */
+#define aubio_ippsSet ippsSet_64f
+#define aubio_ippsZero ippsZero_64f
+#define aubio_ippsCopy ippsCopy_64f
+#define aubio_ippsMul ippsMul_64f
+#define aubio_ippsMulC ippsMulC_64f
+#define aubio_ippsAddC ippsAddC_64f
+#define aubio_ippsLn ippsLn_64f_A26
+#define aubio_ippsMean ippsMean_64f
+#define aubio_ippsSum ippsSum_64f
+#define aubio_ippsMax ippsMax_64f
+#define aubio_ippsMin ippsMin_64f
+#endif /* HAVE_AUBIO_DOUBLE */
#endif
#if !defined(HAVE_MEMCPY_HACKS) && !defined(HAVE_ACCELERATE) && !defined(HAVE_ATLAS) && !defined(HAVE_INTEL_IPP)
--- a/src/cvec.c
+++ b/src/cvec.c
@@ -86,13 +86,8 @@
return;
}
#if defined(HAVE_INTEL_IPP)
- #if HAVE_AUBIO_DOUBLE
- ippsCopy_64f(s->phas, t->phas, (int)s->length);
- ippsCopy_64f(s->norm, t->norm, (int)s->length);
- #else
- ippsCopy_32f(s->phas, t->phas, (int)s->length);
- ippsCopy_32f(s->norm, t->norm, (int)s->length);
- #endif
+ aubio_ippsCopy(s->phas, t->phas, (int)s->length);
+ aubio_ippsCopy(s->norm, t->norm, (int)s->length);
#elif defined(HAVE_MEMCPY_HACKS)
memcpy(t->norm, s->norm, t->length * sizeof(smpl_t));
memcpy(t->phas, s->phas, t->length * sizeof(smpl_t));
@@ -107,11 +102,7 @@
void cvec_norm_set_all(cvec_t *s, smpl_t val) {
#if defined(HAVE_INTEL_IPP)
- #if HAVE_AUBIO_DOUBLE
- ippsSet_64f(val, s->norm, (int)s->length);
- #else
- ippsSet_32f(val, s->norm, (int)s->length);
- #endif
+ aubio_ippsSet(val, s->norm, (int)s->length);
#else
uint_t j;
for (j=0; j< s->length; j++) {
@@ -122,11 +113,7 @@
void cvec_norm_zeros(cvec_t *s) {
#if defined(HAVE_INTEL_IPP)
- #if HAVE_AUBIO_DOUBLE
- ippsZero_64f(s->norm, (int)s->length);
- #else
- ippsZero_32f(s->norm, (int)s->length);
- #endif
+ aubio_ippsZero(s->norm, (int)s->length);
#elif defined(HAVE_MEMCPY_HACKS)
memset(s->norm, 0, s->length * sizeof(smpl_t));
#else
@@ -140,11 +127,7 @@
void cvec_phas_set_all (cvec_t *s, smpl_t val) {
#if defined(HAVE_INTEL_IPP)
- #if HAVE_AUBIO_DOUBLE
- ippsSet_64f(val, s->phas, (int)s->length);
- #else
- ippsSet_32f(val, s->phas, (int)s->length);
- #endif
+ aubio_ippsSet(val, s->phas, (int)s->length);
#else
uint_t j;
for (j=0; j< s->length; j++) {
@@ -155,11 +138,7 @@
void cvec_phas_zeros(cvec_t *s) {
#if defined(HAVE_INTEL_IPP)
- #if HAVE_AUBIO_DOUBLE
- ippsZero_64f(s->phas, (int)s->length);
- #else
- ippsZero_32f(s->phas, (int)s->length);
- #endif
+ aubio_ippsZero(s->phas, (int)s->length);
#elif defined(HAVE_MEMCPY_HACKS)
memset(s->phas, 0, s->length * sizeof(smpl_t));
#else
@@ -178,15 +157,9 @@
void cvec_logmag(cvec_t *s, smpl_t lambda) {
#if defined(HAVE_INTEL_IPP)
- #if HAVE_AUBIO_DOUBLE
- ippsMulC_64f(s->norm, lambda, s->norm, (int)s->length);
- ippsAddC_64f(s->norm, 1.0, s->norm, (int)s->length);
- ippsLn_64f_A26(s->norm, s->norm, (int)s->length);
- #else
- ippsMulC_32f(s->norm, lambda, s->norm, (int)s->length);
- ippsAddC_32f(s->norm, 1.0, s->norm, (int)s->length);
- ippsLn_32f_A21(s->norm, s->norm, (int)s->length);
- #endif
+ aubio_ippsMulC(s->norm, lambda, s->norm, (int)s->length);
+ aubio_ippsAddC(s->norm, 1.0, s->norm, (int)s->length);
+ aubio_ippsLn(s->norm, s->norm, (int)s->length);
#else
uint_t j;
for (j=0; j< s->length; j++) {
--- a/src/fvec.c
+++ b/src/fvec.c
@@ -61,11 +61,7 @@
void fvec_set_all (fvec_t *s, smpl_t val) {
#if defined(HAVE_INTEL_IPP)
- #if HAVE_AUBIO_DOUBLE
- ippsSet_64f(val, s->data, (int)s->length);
- #else
- ippsSet_32f(val, s->data, (int)s->length);
- #endif
+ aubio_ippsSet(val, s->data, (int)s->length);
#elif defined(HAVE_ATLAS)
aubio_catlas_set(s->length, val, s->data, 1);
#elif defined(HAVE_ACCELERATE)
@@ -81,11 +77,7 @@
void fvec_zeros(fvec_t *s) {
#if defined(HAVE_INTEL_IPP)
- #if HAVE_AUBIO_DOUBLE
- ippsZero_64f(s->data, (int)s->length);
- #else
- ippsZero_32f(s->data, (int)s->length);
- #endif
+ aubio_ippsZero(s->data, (int)s->length);
#elif defined(HAVE_ACCELERATE)
aubio_vDSP_vclr(s->data, 1, s->length);
#elif defined(HAVE_MEMCPY_HACKS)
@@ -109,11 +101,7 @@
void fvec_weight(fvec_t *s, const fvec_t *weight) {
uint_t length = MIN(s->length, weight->length);
#if defined(HAVE_INTEL_IPP)
- #if HAVE_AUBIO_DOUBLE
- ippsMul_64f(s->data, weight->data, s->data, (int)length);
- #else
- ippsMul_32f(s->data, weight->data, s->data, (int)length);
- #endif
+ aubio_ippsMul(s->data, weight->data, s->data, (int)length);
#elif defined(HAVE_ACCELERATE)
aubio_vDSP_vmul( s->data, 1, weight->data, 1, s->data, 1, length );
#else
@@ -127,11 +115,7 @@
void fvec_weighted_copy(const fvec_t *in, const fvec_t *weight, fvec_t *out) {
uint_t length = MIN(in->length, MIN(out->length, weight->length));
#if defined(HAVE_INTEL_IPP)
- #if HAVE_AUBIO_DOUBLE
- ippsMul_64f(in->data, weight->data, out->data, (int)length);
- #else
- ippsMul_32f(in->data, weight->data, out->data, (int)length);
- #endif
+ aubio_ippsMul(in->data, weight->data, out->data, (int)length);
#elif defined(HAVE_ACCELERATE)
aubio_vDSP_vmul(in->data, 1, weight->data, 1, out->data, 1, length);
#else
@@ -149,11 +133,7 @@
return;
}
#if defined(HAVE_INTEL_IPP)
- #if HAVE_AUBIO_DOUBLE
- ippsCopy_64f(s->data, t->data, (int)s->length);
- #else
- ippsCopy_32f(s->data, t->data, (int)s->length);
- #endif
+ aubio_ippsCopy(s->data, t->data, (int)s->length);
#elif defined(HAVE_ATLAS)
aubio_cblas_copy(s->length, s->data, 1, t->data, 1);
#elif defined(HAVE_ACCELERATE)
--- a/src/mathutils.c
+++ b/src/mathutils.c
@@ -160,12 +160,8 @@
{
smpl_t tmp = 0.0;
#if defined(HAVE_INTEL_IPP)
- #if HAVE_AUBIO_DOUBLE
- ippsMean_64f(s->data, (int)s->length, &tmp);
- #else
- ippsMean_32f(s->data, (int)s->length, &tmp, ippAlgHintFast);
- #endif
- return tmp;
+ aubio_ippsMean(s->data, (int)s->length, &tmp, ippAlgHintFast);
+ return tmp;
#elif defined(HAVE_ACCELERATE)
aubio_vDSP_meanv(s->data, 1, &tmp, s->length);
return tmp;
@@ -183,11 +179,7 @@
{
smpl_t tmp = 0.0;
#if defined(HAVE_INTEL_IPP)
- #if HAVE_AUBIO_DOUBLE
- ippsSum_64f(s->data, (int)s->length, &tmp);
- #else
- ippsSum_32f(s->data, (int)s->length, &tmp, ippAlgHintFast);
- #endif
+ aubio_ippsSum(s->data, (int)s->length, &tmp, ippAlgHintFast);
#elif defined(HAVE_ACCELERATE)
aubio_vDSP_sve(s->data, 1, &tmp, s->length);
#else
@@ -204,11 +196,7 @@
{
#if defined(HAVE_INTEL_IPP)
smpl_t tmp = 0.;
- #if HAVE_AUBIO_DOUBLE
- ippsMax_64f( s->data, (int)s->length, &tmp);
- #else
- ippsMax_32f( s->data, (int)s->length, &tmp);
-#endif
+ aubio_ippsMax( s->data, (int)s->length, &tmp);
#elif defined(HAVE_ACCELERATE)
smpl_t tmp = 0.;
aubio_vDSP_maxv( s->data, 1, &tmp, s->length );
@@ -227,11 +215,7 @@
{
#if defined(HAVE_INTEL_IPP)
smpl_t tmp = 0.;
- #if HAVE_AUBIO_DOUBLE
- ippsMin_64f(s->data, (int)s->length, &tmp);
- #else
- ippsMin_32f(s->data, (int)s->length, &tmp);
-#endif
+ aubio_ippsMin(s->data, (int)s->length, &tmp);
#elif defined(HAVE_ACCELERATE)
smpl_t tmp = 0.;
aubio_vDSP_minv(s->data, 1, &tmp, s->length);