aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--utils/convolvetest/Makefile16
-rw-r--r--utils/convolvetest/convtest.ok72
-rw-r--r--utils/convolvetest/main.c150
3 files changed, 238 insertions, 0 deletions
diff --git a/utils/convolvetest/Makefile b/utils/convolvetest/Makefile
new file mode 100644
index 0000000..0ce4cb1
--- /dev/null
+++ b/utils/convolvetest/Makefile
@@ -0,0 +1,16 @@
+all: main.o convolve_base.o convolve.o
+ gcc -g -Wall ./*.o -o convtest -losmocore
+
+clean:
+ rm -f ./*.o
+ rm -f ./convtest
+
+main.o: main.c
+ gcc -g -Wall -c main.c
+
+convolve_base.o: ../../Transceiver52M/common/convolve_base.c
+ gcc -std=c99 -c ../../Transceiver52M/common/convolve_base.c
+
+convolve.o: ../../Transceiver52M/x86/convolve.c
+ gcc -std=c99 -c ../../Transceiver52M/x86/convolve.c -I ../../Transceiver52M/common/ -msse3 -DHAVE_SSE3
+
diff --git a/utils/convolvetest/convtest.ok b/utils/convolvetest/convtest.ok
new file mode 100644
index 0000000..5766252
--- /dev/null
+++ b/utils/convolvetest/convtest.ok
@@ -0,0 +1,72 @@
+==== TEST COMPLEX BASE IMPLEMENTATION ====
+float x[] = {0.828957,0.675654,0.904170,0.191112,0.394521,0.706067,0.868924,0.547397,0.738959,0.932485,0.233119,0.926576,0.551443,0.933420,0.494407,0.552568,0.939129,0.799646,0.814139,0.594497,0.657201,0.995300,0.935852,0.324541,0.874309,0.589157,0.637771,0.759324,0.775421,0.794910,0.262785,0.604379,0.470564,0.166955}
+
+float h[] = {0.726144,0.746635,0.470674,0.211604,0.963092,0.264553,0.265818,0.725771,0.590649,0.313560,0.547613,0.946811,0.793753,0.690502,0.276120,0.792995,0.446645}
+
+float y[] = {0.389293,10.824917,-0.676577,10.619646,0.283489,11.279525,0.384482,11.586230,0.711259,11.540458,-0.391531,11.281723,0.019900,12.278080,-0.070459,11.104558,0.087938,11.825965,-1.003252,11.698885,0.358887,11.911197,-0.678904,11.933812,0.245140,11.886644}
+
+==== TEST COMPLEX SSE3 IMPLEMENTATION: (h_len%4=0) ====
+float x[] = {0.828957,0.675654,0.904170,0.191112,0.394521,0.706067,0.868924,0.547397,0.738959,0.932485,0.233119,0.926576,0.551443,0.933420,0.494407,0.552568,0.939129,0.799646,0.814139,0.594497,0.657201,0.995300,0.935852,0.324541,0.874309,0.589157,0.637771,0.759324,0.775421,0.794910,0.262785,0.604379,0.470564,0.166955}
+
+float h[] = {0.726144,0.746635,0.470674,0.211604,0.963092,0.264553,0.265818,0.725771,0.590649,0.313560,0.547613,0.946811,0.793753,0.690502,0.276120,0.792995,0.446645,0.327805,0.785346,0.676628}
+
+float y[] = {-0.641594,12.367426,-0.970113,12.963129,-0.466783,13.747334,0.637486,13.341836,-0.168561,14.091346,0.306652,15.018833,0.233741,14.726789,-0.011241,15.034849,0.000155,13.639509,0.558827,15.495646,-0.406179,14.103148,-0.000244,15.591370,-0.492319,14.785577}
+
+==== TEST COMPLEX SSE3 IMPLEMENTATION: (h_len%8=0) ====
+float x[] = {0.828957,0.675654,0.904170,0.191112,0.394521,0.706067,0.868924,0.547397,0.738959,0.932485,0.233119,0.926576,0.551443,0.933420,0.494407,0.552568,0.939129,0.799646,0.814139,0.594497,0.657201,0.995300,0.935852,0.324541,0.874309,0.589157,0.637771,0.759324,0.775421,0.794910,0.262785,0.604379,0.470564,0.166955}
+
+float h[] = {0.726144,0.746635,0.470674,0.211604,0.963092,0.264553,0.265818,0.725771,0.590649,0.313560,0.547613,0.946811,0.793753,0.690502,0.276120,0.792995}
+
+float y[] = {-0.278295,10.097409,0.919633,11.502825,0.340383,10.979163,0.891132,11.679869,0.425363,11.186544,1.099703,12.121126,0.188196,11.180099,0.228905,12.436676,0.149904,11.522589,0.543155,11.703615,0.033465,12.425473,0.561782,12.373415,-0.218184,12.154579}
+
+
+
+==== TEST REAL BASE IMPLEMENTATION ====
+float x[] = {0.828957,0.675654,0.904170,0.191112,0.394521,0.706067,0.868924,0.547397,0.738959,0.932485,0.233119,0.926576,0.551443,0.933420,0.494407,0.552568,0.939129,0.799646,0.814139,0.594497,0.657201,0.995300,0.935852,0.324541,0.874309,0.589157,0.637771,0.759324,0.775421,0.794910,0.262785,0.604379,0.470564,0.166955}
+
+float h[] = {0.726144,0.746635,0.470674,0.211604,0.963092,0.264553,0.265818,0.725771,0.590649,0.313560,0.547613,0.946811,0.793753,0.690502,0.276120,0.792995,0.446645}
+
+float y[] = {5.354852,5.387001,4.829278,5.046340,5.849788,5.775999,5.653334,5.372714,5.999860,5.593828,5.628739,5.178002,6.010774,6.186034,6.337766,5.538046,5.616131,6.289612,5.486091,5.835261,6.277413,5.894117,5.563587,6.082063,5.828556,6.160175}
+
+==== TEST REAL SSE3 IMPLEMENTATION (hlen=4) ====
+float x[] = {0.828957,0.675654,0.904170,0.191112,0.394521,0.706067,0.868924,0.547397,0.738959,0.932485,0.233119,0.926576,0.551443,0.933420,0.494407,0.552568,0.939129,0.799646,0.814139,0.594497,0.657201,0.995300,0.935852,0.324541,0.874309,0.589157,0.637771,0.759324,0.775421,0.794910,0.262785,0.604379,0.470564,0.166955}
+
+float h[] = {0.726144,0.746635,0.470674,0.211604}
+
+float y[] = {1.154625,1.856899,1.754012,1.866038,1.759821,1.614741,1.946849,1.905307,2.034228,1.369325,1.929276,1.644739,1.911431,1.455565,1.751712,1.711433,1.206255,1.551974,1.351406,1.252433,1.410497,1.527218,1.666560,1.330974,1.544475,1.701906}
+
+==== TEST REAL SSE3 IMPLEMENTATION (hlen=8) ====
+float x[] = {0.828957,0.675654,0.904170,0.191112,0.394521,0.706067,0.868924,0.547397,0.738959,0.932485,0.233119,0.926576,0.551443,0.933420,0.494407,0.552568,0.939129,0.799646,0.814139,0.594497,0.657201,0.995300,0.935852,0.324541,0.874309,0.589157,0.637771,0.759324,0.775421,0.794910,0.262785,0.604379,0.470564,0.166955}
+
+float h[] = {0.726144,0.746635,0.470674,0.211604,0.963092,0.264553,0.265818,0.725771}
+
+float y[] = {2.966950,2.964003,3.035802,3.567513,2.983864,3.487861,3.089418,3.836586,2.979637,3.173361,3.524760,3.308944,3.511707,2.951268,3.500564,3.466951,3.174077,2.778949,3.124344,2.816606,3.196814,2.774090,3.272130,2.980138,2.646414,3.090803}
+
+==== TEST REAL SSE3 IMPLEMENTATION (hlen=12) ====
+float x[] = {0.828957,0.675654,0.904170,0.191112,0.394521,0.706067,0.868924,0.547397,0.738959,0.932485,0.233119,0.926576,0.551443,0.933420,0.494407,0.552568,0.939129,0.799646,0.814139,0.594497,0.657201,0.995300,0.935852,0.324541,0.874309,0.589157,0.637771,0.759324,0.775421,0.794910,0.262785,0.604379,0.470564,0.166955}
+
+float h[] = {0.726144,0.746635,0.470674,0.211604,0.963092,0.264553,0.265818,0.725771,0.590649,0.313560,0.547613,0.946811}
+
+float y[] = {3.906606,3.831477,4.613783,4.371631,4.441847,4.311853,4.446086,5.089131,4.708794,4.314635,4.866886,4.812932,4.678810,4.796319,4.687846,5.426141,4.119072,4.687284,4.516533,4.303559,4.733458,4.146965,5.133350,4.832816,4.598291,4.252030}
+
+==== TEST REAL SSE3 IMPLEMENTATION (hlen=16) ====
+float x[] = {0.828957,0.675654,0.904170,0.191112,0.394521,0.706067,0.868924,0.547397,0.738959,0.932485,0.233119,0.926576,0.551443,0.933420,0.494407,0.552568,0.939129,0.799646,0.814139,0.594497,0.657201,0.995300,0.935852,0.324541,0.874309,0.589157,0.637771,0.759324,0.775421,0.794910,0.262785,0.604379,0.470564,0.166955}
+
+float h[] = {0.726144,0.746635,0.470674,0.211604,0.963092,0.264553,0.265818,0.725771,0.590649,0.313560,0.547613,0.946811,0.793753,0.690502,0.276120,0.792995}
+
+float y[] = {4.845784,5.086479,6.160082,6.147918,5.549072,5.538811,6.264142,6.083664,5.942431,5.214122,6.458036,6.120992,6.385656,5.751343,6.099504,6.738166,5.942206,5.756058,6.343914,6.239408,6.090616,6.325348,6.214744,6.674619,5.691174,6.413076}
+
+==== TEST REAL SSE3 IMPLEMENTATION (hlen=20) ====
+float x[] = {0.828957,0.675654,0.904170,0.191112,0.394521,0.706067,0.868924,0.547397,0.738959,0.932485,0.233119,0.926576,0.551443,0.933420,0.494407,0.552568,0.939129,0.799646,0.814139,0.594497,0.657201,0.995300,0.935852,0.324541,0.874309,0.589157,0.637771,0.759324,0.775421,0.794910,0.262785,0.604379,0.470564,0.166955}
+
+float h[] = {0.726144,0.746635,0.470674,0.211604,0.963092,0.264553,0.265818,0.725771,0.590649,0.313560,0.547613,0.946811,0.793753,0.690502,0.276120,0.792995,0.446645,0.327805,0.785346,0.676628}
+
+float y[] = {6.148925,6.262301,5.792440,6.652380,6.759685,6.515733,6.943458,6.334218,6.539823,6.542612,7.766725,7.472028,7.258010,6.947061,7.347066,7.503224,7.134092,6.244353,7.690946,7.584768,7.779833,6.845586,7.351567,8.099596,7.393943,7.176465}
+
+==== TEST REAL SSE3 IMPLEMENTATION (h_len%4=0) ====
+float x[] = {0.828957,0.675654,0.904170,0.191112,0.394521,0.706067,0.868924,0.547397,0.738959,0.932485,0.233119,0.926576,0.551443,0.933420,0.494407,0.552568,0.939129,0.799646,0.814139,0.594497,0.657201,0.995300,0.935852,0.324541,0.874309,0.589157,0.637771,0.759324,0.775421,0.794910,0.262785,0.604379,0.470564,0.166955}
+
+float h[] = {0.726144,0.746635,0.470674,0.211604,0.963092,0.264553,0.265818,0.725771,0.590649,0.313560,0.547613,0.946811,0.793753,0.690502,0.276120,0.792995,0.446645,0.327805,0.785346,0.676628,0.906507,0.279178,0.015699,0.609179}
+
+float y[] = {7.032490,7.904466,6.745667,7.146502,6.958916,7.972230,7.314566,6.972099,7.773273,7.740826,7.380684,7.907260,8.446323,7.862378,8.022881,7.726059,7.748359,7.602177,8.926439,8.905205,8.569546,7.948394,8.588051,8.850824,8.592319,7.636216}
+
diff --git a/utils/convolvetest/main.c b/utils/convolvetest/main.c
new file mode 100644
index 0000000..ff88ba5
--- /dev/null
+++ b/utils/convolvetest/main.c
@@ -0,0 +1,150 @@
+#include <stdio.h>
+#include <string.h>
+#include <osmocom/core/utils.h>
+#include "../../Transceiver52M/common/convolve.h"
+
+#define TESTVEC_LEN 1000
+#define DO_INIT 1
+
+float x_vect[TESTVEC_LEN];
+float y_vect[TESTVEC_LEN];
+float h_vect[TESTVEC_LEN];
+
+float *x;
+float *h;
+float *y;
+
+/* Generate some random values for testing */
+void gen_floats(float *vect, int len)
+{
+ int i;
+ for(i=0;i<len;i++) {
+ vect[i] = (float)rand()/(float)(RAND_MAX);
+ }
+}
+
+/* Reset testvectors */
+static void reset_testvec(int seed)
+{
+ srand(seed);
+ memset(x_vect,0,sizeof(x_vect));
+ memset(y_vect,0,sizeof(y_vect));
+ memset(h_vect,0,sizeof(h_vect));
+
+ x=x_vect + TESTVEC_LEN/2;
+ y=y_vect + TESTVEC_LEN/2;
+ h=h_vect + TESTVEC_LEN/2;
+
+ gen_floats(x_vect,TESTVEC_LEN);
+ gen_floats(h_vect,TESTVEC_LEN);
+}
+
+/* Show float vector data cut and paste friendly */
+static void dump_floats(float *vect, int len, char *name)
+{
+ int i;
+
+ printf("float %s[] = {", name);
+ for(i=0;i<len;i++) {
+
+ printf("%f",vect[i]);
+
+ if(i<len-1)
+ printf(",");
+ }
+ printf("}\n");
+}
+
+/* Test complex convolution */
+static void test_convolve_complex(int h_len)
+{
+ int x_len;
+ int y_len;
+ int start;
+ int len;
+ int step;
+ int offset;
+
+ x_len=34;
+ y_len=26;
+ start=8;
+ len=26;
+ step=1;
+ offset=1;
+ reset_testvec(0);
+ dump_floats(x,x_len,"x");
+ printf("\n");
+ dump_floats(h,h_len,"h");
+ printf("\n");
+ convolve_complex(x, x_len, h, h_len, y, y_len, start, len, step, offset);
+ dump_floats(y,y_len,"y");
+ printf("\n");
+}
+
+/* Test real convolution */
+static void test_convolve_real(int h_len)
+{
+ int x_len;
+ int y_len;
+ int start;
+ int len;
+ int step;
+ int offset;
+
+ x_len=34;
+ y_len=26;
+ start=8;
+ len=26;
+ step=1;
+ offset=1;
+ reset_testvec(0);
+ dump_floats(x,x_len,"x");
+ printf("\n");
+ dump_floats(h,h_len,"h");
+ printf("\n");
+ convolve_real(x, x_len, h, h_len, y, y_len, start, len, step, offset);
+ dump_floats(y,y_len,"y");
+ printf("\n");
+}
+
+int main(void)
+{
+#if DO_INIT == 1
+ convolve_init();
+#endif
+
+ printf("==== TEST COMPLEX BASE IMPLEMENTATION ====\n");
+ test_convolve_complex(17);
+
+ printf("==== TEST COMPLEX SSE3 IMPLEMENTATION: (h_len%%4=0) ====\n");
+ test_convolve_complex(20);
+
+ printf("==== TEST COMPLEX SSE3 IMPLEMENTATION: (h_len%%8=0) ====\n");
+ test_convolve_complex(16);
+
+ printf("\n");
+ printf("\n");
+
+ printf("==== TEST REAL BASE IMPLEMENTATION ====\n");
+ test_convolve_real(17);
+
+ printf("==== TEST REAL SSE3 IMPLEMENTATION (hlen=4) ====\n");
+ test_convolve_real(4);
+
+ printf("==== TEST REAL SSE3 IMPLEMENTATION (hlen=8) ====\n");
+ test_convolve_real(8);
+
+ printf("==== TEST REAL SSE3 IMPLEMENTATION (hlen=12) ====\n");
+ test_convolve_real(12);
+
+ printf("==== TEST REAL SSE3 IMPLEMENTATION (hlen=16) ====\n");
+ test_convolve_real(16);
+
+ printf("==== TEST REAL SSE3 IMPLEMENTATION (hlen=20) ====\n");
+ test_convolve_real(20);
+
+ printf("==== TEST REAL SSE3 IMPLEMENTATION (h_len%%4=0) ====\n");
+ test_convolve_real(24);
+
+ return 0;
+}