diff options
author | Tom Rondeau | 2010-12-09 17:53:05 -0500 |
---|---|---|
committer | Tom Rondeau | 2010-12-09 17:53:05 -0500 |
commit | 31c85c66f38ed304db06e0696b3df1d2407378c8 (patch) | |
tree | ddc75e6af8f43afdd19836e201e347248ccbb48b /volk | |
parent | f3c684751dc3da3a06d5960d8b961739bdf0fd12 (diff) | |
download | gnuradio-31c85c66f38ed304db06e0696b3df1d2407378c8.tar.gz gnuradio-31c85c66f38ed304db06e0696b3df1d2407378c8.tar.bz2 gnuradio-31c85c66f38ed304db06e0696b3df1d2407378c8.zip |
volk: Adding a few more generic-only test cases.
Diffstat (limited to 'volk')
-rw-r--r-- | volk/lib/qa_32f_add_aligned16.cc | 55 | ||||
-rw-r--r-- | volk/lib/qa_32f_divide_aligned16.cc | 55 | ||||
-rw-r--r-- | volk/lib/qa_32f_multiply_aligned16.cc | 55 | ||||
-rw-r--r-- | volk/lib/qa_32f_sqrt_aligned16.cc | 53 |
4 files changed, 215 insertions, 3 deletions
diff --git a/volk/lib/qa_32f_add_aligned16.cc b/volk/lib/qa_32f_add_aligned16.cc index 92f35c7ec..002aebfc9 100644 --- a/volk/lib/qa_32f_add_aligned16.cc +++ b/volk/lib/qa_32f_add_aligned16.cc @@ -1,3 +1,22 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + */ + #include <volk/volk.h> #include <qa_32f_add_aligned16.h> #include <volk/volk_32f_add_aligned16.h> @@ -8,7 +27,41 @@ #ifndef LV_HAVE_SSE void qa_32f_add_aligned16::t1() { - printf("sse not available... no test performed\n"); + clock_t start, end; + double total; + const int vlen = 3201; + const int ITERS = 10000; + float input0[vlen] __attribute__ ((aligned (16))); + float input1[vlen] __attribute__ ((aligned (16))); + + float output0[vlen] __attribute__ ((aligned (16))); + float output_known[vlen] __attribute__ ((aligned (16))); + + for(int i = 0; i < vlen; ++i) { + input0[i] = ((float) (rand() - (RAND_MAX/2))) / static_cast<float>((RAND_MAX/2)); + input1[i] = ((float) (rand() - (RAND_MAX/2))) / static_cast<float>((RAND_MAX/2)); + output_known[i] = input0[i] + input1[i]; + } + printf("32f_add_aligned\n"); + + start = clock(); + for(int count = 0; count < ITERS; ++count) { + volk_32f_add_aligned16_manual(output0, input0, input1, vlen, "generic"); + } + end = clock(); + total = (double)(end-start)/(double)CLOCKS_PER_SEC; + printf("generic_time: %f\n", total); + + /* + for(int i = 0; i < 10; ++i) { + printf("inputs: %f, %f\n", input0[i], input1[i]); + printf("generic... %f == %f\n", output0[i], output_known[i]); + } + */ + + for(int i = 0; i < vlen; ++i) { + CPPUNIT_ASSERT_EQUAL(output0[i], output_known[i]); + } } #else diff --git a/volk/lib/qa_32f_divide_aligned16.cc b/volk/lib/qa_32f_divide_aligned16.cc index b20999beb..8826bf94f 100644 --- a/volk/lib/qa_32f_divide_aligned16.cc +++ b/volk/lib/qa_32f_divide_aligned16.cc @@ -1,3 +1,22 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + */ + #include <volk/volk.h> #include <qa_32f_divide_aligned16.h> #include <volk/volk_32f_divide_aligned16.h> @@ -8,7 +27,41 @@ #ifndef LV_HAVE_SSE void qa_32f_divide_aligned16::t1() { - printf("sse not available... no test performed\n"); + clock_t start, end; + double total; + const int vlen = 3201; + const int ITERS = 10000; + float input0[vlen] __attribute__ ((aligned (16))); + float input1[vlen] __attribute__ ((aligned (16))); + + float output0[vlen] __attribute__ ((aligned (16))); + float output_known[vlen] __attribute__ ((aligned (16))); + + for(int i = 0; i < vlen; ++i) { + input0[i] = ((float) (rand() - (RAND_MAX/2))) / static_cast<float>((RAND_MAX/2)); + input1[i] = ((float) (rand() - (RAND_MAX/2))) / static_cast<float>((RAND_MAX/2)); + output_known[i] = input0[i] / input1[i]; + } + printf("32f_divide_aligned\n"); + + start = clock(); + for(int count = 0; count < ITERS; ++count) { + volk_32f_divide_aligned16_manual(output0, input0, input1, vlen, "generic"); + } + end = clock(); + total = (double)(end-start)/(double)CLOCKS_PER_SEC; + printf("generic_time: %f\n", total); + + /* + for(int i = 0; i < 10; ++i) { + printf("inputs: %f, %f\n", input0[i], input1[i]); + printf("generic... %f == %f\n", output0[i], output_known[i]); + } + */ + + for(int i = 0; i < vlen; ++i) { + CPPUNIT_ASSERT_EQUAL(output0[i], output_known[i]); + } } #else diff --git a/volk/lib/qa_32f_multiply_aligned16.cc b/volk/lib/qa_32f_multiply_aligned16.cc index c77fe97da..e52748466 100644 --- a/volk/lib/qa_32f_multiply_aligned16.cc +++ b/volk/lib/qa_32f_multiply_aligned16.cc @@ -1,3 +1,22 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + */ + #include <volk/volk.h> #include <qa_32f_multiply_aligned16.h> #include <volk/volk_32f_multiply_aligned16.h> @@ -8,7 +27,41 @@ #ifndef LV_HAVE_SSE void qa_32f_multiply_aligned16::t1() { - printf("sse not available... no test performed\n"); + clock_t start, end; + double total; + const int vlen = 3201; + const int ITERS = 10000; + float input0[vlen] __attribute__ ((aligned (16))); + float input1[vlen] __attribute__ ((aligned (16))); + + float output0[vlen] __attribute__ ((aligned (16))); + float output_known[vlen] __attribute__ ((aligned (16))); + + for(int i = 0; i < vlen; ++i) { + input0[i] = ((float) (rand() - (RAND_MAX/2))) / static_cast<float>((RAND_MAX/2)); + input1[i] = ((float) (rand() - (RAND_MAX/2))) / static_cast<float>((RAND_MAX/2)); + output_known[i] = input0[i] * input1[i]; + } + printf("32f_multiply_aligned\n"); + + start = clock(); + for(int count = 0; count < ITERS; ++count) { + volk_32f_multiply_aligned16_manual(output0, input0, input1, vlen, "generic"); + } + end = clock(); + total = (double)(end-start)/(double)CLOCKS_PER_SEC; + printf("generic_time: %f\n", total); + + /* + for(int i = 0; i < 10; ++i) { + printf("inputs: %f, %f\n", input0[i], input1[i]); + printf("generic... %f == %f\n", output0[i], output_known[i]); + } + */ + + for(int i = 0; i < vlen; ++i) { + CPPUNIT_ASSERT_EQUAL(output0[i], output_known[i]); + } } #else diff --git a/volk/lib/qa_32f_sqrt_aligned16.cc b/volk/lib/qa_32f_sqrt_aligned16.cc index a3e6abc18..9a5f71de0 100644 --- a/volk/lib/qa_32f_sqrt_aligned16.cc +++ b/volk/lib/qa_32f_sqrt_aligned16.cc @@ -1,3 +1,22 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + */ + #include <volk/volk.h> #include <qa_32f_sqrt_aligned16.h> #include <volk/volk_32f_sqrt_aligned16.h> @@ -9,6 +28,40 @@ void qa_32f_sqrt_aligned16::t1() { printf("sse not available... no test performed\n"); + clock_t start, end; + double total; + const int vlen = 3201; + const int ITERS = 10000; + float input0[vlen] __attribute__ ((aligned (16))); + + float output0[vlen] __attribute__ ((aligned (16))); + float output_known[vlen] __attribute__ ((aligned (16))); + + // No reason to test negative numbers because they result in NaN. + for(int i = 0; i < vlen; ++i) { + input0[i] = ((float) (rand()) / static_cast<float>(RAND_MAX)); + output_known[i] = sqrt(input0[i]); + } + printf("32f_sqrt_aligned\n"); + + start = clock(); + for(int count = 0; count < ITERS; ++count) { + volk_32f_sqrt_aligned16_manual(output0, input0, vlen, "generic"); + } + end = clock(); + total = (double)(end-start)/(double)CLOCKS_PER_SEC; + printf("generic_time: %f\n", total); + + /* + for(int i = 0; i < 10; ++i) { + printf("inputs: %f\n", input0[i]); + printf("generic... %f == %f\n", output0[i], output_known[i]); + } + */ + + for(int i = 0; i < vlen; ++i) { + CPPUNIT_ASSERT_DOUBLES_EQUAL(output0[i], output_known[i], fabs(output0[i])*1e-4); + } } #else |