Commit af7e23f0 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

resample: error depends on magnitude of input vectors

parent 583d1729
......@@ -35,18 +35,22 @@
#ifndef RESAMPLE_CHECKASM_H
#define RESAMPLE_CHECKASM_H
#include <math.h>
#include <stdio.h>
#include "os_support.h"
#define RESAMPLE_CHECK_INNER_PRODUCT(a, b, len, ret, expected, fmt, epsilon) \
#define RESAMPLE_CHECK_INNER_PRODUCT(a, b, len, actual, expected, fmt, epsilon) \
do { \
int k; \
double sum_magnitudes = 0.0; \
for (k = 0; k < len; k++) { \
sum_magnitudes += a[k]*a[k] + b[k]*b[k]; \
expected += a[k]*b[k]; \
} \
if (expected - ret > epsilon || ret - expected > epsilon) { \
fprintf(stderr, "ASM mismatch: got:"fmt", expected:"fmt"\n", ret, expected); \
speex_assert(expected == ret); \
double normalized_error = fabs(expected - actual)/sum_magnitudes; \
if (normalized_error > epsilon) { \
fprintf(stderr, "ASM mismatch: Error:"fmt" exceeds:"fmt"\n", normalized_error, epsilon); \
speex_assert(0); \
} \
} while(0)
......
......@@ -212,7 +212,7 @@ static inline float inner_product_single(const float *a, const float *b, unsigne
"q9", "q10", "q11");
#if defined(CHECK_ASM)
expected = 0.f;
RESAMPLE_CHECK_INNER_PRODUCT(a, b, len, ret, expected, "%f", 0.1f);
RESAMPLE_CHECK_INNER_PRODUCT(a, b, len, ret, expected, "%f", 1e-4f);
#endif
return ret;
}
......
......@@ -59,7 +59,7 @@ static inline float inner_product_single(const float *a, const float *b, unsigne
_mm_store_ss(&ret, sum);
#if defined(CHECK_ASM)
expected = 0.f;
RESAMPLE_CHECK_INNER_PRODUCT(a, b, len, ret, expected, "%f", 1e-15f);
RESAMPLE_CHECK_INNER_PRODUCT(a, b, len, ret, expected, "%.15f", 1e-7);
#endif
return ret;
}
......@@ -109,7 +109,7 @@ static inline double inner_product_double(const float *a, const float *b, unsign
_mm_store_sd(&ret, sum);
#if defined(CHECK_ASM)
expected = 0.0;
RESAMPLE_CHECK_INNER_PRODUCT(a, b, len, ret, expected, "%lf", 1e-15);
RESAMPLE_CHECK_INNER_PRODUCT(a, b, len, ret, expected, "%lf", 1e-7);
#endif
return ret;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment