src/aubio_priv.h: define ipp aliases for single/double precision, use them in cvec...
authorPaul Brossier <piem@piem.org>
Sun, 1 Oct 2017 13:30:10 +0000 (15:30 +0200)
committerPaul Brossier <piem@piem.org>
Sun, 1 Oct 2017 13:30:10 +0000 (15:30 +0200)
src/aubio_priv.h
src/cvec.c
src/fvec.c
src/mathutils.c

index 86dd0e7..afa9acd 100644 (file)
 #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)
index bde7511..927e9cf 100644 (file)
@@ -86,13 +86,8 @@ void cvec_copy(const cvec_t *s, cvec_t *t) {
     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_copy(const cvec_t *s, cvec_t *t) {
 
 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_set_all(cvec_t *s, smpl_t val) {
 
 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_norm_ones(cvec_t *s) {
 
 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_set_all (cvec_t *s, smpl_t val) {
 
 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_zeros(cvec_t *s) {
 
 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++) {
index 6161a6a..f69b1ef 100644 (file)
@@ -61,11 +61,7 @@ void fvec_print(const fvec_t *s) {
 
 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_set_all (fvec_t *s, smpl_t val) {
 
 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_rev(fvec_t *s) {
 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_weight(fvec_t *s, const fvec_t *weight) {
 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 @@ void fvec_copy(const fvec_t *s, fvec_t *t) {
     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)
index ef07d80..1526cde 100644 (file)
@@ -160,12 +160,8 @@ fvec_mean (fvec_t * s)
 {
   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 @@ fvec_sum (fvec_t * s)
 {
   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 @@ fvec_max (fvec_t * s)
 {
 #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 @@ fvec_min (fvec_t * s)
 {
 #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);