Changeset 986131d for src/mathutils.c


Ignore:
Timestamp:
Jul 29, 2017, 5:55:35 PM (2 years ago)
Author:
Eduard Müller <mueller.eduard@googlemail.com>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master
Children:
7100895
Parents:
34ce715
Message:

Intel IPP support for aubio

See emuell/aubio/ intel_ipp2 for details please

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mathutils.c

    r34ce715 r986131d  
    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 */
     
    155161{
    156162  smpl_t tmp = 0.0;
    157 #ifndef HAVE_ACCELERATE
     163#if defined(HAVE_INTEL_IPP)
     164  #if HAVE_AUBIO_DOUBLE
     165    ippsMean_64f(s->data, (int)s->length, &tmp);
     166  #else
     167    ippsMean_32f(s->data, (int)s->length, &tmp, ippAlgHintFast);
     168  #endif
     169    return tmp;
     170#elif defined(HAVE_ACCELERATE)
     171  aubio_vDSP_meanv(s->data, 1, &tmp, s->length);
     172  return tmp;
     173#else
    158174  uint_t j;
    159175  for (j = 0; j < s->length; j++) {
    160176    tmp += s->data[j];
    161177  }
    162   return tmp / (smpl_t) (s->length);
    163 #else
    164   aubio_vDSP_meanv(s->data, 1, &tmp, s->length);
    165   return tmp;
    166 #endif /* HAVE_ACCELERATE */
     178  return tmp / (smpl_t)(s->length);
     179#endif
    167180}
    168181
     
    171184{
    172185  smpl_t tmp = 0.0;
    173 #ifndef HAVE_ACCELERATE
     186#if defined(HAVE_INTEL_IPP)
     187  #if HAVE_AUBIO_DOUBLE
     188    ippsSum_64f(s->data, (int)s->length, &tmp);
     189  #else
     190    ippsSum_32f(s->data, (int)s->length, &tmp, ippAlgHintFast);
     191  #endif
     192#elif defined(HAVE_ACCELERATE)
     193  aubio_vDSP_sve(s->data, 1, &tmp, s->length);
     194#else
    174195  uint_t j;
    175196  for (j = 0; j < s->length; j++) {
    176197    tmp += s->data[j];
    177198  }
    178 #else
    179   aubio_vDSP_sve(s->data, 1, &tmp, s->length);
    180 #endif /* HAVE_ACCELERATE */
     199#endif
    181200  return tmp;
    182201}
     
    185204fvec_max (fvec_t * s)
    186205{
    187 #ifndef HAVE_ACCELERATE
    188   uint_t j;
    189   smpl_t tmp = 0.0;
    190   for (j = 0; j < s->length; j++) {
     206#if defined(HAVE_INTEL_IPP)
     207  smpl_t tmp = 0.;
     208  #if HAVE_AUBIO_DOUBLE
     209    ippsMax_64f( s->data, (int)s->length, &tmp);
     210  #else
     211    ippsMax_32f( s->data, (int)s->length, &tmp);
     212#endif
     213#elif defined(HAVE_ACCELERATE)
     214  smpl_t tmp = 0.;
     215  aubio_vDSP_maxv( s->data, 1, &tmp, s->length );
     216#else
     217  uint_t j;
     218  smpl_t tmp = s->data[0];
     219  for (j = 1; j < s->length; j++) {
    191220    tmp = (tmp > s->data[j]) ? tmp : s->data[j];
    192221  }
    193 #else
     222#endif
     223  return tmp;
     224}
     225
     226smpl_t
     227fvec_min (fvec_t * s)
     228{
     229#if defined(HAVE_INTEL_IPP)
    194230  smpl_t tmp = 0.;
    195   aubio_vDSP_maxv(s->data, 1, &tmp, s->length);
    196 #endif
    197   return tmp;
    198 }
    199 
    200 smpl_t
    201 fvec_min (fvec_t * s)
    202 {
    203 #ifndef HAVE_ACCELERATE
    204   uint_t j;
    205   smpl_t tmp = s->data[0];
    206   for (j = 0; j < s->length; j++) {
    207     tmp = (tmp < s->data[j]) ? tmp : s->data[j];
    208   }
    209 #else
     231  #if HAVE_AUBIO_DOUBLE
     232    ippsMin_64f(s->data, (int)s->length, &tmp);
     233  #else
     234    ippsMin_32f(s->data, (int)s->length, &tmp);
     235#endif
     236#elif defined(HAVE_ACCELERATE)
    210237  smpl_t tmp = 0.;
    211238  aubio_vDSP_minv(s->data, 1, &tmp, s->length);
     239#else
     240  uint_t j;
     241  smpl_t tmp = s->data[0];
     242  for (j = 1; j < s->length; j++) {
     243    tmp = (tmp < s->data[j]) ? tmp : s->data[j];
     244  }
    212245#endif
    213246  return tmp;
     
    570603}
    571604
     605uint_t
     606aubio_power_of_two_order (uint_t a)
     607{
     608  int order = 0;
     609  int temp = aubio_next_power_of_two(a);
     610  while (temp >>= 1) {
     611    ++order;
     612  }
     613  return order;
     614}
     615
    572616smpl_t
    573617aubio_db_spl (const fvec_t * o)
     
    634678
    635679void
     680aubio_init (void)
     681{
     682/* initialize intel IPP */
     683#ifdef HAVE_INTEL_IPP
     684  IppStatus status = ippInit();
     685  if (status != ippStsNoErr) {
     686    fprintf (stderr, "Error: failed to initialize Intel IPP - status %d\n", status);
     687  }
     688#endif
     689}
     690
     691void
    636692aubio_cleanup (void)
    637693{
Note: See TracChangeset for help on using the changeset viewer.