resample-native: small tweaks

This commit is contained in:
Wim Taymans 2019-03-29 12:08:45 +01:00
parent d260cb19be
commit d47353c0e6
2 changed files with 23 additions and 33 deletions

View file

@ -30,19 +30,20 @@
static void inner_product_avx(float *d, const float * SPA_RESTRICT s,
const float * SPA_RESTRICT taps, uint32_t n_taps)
{
__m256 sy[2] = { _mm256_setzero_ps(), _mm256_setzero_ps() };
__m256 sy[2] = { _mm256_setzero_ps(), _mm256_setzero_ps() }, ty;
__m128 sx[2];
uint32_t i = 0;
uint32_t n_taps4 = n_taps & ~0xf;
for (; i < n_taps4; i += 16) {
sy[0] = _mm256_fmadd_ps(_mm256_loadu_ps(s + i + 0), _mm256_load_ps(taps + i + 0), sy[0]);
sy[1] = _mm256_fmadd_ps(_mm256_loadu_ps(s + i + 8), _mm256_load_ps(taps + i + 8), sy[1]);
ty = (__m256)_mm256_lddqu_si256((__m256i*)(s + i + 0));
sy[0] = _mm256_fmadd_ps(ty, _mm256_load_ps(taps + i + 0), sy[0]);
ty = (__m256)_mm256_lddqu_si256((__m256i*)(s + i + 8));
sy[1] = _mm256_fmadd_ps(ty, _mm256_load_ps(taps + i + 8), sy[1]);
}
sy[0] = _mm256_add_ps(sy[0], sy[1]);
sx[0] = _mm256_extractf128_ps(sy[0], 0);
sy[0] = _mm256_add_ps(sy[1], sy[0]);
sx[1] = _mm256_extractf128_ps(sy[0], 1);
sx[0] = _mm256_extractf128_ps(sy[0], 0);
for (; i < n_taps; i += 8) {
sx[0] = _mm_fmadd_ps(_mm_loadu_ps(s + i + 0), _mm_load_ps(taps + i + 0), sx[0]);
sx[1] = _mm_fmadd_ps(_mm_loadu_ps(s + i + 4), _mm_load_ps(taps + i + 4), sx[1]);
@ -69,9 +70,8 @@ static void inner_product_ip_avx(float *d, const float * SPA_RESTRICT s,
sy[0] = _mm256_fmadd_ps(ty, _mm256_load_ps(t0 + i + 8), sy[0]);
sy[1] = _mm256_fmadd_ps(ty, _mm256_load_ps(t1 + i + 8), sy[1]);
}
sy[0] = _mm256_add_ps(sy[0], sy[1]);
sx[0] = _mm256_extractf128_ps(sy[0], 0);
sx[1] = _mm256_extractf128_ps(sy[0], 1);
sx[0] = _mm256_extractf128_ps(_mm256_hadd_ps(sy[0], sy[0]), 0);
sx[1] = _mm256_extractf128_ps(_mm256_hadd_ps(sy[1], sy[1]), 0);
for (; i < n_taps; i += 8) {
tx = _mm_loadu_ps(s + i + 0);
sx[0] = _mm_fmadd_ps(tx, _mm_load_ps(t0 + i + 0), sx[0]);

View file

@ -51,23 +51,13 @@ struct native_data {
float *hist_mem;
};
#define DEFINE_RESAMPLER_COPY(arch) \
void do_resample_copy_##arch(struct resample *r, \
const void * SPA_RESTRICT src[], uint32_t *in_len, \
void * SPA_RESTRICT dst[], uint32_t offs, uint32_t *out_len)
#define DEFINE_RESAMPLER_FULL(arch) \
void do_resample_full_##arch(struct resample *r, \
const void * SPA_RESTRICT src[], uint32_t *in_len, \
void * SPA_RESTRICT dst[], uint32_t offs, uint32_t *out_len)
#define DEFINE_RESAMPLER_INTER(arch) \
void do_resample_inter_##arch(struct resample *r, \
#define DEFINE_RESAMPLER(type,arch) \
void do_resample_##type##_##arch(struct resample *r, \
const void * SPA_RESTRICT src[], uint32_t *in_len, \
void * SPA_RESTRICT dst[], uint32_t offs, uint32_t *out_len)
#define MAKE_RESAMPLER_COPY(arch) \
DEFINE_RESAMPLER_COPY(arch) \
DEFINE_RESAMPLER(copy,arch) \
{ \
struct native_data *data = r->data; \
uint32_t index, n_taps = data->n_taps; \
@ -94,7 +84,7 @@ DEFINE_RESAMPLER_COPY(arch) \
}
#define MAKE_RESAMPLER_FULL(arch) \
DEFINE_RESAMPLER_FULL(arch) \
DEFINE_RESAMPLER(full,arch) \
{ \
struct native_data *data = r->data; \
uint32_t n_taps = data->n_taps, stride = data->filter_stride_os; \
@ -133,7 +123,7 @@ DEFINE_RESAMPLER_FULL(arch) \
}
#define MAKE_RESAMPLER_INTER(arch) \
DEFINE_RESAMPLER_INTER(arch) \
DEFINE_RESAMPLER(inter,arch) \
{ \
struct native_data *data = r->data; \
uint32_t index, phase, stride = data->filter_stride; \
@ -180,19 +170,19 @@ DEFINE_RESAMPLER_INTER(arch) \
}
DEFINE_RESAMPLER_COPY(c);
DEFINE_RESAMPLER_FULL(c);
DEFINE_RESAMPLER_INTER(c);
DEFINE_RESAMPLER(copy,c);
DEFINE_RESAMPLER(full,c);
DEFINE_RESAMPLER(inter,c);
#if defined (HAVE_SSE)
DEFINE_RESAMPLER_FULL(sse);
DEFINE_RESAMPLER_INTER(sse);
DEFINE_RESAMPLER(full,sse);
DEFINE_RESAMPLER(inter,sse);
#endif
#if defined (HAVE_SSSE3)
DEFINE_RESAMPLER_FULL(ssse3);
DEFINE_RESAMPLER_INTER(ssse3);
DEFINE_RESAMPLER(full,ssse3);
DEFINE_RESAMPLER(inter,ssse3);
#endif
#if defined (HAVE_AVX) && defined(HAVE_FMA)
DEFINE_RESAMPLER_FULL(avx);
DEFINE_RESAMPLER_INTER(avx);
DEFINE_RESAMPLER(full,avx);
DEFINE_RESAMPLER(inter,avx);
#endif