Cleaning tests. Added test for the RTCM printer.

git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@495 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
Carles Fernandez
2014-03-23 09:45:03 +00:00
parent 7e752653b4
commit daba798d8a
34 changed files with 336 additions and 544 deletions
+69 -24
View File
@@ -7,7 +7,7 @@
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors)
* Copyright (C) 2010-2014 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
@@ -31,43 +31,88 @@
*/
#include <gtest/gtest.h>
#include <gflags/gflags.h>
#include <complex>
#include <sys/time.h>
#include <iostream>
#include <glog/log_severity.h>
#include <glog/logging.h>
using google::LogMessage;
#include <complex>
#include <ctime>
#include <armadillo>
#include <gflags/gflags.h>
DEFINE_int32(size_multiply_test, 100000, "Size of the arrays used for calculations");
TEST(Multiply_Test, StandardCImplementation)
TEST(Multiply_Test, StandardCComplexImplementation)
{
//LOG_AT_LEVEL(INFO) << "Using standard C++ library implementation to perform complex arithmetic";
std::complex<float>* input = new std::complex<float>[FLAGS_size_multiply_test];
std::complex<float>* output = new std::complex<float>[FLAGS_size_multiply_test];
memset(input, 0, sizeof(std::complex<float>) * FLAGS_size_multiply_test);
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
for(int i = 0; i < FLAGS_size_multiply_test; i++)
{
output[i] = input[i] * input[i];
}
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
std::cout << "Multiplication of "<< FLAGS_size_multiply_test
<< " complex<float> finished in " << (end - begin)
<< " microseconds" << std::endl;
ASSERT_LE(0, end - begin);
}
//LOG_AT_LEVEL(INFO) << "Allocated two vectors containing " << FLAGS_size << " complex numbers";
//LOG_AT_LEVEL(INFO) << "Begin multiplications";
TEST(Multiply_Test, StandardCDoubleImplementation)
{
double input[FLAGS_size_multiply_test];
double output[FLAGS_size_multiply_test];
memset(input, 0, sizeof(double) * FLAGS_size_multiply_test);
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
for(int i = 0; i < FLAGS_size_multiply_test; i++)
{
output[i] = input[i] * input[i];
}
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
std::cout << "Multiplication of "<< FLAGS_size_multiply_test
<< " doubles finished in " << (end - begin)
<< " microseconds" << std::endl;
ASSERT_LE(0, end - begin);
}
TEST(Multiply_Test, ArmadilloComplexImplementation)
{
arma::cx_fvec input(FLAGS_size_multiply_test, arma::fill::zeros);
arma::cx_fvec output(FLAGS_size_multiply_test);
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
for(int i=0; i<FLAGS_size_multiply_test; i++)
{
output[i] = input[i] * input[i];
}
output = input % input;
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec *1000000 + tv.tv_usec;
// LOG_AT_LEVEL(INFO) << "Finished in " << (end - begin) << " microseconds";
std::cout << "Multiplication of "<< FLAGS_size_multiply_test << " complex<float> finished in " << (end - begin) << " microseconds" << std::endl;
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
std::cout << "Element-wise multiplication of "<< FLAGS_size_multiply_test
<< "-length complex armadillo vectors finished in " << (end - begin)
<< " microseconds" << std::endl;
ASSERT_LE(0, end - begin);
}
TEST(Multiply_Test, ArmadilloImplementation)
{
arma::vec input(FLAGS_size_multiply_test, arma::fill::zeros);
arma::vec output(FLAGS_size_multiply_test);
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
output = input % input;
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
std::cout << "Element-wise multiplication of "<< FLAGS_size_multiply_test
<< "-length armadillo vectors finished in " << (end - begin)
<< " microseconds" << std::endl;
ASSERT_LE(0, end - begin);
}
-161
View File
@@ -1,161 +0,0 @@
/*!
* \file cordic_test.cc
* \brief Test of the CORDIC (COordinate Rotation DIgital Computer) algorithm
* \author Carles Fernandez-Prades, 2012. cfernandez(at)cttc.es
* Javier Arribas, 2012. jarribas(at)cttc.es
*
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* This file is part of GNSS-SDR.
*
* GNSS-SDR 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 of the License, or
* at your option) any later version.
*
* GNSS-SDR 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 GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
#include "GPS_L1_CA.h"
#include <iostream>
#include <cmath>
#include <gtest/gtest.h>
#include "cordic.h"
#include <sys/time.h>
#include <algorithm>
#include <cstdlib> // for RAND_MAX
#include <gnuradio/fxpt_nco.h>
#include "nco_lib.h"
TEST(Cordic_Test, StandardCIsFasterThanCordic)
{
int largest_k = 10;
Cordic* cordicPtr;
cordicPtr = new Cordic(largest_k);
std::complex<float> *d_carr_sign;
float* d_carr_sign_I;
float* d_carr_sign_Q;
// carrier parameters
int d_vector_length = 4000;
float phase_rad;
float phase_step_rad;
float carrier_freq = 2000;
float d_fs_in = 4000000;
phase_step_rad = (float)GPS_TWO_PI*carrier_freq / (float)d_fs_in;
// space for carrier wipeoff and signal baseband vectors
if (posix_memalign((void**)&d_carr_sign, 16, d_vector_length * sizeof(std::complex<float>) * 2) == 0){};
if (posix_memalign((void**)&d_carr_sign_I, 16, d_vector_length * sizeof(float) * 2) == 0){};
if (posix_memalign((void**)&d_carr_sign_Q, 16, d_vector_length * sizeof(float) * 2) == 0){};
double sin_d,cos_d;
double sin_f,cos_f;
double niter = 10000;
struct timeval tv;
//*** NON-OPTIMIZED CORDIC *****
gettimeofday(&tv, NULL);
long long int begin1 = tv.tv_sec * 1000000 + tv.tv_usec;
for(int i=0; i<niter; i++)
{
phase_rad=0;
for(int j=0; j<d_vector_length; j++)
{
cordicPtr->cordic_get_cos_sin(phase_rad, cos_d, sin_d);
d_carr_sign[j] = std::complex<float>(cos_d, -sin_d);
phase_rad = phase_rad + phase_step_rad;
}
}
gettimeofday(&tv, NULL);
long long int end1 = tv.tv_sec *1000000 + tv.tv_usec;
//*** STD COS, SIN standalone *****
gettimeofday(&tv, NULL);
long long int begin2 = tv.tv_sec * 1000000 + tv.tv_usec;
for(int i=0; i<niter; i++)
{
for(int j=0;j<d_vector_length;j++)
{
cos_f = std::cos(phase_rad);
sin_f = std::sin(phase_rad);
d_carr_sign[j] =std::complex<float>(cos_f, -sin_f);
phase_rad = phase_rad + phase_step_rad;
}
}
gettimeofday(&tv, NULL);
long long int end2 = tv.tv_sec *1000000 + tv.tv_usec;
//*** GNU RADIO FIXED POINT ARITHMETIC ********
gettimeofday(&tv, NULL);
long long int begin3 = tv.tv_sec * 1000000 + tv.tv_usec;
for(int i=0; i<niter; i++)
{
gr::fxpt_nco(d_carr_sign, d_vector_length,0, phase_step_rad);
}
gettimeofday(&tv, NULL);
long long int end3 = tv.tv_sec *1000000 + tv.tv_usec;
//*** SSE2 NCO ****************
gettimeofday(&tv, NULL);
long long int begin4 = tv.tv_sec * 1000000 + tv.tv_usec;
for(int i=0; i<niter; i++)
{
sse_nco(d_carr_sign, d_vector_length,0, phase_step_rad);
}
gettimeofday(&tv, NULL);
long long int end4 = tv.tv_sec *1000000 + tv.tv_usec;
//*** GNU RADIO FIXED POINT ARITHMETIC COPY BY REFERENCE********
gettimeofday(&tv, NULL);
long long int begin5 = tv.tv_sec * 1000000 + tv.tv_usec;
for(int i=0; i<niter; i++)
{
gr::fxpt_nco_cpyref(d_carr_sign, d_vector_length,0, phase_step_rad);
}
gettimeofday(&tv, NULL);
long long int end5 = tv.tv_sec *1000000 + tv.tv_usec;
//*** GNU RADIO FIXED POINT ARITHMETIC COPY BY REFERENCE SPLIT IQ********
gettimeofday(&tv, NULL);
long long int begin6 = tv.tv_sec * 1000000 + tv.tv_usec;
for(int i=0; i<niter; i++)
{
gr::fxpt_nco_IQ_split(d_carr_sign_I, d_carr_sign_Q, d_vector_length,0, phase_step_rad);
}
gettimeofday(&tv, NULL);
long long int end6 = tv.tv_sec *1000000 + tv.tv_usec;
delete cordicPtr;
std::cout << "NON-OPTIMIZED CORDIC computed " << niter << " times in " << (end1-begin1) << " microseconds" << std::endl;
std::cout << "STD LIB ARITHM computed " << niter << " times in " << (end2-begin2) << " microseconds" << std::endl;
std::cout << "FXPT CORDIC computed " << niter << " times in " << (end3-begin3) << " microseconds" << std::endl;
std::cout << "SSE CORDIC computed " << niter << " times in " << (end4-begin4) << " microseconds" << std::endl;
std::cout << "FXPT CORDIC CPY REF computed " << niter << " times in " << (end5-begin5) << " microseconds" << std::endl;
std::cout << "FXPT CORDIC CPY REF SPLIT computed " << niter << " times in " << (end6-begin6) << " microseconds" << std::endl;
EXPECT_TRUE((end2-begin2) < (end1-begin1)); // if true, standard C++ is faster than the cordic implementation
}
-92
View File
@@ -1,92 +0,0 @@
/*!
* \file correlations_libc.cc
* \brief This file implements a unit test for correlation
* \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com
* Carles Fernandez-Prades, 2012. cfernandez(at)cttc.es
*
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* This file is part of GNSS-SDR.
*
* GNSS-SDR 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 of the License, or
* at your option) any later version.
*
* GNSS-SDR 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 GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
#include <gtest/gtest.h>
#include <complex>
#include <sys/time.h>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <glog/log_severity.h>
#include <glog/logging.h>
#include <gflags/gflags.h>
using google::LogMessage;
DEFINE_int32(N, 2046, "Samples per millisecond of signal");
DEFINE_int32(M, 3, "Number of correlations per GNSS-SDR channel");
DEFINE_int32(C, 12, "Number of channels to simulate");
DEFINE_string(data_type, "complex", "Data type for samples");
TEST(Correlation_Test, StandardCImplementation)
{
int correlations = FLAGS_M * FLAGS_C;
//LOG_AT_LEVEL(INFO) << "Simulating " << FLAGS_C << " channels";
//LOG_AT_LEVEL(INFO) << FLAGS_M << " correlations per channel";
//LOG_AT_LEVEL(INFO) << "Performing " << correlations << " correlations";
//LOG_AT_LEVEL(INFO) << "Testing standard C++ library using complex numbers";
std::complex<float>* input = new std::complex<float>[FLAGS_N];
std::complex<float> accum;
std::srand((unsigned)time(0));
for(int i=0; i < FLAGS_N; i++)
{
input[i] = std::complex<float>(std::rand() % 10000, std::rand() % 10000);
}
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
for(int i=0; i<correlations; i++)
{
for(int j=0; j < FLAGS_N; j++)
{
input[j] = input[j] * input[j];
input[j] = input[j] * input[j];
accum += input[j];
}
}
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
std::cout << correlations << " correlations of " << FLAGS_N
<< "-length vectors computed in " << (end - begin)
<< " microseconds" << std::endl;
}