Changeset 923a7a8


Ignore:
Timestamp:
Nov 26, 2013, 4:44:17 AM (6 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
39a7b26
Parents:
2dbcafa
Message:

src/{fvec,fmat}.c: use memcpy and memset to optimise when possible, add option to disable

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/fmat.c

    r2dbcafa r923a7a8  
    8787
    8888void fmat_zeros(fmat_t *s) {
     89#if HAVE_MEMCPY_HACKS
     90  memset(s->data, 0, s->height * s->length * sizeof(smpl_t));
     91#else
    8992  fmat_set(s, 0.);
     93#endif
    9094}
    9195
     
    114118
    115119void fmat_copy(fmat_t *s, fmat_t *t) {
    116   uint_t i,j;
    117   uint_t height = MIN(s->height, t->height);
    118   uint_t length = MIN(s->length, t->length);
    119120  if (s->height != t->height) {
    120     AUBIO_ERR("warning, trying to copy %d rows to %d rows \n",
     121    AUBIO_ERR("trying to copy %d rows to %d rows \n",
    121122            s->height, t->height);
     123    return;
    122124  }
    123125  if (s->length != t->length) {
    124     AUBIO_ERR("warning, trying to copy %d columns to %d columns\n",
     126    AUBIO_ERR("trying to copy %d columns to %d columns\n",
    125127            s->length, t->length);
     128    return;
    126129  }
    127   for (i=0; i< height; i++) {
    128     for (j=0; j< length; j++) {
     130#if HAVE_MEMCPY_HACKS
     131  memcpy(t->data, s->data, t->height * t->length * sizeof(smpl_t));
     132#else
     133  uint_t i,j;
     134  for (i=0; i< t->height; i++) {
     135    for (j=0; j< t->length; j++) {
    129136      t->data[i][j] = s->data[i][j];
    130137    }
    131138  }
     139#endif
    132140}
    133141
  • src/fvec.c

    r2dbcafa r923a7a8  
    6464
    6565void fvec_zeros(fvec_t *s) {
     66#if HAVE_MEMCPY_HACKS
     67  memset(s->data, 0, s->length * sizeof(smpl_t));
     68#else
    6669  fvec_set(s, 0.);
     70#endif
    6771}
    6872
     
    8791
    8892void fvec_copy(fvec_t *s, fvec_t *t) {
     93  if (s->length != t->length) {
     94    AUBIO_ERR("trying to copy %d elements to %d elements \n",
     95        s->length, t->length);
     96    return;
     97  }
     98#if HAVE_MEMCPY_HACKS
     99  memcpy(t->data, s->data, t->length * sizeof(smpl_t));
     100#else
    89101  uint_t j;
    90   uint_t length = t->length;
    91   if (s->length != t->length) {
    92     AUBIO_WRN("trying to copy %d elements to %d elements \n",
    93         s->length, t->length);
    94     length = MIN(s->length, t->length);
    95   }
    96   for (j=0; j< length; j++) {
     102  for (j=0; j< t->length; j++) {
    97103    t->data[j] = s->data[j];
    98104  }
     105#endif
    99106}
  • src/lvec.c

    r2dbcafa r923a7a8  
    6767
    6868void lvec_zeros(lvec_t *s) {
     69#if HAVE_MEMCPY_HACKS
     70  memset(s->data, 0, s->length * sizeof(lsmp_t));
     71#else
    6972  lvec_set(s, 0.);
     73#endif
    7074}
    7175
  • wscript

    r2dbcafa r923a7a8  
    5959  add_option_enable_disable(ctx, 'samplerate', default = None,
    6060          help_str = 'compile with samplerate (auto)', help_disable_str = 'disable samplerate')
     61  add_option_enable_disable(ctx, 'memcpy', default = True,
     62          help_str = 'use memcpy hacks (default)',
     63          help_disable_str = 'do not use memcpy hacks')
    6164  add_option_enable_disable(ctx, 'double', default = False,
    6265          help_str = 'compile aubio in double precision mode',
     
    183186    ctx.msg('Checking for FFT implementation', 'ooura')
    184187
     188  # use memcpy hacks
     189  if (ctx.options.enable_memcpy == True):
     190    ctx.define('HAVE_MEMCPY_HACKS', 1)
     191  else:
     192    ctx.define('HAVE_MEMCPY_HACKS', 0)
     193
    185194  if (ctx.options.enable_jack != False):
    186195    ctx.check_cfg(package = 'jack', atleast_version = '0.15.0',
Note: See TracChangeset for help on using the changeset viewer.