1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-14 20:20:35 +00:00

working on tests. Removing obsolete files

git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@500 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
Carles Fernandez 2014-03-29 19:11:32 +00:00
parent 9f2f4335a0
commit 95e123eef1
9 changed files with 155 additions and 195 deletions

View File

@ -41,13 +41,14 @@ DEFINE_int32(size_carrier_test, 100000, "Size of the arrays used for complex car
TEST(ComplexCarrier_Test, StandardComplexImplementation) TEST(ComplexCarrier_Test, StandardComplexImplementation)
{ {
std::complex<float>* input = new std::complex<float>[FLAGS_size_carrier_test]; // Dynamic allocation creates new usable space on the program STACK
// (an area of RAM specifically allocated to the program)
std::complex<float>* output = new std::complex<float>[FLAGS_size_carrier_test]; std::complex<float>* output = new std::complex<float>[FLAGS_size_carrier_test];
memset(input, 0, sizeof(std::complex<float>) * FLAGS_size_carrier_test); const double _f = 2000;
double _f = 2000; const double _fs = 2000000;
double _fs = 2000000; const double phase_step = (double)((GPS_TWO_PI * _f) / _fs);
double phase_step = (double)((GPS_TWO_PI * _f) / _fs);
double phase = 0; double phase = 0;
struct timeval tv; struct timeval tv;
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec; long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
@ -61,26 +62,61 @@ TEST(ComplexCarrier_Test, StandardComplexImplementation)
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec; long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
std::cout << "A " << FLAGS_size_carrier_test std::cout << "A " << FLAGS_size_carrier_test
<< "-length complex carrier generated in " << (end - begin) << "-length complex carrier in standard C++ (dynamic allocation) generated in " << (end - begin)
<< " microseconds" << std::endl; << " microseconds" << std::endl;
ASSERT_LE(0, end - begin); ASSERT_LE(0, end - begin);
std::complex<float> expected(1,0);
delete input; std::vector<std::complex<float>> mag(FLAGS_size_carrier_test);
for(int i = 0; i < FLAGS_size_carrier_test; i++)
{
mag[i] = output[i] * std::conj(output[i]);
ASSERT_FLOAT_EQ(std::norm(expected), std::norm(mag[i]));
}
delete output; delete output;
} }
TEST(ComplexCarrier_Test, C11ComplexImplementation)
{
// declaration: load data onto the program data segment
std::vector<std::complex<float>> output(FLAGS_size_carrier_test);
const double _f = 2000;
const double _fs = 2000000;
const double phase_step = (double)((GPS_TWO_PI * _f) / _fs);
double phase = 0;
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
int pos = 0;
for (int i = 0; i < FLAGS_size_carrier_test; i++)
{
output[i] = std::complex<float>(cos(phase), sin(phase));
phase += phase_step;
}
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
std::cout << "A " << FLAGS_size_carrier_test
<< "-length complex carrier in standard C++ (declaration) generated in " << (end - begin)
<< " microseconds" << std::endl;
ASSERT_LE(0, end - begin);
std::complex<float> expected(1,0);
std::vector<std::complex<float>> mag(FLAGS_size_carrier_test);
for(int i = 0; i < FLAGS_size_carrier_test; i++)
{
mag[i] = output[i] * std::conj(output[i]);
ASSERT_FLOAT_EQ(std::norm(expected), std::norm(mag[i]));
}
}
TEST(ComplexCarrier_Test, OwnComplexImplementation) TEST(ComplexCarrier_Test, OwnComplexImplementation)
{ {
std::complex<float>* input = new std::complex<float>[FLAGS_size_carrier_test];
memset(input, 0, sizeof(std::complex<float>) * FLAGS_size_carrier_test);
std::complex<float>* output = new std::complex<float>[FLAGS_size_carrier_test]; std::complex<float>* output = new std::complex<float>[FLAGS_size_carrier_test];
double _f = 2000; double _f = 2000;
double _fs = 2000000; double _fs = 2000000;
//double phase_step = (double)((GPS_TWO_PI * _f) / _fs);
//double phase = 0;
struct timeval tv; struct timeval tv;
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec; long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
@ -93,6 +129,12 @@ TEST(ComplexCarrier_Test, OwnComplexImplementation)
<< "-length complex carrier using fixed point generated in " << (end - begin) << "-length complex carrier using fixed point generated in " << (end - begin)
<< " microseconds" << std::endl; << " microseconds" << std::endl;
ASSERT_LE(0, end - begin); ASSERT_LE(0, end - begin);
delete input; std::complex<float> expected(1,0);
std::vector<std::complex<float>> mag(FLAGS_size_carrier_test);
for(int i = 0; i < FLAGS_size_carrier_test; i++)
{
mag[i] = output[i] * std::conj(output[i]);
ASSERT_NEAR(std::norm(expected), std::norm(mag[i]), 0.0001);
}
delete output; delete output;
} }

View File

@ -57,7 +57,7 @@ TEST(Conjugate_Test, StandardCComplexImplementation)
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec; long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
std::cout << "Conjugate of a " << FLAGS_size_conjugate_test std::cout << "Conjugate of a " << FLAGS_size_conjugate_test
<< "-length complex float vector finished in " << (end - begin) << "-length complex float vector in standard C finished in " << (end - begin)
<< " microseconds" << std::endl; << " microseconds" << std::endl;
ASSERT_LE(0, end - begin); ASSERT_LE(0, end - begin);
delete input; delete input;
@ -65,6 +65,34 @@ TEST(Conjugate_Test, StandardCComplexImplementation)
} }
TEST(Conjugate_Test, C11ComplexImplementation)
{
const std::vector<std::complex<float>> input(FLAGS_size_conjugate_test);
std::vector<std::complex<float>> output(FLAGS_size_conjugate_test);
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
int pos = 0;
for (const auto &item : input)
{
output[pos++] = std::conj(item);
}
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
std::cout << "Conjugate of a " << FLAGS_size_conjugate_test
<< " complex<float> vector (C++11-style) finished in " << (end - begin)
<< " microseconds" << std::endl;
ASSERT_LE(0, end - begin);
std::complex<float> expected(0,0);
std::complex<float> result(0,0);
for (const auto &item : output)
{
result += item;
}
ASSERT_EQ(expected, result);
}
TEST(Conjugate_Test, ArmadilloComplexImplementation) TEST(Conjugate_Test, ArmadilloComplexImplementation)
{ {

View File

@ -59,12 +59,40 @@ TEST(MagnitudeSquared_Test, StandardCComplexImplementation)
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec; long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
std::cout << "The squared magnitude of a " << FLAGS_size_magnitude_test std::cout << "The squared magnitude of a " << FLAGS_size_magnitude_test
<< "-length vector computed in " << (end - begin) << "-length vector in standard C computed in " << (end - begin)
<< " microseconds" << std::endl; << " microseconds" << std::endl;
ASSERT_LE(0, end - begin); ASSERT_LE(0, end - begin);
} }
TEST(MagnitudeSquared_Test, C11ComplexImplementation)
{
const std::vector<std::complex<float>> input(FLAGS_size_magnitude_test);
std::vector<std::complex<float>> output(FLAGS_size_magnitude_test);
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
int pos = 0;
for (const auto &item : input)
{
output[pos] = std::norm(item);
pos++;
}
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
std::cout << "The squared magnitude of a " << FLAGS_size_magnitude_test
<< " complex<float> vector (C++11-style) finished in " << (end - begin)
<< " microseconds" << std::endl;
ASSERT_LE(0, end - begin);
std::complex<float> expected(0,0);
std::complex<float> result(0,0);
for (const auto &item : output)
{
result += item;
}
ASSERT_EQ(expected, result);
}
TEST(MagnitudeSquared_Test, ArmadilloComplexImplementation) TEST(MagnitudeSquared_Test, ArmadilloComplexImplementation)
@ -108,5 +136,5 @@ TEST(MagnitudeSquared_Test, VolkComplexImplementation)
delete output; delete output;
} }
// volk_32f_accumulator_s32f_a(&d_input_power, d_magnitude, d_fft_size); // volk_32f_accumulator_s32f(&d_input_power, d_magnitude, d_fft_size);

View File

@ -56,7 +56,7 @@ TEST(Multiply_Test, StandardCDoubleImplementation)
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec; long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
std::cout << "Element-wise multiplication of " << FLAGS_size_multiply_test std::cout << "Element-wise multiplication of " << FLAGS_size_multiply_test
<< " doubles finished in " << (end - begin) << " doubles in standard C finished in " << (end - begin)
<< " microseconds" << std::endl; << " microseconds" << std::endl;
ASSERT_LE(0, end - begin); ASSERT_LE(0, end - begin);
double acc = 0; double acc = 0;
@ -85,7 +85,7 @@ TEST(Multiply_Test, ArmadilloImplementation)
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec; long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
std::cout << "Element-wise multiplication of " << FLAGS_size_multiply_test std::cout << "Element-wise multiplication of " << FLAGS_size_multiply_test
<< "-length double armadillo vectors finished in " << (end - begin) << "-length double Armadillo vectors finished in " << (end - begin)
<< " microseconds" << std::endl; << " microseconds" << std::endl;
ASSERT_LE(0, end - begin); ASSERT_LE(0, end - begin);
ASSERT_EQ(0, arma::norm(output)); ASSERT_EQ(0, arma::norm(output));
@ -110,7 +110,7 @@ TEST(Multiply_Test, StandardCComplexImplementation)
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec; long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
std::cout << "Element-wise multiplication of " << FLAGS_size_multiply_test std::cout << "Element-wise multiplication of " << FLAGS_size_multiply_test
<< " complex<float> finished in " << (end - begin) << " complex<float> in standard C finished in " << (end - begin)
<< " microseconds" << std::endl; << " microseconds" << std::endl;
ASSERT_LE(0, end - begin); ASSERT_LE(0, end - begin);
std::complex<float> expected(0,0); std::complex<float> expected(0,0);
@ -127,6 +127,40 @@ TEST(Multiply_Test, StandardCComplexImplementation)
TEST(Multiply_Test, C11ComplexImplementation)
{
const std::vector<std::complex<float>> input(FLAGS_size_multiply_test);
std::vector<std::complex<float>> output(FLAGS_size_multiply_test);
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
// Trying a range-based for
int pos = 0;
for (const auto &item : input)
{
output[pos] = item * item;
pos++;
}
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
std::cout << "Element-wise multiplication of " << FLAGS_size_multiply_test
<< " complex<float> vector (C++11-style) finished in " << (end - begin)
<< " microseconds" << std::endl;
ASSERT_LE(0, end - begin);
std::complex<float> expected(0,0);
std::complex<float> result(0,0);
// auto result = std::inner_product(output.begin(), output.end(), output.begin(), 0);
for (const auto &item : output)
{
result += item;
}
ASSERT_EQ(expected, result);
}
TEST(Multiply_Test, ArmadilloComplexImplementation) TEST(Multiply_Test, ArmadilloComplexImplementation)
{ {
arma::cx_fvec input(FLAGS_size_multiply_test, arma::fill::zeros); arma::cx_fvec input(FLAGS_size_multiply_test, arma::fill::zeros);

View File

@ -52,7 +52,6 @@
#include "gnss_sdr_valve.h" #include "gnss_sdr_valve.h"
class GpsL1CaPcpsOpenClAcquisitionGSoC2013Test: public ::testing::Test class GpsL1CaPcpsOpenClAcquisitionGSoC2013Test: public ::testing::Test
{ {
protected: protected:
@ -66,8 +65,7 @@ protected:
} }
~GpsL1CaPcpsOpenClAcquisitionGSoC2013Test() ~GpsL1CaPcpsOpenClAcquisitionGSoC2013Test()
{ {}
}
void init(); void init();
void config_1(); void config_1();
@ -329,9 +327,6 @@ void GpsL1CaPcpsOpenClAcquisitionGSoC2013Test::process_message()
{ {
correct_estimation_counter++; correct_estimation_counter++;
} }
// std::cout << "Acq delay samples = " << (double)gnss_synchro.Acq_delay_samples << std::endl;
// std::cout << "Acq doppler Hz = " << (double)gnss_synchro.Acq_doppler_hz << std::endl;
} }
realization_counter++; realization_counter++;
@ -446,7 +441,7 @@ TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ValidationOfResults)
top_block->connect(signal_source->get_right_block(), 0, acquisition->get_left_block(), 0); top_block->connect(signal_source->get_right_block(), 0, acquisition->get_left_block(), 0);
}) << "Failure connecting the blocks of acquisition test." << std::endl; }) << "Failure connecting the blocks of acquisition test." << std::endl;
// i = 0 --> sallite in acquisition is visible // i = 0 --> satellite in acquisition is visible
// i = 1 --> satellite in acquisition is not visible // i = 1 --> satellite in acquisition is not visible
for (unsigned int i = 0; i < 2; i++) for (unsigned int i = 0; i < 2; i++)
{ {
@ -535,7 +530,7 @@ TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ValidationOfResultsProbabilitie
std::cout << "Probability of false alarm (target) = " << 0.1 << std::endl; std::cout << "Probability of false alarm (target) = " << 0.1 << std::endl;
// i = 0 --> sallite in acquisition is visible (prob of detection and prob of detection with wrong estimation) // i = 0 --> satellite in acquisition is visible (prob of detection and prob of detection with wrong estimation)
// i = 1 --> satellite in acquisition is not visible (prob of false detection) // i = 1 --> satellite in acquisition is not visible (prob of false detection)
for (unsigned int i = 0; i < 2; i++) for (unsigned int i = 0; i < 2; i++)
{ {

View File

@ -1,38 +0,0 @@
#include <gflags/gflags.h>
#include <glog/logging.h>
#include "control_message_factory.h"
#include <gr_complex_to_interleaved_short.h>
#include <gnuradio/gr_file_source.h>
#include <gnuradio/gr_file_sink.h>
#include <gr_top_block.h>
#include <gnuradio/gr_io_signature.h>
#include <gnuradio/gr_sync_block.h>
using google::LogMessage;
DEFINE_string(in_file, "", "Path to the file containing the samples in gr_complex");
DEFINE_string(out_file, "", "Path to the file containing the samples in short");
int main(int argc, char** argv) {
google::InitGoogleLogging(argv[0]);
google::ParseCommandLineFlags(&argc, &argv, true);
DLOG(INFO) << "in_file " << FLAGS_in_file;
DLOG(INFO) << "out_file " << FLAGS_out_file;
gr_block_sptr file_source = gr_make_file_source(sizeof(gr_complex), FLAGS_in_file.c_str(), false);
gr_block_sptr file_sink = gr_make_file_sink(sizeof(short), FLAGS_out_file.c_str());
gr_block_sptr converter = gr_make_complex_to_interleaved_short();
gr_top_block_sptr top_block = gr_make_top_block("complex to short");
top_block->connect(file_source, 0, converter, 0);
top_block->connect(converter, 0, file_sink, 0);
top_block->run();
DLOG(INFO) << "Finished";
}

View File

@ -1,54 +0,0 @@
#include <gflags/gflags.h>
#include <glog/log_severity.h>
#include <glog/logging.h>
#include <gnuradio/gr_float_to_complex.h>
#include <gnuradio/gr_head.h>
#include <gnuradio/gr_file_sink.h>
#include <gnuradio/gr_top_block.h>
#include "dbfcttc_gpsprn.h"
#include "gnss_sdr_direct_resampler_ccf.h"
using google::LogMessage;
DEFINE_string(filename, "./data/prn_code.dat", "Path to the file where the prn code will be stored.");
DEFINE_int32(fs, 2048000, "FS of the resulting code.");
DEFINE_int32(satellite, 0, "ID of the satellite");
DEFINE_int32(time,0.001,"Signal duration"); // javi
int main(int argc, char** argv) {
google::InitGoogleLogging(argv[0]);
google::ParseCommandLineFlags(&argc, &argv, true);
// unsigned int number_of_codes = 1023; // not needed (javi)
unsigned int phase = 0;
DLOG(INFO) << "satellite " << FLAGS_satellite;
DLOG(INFO) << "fs " << FLAGS_fs;
DLOG(INFO) << "filename " << FLAGS_filename;
dbfcttc_gpsprn_sptr prn_source = dbfcttc_make_gpsprn(FLAGS_satellite, phase);
gr_float_to_complex_sptr float2complex = gr_make_float_to_complex(1);
// resample prn_codes from 1,023 Msps to 2,048 Msps
gnss_sdr_direct_resampler_ccf_sptr resampler = gnss_sdr_make_direct_resampler_ccf(1023000, FLAGS_fs);
// Valve is used to stop the flow after an amount of samples went through the block
gr_block_sptr valve = gr_make_head(sizeof(gr_complex), FLAGS_fs*FLAGS_time);
gr_file_sink_sptr file = gr_make_file_sink(sizeof(gr_complex), FLAGS_filename.c_str());
gr_top_block_sptr top_block = gr_make_top_block("prn codes generator");
top_block->connect(prn_source, 0, float2complex, 0);
top_block->connect(float2complex, 0, resampler , 0);
top_block->connect(resampler, 0, valve, 0);
top_block->connect(valve, 0, file, 0);
top_block->run();
DLOG(INFO) << "Finished";
}

View File

@ -1,38 +0,0 @@
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <gr_sig_source_c.h>
#include <gr_head.h>
#include <gr_file_sink.h>
#include <gr_top_block.h>
using google::LogMessage;
DEFINE_string(filename, "./signal_samples/saw_signal.dat", "Path to the file where the prn code will be stored.");
DEFINE_int32(fs, 4000000, "FS of the resulting code.");
DEFINE_int32(samples, 16000, "Number of samples to be generated");
DEFINE_int32(f, 250, "Frequency of the signal");
DEFINE_int32(a, 16000, "Amplitude of the signal");
int main(int argc, char** argv) {
google::InitGoogleLogging(argv[0]);
google::ParseCommandLineFlags(&argc, &argv, true);
DLOG(INFO) << "fs " << FLAGS_fs;
DLOG(INFO) << "filename " << FLAGS_filename;
DLOG(INFO) << "samples " << FLAGS_samples;
gr_block_sptr source = gr_make_sig_source_c(FLAGS_fs, GR_SAW_WAVE, FLAGS_f, FLAGS_a, 0);
gr_block_sptr file_sink = gr_make_file_sink(sizeof(gr_complex), FLAGS_filename.c_str());
gr_block_sptr valve = gr_make_head(sizeof(gr_complex), FLAGS_samples);
gr_top_block_sptr top_block = gr_make_top_block("saw signal generator");
top_block->connect(source, 0, valve, 0);
top_block->connect(valve, 0, file_sink, 0);
top_block->run();
DLOG(INFO) << "Finished";
}

View File

@ -1,37 +0,0 @@
#include <gflags/gflags.h>
#include <glog/log_severity.h>
#include <glog/logging.h>
#include <gr_interleaved_short_to_complex.h>
#include <gr_file_source.h>
#include <gr_file_sink.h>
#include <gr_top_block.h>
using google::LogMessage;
DEFINE_string(in_file, "", "Path to the file containing the samples in shorts");
DEFINE_string(out_file, "", "Path to the file containing the samples in gr_complex");
int main(int argc, char** argv) {
google::InitGoogleLogging(argv[0]);
google::ParseCommandLineFlags(&argc, &argv, true);
DLOG(INFO) << "in_file " << FLAGS_in_file;
DLOG(INFO) << "out_file " << FLAGS_out_file;
gr_block_sptr file_source = gr_make_file_source(sizeof(short), FLAGS_in_file.c_str(), false);
gr_block_sptr file_sink = gr_make_file_sink(sizeof(gr_complex), FLAGS_out_file.c_str());
gr_block_sptr converter = gr_make_interleaved_short_to_complex();
gr_top_block_sptr top_block = gr_make_top_block("short to complex");
top_block->connect(file_source, 0, converter, 0);
top_block->connect(converter, 0, file_sink, 0);
top_block->run();
DLOG(INFO) << "Finished";
}