Changeset 81b3910 for src/mathutils.c


Ignore:
Timestamp:
Oct 1, 2017, 12:50:15 PM (2 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master
Children:
a6b5bf1
Parents:
16c12a1 (diff), faeec7c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'intel_ipp_pull' of https://github.com/emuell/aubio into emuell-intel_ipp_pull

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mathutils.c

    r16c12a1 r81b3910  
    2525#include "mathutils.h"
    2626#include "musicutils.h"
     27
     28#if defined HAVE_INTEL_IPP
     29#include <ippcore.h>
     30#include <ippvm.h>
     31#include <ipps.h>
     32#endif
    2733
    2834/** Window types */
     
    160166{
    161167  smpl_t tmp = 0.0;
    162 #ifndef HAVE_ACCELERATE
     168#if defined(HAVE_INTEL_IPP)
     169  #if HAVE_AUBIO_DOUBLE
     170    ippsMean_64f(s->data, (int)s->length, &tmp);
     171  #else
     172    ippsMean_32f(s->data, (int)s->length, &tmp, ippAlgHintFast);
     173  #endif
     174    return tmp;
     175#elif defined(HAVE_ACCELERATE)
     176  aubio_vDSP_meanv(s->data, 1, &tmp, s->length);
     177  return tmp;
     178#else
    163179  uint_t j;
    164180  for (j = 0; j < s->length; j++) {
    165181    tmp += s->data[j];
    166182  }
    167   return tmp / (smpl_t) (s->length);
    168 #else
    169   aubio_vDSP_meanv(s->data, 1, &tmp, s->length);
    170   return tmp;
    171 #endif /* HAVE_ACCELERATE */
     183  return tmp / (smpl_t)(s->length);
     184#endif
    172185}
    173186
     
    176189{
    177190  smpl_t tmp = 0.0;
    178 #ifndef HAVE_ACCELERATE
     191#if defined(HAVE_INTEL_IPP)
     192  #if HAVE_AUBIO_DOUBLE
     193    ippsSum_64f(s->data, (int)s->length, &tmp);
     194  #else
     195    ippsSum_32f(s->data, (int)s->length, &tmp, ippAlgHintFast);
     196  #endif
     197#elif defined(HAVE_ACCELERATE)
     198  aubio_vDSP_sve(s->data, 1, &tmp, s->length);
     199#else
    179200  uint_t j;
    180201  for (j = 0; j < s->length; j++) {
    181202    tmp += s->data[j];
    182203  }
    183 #else
    184   aubio_vDSP_sve(s->data, 1, &tmp, s->length);
    185 #endif /* HAVE_ACCELERATE */
     204#endif
    186205  return tmp;
    187206}
     
    190209fvec_max (fvec_t * s)
    191210{
    192 #ifndef HAVE_ACCELERATE
    193   uint_t j;
    194   smpl_t tmp = 0.0;
    195   for (j = 0; j < s->length; j++) {
     211#if defined(HAVE_INTEL_IPP)
     212  smpl_t tmp = 0.;
     213  #if HAVE_AUBIO_DOUBLE
     214    ippsMax_64f( s->data, (int)s->length, &tmp);
     215  #else
     216    ippsMax_32f( s->data, (int)s->length, &tmp);
     217#endif
     218#elif defined(HAVE_ACCELERATE)
     219  smpl_t tmp = 0.;
     220  aubio_vDSP_maxv( s->data, 1, &tmp, s->length );
     221#else
     222  uint_t j;
     223  smpl_t tmp = s->data[0];
     224  for (j = 1; j < s->length; j++) {
    196225    tmp = (tmp > s->data[j]) ? tmp : s->data[j];
    197226  }
    198 #else
     227#endif
     228  return tmp;
     229}
     230
     231smpl_t
     232fvec_min (fvec_t * s)
     233{
     234#if defined(HAVE_INTEL_IPP)
    199235  smpl_t tmp = 0.;
    200   aubio_vDSP_maxv(s->data, 1, &tmp, s->length);
    201 #endif
    202   return tmp;
    203 }
    204 
    205 smpl_t
    206 fvec_min (fvec_t * s)
    207 {
    208 #ifndef HAVE_ACCELERATE
    209   uint_t j;
    210   smpl_t tmp = s->data[0];
    211   for (j = 0; j < s->length; j++) {
    212     tmp = (tmp < s->data[j]) ? tmp : s->data[j];
    213   }
    214 #else
     236  #if HAVE_AUBIO_DOUBLE
     237    ippsMin_64f(s->data, (int)s->length, &tmp);
     238  #else
     239    ippsMin_32f(s->data, (int)s->length, &tmp);
     240#endif
     241#elif defined(HAVE_ACCELERATE)
    215242  smpl_t tmp = 0.;
    216243  aubio_vDSP_minv(s->data, 1, &tmp, s->length);
     244#else
     245  uint_t j;
     246  smpl_t tmp = s->data[0];
     247  for (j = 1; j < s->length; j++) {
     248    tmp = (tmp < s->data[j]) ? tmp : s->data[j];
     249  }
    217250#endif
    218251  return tmp;
     
    575608}
    576609
     610uint_t
     611aubio_power_of_two_order (uint_t a)
     612{
     613  int order = 0;
     614  int temp = aubio_next_power_of_two(a);
     615  while (temp >>= 1) {
     616    ++order;
     617  }
     618  return order;
     619}
     620
    577621smpl_t
    578622aubio_db_spl (const fvec_t * o)
     
    639683
    640684void
     685aubio_init (void)
     686{
     687/* initialize intel IPP */
     688#ifdef HAVE_INTEL_IPP
     689  IppStatus status = ippInit();
     690  if (status != ippStsNoErr) {
     691    fprintf (stderr, "Error: failed to initialize Intel IPP - status %d\n", status);
     692  }
     693#endif
     694}
     695
     696void
    641697aubio_cleanup (void)
    642698{
Note: See TracChangeset for help on using the changeset viewer.