Eliminate ctime library. Replaced by chrono or boost::date_time

This commit is contained in:
Carles Fernandez 2017-08-11 05:18:38 +02:00
parent ed5191fc54
commit 18cd7daa09
46 changed files with 759 additions and 880 deletions

View File

@ -326,8 +326,7 @@ rtklib_pvt_cc::rtklib_pvt_cc(unsigned int nchannels, bool dump, std::string dump
std::cout << "GNSS-SDR can not create message queues!" << std::endl;
throw new std::exception();
}
gettimeofday(&tv, NULL);
begin = tv.tv_sec * 1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
}
@ -568,9 +567,9 @@ int rtklib_pvt_cc::work (int noutput_items, gr_vector_const_void_star &input_ite
<< " [deg], Height= " << d_ls_pvt->d_height_m << " [m]" << std::endl;
ttff_msgbuf ttff;
ttff.mtype = 1;
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
ttff.ttff = static_cast<double>(end - begin) / 1000000.0;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
ttff.ttff = elapsed_seconds.count();
send_sys_v_ttff_msg(ttff);
first_fix = false;
}

View File

@ -31,7 +31,7 @@
#ifndef GNSS_SDR_RTKLIB_PVT_CC_H
#define GNSS_SDR_RTKLIB_PVT_CC_H
#include <ctime>
#include <chrono>
#include <fstream>
#include <utility>
#include <string>
@ -143,8 +143,7 @@ private:
double ttff;
} ttff_msgbuf;
bool send_sys_v_ttff_msg(ttff_msgbuf ttff);
struct timeval tv;
long long int begin;
std::chrono::time_point<std::chrono::system_clock> start, end;
public:
rtklib_pvt_cc(unsigned int nchannels,

View File

@ -31,9 +31,9 @@
#include "geojson_printer.h"
#include <ctime>
#include <iomanip>
#include <sstream>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <glog/logging.h>
GeoJSON_Printer::GeoJSON_Printer()
@ -51,41 +51,39 @@ GeoJSON_Printer::~GeoJSON_Printer ()
bool GeoJSON_Printer::set_headers(std::string filename, bool time_tag_name)
{
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time(); //::local_sec_clock::local_time(zone);
tm timeinfo = boost::posix_time::to_tm(pt);
if (time_tag_name)
{
std::stringstream strm0;
const int year = timeinfo->tm_year - 100;
const int year = timeinfo.tm_year - 100;
strm0 << year;
const int month = timeinfo->tm_mon + 1;
const int month = timeinfo.tm_mon + 1;
if(month < 10)
{
strm0 << "0";
}
strm0 << month;
const int day = timeinfo->tm_mday;
const int day = timeinfo.tm_mday;
if(day < 10)
{
strm0 << "0";
}
strm0 << day << "_";
const int hour = timeinfo->tm_hour;
const int hour = timeinfo.tm_hour;
if(hour < 10)
{
strm0 << "0";
}
strm0 << hour;
const int min = timeinfo->tm_min;
const int min = timeinfo.tm_min;
if(min < 10)
{
strm0 << "0";
}
strm0 << min;
const int sec = timeinfo->tm_sec;
const int sec = timeinfo.tm_sec;
if(sec < 10)
{
strm0 << "0";

View File

@ -30,51 +30,47 @@
*/
#include "kml_printer.h"
#include <ctime>
#include <sstream>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <glog/logging.h>
using google::LogMessage;
bool Kml_Printer::set_headers(std::string filename, bool time_tag_name)
{
boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time();
tm timeinfo = boost::posix_time::to_tm(pt);
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
if (time_tag_name)
{
std::stringstream strm0;
const int year = timeinfo->tm_year - 100;
const int year = timeinfo.tm_year - 100;
strm0 << year;
const int month = timeinfo->tm_mon + 1;
const int month = timeinfo.tm_mon + 1;
if(month < 10)
{
strm0 << "0";
}
strm0 << month;
const int day = timeinfo->tm_mday;
const int day = timeinfo.tm_mday;
if(day < 10)
{
strm0 << "0";
}
strm0 << day << "_";
const int hour = timeinfo->tm_hour;
const int hour = timeinfo.tm_hour;
if(hour < 10)
{
strm0 << "0";
}
strm0 << hour;
const int min = timeinfo->tm_min;
const int min = timeinfo.tm_min;
if(min < 10)
{
strm0 << "0";
}
strm0 << min;
const int sec = timeinfo->tm_sec;
const int sec = timeinfo.tm_sec;
if(sec < 10)
{
strm0 << "0";
@ -88,6 +84,7 @@ bool Kml_Printer::set_headers(std::string filename, bool time_tag_name)
kml_filename = filename + ".kml";
}
kml_file.open(kml_filename.c_str());
if (kml_file.is_open())
{
DLOG(INFO) << "KML printer writing on " << filename.c_str();
@ -98,7 +95,7 @@ bool Kml_Printer::set_headers(std::string filename, bool time_tag_name)
<< "<kml xmlns=\"http://www.opengis.net/kml/2.2\">" << std::endl
<< " <Document>" << std::endl
<< " <name>GNSS Track</name>" << std::endl
<< " <description>GNSS-SDR Receiver position log file created at " << asctime (timeinfo)
<< " <description>GNSS-SDR Receiver position log file created at " << pt
<< " </description>" << std::endl
<< "<Style id=\"yellowLineGreenPoly\">" << std::endl
<< " <LineStyle>" << std::endl

View File

@ -32,11 +32,11 @@
*/
#include "rtcm_printer.h"
#include <ctime>
#include <iostream>
#include <iomanip>
#include <fcntl.h> // for O_RDWR
#include <termios.h> // for tcgetattr
#include <boost/date_time/posix_time/posix_time.hpp>
#include <gflags/gflags.h>
#include <glog/logging.h>
@ -45,41 +45,39 @@ using google::LogMessage;
Rtcm_Printer::Rtcm_Printer(std::string filename, bool flag_rtcm_server, bool flag_rtcm_tty_port, unsigned short rtcm_tcp_port, unsigned short rtcm_station_id, std::string rtcm_dump_devname, bool time_tag_name)
{
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time();
tm timeinfo = boost::posix_time::to_tm(pt);
if (time_tag_name)
{
std::stringstream strm0;
const int year = timeinfo->tm_year - 100;
const int year = timeinfo.tm_year - 100;
strm0 << year;
const int month = timeinfo->tm_mon + 1;
const int month = timeinfo.tm_mon + 1;
if(month < 10)
{
strm0 << "0";
}
strm0 << month;
const int day = timeinfo->tm_mday;
const int day = timeinfo.tm_mday;
if(day < 10)
{
strm0 << "0";
}
strm0 << day << "_";
const int hour = timeinfo->tm_hour;
const int hour = timeinfo.tm_hour;
if(hour < 10)
{
strm0 << "0";
}
strm0 << hour;
const int min = timeinfo->tm_min;
const int min = timeinfo.tm_min;
if(min < 10)
{
strm0 << "0";
}
strm0 << min;
const int sec = timeinfo->tm_sec;
const int sec = timeinfo.tm_sec;
if(sec < 10)
{
strm0 << "0";

View File

@ -32,6 +32,7 @@
#include "gnss_sdr_valve.h"
#include <algorithm> // for min
#include <cstring> // for memcpy
#include <gnuradio/io_signature.h>
#include "control_message_factory.h"
@ -66,6 +67,10 @@ int gnss_sdr_valve::work (int noutput_items,
unsigned long long n = std::min(d_nitems - d_ncopied_items, (long long unsigned int)noutput_items);
if (n == 0) return 0;
memcpy (output_items[0], input_items[0], n * input_signature()->sizeof_stream_item(0));
//for(long long i = 0; i++; i<n)
// {
// output_items[i] = input_items[i];
// }
d_ncopied_items += n;
return n;
}

View File

@ -33,7 +33,6 @@
#ifndef GNSS_SDR_GNSS_SDR_VALVE_H_
#define GNSS_SDR_GNSS_SDR_VALVE_H_
#include <cstring>
#include <gnuradio/sync_block.h>
#include <gnuradio/msg_queue.h>
#include <boost/shared_ptr.hpp>
@ -54,8 +53,8 @@ class gnss_sdr_valve : public gr::sync_block
gnss_sdr_valve (size_t sizeof_stream_item,
unsigned long long nitems,
gr::msg_queue::sptr queue);
unsigned long long d_nitems;
unsigned long long d_ncopied_items;
unsigned long long d_nitems;
unsigned long long d_ncopied_items;
gr::msg_queue::sptr d_queue;
public:

View File

@ -53,14 +53,13 @@
#ifndef GNSS_SDR_RTKLIB_H_
#define GNSS_SDR_RTKLIB_H_
#include <cstdio>
#include <cstdlib>
#include <cstdarg>
#include <cmath>
#include <ctime>
#include <cctype>
#include <pthread.h>
#include <netinet/in.h>
#include <cctype>
#include <cmath>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include "MATH_CONSTANTS.h"
#include "gnss_frequencies.h"
#include "gnss_obs_codes.h"

View File

@ -18,7 +18,7 @@
#include "qa_utils.h"
#include <ctime>
#include <chrono>
#include <cmath>
#include <limits>
#include <list>
@ -486,10 +486,10 @@ bool run_volk_gnsssdr_tests(volk_gnsssdr_func_desc_t desc,
//now run the test
vlen = vlen - vlen_twiddle;
clock_t start, end;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::vector<double> profile_times;
for(size_t i = 0; i < arch_list.size(); i++) {
start = clock();
start = std::chrono::system_clock::now();
switch(both_sigs.size())
{
@ -614,8 +614,9 @@ bool run_volk_gnsssdr_tests(volk_gnsssdr_func_desc_t desc,
break;
}
end = clock();
double arch_time = 1000.0 * (double)(end-start)/(double)CLOCKS_PER_SEC;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
double arch_time = 1000.0 * elapsed_seconds.count();
std::cout << arch_list[i] << " completed in " << arch_time << "ms" << std::endl;
volk_gnsssdr_test_time_t result;
result.name = arch_list[i];

View File

@ -38,8 +38,7 @@
#define GOOGLE_STRIP_LOG 0
#endif
#include <ctime>
#include <cstdlib>
#include <chrono>
#include <memory>
#include <boost/exception/diagnostic_information.hpp>
#include <boost/exception_ptr.hpp>
@ -118,12 +117,11 @@ int main(int argc, char** argv)
<< " does not exist, attempting to create it."
<< std::endl;
boost::system::error_code ec;
boost::filesystem::create_directory(p, ec);
if(ec != 0)
if(!boost::filesystem::create_directory(p, ec))
{
std::cout << "Could not create the " << FLAGS_log_dir << " folder. GNSS-SDR program ended." << std::endl;
google::ShutDownCommandLineFlags();
std::exit(0);
return 1;
}
}
std::cout << "Logging with be done at " << FLAGS_log_dir << std::endl;
@ -133,9 +131,8 @@ int main(int argc, char** argv)
std::unique_ptr<ControlThread> control_thread(new ControlThread());
// record startup time
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
try
{
@ -153,11 +150,13 @@ int main(int argc, char** argv)
{
LOG(INFO) << "Unexpected catch";
}
// report the elapsed time
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "Total GNSS-SDR run time "
<< (static_cast<double>(end - begin)) / 1000000.0
<< elapsed_seconds.count()
<< " [seconds]" << std::endl;
google::ShutDownCommandLineFlags();

View File

@ -32,9 +32,8 @@
#include <cerrno>
#include <chrono>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <random>
@ -484,12 +483,9 @@ TEST_F(TfttGpsL1CATest, ColdStart)
}
// record startup time
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
std::cout << "Starting measurement " << num_measurements + 1 << " / " << FLAGS_num_measurements << std::endl;
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
// start receiver
try
{
@ -505,9 +501,9 @@ TEST_F(TfttGpsL1CATest, ColdStart)
}
// stop clock
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
double ttff = static_cast<double>(end - begin) / 1000000.0;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
double ttff = elapsed_seconds.count();
std::shared_ptr<GNSSFlowgraph> flowgraph = control_thread->flowgraph();
EXPECT_FALSE(flowgraph->running());
@ -569,11 +565,9 @@ TEST_F(TfttGpsL1CATest, HotStart)
control_thread = std::make_shared<ControlThread>(config2);
}
// record startup time
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
std::cout << "Starting measurement " << num_measurements + 1 << " / " << FLAGS_num_measurements << std::endl;
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
// start receiver
try
@ -590,9 +584,9 @@ TEST_F(TfttGpsL1CATest, HotStart)
}
// stop clock
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
double ttff = static_cast<double>(end - begin) / 1000000.0;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
double ttff = elapsed_seconds.count();
std::shared_ptr<GNSSFlowgraph> flowgraph = control_thread->flowgraph();
EXPECT_FALSE(flowgraph->running());

View File

@ -29,9 +29,8 @@
* -------------------------------------------------------------------------
*/
#include <chrono>
#include <complex>
#include <ctime>
#include "gps_sdr_signal_processing.h"
#include "gnss_signal_processing.h"
@ -45,22 +44,20 @@ TEST(CodeGenerationTest, CodeGenGPSL1Test)
int iterations = 1000;
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
for(int i = 0; i < iterations; i++)
{
gps_l1_ca_code_gen_complex( _dest, _prn, _chip_shift);
}
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
ASSERT_LE(0, elapsed_seconds.count());
std::cout << "Generation completed in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
delete[] _dest;
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
ASSERT_LE(0, end - begin);
std::cout << "Generation completed in " << (end - begin) << " microseconds" << std::endl;
/* std::complex<float>* _dest2 = new std::complex<float>[1023];gettimeofday(&tv, NULL);
long long int begin2 = tv.tv_sec * 1000000 + tv.tv_usec;
@ -95,21 +92,20 @@ TEST(CodeGenerationTest, CodeGenGPSL1SampledTest)
int iterations = 1000;
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
for(int i = 0; i < iterations; i++)
{
gps_l1_ca_code_gen_complex_sampled( _dest, _prn, _fs, _chip_shift);
}
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
delete[] _dest;
ASSERT_LE(0, end - begin);
std::cout << "Generation completed in " << (end - begin) << " microseconds" << std::endl;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
ASSERT_LE(0, elapsed_seconds.count());
std::cout << "Generation completed in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
delete[] _dest;
/* std::complex<float>* _dest2 = new std::complex<float>[_samplesPerCode];
gettimeofday(&tv, NULL);
@ -143,18 +139,18 @@ TEST(CodeGenerationTest, ComplexConjugateTest)
int iterations = 1000;
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
for(int i = 0; i < iterations; i++)
{
complex_exp_gen_conj( _dest, _f, _fs, _samplesPerCode);
}
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
ASSERT_LE(0, elapsed_seconds.count());
std::cout << "Generation completed in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
delete[] _dest;
ASSERT_LE(0, end - begin);
std::cout << "Carrier generation completed in " << (end - begin) << " microseconds" << std::endl;
}

View File

@ -29,9 +29,8 @@
* -------------------------------------------------------------------------
*/
#include <chrono>
#include <complex>
#include <ctime>
#include <armadillo>
#include "gnss_signal_processing.h"
@ -48,9 +47,8 @@ TEST(ComplexCarrierTest, StandardComplexImplementation)
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;
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
for(int i = 0; i < FLAGS_size_carrier_test; i++)
{
@ -58,10 +56,10 @@ TEST(ComplexCarrierTest, StandardComplexImplementation)
phase += phase_step;
}
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "A " << FLAGS_size_carrier_test
<< "-length complex carrier in standard C++ (dynamic allocation) generated in " << (end - begin)
<< "-length complex carrier in standard C++ (dynamic allocation) generated in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
std::complex<float> expected(1,0);
@ -76,7 +74,7 @@ TEST(ComplexCarrierTest, StandardComplexImplementation)
ASSERT_FLOAT_EQ(std::norm(expected), std::norm(mag[i]));
}
ASSERT_LE(0, end - begin);
ASSERT_LE(0, elapsed_seconds.count() * 1e6);
}
@ -89,20 +87,20 @@ TEST(ComplexCarrierTest, C11ComplexImplementation)
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;
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
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;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "A " << FLAGS_size_carrier_test
<< "-length complex carrier in standard C++ (declaration) generated in " << (end - begin)
<< "-length complex carrier in standard C++ (declaration) generated in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
ASSERT_LE(0, end - begin);
ASSERT_LE(0, elapsed_seconds.count() * 1e6);
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++)
@ -120,16 +118,15 @@ TEST(ComplexCarrierTest, OwnComplexImplementation)
std::complex<float>* output = new std::complex<float>[FLAGS_size_carrier_test];
double _f = 2000;
double _fs = 2000000;
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
complex_exp_gen(output, _f, _fs, (unsigned int)FLAGS_size_carrier_test);
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "A " << FLAGS_size_carrier_test
<< "-length complex carrier using fixed point generated in " << (end - begin)
<< "-length complex carrier using fixed point generated in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
std::complex<float> expected(1,0);
@ -143,5 +140,5 @@ TEST(ComplexCarrierTest, OwnComplexImplementation)
{
ASSERT_NEAR(std::norm(expected), std::norm(mag[i]), 0.0001);
}
ASSERT_LE(0, end - begin);
ASSERT_LE(0, elapsed_seconds.count() * 1e6);
}

View File

@ -30,8 +30,8 @@
*/
#include <chrono>
#include <complex>
#include <ctime>
#include <armadillo>
#include <volk/volk.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
@ -46,24 +46,23 @@ TEST(ConjugateTest, StandardCComplexImplementation)
std::complex<float>* output = new std::complex<float>[FLAGS_size_conjugate_test];
memset(input, 0, sizeof(std::complex<float>) * FLAGS_size_conjugate_test);
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
for(int i = 0; i < FLAGS_size_conjugate_test; i++)
{
output[i] = std::conj(input[i]);
}
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "Conjugate of a " << FLAGS_size_conjugate_test
<< "-length complex float vector in standard C finished in " << (end - begin)
<< "-length complex float vector in standard C finished in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
delete[] input;
delete[] output;
ASSERT_LE(0, end - begin);
ASSERT_LE(0, elapsed_seconds.count() * 1e6);
}
@ -72,20 +71,19 @@ TEST(ConjugateTest, 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;
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
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;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "Conjugate of a " << FLAGS_size_conjugate_test
<< " complex<float> vector (C++11-style) finished in " << (end - begin)
<< " complex<float> vector (C++11-style) finished in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
ASSERT_LE(0, end - begin);
ASSERT_LE(0, elapsed_seconds.count() * 1e6);
std::complex<float> expected(0,0);
std::complex<float> result(0,0);
@ -102,18 +100,17 @@ TEST(ConjugateTest, ArmadilloComplexImplementation)
arma::cx_fvec input(FLAGS_size_conjugate_test, arma::fill::zeros);
arma::cx_fvec output(FLAGS_size_conjugate_test);
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
output = arma::conj(input);
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "Conjugate of a " << FLAGS_size_conjugate_test
<< "-length complex float Armadillo vector finished in " << (end - begin)
<< "-length complex float Armadillo vector finished in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
ASSERT_LE(0, end - begin);
ASSERT_LE(0, elapsed_seconds.count() * 1e6);
}
@ -123,18 +120,17 @@ TEST(ConjugateTest, VolkComplexImplementation)
std::complex<float>* output = static_cast<std::complex<float>*>(volk_gnsssdr_malloc(FLAGS_size_conjugate_test * sizeof(std::complex<float>), volk_gnsssdr_get_alignment()));
memset(input, 0, sizeof(std::complex<float>) * FLAGS_size_conjugate_test);
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
volk_32fc_conjugate_32fc(output, input, FLAGS_size_conjugate_test);
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "Conjugate of a "<< FLAGS_size_conjugate_test
<< "-length complex float vector using VOLK finished in " << (end - begin)
<< "-length complex float vector using VOLK finished in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
ASSERT_LE(0, end - begin);
ASSERT_LE(0, elapsed_seconds.count() * 1e6);
volk_gnsssdr_free(input);
volk_gnsssdr_free(output);
}

View File

@ -29,7 +29,7 @@
* -------------------------------------------------------------------------
*/
#include <ctime>
#include <chrono>
#include <gnuradio/fft/fft.h>
@ -38,7 +38,7 @@ DEFINE_int32(fft_iterations_test, 1000, "Number of averaged iterations in FFT le
TEST(FFTLengthTest, MeasureExecutionTime)
{
unsigned int d_fft_size;
struct timeval tv;
std::chrono::time_point<std::chrono::system_clock> start, end;
unsigned int fft_sizes [18] = { 1000, 1024, 1960, 2000, 2048, 4000, 4096, 4725, 8000, 8192, 10368, 12000, 16000, 16384, 27000, 32768, 50000, 65536 };
double execution_times [18];
@ -50,15 +50,14 @@ TEST(FFTLengthTest, MeasureExecutionTime)
d_fft = new gr::fft::fft_complex(d_fft_size, true);
std::fill_n( d_fft->get_inbuf(), d_fft_size, gr_complex( 0.0, 0.0 ) );
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
for(int k = 0; k < FLAGS_fft_iterations_test; k++)
{
d_fft->execute();
}
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
execution_times[i] = static_cast<double>(end - begin) / (1000000.0 * static_cast<double>(FLAGS_fft_iterations_test));
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
execution_times[i] = elapsed_seconds.count() / static_cast<double>(FLAGS_fft_iterations_test);
std::cout << "FFT execution time for length=" << d_fft_size << " : " << execution_times[i] << " [s]" << std::endl;
delete d_fft;
}

View File

@ -31,8 +31,8 @@
*/
#include <chrono>
#include <complex>
#include <ctime>
#include <armadillo>
#include <volk/volk.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
@ -45,45 +45,44 @@ TEST(MagnitudeSquaredTest, StandardCComplexImplementation)
std::complex<float>* input = new std::complex<float>[FLAGS_size_magnitude_test];
float* output = new float[FLAGS_size_magnitude_test];
unsigned int number = 0;
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
for(number = 0; number < (unsigned int)FLAGS_size_magnitude_test; number++)
{
output[number] = (input[number].real() * input[number].real()) + (input[number].imag() * input[number].imag());
}
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "The squared magnitude of a " << FLAGS_size_magnitude_test
<< "-length vector in standard C computed in " << (end - begin)
<< "-length vector in standard C computed in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
delete[] input;
delete[] output;
ASSERT_LE(0, end - begin);
ASSERT_LE(0, elapsed_seconds.count() * 1e6);
}
TEST(MagnitudeSquaredTest, C11ComplexImplementation)
{
const std::vector<std::complex<float>> input(FLAGS_size_magnitude_test);
std::vector<float> output(FLAGS_size_magnitude_test);
struct timeval tv;
int pos = 0;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
for (const auto &item : input)
{
output[pos++] = std::norm(item);
}
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "The squared magnitude of a " << FLAGS_size_magnitude_test
<< " complex<float> vector (C++11-style) finished in " << (end - begin)
<< " complex<float> vector (C++11-style) finished in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
ASSERT_LE(0, end - begin);
ASSERT_LE(0, elapsed_seconds.count() * 1e6);
std::complex<float> expected(0,0);
std::complex<float> result(0,0);
@ -99,41 +98,38 @@ TEST(MagnitudeSquaredTest, ArmadilloComplexImplementation)
{
arma::cx_fvec input(FLAGS_size_magnitude_test, arma::fill::zeros);
arma::fvec output(FLAGS_size_magnitude_test);
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
output = arma::abs(arma::square(input));
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "The squared magnitude of a " << FLAGS_size_magnitude_test
<< "-length vector using Armadillo computed in " << (end - begin)
<< "-length vector using Armadillo computed in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
ASSERT_LE(0, end - begin);
ASSERT_LE(0, elapsed_seconds.count() * 1e6);
}
TEST(MagnitudeSquaredTest, VolkComplexImplementation)
{
std::complex<float>* input = static_cast<std::complex<float>*>(volk_gnsssdr_malloc(FLAGS_size_magnitude_test * sizeof(std::complex<float>), volk_gnsssdr_get_alignment()));
memset(input, 0, sizeof(std::complex<float>) * FLAGS_size_magnitude_test);
float* output = static_cast<float*>(volk_gnsssdr_malloc(FLAGS_size_magnitude_test * sizeof(float), volk_gnsssdr_get_alignment()));
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
volk_32fc_magnitude_squared_32f(output, input, static_cast<unsigned int>(FLAGS_size_magnitude_test));
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "The squared magnitude of a " << FLAGS_size_magnitude_test
<< "-length vector using VOLK computed in " << (end - begin)
<< "-length vector using VOLK computed in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
volk_gnsssdr_free(input);
volk_gnsssdr_free(output);
ASSERT_LE(0, end - begin);
ASSERT_LE(0, elapsed_seconds.count() * 1e6);
}
// volk_32f_accumulator_s32f(&d_input_power, d_magnitude, d_fft_size);

View File

@ -31,8 +31,8 @@
*/
#include <chrono>
#include <complex>
#include <ctime>
#include <numeric>
#include <armadillo>
#include <volk/volk.h>
@ -46,19 +46,18 @@ TEST(MultiplyTest, StandardCDoubleImplementation)
double* input = new double[FLAGS_size_multiply_test];
double* output = new double[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;
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
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;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "Element-wise multiplication of " << FLAGS_size_multiply_test
<< " doubles in standard C finished in " << (end - begin)
<< " doubles in standard C finished in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
double acc = 0;
@ -69,7 +68,7 @@ TEST(MultiplyTest, StandardCDoubleImplementation)
}
delete[] input;
delete[] output;
ASSERT_LE(0, end - begin);
ASSERT_LE(0, elapsed_seconds.count() * 1e6);
ASSERT_EQ(expected, acc);
}
@ -79,18 +78,17 @@ TEST(MultiplyTest, 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;
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
output = input % input;
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "Element-wise multiplication of " << FLAGS_size_multiply_test
<< "-length double Armadillo vectors finished in " << (end - begin)
<< "-length double Armadillo vectors finished in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
ASSERT_LE(0, end - begin);
ASSERT_LE(0, elapsed_seconds.count() * 1e6);
ASSERT_EQ(0, arma::norm(output,2));
}
@ -101,19 +99,18 @@ TEST(MultiplyTest, StandardCComplexImplementation)
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;
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
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;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "Element-wise multiplication of " << FLAGS_size_multiply_test
<< " complex<float> in standard C finished in " << (end - begin)
<< " complex<float> in standard C finished in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
std::complex<float> expected(0,0);
@ -124,7 +121,7 @@ TEST(MultiplyTest, StandardCComplexImplementation)
}
delete[] input;
delete[] output;
ASSERT_LE(0, end - begin);
ASSERT_LE(0, elapsed_seconds.count() * 1e6);
ASSERT_EQ(expected, result);
}
@ -135,9 +132,8 @@ TEST(MultiplyTest, C11ComplexImplementation)
const std::vector<std::complex<float>> input(FLAGS_size_multiply_test);
std::vector<std::complex<float>> output(FLAGS_size_multiply_test);
int pos = 0;
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
// Trying a range-based for
for (const auto &item : input)
@ -145,12 +141,12 @@ TEST(MultiplyTest, C11ComplexImplementation)
output[pos++] = item * item;
}
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "Element-wise multiplication of " << FLAGS_size_multiply_test
<< " complex<float> vector (C++11-style) finished in " << (end - begin)
<< " complex<float> vector (C++11-style) finished in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
ASSERT_LE(0, end - begin);
ASSERT_LE(0, elapsed_seconds.count() * 1e6);
std::complex<float> expected(0,0);
auto result = std::inner_product(output.begin(), output.end(), output.begin(), expected);
@ -163,18 +159,17 @@ TEST(MultiplyTest, 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;
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
output = input % input;
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "Element-wise multiplication of " << FLAGS_size_multiply_test
<< "-length complex float Armadillo vectors finished in " << (end - begin)
<< "-length complex float Armadillo vectors finished in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
ASSERT_LE(0, end - begin);
ASSERT_LE(0, elapsed_seconds.count() * 1e6);
ASSERT_EQ(0, arma::norm(output,2));
}
@ -187,18 +182,17 @@ TEST(MultiplyTest, VolkComplexImplementation)
std::complex<float>* output = static_cast<std::complex<float>*>(volk_gnsssdr_malloc(FLAGS_size_multiply_test * sizeof(std::complex<float>), volk_gnsssdr_get_alignment()));
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;
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
volk_32fc_x2_multiply_32fc(output, input, input, FLAGS_size_multiply_test);
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "Element-wise multiplication of " << FLAGS_size_multiply_test
<< "-length complex float vector using VOLK finished in " << (end - begin)
<< "-length complex float vector using VOLK finished in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
ASSERT_LE(0, end - begin);
ASSERT_LE(0, elapsed_seconds.count() * 1e6);
float* mag = static_cast<float*>(volk_gnsssdr_malloc(FLAGS_size_multiply_test * sizeof(float), volk_gnsssdr_get_alignment()));
volk_32fc_magnitude_32f(mag, output, FLAGS_size_multiply_test);

View File

@ -30,9 +30,8 @@
*/
#include <ctime>
#include <chrono>
#include <iostream>
#include <boost/chrono.hpp>
#include <boost/shared_ptr.hpp>
#include <gnuradio/top_block.h>
#include <gnuradio/blocks/file_source.h>
@ -341,16 +340,13 @@ void GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test::start_queue()
void GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test::wait_message()
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
while (!stop)
{
acquisition->reset();
gettimeofday(&tv, NULL);
begin = tv.tv_sec *1e6 + tv.tv_usec;
start = std::chrono::system_clock::now();
try
{
@ -361,10 +357,10 @@ void GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test::wait_message()
DLOG(FATAL) << "Boost exception: " << boost::diagnostic_information(e);
}
gettimeofday(&tv, NULL);
end = tv.tv_sec*1e6 + tv.tv_usec;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
mean_acq_time_us += (end - begin);
mean_acq_time_us += elapsed_seconds.count() * 1e6;
process_message();
}
@ -423,9 +419,8 @@ TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, Instantiate)
TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ConnectAndRun)
{
int nsamples = floor(fs_in*integration_time_ms*1e-3);
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
config_1();
queue = gr::msg_queue::make(0);
@ -465,14 +460,13 @@ TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ConnectAndRun)
}) << "Failure connecting the blocks of acquisition test." << std::endl;
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec *1e6 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec *1e6 + tv.tv_usec;
}) << "Failure running he top_block." << std::endl;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
std::cout << "Processed " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}
TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ValidationOfResults)

View File

@ -31,9 +31,8 @@
*/
#include <ctime>
#include <chrono>
#include <iostream>
#include <boost/chrono.hpp>
#include <gnuradio/top_block.h>
#include <gnuradio/blocks/file_source.h>
#include <gnuradio/analog/sig_source_waveform.h>
@ -355,23 +354,21 @@ void GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test::start_queue()
void GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test::wait_message()
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
while (!stop)
{
acquisition->reset();
gettimeofday(&tv, NULL);
begin = tv.tv_sec*1e6 + tv.tv_usec;
start = std::chrono::system_clock::now();
channel_internal_queue.wait_and_pop(message);
gettimeofday(&tv, NULL);
end = tv.tv_sec*1e6 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
mean_acq_time_us += (end - begin);
mean_acq_time_us += elapsed_seconds.count() * 1e6;
process_message();
}
@ -435,9 +432,8 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test, Instantiate)
TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test, ConnectAndRun)
{
int nsamples = floor(fs_in*integration_time_ms*1e-3);
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
top_block = gr::make_top_block("Acquisition test");
queue = gr::msg_queue::make(0);
config_1();
@ -456,14 +452,13 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test, ConnectAndRun)
}) << "Failure connecting the blocks of acquisition test." << std::endl;
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec*1e6 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec*1e6 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
std::cout << "Processed " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}

View File

@ -41,9 +41,8 @@
*/
#include <ctime>
#include <chrono>
#include <iostream>
#include <boost/chrono.hpp>
#include <gnuradio/top_block.h>
#include <gnuradio/blocks/file_source.h>
#include <gnuradio/analog/sig_source_waveform.h>
@ -213,9 +212,8 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoCTest, ConnectAndRun)
{
int fs_in = 4000000;
int nsamples = 4*fs_in;
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
queue = gr::msg_queue::make(0);
top_block = gr::make_top_block("Acquisition test");
@ -234,20 +232,18 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoCTest, ConnectAndRun)
}) << "Failure connecting the blocks of acquisition test." << std::endl;
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec * 1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
std::cout << "Processed " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}
TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoCTest, ValidationOfResults)
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
queue = gr::msg_queue::make(0);
top_block = gr::make_top_block("Acquisition test");
@ -299,17 +295,16 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoCTest, ValidationOfResults)
}) << "Failure starting acquisition" << std::endl;
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec * 1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
stop_queue();
unsigned long int nsamples = gnss_synchro.Acq_samplestamp_samples;
std::cout << "Acquired " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
std::cout << "Acquired " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 0=ACQ STOP.";

View File

@ -31,8 +31,8 @@
*/
#include <chrono>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <boost/make_shared.hpp>
#include <gnuradio/top_block.h>
@ -152,6 +152,7 @@ void GalileoE1PcpsAmbiguousAcquisitionTest::init()
config->set_property("Acquisition1.cboc", "true");
}
TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, Instantiate)
{
init();
@ -164,9 +165,8 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, ConnectAndRun)
{
int fs_in = 4000000;
int nsamples = 4*fs_in;
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
top_block = gr::make_top_block("Acquisition test");
gr::msg_queue::sptr queue = gr::msg_queue::make(0);
init();
@ -184,21 +184,19 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, ConnectAndRun)
}) << "Failure connecting the blocks of acquisition test." << std::endl;
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec*1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec*1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
std::cout << "Processed " << nsamples << " samples in " << (end-begin) << " microseconds" << std::endl;
std::cout << "Processed " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}
TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, ValidationOfResults)
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
double expected_delay_samples = 2920; //18250;
double expected_doppler_hz = -632;
@ -247,15 +245,14 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, ValidationOfResults)
acquisition->set_state(1);
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec * 1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
unsigned long int nsamples = gnss_synchro.Acq_samplestamp_samples;
std::cout << "Acquired " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
std::cout << "Acquired " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
ASSERT_EQ(1, msg_rx->rx_message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS.";
std::cout << "Delay: " << gnss_synchro.Acq_delay_samples << std::endl;

View File

@ -31,7 +31,7 @@
*/
#include <ctime>
#include <chrono>
#include <iostream>
#include <boost/shared_ptr.hpp>
#include <gnuradio/top_block.h>
@ -349,23 +349,21 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisitionTest::start_queue()
void GalileoE1PcpsCccwsrAmbiguousAcquisitionTest::wait_message()
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
while (!stop)
{
acquisition->reset();
gettimeofday(&tv, NULL);
begin = tv.tv_sec *1e6 + tv.tv_usec;
start = std::chrono::system_clock::now();
channel_internal_queue.wait_and_pop(message);
gettimeofday(&tv, NULL);
end = tv.tv_sec *1e6 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
mean_acq_time_us += (end-begin);
mean_acq_time_us += elapsed_seconds.count() * 1e6;
process_message();
}
@ -427,9 +425,8 @@ TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, Instantiate)
TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ConnectAndRun)
{
int nsamples = floor(fs_in*integration_time_ms*1e-3);
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
config_1();
top_block = gr::make_top_block("Acquisition test");
@ -449,14 +446,13 @@ TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ConnectAndRun)
}) << "Failure connecting the blocks of acquisition test."<< std::endl;
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec *1e6 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec *1e6 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block."<< std::endl;
std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
std::cout << "Processed " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}
TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ValidationOfResults)

View File

@ -31,7 +31,7 @@
*/
#include <ctime>
#include <chrono>
#include <fstream>
#include <iostream>
#include <stdexcept>
@ -466,28 +466,27 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test::start_queue()
void GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test::wait_message()
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> begin, end;
std::chrono::duration<double> elapsed_seconds;
while (!stop)
{
acquisition->reset();
gettimeofday(&tv, NULL);
begin = tv.tv_sec*1e6 + tv.tv_usec;
begin = std::chrono::system_clock::now();
channel_internal_queue.wait_and_pop(message);
gettimeofday(&tv, NULL);
end = tv.tv_sec*1e6 + tv.tv_usec;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - begin;
mean_acq_time_us += (end - begin);
mean_acq_time_us += elapsed_seconds.count() * 1e6;
process_message();
}
}
void GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test::process_message()
{
if (message == 1)
@ -505,7 +504,6 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test::process_message()
{
correct_estimation_counter++;
}
}
else if(message == 2 && gnss_synchro.PRN == 10)
{
@ -539,6 +537,7 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test::process_message()
}
}
void GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test::stop_queue()
{
stop = true;
@ -557,9 +556,8 @@ TEST_F(GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test, ConnectAndRun)
{
LOG(INFO) << "**Start connect and run test";
int nsamples = floor(fs_in*integration_time_ms*1e-3);
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> begin, end;
std::chrono::duration<double> elapsed_seconds;
top_block = gr::make_top_block("Acquisition test");
queue = gr::msg_queue::make(0);
@ -581,18 +579,18 @@ TEST_F(GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test, ConnectAndRun)
}) << "Failure connecting the blocks of acquisition test."<< std::endl;
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec * 1e6 + tv.tv_usec;
begin = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec * 1e6 + tv.tv_usec;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - begin;
}) << "Failure running the top_block."<< std::endl;
std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
std::cout << "Processed " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
LOG(INFO) << "----end connect and run test-----";
LOG(INFO) << "**End connect and run test";
}
TEST_F(GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test, ValidationOfResults)
{
LOG(INFO) << "Start validation of results test";
@ -772,6 +770,7 @@ TEST_F(GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test, ValidationOfResul
DLOG(INFO) << "End validation of results with noise+interference test";
}
TEST_F(GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test, ValidationOfResultsProbabilities)
{
config_2();
@ -866,8 +865,6 @@ TEST_F(GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test, ValidationOfResul
pdpfafile << FLAGS_e1_value_threshold << "," << Pd << "," << Pfa_p << "," << Pmd << std::endl;
pdpfafile.close();
}
}
else if (i == 1)
{

View File

@ -33,10 +33,9 @@
#include <ctime>
#include <chrono>
#include <iostream>
#include <boost/shared_ptr.hpp>
#include <boost/chrono.hpp>
#include <boost/thread.hpp>
#include <gnuradio/top_block.h>
#include <gnuradio/blocks/file_source.h>
@ -107,9 +106,11 @@ GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx::GalileoE1PcpsTongAmbig
rx_message = 0;
}
GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx::~GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx()
{}
class GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test: public ::testing::Test
{
protected:
@ -170,6 +171,7 @@ protected:
double Pfa_a;
};
void GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test::init()
{
message = 0;
@ -185,6 +187,7 @@ void GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test::init()
Pfa_a = 0;
}
void GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test::config_1()
{
gnss_synchro.Channel_ID = 0;
@ -256,6 +259,7 @@ void GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test::config_1()
config->set_property("Acquisition_Galileo.dump", "false");
}
void GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test::config_2()
{
gnss_synchro.Channel_ID = 0;
@ -345,36 +349,37 @@ void GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test::config_2()
config->set_property("Acquisition_Galileo.dump", "false");
}
void GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test::start_queue()
{
stop = false;
ch_thread = boost::thread(&GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test::wait_message, this);
}
void GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test::wait_message()
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
while (!stop)
{
acquisition->reset();
gettimeofday(&tv, NULL);
begin = tv.tv_sec *1e6 + tv.tv_usec;
start = std::chrono::system_clock::now();
channel_internal_queue.wait_and_pop(message);
gettimeofday(&tv, NULL);
end = tv.tv_sec *1e6 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
mean_acq_time_us += (end - begin);
mean_acq_time_us += elapsed_seconds.count() * 1e6;
process_message();
}
}
void GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test::process_message()
{
if (message == 1)
@ -416,11 +421,13 @@ void GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test::process_message()
}
}
void GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test::stop_queue()
{
stop = true;
}
TEST_F(GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test, Instantiate)
{
config_1();
@ -428,12 +435,12 @@ TEST_F(GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test, Instantiate)
acquisition = std::dynamic_pointer_cast<GalileoE1PcpsTongAmbiguousAcquisition>(acq_);
}
TEST_F(GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test, ConnectAndRun)
{
int nsamples = floor(fs_in*integration_time_ms*1e-3);
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
top_block = gr::make_top_block("Acquisition test");
queue = gr::msg_queue::make(0);
config_1();
@ -449,16 +456,16 @@ TEST_F(GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test, ConnectAndRun)
}) << "Failure connecting the blocks of acquisition test." << std::endl;
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec * 1e6 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec * 1e6 + tv.tv_usec;
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
std::cout << "Processed " << nsamples << " samples in " << (end-begin) << " microseconds" << std::endl;
std::cout << "Processed " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}
TEST_F(GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test, ValidationOfResults)
{
config_1();
@ -547,6 +554,7 @@ TEST_F(GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test, ValidationOfResults)
}
}
TEST_F(GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test, ValidationOfResultsProbabilities)
{
config_2();

View File

@ -29,9 +29,8 @@
* -------------------------------------------------------------------------
*/
#include <ctime>
#include <chrono>
#include <iostream>
#include <boost/chrono.hpp>
#include <gnuradio/top_block.h>
#include <gnuradio/blocks/file_source.h>
#include <gnuradio/analog/sig_source_waveform.h>
@ -105,6 +104,7 @@ GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx::GalileoE5aPcpsAcquisition
rx_message = 0;
}
GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx::~GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx()
{}
@ -183,6 +183,7 @@ protected:
int sat = 0;
};
void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::init()
{
message = 0;
@ -198,6 +199,7 @@ void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::init()
Pfa_a = 0;
}
void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::config_1()
{
gnss_synchro.Channel_ID = 0;
@ -207,7 +209,6 @@ void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::config_1()
std::string signal = "5X";
signal.copy(gnss_synchro.Signal,2,0);
integration_time_ms = 3;
//fs_in = 11e6;
//fs_in = 18e6;
@ -295,6 +296,7 @@ void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::config_1()
config->set_property("SignalSource.dump_filename", "../data/acquisition.dat");
}
void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::config_2()
{
gnss_synchro.Channel_ID = 0;
@ -341,6 +343,7 @@ void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::config_2()
config->set_property("SignalSource.dump_filename", "../data/acquisition.dat");
}
void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::config_3()
{
gnss_synchro.Channel_ID = 0;
@ -349,7 +352,6 @@ void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::config_3()
std::string signal = "5X";
signal.copy(gnss_synchro.Signal,2,0);
integration_time_ms = 3;
//fs_in = 10.24e6;
//fs_in = 12e6;
@ -463,36 +465,37 @@ void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::config_3()
config->set_property("SignalSource.dump_filename", "../data/acquisition.dat");
}
void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::start_queue()
{
stop = false;
ch_thread = boost::thread(&GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::wait_message, this);
}
void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::wait_message()
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
while (!stop)
{
acquisition->reset();
gettimeofday(&tv, NULL);
begin = tv.tv_sec *1e6 + tv.tv_usec;
start = std::chrono::system_clock::now();
channel_internal_queue.wait_and_pop(message);
gettimeofday(&tv, NULL);
end = tv.tv_sec *1e6 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
mean_acq_time_us += (end-begin);
mean_acq_time_us += elapsed_seconds.count() * 1e6;
process_message();
}
}
void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::process_message()
{
if (message == 1)
@ -577,9 +580,8 @@ TEST_F(GalileoE5aPcpsAcquisitionGSoC2014GensourceTest, ConnectAndRun)
config_1();
//int nsamples = floor(5*fs_in*integration_time_ms*1e-3);
int nsamples = 21000*3;
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
acquisition = std::make_shared<GalileoE5aNoncoherentIQAcquisitionCaf>(config.get(), "Acquisition", 1, 1);
boost::shared_ptr<GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx> msg_rx = GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx_make(channel_internal_queue);
queue = gr::msg_queue::make(0);
@ -595,14 +597,13 @@ TEST_F(GalileoE5aPcpsAcquisitionGSoC2014GensourceTest, ConnectAndRun)
}) << "Failure connecting the blocks of acquisition test."<< std::endl;
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec *1e6 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec *1e6 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block."<< std::endl;
std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
std::cout << "Processed " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}
/*

View File

@ -31,7 +31,7 @@
*/
#include <ctime>
#include <chrono>
#include <iostream>
#include <gnuradio/top_block.h>
#include <gnuradio/blocks/file_source.h>
@ -171,6 +171,7 @@ protected:
double Pfa_a;
};
void GpsL1CaPcpsAcquisitionGSoC2013Test::init()
{
message = 0;
@ -186,6 +187,7 @@ void GpsL1CaPcpsAcquisitionGSoC2013Test::init()
Pfa_a = 0;
}
void GpsL1CaPcpsAcquisitionGSoC2013Test::config_1()
{
gnss_synchro.Channel_ID = 0;
@ -350,23 +352,21 @@ void GpsL1CaPcpsAcquisitionGSoC2013Test::start_queue()
void GpsL1CaPcpsAcquisitionGSoC2013Test::wait_message()
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
while (!stop)
{
acquisition->reset();
gettimeofday(&tv, NULL);
begin = tv.tv_sec *1e6 + tv.tv_usec;
start = std::chrono::system_clock::now();
channel_internal_queue.wait_and_pop(message);
gettimeofday(&tv, NULL);
end = tv.tv_sec *1e6 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
mean_acq_time_us += (end-begin);
mean_acq_time_us += elapsed_seconds.count() * 1e6;
process_message();
}
@ -426,9 +426,8 @@ TEST_F(GpsL1CaPcpsAcquisitionGSoC2013Test, Instantiate)
TEST_F(GpsL1CaPcpsAcquisitionGSoC2013Test, ConnectAndRun)
{
int nsamples = floor(fs_in*integration_time_ms*1e-3);
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
queue = gr::msg_queue::make(0);
top_block = gr::make_top_block("Acquisition test");
@ -446,14 +445,13 @@ TEST_F(GpsL1CaPcpsAcquisitionGSoC2013Test, ConnectAndRun)
}) << "Failure connecting the blocks of acquisition test."<< std::endl;
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec *1e6 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec *1e6 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block."<< std::endl;
std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
std::cout << "Processed " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
delete acquisition;
}

View File

@ -32,10 +32,9 @@
#include <ctime>
#include <chrono>
#include <cstdlib>
#include <iostream>
#include <boost/chrono.hpp>
#include <boost/make_shared.hpp>
#include <gnuradio/top_block.h>
#include <gnuradio/blocks/file_source.h>
@ -163,9 +162,8 @@ TEST_F(GpsL1CaPcpsAcquisitionTest, ConnectAndRun)
{
int fs_in = 4000000;
int nsamples = 4000;
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
gr::msg_queue::sptr queue = gr::msg_queue::make(0);
top_block = gr::make_top_block("Acquisition test");
@ -184,22 +182,20 @@ TEST_F(GpsL1CaPcpsAcquisitionTest, ConnectAndRun)
}) << "Failure connecting the blocks of acquisition test." << std::endl;
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec * 1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
std::cout << "Processed " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}
TEST_F(GpsL1CaPcpsAcquisitionTest, ValidationOfResults)
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
top_block = gr::make_top_block("Acquisition test");
double expected_delay_samples = 524;
@ -248,15 +244,14 @@ TEST_F(GpsL1CaPcpsAcquisitionTest, ValidationOfResults)
acquisition->init();
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec * 1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
unsigned long int nsamples = gnss_synchro.Acq_samplestamp_samples;
std::cout << "Acquired " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
std::cout << "Acquired " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
ASSERT_EQ(1, msg_rx->rx_message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS.";
double delay_error_samples = std::abs(expected_delay_samples - gnss_synchro.Acq_delay_samples);

View File

@ -29,11 +29,11 @@
* -------------------------------------------------------------------------
*/
#include <chrono>
#include <cstdlib>
#include <iostream>
#include <boost/make_shared.hpp>
#include <boost/thread.hpp>
#include <boost/chrono.hpp>
#include <gnuradio/top_block.h>
#include <gnuradio/blocks/file_source.h>
#include <gnuradio/analog/sig_source_waveform.h>
@ -285,6 +285,7 @@ void GpsL1CaPcpsAcquisitionTestFpga::init()
}
TEST_F(GpsL1CaPcpsAcquisitionTestFpga, Instantiate)
{
init();
@ -293,11 +294,11 @@ TEST_F(GpsL1CaPcpsAcquisitionTestFpga, Instantiate)
"Acquisition", 0, 1);
}
TEST_F(GpsL1CaPcpsAcquisitionTestFpga, ValidationOfResults)
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
top_block = gr::make_top_block("Acquisition test");
double expected_delay_samples = 524;
@ -305,11 +306,9 @@ TEST_F(GpsL1CaPcpsAcquisitionTestFpga, ValidationOfResults)
init();
std::shared_ptr < GpsL1CaPcpsAcquisitionFpga > acquisition =
std::make_shared < GpsL1CaPcpsAcquisitionFpga
> (config.get(), "Acquisition", 0, 1);
std::make_shared < GpsL1CaPcpsAcquisitionFpga > (config.get(), "Acquisition", 0, 1);
boost::shared_ptr<GpsL1CaPcpsAcquisitionTestFpga_msg_rx> msg_rx =
GpsL1CaPcpsAcquisitionTestFpga_msg_rx_make();
boost::shared_ptr<GpsL1CaPcpsAcquisitionTestFpga_msg_rx> msg_rx = GpsL1CaPcpsAcquisitionTestFpga_msg_rx_make();
ASSERT_NO_THROW(
{
@ -374,32 +373,25 @@ TEST_F(GpsL1CaPcpsAcquisitionTestFpga, ValidationOfResults)
EXPECT_NO_THROW(
{
gettimeofday(&tv, NULL);
begin = tv.tv_sec * 1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
acquisition->reset(); // launch the tracking process
top_block->wait();
gettimeofday(&tv, NULL);
end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
})<< "Failure running the top_block." << std::endl;
t3.join();
std::cout << "Ran GpsL1CaPcpsAcquisitionTestFpga in " << (end - begin)
<< " microseconds" << std::endl;
std::cout << "Ran GpsL1CaPcpsAcquisitionTestFpga in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
ASSERT_EQ(1, msg_rx->rx_message)
<< "Acquisition failure. Expected message: 1=ACQ SUCCESS.";
ASSERT_EQ(1, msg_rx->rx_message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS.";
double delay_error_samples = std::abs(
expected_delay_samples - gnss_synchro.Acq_delay_samples);
double delay_error_samples = std::abs(expected_delay_samples - gnss_synchro.Acq_delay_samples);
float delay_error_chips = (float) (delay_error_samples * 1023 / 4000);
double doppler_error_hz = std::abs(
expected_doppler_hz - gnss_synchro.Acq_doppler_hz);
EXPECT_LE(doppler_error_hz, 666)
<< "Doppler error exceeds the expected value: 666 Hz = 2/(3*integration period)";
EXPECT_LT(delay_error_chips, 0.5)
<< "Delay error exceeds the expected value: 0.5 chips";
double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz);
EXPECT_LE(doppler_error_hz, 666) << "Doppler error exceeds the expected value: 666 Hz = 2/(3*integration period)";
EXPECT_LT(delay_error_chips, 0.5) << "Delay error exceeds the expected value: 0.5 chips";
}

View File

@ -32,7 +32,7 @@
#include <ctime>
#include <chrono>
#include <iostream>
#include <boost/shared_ptr.hpp>
#include <gnuradio/top_block.h>
@ -292,23 +292,21 @@ void GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test::start_queue()
void GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test::wait_message()
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
while (!stop)
{
acquisition->reset();
gettimeofday(&tv, NULL);
begin = tv.tv_sec *1e6 + tv.tv_usec;
start = std::chrono::system_clock::now();
channel_internal_queue.wait_and_pop(message);
gettimeofday(&tv, NULL);
end = tv.tv_sec *1e6 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
mean_acq_time_us += (end-begin);
mean_acq_time_us += elapsed_seconds.count() * 1e6;
process_message();
}
@ -369,9 +367,8 @@ TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, Instantiate)
TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, ConnectAndRun)
{
int nsamples = floor(fs_in*integration_time_ms*1e-3);
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
queue = gr::msg_queue::make(0);
top_block = gr::make_top_block("Acquisition test");
@ -387,14 +384,13 @@ TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, ConnectAndRun)
}) << "Failure connecting the blocks of acquisition test." << std::endl;
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec *1e6 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec *1e6 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
std::cout << "Processed " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}
TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, ValidationOfResults)

View File

@ -31,7 +31,7 @@
*/
#include <ctime>
#include <chrono>
#include <iostream>
#include <boost/shared_ptr.hpp>
#include <gnuradio/top_block.h>
@ -346,23 +346,21 @@ void GpsL1CaPcpsOpenClAcquisitionGSoC2013Test::start_queue()
void GpsL1CaPcpsOpenClAcquisitionGSoC2013Test::wait_message()
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
while (!stop)
{
acquisition->reset();
gettimeofday(&tv, NULL);
begin = tv.tv_sec *1e6 + tv.tv_usec;
start = std::chrono::system_clock::now();
channel_internal_queue.wait_and_pop(message);
gettimeofday(&tv, NULL);
end = tv.tv_sec *1e6 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
mean_acq_time_us += (end-begin);
mean_acq_time_us += elapsed_seconds.count() * 1e6;
process_message();
}
@ -423,9 +421,8 @@ TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, Instantiate)
TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ConnectAndRun)
{
int nsamples = floor(fs_in*integration_time_ms*1e-3);
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
config_1();
acquisition = std::make_shared<GpsL1CaPcpsOpenClAcquisition>(config.get(), "Acquisition", 1, 1);
@ -441,14 +438,13 @@ TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ConnectAndRun)
}) << "Failure connecting the blocks of acquisition test." << std::endl;
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec * 1e6 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec * 1e6 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
std::cout << "Processed " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}
TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ValidationOfResults)

View File

@ -32,7 +32,7 @@
#include <ctime>
#include <chrono>
#include <iostream>
#include <stdexcept>
#include <glog/logging.h>
@ -198,9 +198,9 @@ void GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test::init()
miss_detection_counter = 0;
Pmd = 0;
}
void GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test::config_1()
{
gnss_synchro.Channel_ID = 0;
@ -269,6 +269,7 @@ void GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test::config_1()
config->set_property("Acquisition.dump", "false");
}
void GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test::config_2()
{
gnss_synchro.Channel_ID = 0;
@ -451,31 +452,31 @@ void GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test::config_3()
config->set_property("Acquisition.dump", "false");
}
void GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test::start_queue()
{
stop = false;
ch_thread = boost::thread(&GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test::wait_message, this);
}
void GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test::wait_message()
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
while (!stop)
{
acquisition->reset();
gettimeofday(&tv, NULL);
begin = tv.tv_sec * 1e6 + tv.tv_usec;
start = std::chrono::system_clock::now();
channel_internal_queue.wait_and_pop(message);
gettimeofday(&tv, NULL);
end = tv.tv_sec * 1e6 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
mean_acq_time_us += (end - begin);
mean_acq_time_us += elapsed_seconds.count() * 1e6;
process_message();
}
@ -542,9 +543,8 @@ TEST_F(GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test, Instantiate)
TEST_F(GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test, ConnectAndRun)
{
int nsamples = floor(fs_in * integration_time_ms * 1e-3);
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
top_block = gr::make_top_block("Acquisition test");
queue = gr::msg_queue::make(0);
boost::shared_ptr<GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx> msg_rx = GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx_make(channel_internal_queue);
@ -562,14 +562,13 @@ TEST_F(GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test, ConnectAndRun)
}) << "Failure connecting the blocks of acquisition test."<< std::endl;
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec * 1e6 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec * 1e6 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block."<< std::endl;
std::cout << "Processed " << nsamples << " samples in " << (end-begin) << " microseconds" << std::endl;
std::cout << "Processed " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}

View File

@ -32,7 +32,7 @@
#include <ctime>
#include <chrono>
#include <iostream>
#include <boost/shared_ptr.hpp>
#include <gnuradio/top_block.h>
@ -346,24 +346,21 @@ void GpsL1CaPcpsTongAcquisitionGSoC2013Test::start_queue()
void GpsL1CaPcpsTongAcquisitionGSoC2013Test::wait_message()
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
while (!stop)
{
acquisition->reset();
gettimeofday(&tv, NULL);
begin = tv.tv_sec *1e6 + tv.tv_usec;
start = std::chrono::system_clock::now();
channel_internal_queue.wait_and_pop(message);
gettimeofday(&tv, NULL);
end = tv.tv_sec*1e6 + tv.tv_usec;
mean_acq_time_us += (end - begin);
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
mean_acq_time_us += elapsed_seconds.count() * 1e6;
process_message();
}
}
@ -423,9 +420,8 @@ TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, Instantiate)
TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ConnectAndRun)
{
int nsamples = floor(fs_in*integration_time_ms*1e-3);
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
top_block = gr::make_top_block("Acquisition test");
queue = gr::msg_queue::make(0);
@ -443,14 +439,13 @@ TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ConnectAndRun)
}) << "Failure connecting the blocks of acquisition test." << std::endl;
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec *1e6 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec *1e6 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
std::cout << "Processed " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}
TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ValidationOfResults)

View File

@ -32,10 +32,9 @@
#include <ctime>
#include <chrono>
#include <cstdlib>
#include <iostream>
#include <boost/chrono.hpp>
#include <boost/make_shared.hpp>
#include <gnuradio/top_block.h>
#include <gnuradio/blocks/file_source.h>
@ -170,9 +169,8 @@ TEST_F(GpsL2MPcpsAcquisitionTest, Instantiate)
TEST_F(GpsL2MPcpsAcquisitionTest, ConnectAndRun)
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
top_block = gr::make_top_block("Acquisition test");
queue = gr::msg_queue::make(0);
@ -190,21 +188,19 @@ TEST_F(GpsL2MPcpsAcquisitionTest, ConnectAndRun)
}) << "Failure connecting the blocks of acquisition test." << std::endl;
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec * 1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
std::cout << "Processed " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}
TEST_F(GpsL2MPcpsAcquisitionTest, ValidationOfResults)
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
top_block = gr::make_top_block("Acquisition test");
queue = gr::msg_queue::make(0);
double expected_delay_samples = 1;//2004;
@ -262,15 +258,14 @@ TEST_F(GpsL2MPcpsAcquisitionTest, ValidationOfResults)
}) << "Failure set_state and init acquisition test" << std::endl;
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec * 1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
//unsigned long int Acq_samplestamp_samples = gnss_synchro.Acq_samplestamp_samples;
std::cout << "Acquisition process runtime duration: " << (end - begin) << " microseconds" << std::endl;
std::cout << "Acquisition process runtime duration: " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
std::cout << "gnss_synchro.Acq_doppler_hz = " << gnss_synchro.Acq_doppler_hz << " Hz" << std::endl;
std::cout << "gnss_synchro.Acq_delay_samples = " << gnss_synchro.Acq_delay_samples << " Samples" << std::endl;

View File

@ -28,8 +28,8 @@
* -------------------------------------------------------------------------
*/
#include <chrono>
#include <complex>
#include <ctime>
#include <iostream>
#include <stdint.h>
#include <gflags/gflags.h>
@ -75,6 +75,7 @@ protected:
int nsamples = FLAGS_filter_test_nsamples;
};
void FirFilterTest::init()
{
config->set_property("InputFilter.taps_item_type", "float");
@ -99,24 +100,28 @@ void FirFilterTest::init()
//config->set_property("InputFilter.dump", "true");
}
void FirFilterTest::configure_cbyte_cbyte()
{
config->set_property("InputFilter.input_item_type", "cbyte");
config->set_property("InputFilter.output_item_type", "cbyte");
}
void FirFilterTest::configure_gr_complex_gr_complex()
{
config->set_property("InputFilter.input_item_type", "gr_complex");
config->set_property("InputFilter.output_item_type", "gr_complex");
}
void FirFilterTest::configure_cshort_cshort()
{
config->set_property("InputFilter.input_item_type", "cshort");
config->set_property("InputFilter.output_item_type", "cshort");
}
void FirFilterTest::configure_cbyte_gr_complex()
{
config->set_property("InputFilter.input_item_type", "cbyte");
@ -144,6 +149,7 @@ TEST_F(FirFilterTest, InstantiateCshortCshort)
ASSERT_EQ(1, res);
}
TEST_F(FirFilterTest, InstantiateCbyteCbyte)
{
init();
@ -154,6 +160,7 @@ TEST_F(FirFilterTest, InstantiateCbyteCbyte)
ASSERT_EQ(1, res);
}
TEST_F(FirFilterTest, InstantiateCbyteGrComplex)
{
init();
@ -164,12 +171,12 @@ TEST_F(FirFilterTest, InstantiateCbyteGrComplex)
ASSERT_EQ(1, res);
}
TEST_F(FirFilterTest, ConnectAndRun)
{
int fs_in = 4000000;
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
top_block = gr::make_top_block("Fir filter test");
init();
@ -188,21 +195,19 @@ TEST_F(FirFilterTest, ConnectAndRun)
}) << "Failure connecting the top_block."<< std::endl;
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec * 1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
std::cout << "Filtered " << nsamples << " samples in " << (end-begin) << " microseconds" << std::endl;
std::cout << "Filtered " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}
TEST_F(FirFilterTest, ConnectAndRunGrcomplex)
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
top_block = gr::make_top_block("Fir filter test");
init();
@ -232,20 +237,18 @@ TEST_F(FirFilterTest, ConnectAndRunGrcomplex)
}) << "Failure connecting the top_block."<< std::endl;
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec * 1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
std::cout << "Filtered " << nsamples << " gr_complex samples in " << (end-begin) << " microseconds" << std::endl;
std::cout << "Filtered " << nsamples << " gr_complex samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}
TEST_F(FirFilterTest, ConnectAndRunCshorts)
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
top_block = gr::make_top_block("Fir filter test");
init();
@ -277,22 +280,20 @@ TEST_F(FirFilterTest, ConnectAndRunCshorts)
}) << "Failure connecting the top_block."<< std::endl;
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec * 1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
std::cout << "Filtered " << nsamples << " std::complex<int16_t> samples in " << (end-begin) << " microseconds" << std::endl;
std::cout << "Filtered " << nsamples << " std::complex<int16_t> samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}
TEST_F(FirFilterTest, ConnectAndRunCbytes)
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
top_block = gr::make_top_block("Fir filter test");
init();
@ -324,21 +325,19 @@ TEST_F(FirFilterTest, ConnectAndRunCbytes)
}) << "Failure connecting the top_block."<< std::endl;
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec * 1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
std::cout << "Filtered " << nsamples << " std::complex<int8_t> samples in " << (end-begin) << " microseconds" << std::endl;
std::cout << "Filtered " << nsamples << " std::complex<int8_t> samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}
TEST_F(FirFilterTest, ConnectAndRunCbyteGrcomplex)
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
top_block = gr::make_top_block("Fir filter test");
init();
@ -370,11 +369,10 @@ TEST_F(FirFilterTest, ConnectAndRunCbyteGrcomplex)
}) << "Failure connecting the top_block."<< std::endl;
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec * 1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
std::cout << "Filtered " << nsamples << " samples in " << (end-begin) << " microseconds" << std::endl;
std::cout << "Filtered " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}

View File

@ -31,8 +31,8 @@
*/
#include <unistd.h>
#include <chrono>
#include <cstdlib>
#include <ctime>
#include <exception>
#include <iostream>
#include <armadillo>
@ -437,6 +437,7 @@ void HybridObservablesTest::check_results_code_psudorange(
ASSERT_GT(min_error, -2);
}
TEST_F(HybridObservablesTest, ValidationOfResults)
{
// Configure the signal generator
@ -444,13 +445,12 @@ TEST_F(HybridObservablesTest, ValidationOfResults)
// Generate signal raw signal samples and observations RINEX file
if (FLAGS_disable_generator==false)
{
generate_signal();
}
{
generate_signal();
}
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
configure_receiver();
@ -502,7 +502,7 @@ TEST_F(HybridObservablesTest, ValidationOfResults)
{
throw std::exception();
};
})<< "Failure reading true observables file" << std::endl;
}) << "Failure reading true observables file" << std::endl;
//restart the epoch counter
true_obs_data_ch0.restart();
@ -524,8 +524,6 @@ TEST_F(HybridObservablesTest, ValidationOfResults)
std::shared_ptr<TelemetryDecoderInterface> tlm_ch0(new GpsL1CaTelemetryDecoder(config.get(), "TelemetryDecoder_1C",1, 1));
std::shared_ptr<TelemetryDecoderInterface> tlm_ch1(new GpsL1CaTelemetryDecoder(config.get(), "TelemetryDecoder_1C",1, 1));
ASSERT_NO_THROW( {
tlm_ch0->set_channel(0);
tlm_ch1->set_channel(1);
@ -540,7 +538,6 @@ TEST_F(HybridObservablesTest, ValidationOfResults)
//Observables
std::shared_ptr<ObservablesInterface> observables(new HybridObservables(config.get(), "Observables",2, 2));
ASSERT_NO_THROW( {
tracking_ch0->set_channel(gnss_synchro_ch0.Channel_ID);
tracking_ch1->set_channel(gnss_synchro_ch1.Channel_ID);
@ -584,11 +581,10 @@ TEST_F(HybridObservablesTest, ValidationOfResults)
tracking_ch1->start_tracking();
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec * 1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
//check results
@ -700,7 +696,6 @@ TEST_F(HybridObservablesTest, ValidationOfResults)
measuded_ch1_Pseudorange_m = measuded_ch1_Pseudorange_m.subvec(initial_meas_point(0), measuded_ch1_Pseudorange_m.size() - 1);
measuded_ch1_Acc_carrier_phase_hz = measuded_ch1_Acc_carrier_phase_hz.subvec(initial_meas_point(0), measuded_ch1_Acc_carrier_phase_hz.size() - 1);
//correct the clock error using true values (it is not possible for a receiver to correct
//the receiver clock offset error at the observables level because it is required the
//decoding of the ephemeris data and solve the PVT equations)
@ -708,14 +703,16 @@ TEST_F(HybridObservablesTest, ValidationOfResults)
//find the reference satellite and compute the receiver time offset at obsevable level
arma::vec receiver_time_offset_s;
if (measuded_ch0_Pseudorange_m(0)<measuded_ch1_Pseudorange_m(0))
{
receiver_time_offset_s=true_ch0_dist_m/GPS_C_m_s-GPS_STARTOFFSET_ms/1000.0;
}else{
receiver_time_offset_s=true_ch1_dist_m/GPS_C_m_s-GPS_STARTOFFSET_ms/1000.0;
}
arma::vec corrected_reference_TOW_s=true_ch0_tow_s-receiver_time_offset_s;
{
receiver_time_offset_s = true_ch0_dist_m / GPS_C_m_s - GPS_STARTOFFSET_ms/1000.0;
}
else
{
receiver_time_offset_s = true_ch1_dist_m / GPS_C_m_s - GPS_STARTOFFSET_ms/1000.0;
}
arma::vec corrected_reference_TOW_s = true_ch0_tow_s - receiver_time_offset_s;
std::cout<<"receiver_time_offset_s [0]: "<<receiver_time_offset_s(0)<<std::endl;
std::cout <<" receiver_time_offset_s [0]: " << receiver_time_offset_s(0) << std::endl;
//compare measured observables
check_results_code_psudorange(true_ch0_dist_m, true_ch1_dist_m, corrected_reference_TOW_s,
@ -728,6 +725,6 @@ TEST_F(HybridObservablesTest, ValidationOfResults)
measuded_ch1_Acc_carrier_phase_hz,
measuded_ch0_RX_time_s);
std::cout << "Test completed in " << (end - begin) << " microseconds" << std::endl;
std::cout << "Test completed in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}

View File

@ -32,7 +32,7 @@
*/
#include <ctime>
#include <chrono>
#include <iostream>
#include <gnuradio/top_block.h>
#include <gnuradio/analog/sig_source_waveform.h>
@ -47,14 +47,13 @@ TEST(DirectResamplerConditionerCcTest, InstantiationAndRunTest)
{
double fs_in = 8000000.0; // Input sampling frequency in Hz
double fs_out = 4000000.0; // sampling freuqncy of the resampled signal in Hz
struct timeval tv;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
int nsamples = 1000000; //Number of samples to be computed
gr::msg_queue::sptr queue = gr::msg_queue::make(0);
gr::top_block_sptr top_block = gr::make_top_block("direct_resampler_conditioner_cc_test");
boost::shared_ptr<gr::analog::sig_source_c> source = gr::analog::sig_source_c::make(fs_in, gr::analog::GR_SIN_WAVE, 1000.0, 1.0, gr_complex(0.0));
boost::shared_ptr<gr::block> valve = gnss_sdr_make_valve(sizeof(gr_complex), nsamples, queue);
long long int begin = 0;
long long int end = 0;
EXPECT_NO_THROW({
direct_resampler_conditioner_cc_sptr resampler = direct_resampler_make_conditioner_cc(fs_in, fs_out);
@ -70,13 +69,12 @@ TEST(DirectResamplerConditionerCcTest, InstantiationAndRunTest)
}) << "Connection failure of direct_resampler_conditioner.";
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec *1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec *1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
top_block->stop();
}) << "Failure running direct_resampler_conditioner.";
std::cout << "Resampled " << nsamples << " samples in " << (end-begin) << " microseconds" << std::endl;
std::cout << "Resampled " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}

View File

@ -31,8 +31,8 @@
*/
#include <unistd.h>
#include <chrono>
#include <cstdlib>
#include <ctime>
#include <exception>
#include <iostream>
#include <string>
@ -336,14 +336,13 @@ TEST_F(GpsL1CATelemetryDecoderTest, ValidationOfResults)
configure_generator();
// Generate signal raw signal samples and observations RINEX file
if (FLAGS_disable_generator==false)
{
generate_signal();
}
if (FLAGS_disable_generator == false)
{
generate_signal();
}
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
configure_receiver();
@ -416,11 +415,10 @@ TEST_F(GpsL1CATelemetryDecoderTest, ValidationOfResults)
tracking->start_tracking();
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec * 1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
//check results
@ -478,6 +476,6 @@ TEST_F(GpsL1CATelemetryDecoderTest, ValidationOfResults)
check_results(true_timestamp_s, true_tow_s, tlm_timestamp_s, tlm_tow_s);
std::cout << "Test completed in " << (end - begin) << " microseconds" << std::endl;
std::cout << "Test completed in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}

View File

@ -29,7 +29,7 @@
* -------------------------------------------------------------------------
*/
#include <ctime>
#include <chrono>
#include <complex>
#include <random>
#include <thread>
@ -59,10 +59,12 @@ void run_correlator_cpu(cpu_multicorrelator* correlator,
}
}
TEST(CpuMulticorrelatorTest, MeasureExecutionTime)
{
struct timeval tv;
int max_threads=FLAGS_cpu_multicorrelator_max_threads_test;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
int max_threads = FLAGS_cpu_multicorrelator_max_threads_test;
std::vector<std::thread> thread_pool;
cpu_multicorrelator* correlator_pool[max_threads];
unsigned int correlation_sizes [3] = { 2048, 4096, 8192};
@ -72,8 +74,8 @@ TEST(CpuMulticorrelatorTest, MeasureExecutionTime)
gr_complex* in_cpu;
gr_complex* d_correlator_outs;
int d_n_correlator_taps=3;
int d_vector_length=correlation_sizes[2]; //max correlation size to allocate all the necessary memory
int d_n_correlator_taps = 3;
int d_vector_length = correlation_sizes[2]; //max correlation size to allocate all the necessary memory
float* d_local_code_shift_chips;
//allocate host memory
@ -85,12 +87,12 @@ TEST(CpuMulticorrelatorTest, MeasureExecutionTime)
d_n_correlator_taps = 3; // Early, Prompt, and Late
d_correlator_outs = static_cast<gr_complex*>(volk_gnsssdr_malloc(d_n_correlator_taps*sizeof(gr_complex), volk_gnsssdr_get_alignment()));
for (int n = 0; n < d_n_correlator_taps; n++)
{
d_correlator_outs[n] = gr_complex(0,0);
}
{
d_correlator_outs[n] = gr_complex(0,0);
}
d_local_code_shift_chips = static_cast<float*>(volk_gnsssdr_malloc(d_n_correlator_taps*sizeof(float), volk_gnsssdr_get_alignment()));
// Set TAPs delay values [chips]
float d_early_late_spc_chips=0.5;
float d_early_late_spc_chips = 0.5;
d_local_code_shift_chips[0] = - d_early_late_spc_chips;
d_local_code_shift_chips[1] = 0.0;
d_local_code_shift_chips[2] = d_early_late_spc_chips;
@ -104,65 +106,65 @@ TEST(CpuMulticorrelatorTest, MeasureExecutionTime)
std::random_device r;
std::default_random_engine e1(r());
std::uniform_real_distribution<float> uniform_dist(0, 1);
for (int n=0;n<2*d_vector_length;n++)
{
in_cpu[n]=std::complex<float>(uniform_dist(e1), uniform_dist(e1));
}
for (int n = 0; n < 2 * d_vector_length; n++)
{
in_cpu[n] = std::complex<float>(uniform_dist(e1), uniform_dist(e1));
}
for (int n=0;n<max_threads;n++)
{
correlator_pool[n] = new cpu_multicorrelator();
correlator_pool[n]->init(d_vector_length, d_n_correlator_taps);
correlator_pool[n]->set_input_output_vectors(d_correlator_outs, in_cpu);
correlator_pool[n]->set_local_code_and_taps(static_cast<int>(GPS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips);
}
for (int n = 0; n < max_threads; n++)
{
correlator_pool[n] = new cpu_multicorrelator();
correlator_pool[n]->init(d_vector_length, d_n_correlator_taps);
correlator_pool[n]->set_input_output_vectors(d_correlator_outs, in_cpu);
correlator_pool[n]->set_local_code_and_taps(static_cast<int>(GPS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips);
}
float d_rem_carrier_phase_rad=0.0;
float d_carrier_phase_step_rad=0.1;
float d_code_phase_step_chips=0.3;
float d_rem_code_phase_chips=0.4;
float d_rem_carrier_phase_rad = 0.0;
float d_carrier_phase_step_rad = 0.1;
float d_code_phase_step_chips = 0.3;
float d_rem_code_phase_chips = 0.4;
EXPECT_NO_THROW(
for(int correlation_sizes_idx = 0; correlation_sizes_idx < 3; correlation_sizes_idx++)
{
for(int current_max_threads=1; current_max_threads<(max_threads+1); current_max_threads++)
{
std::cout<<"Running "<<current_max_threads<<" concurrent correlators"<<std::endl;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
//create the concurrent correlator threads
for (int current_thread=0;current_thread<current_max_threads;current_thread++)
for(int correlation_sizes_idx = 0; correlation_sizes_idx < 3; correlation_sizes_idx++)
{
thread_pool.push_back(std::thread(run_correlator_cpu,
correlator_pool[current_thread],
d_rem_carrier_phase_rad,
d_carrier_phase_step_rad,
d_code_phase_step_chips,
d_rem_code_phase_chips,
correlation_sizes[correlation_sizes_idx]));
}
//wait the threads to finish they work and destroy the thread objects
for(auto &t : thread_pool){
t.join();
}
thread_pool.clear();
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
execution_times[correlation_sizes_idx] = static_cast<double>(end - begin) / (1000000.0 * static_cast<double>(FLAGS_cpu_multicorrelator_iterations_test));
std::cout << "CPU Multicorrelator execution time for length=" << correlation_sizes[correlation_sizes_idx] << " : " << execution_times[correlation_sizes_idx] << " [s]" << std::endl;
for(int current_max_threads = 1; current_max_threads < (max_threads+1); current_max_threads++)
{
std::cout << "Running " << current_max_threads << " concurrent correlators" << std::endl;
start = std::chrono::system_clock::now();
//create the concurrent correlator threads
for (int current_thread = 0; current_thread < current_max_threads; current_thread++)
{
thread_pool.push_back(std::thread(run_correlator_cpu,
correlator_pool[current_thread],
d_rem_carrier_phase_rad,
d_carrier_phase_step_rad,
d_code_phase_step_chips,
d_rem_code_phase_chips,
correlation_sizes[correlation_sizes_idx]));
}
//wait the threads to finish they work and destroy the thread objects
for(auto &t : thread_pool)
{
t.join();
}
thread_pool.clear();
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
execution_times[correlation_sizes_idx] = elapsed_seconds.count() / static_cast<double>(FLAGS_cpu_multicorrelator_iterations_test);
std::cout << "CPU Multicorrelator execution time for length=" << correlation_sizes[correlation_sizes_idx]
<< " : " << execution_times[correlation_sizes_idx] << " [s]" << std::endl;
}
}
}
}
);
volk_gnsssdr_free(d_local_code_shift_chips);
volk_gnsssdr_free(d_correlator_outs);
volk_gnsssdr_free(d_ca_code);
volk_gnsssdr_free(in_cpu);
for (int n=0;n<max_threads;n++)
{
correlator_pool[n]->free();
}
for (int n = 0; n< max_threads; n++)
{
correlator_pool[n]->free();
}
}

View File

@ -31,7 +31,7 @@
*/
#include <ctime>
#include <chrono>
#include <iostream>
#include <gnuradio/top_block.h>
#include <gnuradio/blocks/file_source.h>
@ -112,9 +112,8 @@ TEST_F(GalileoE1DllPllVemlTrackingInternalTest, ConnectAndRun)
{
int fs_in = 8000000;
int nsamples = 40000000;
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
init();
queue = gr::msg_queue::make(0);
top_block = gr::make_top_block("Tracking test");
@ -145,23 +144,21 @@ TEST_F(GalileoE1DllPllVemlTrackingInternalTest, ConnectAndRun)
tracking->start_tracking();
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec *1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); //Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec *1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
std::cout << "Processed " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}
TEST_F(GalileoE1DllPllVemlTrackingInternalTest, ValidationOfResults)
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
// int num_samples = 40000000; // 4 Msps
// unsigned int skiphead_sps = 24000000; // 4 Msps
int num_samples = 80000000; // 8 Msps
@ -209,12 +206,11 @@ TEST_F(GalileoE1DllPllVemlTrackingInternalTest, ValidationOfResults)
tracking->start_tracking();
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec *1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec *1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
std::cout << "Tracked " << num_samples << " samples in " << (end - begin) << " microseconds" << std::endl;
std::cout << "Tracked " << num_samples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}

View File

@ -31,7 +31,7 @@
*/
#include <ctime>
#include <chrono>
#include <iostream>
#include <gnuradio/top_block.h>
#include <gnuradio/blocks/file_source.h>
@ -101,9 +101,8 @@ void GalileoE5aTrackingTest::init()
TEST_F(GalileoE5aTrackingTest, ValidationOfResults)
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
int fs_in = 32000000;
int nsamples = 32000000*5;
init();
@ -146,13 +145,12 @@ TEST_F(GalileoE5aTrackingTest, ValidationOfResults)
tracking->start_tracking();
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec *1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec *1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
std::cout << "Tracked " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
std::cout << "Tracked " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}

View File

@ -31,7 +31,7 @@
*/
#include <ctime>
#include <chrono>
#include <iostream>
#include <unistd.h>
#include <armadillo>

View File

@ -31,13 +31,12 @@
* -------------------------------------------------------------------------
*/
#include <ctime>
#include <chrono>
#include <fcntl.h>
#include <iostream>
#include <unistd.h>
#include <armadillo>
#include <boost/thread.hpp>// to test the FPGA we have to create a simultaneous task to send the samples using the DMA and stop the test
#include <boost/chrono.hpp> // temporary for debugging
#include <stdio.h>// FPGA read input file
#include <gnuradio/top_block.h>
#include <gnuradio/blocks/file_source.h>
@ -61,17 +60,17 @@
#include "signal_generator_flags.h"
#include "interleaved_byte_to_complex_short.h"
#define DMA_TRACK_TRANSFER_SIZE 2046 // DMA transfer size for tracking
#define MIN_SAMPLES_REMAINING 20000 // number of remaining samples in the DMA that causes the CPU to stop the flowgraph (it has to be a bit alrger than 2x max packet size)
#define FIVE_SECONDS 5000000 // five seconds in microseconds
#define DMA_TRACK_TRANSFER_SIZE 2046 // DMA transfer size for tracking
#define MIN_SAMPLES_REMAINING 20000 // number of remaining samples in the DMA that causes the CPU to stop the flowgraph (it has to be a bit alrger than 2x max packet size)
#define FIVE_SECONDS 5000000 // five seconds in microseconds
void send_tracking_gps_input_samples(FILE *rx_signal_file,
int num_remaining_samples, gr::top_block_sptr top_block)
{
int num_samples_transferred = 0; // number of samples that have been transferred to the DMA so far
int num_samples_transferred = 0; // number of samples that have been transferred to the DMA so far
static int flowgraph_stopped = 0; // flag to indicate if the flowgraph is stopped already
char *buffer_DMA; // temporary buffer to store the samples to be sent to the DMA
int dma_descr; // DMA descriptor
int dma_descr; // DMA descriptor
dma_descr = open("/dev/loop_tx", O_WRONLY);
if (dma_descr < 0)
{
@ -87,7 +86,6 @@ void send_tracking_gps_input_samples(FILE *rx_signal_file,
while (num_remaining_samples > 0)
{
if (num_remaining_samples < MIN_SAMPLES_REMAINING)
{
if (flowgraph_stopped == 0)
@ -100,24 +98,18 @@ void send_tracking_gps_input_samples(FILE *rx_signal_file,
if (num_remaining_samples > DMA_TRACK_TRANSFER_SIZE)
{
fread(buffer_DMA, DMA_TRACK_TRANSFER_SIZE, 1,
rx_signal_file);
fread(buffer_DMA, DMA_TRACK_TRANSFER_SIZE, 1,rx_signal_file);
assert(
DMA_TRACK_TRANSFER_SIZE == write(dma_descr, &buffer_DMA[0], DMA_TRACK_TRANSFER_SIZE));
num_remaining_samples = num_remaining_samples
- DMA_TRACK_TRANSFER_SIZE;
num_samples_transferred = num_samples_transferred
+ DMA_TRACK_TRANSFER_SIZE;
assert(DMA_TRACK_TRANSFER_SIZE == write(dma_descr, &buffer_DMA[0], DMA_TRACK_TRANSFER_SIZE));
num_remaining_samples = num_remaining_samples - DMA_TRACK_TRANSFER_SIZE;
num_samples_transferred = num_samples_transferred + DMA_TRACK_TRANSFER_SIZE;
}
else
{
fread(buffer_DMA, num_remaining_samples, 1, rx_signal_file);
assert(
num_remaining_samples == write(dma_descr, &buffer_DMA[0], num_remaining_samples));
num_samples_transferred = num_samples_transferred
+ num_remaining_samples;
assert(num_remaining_samples == write(dma_descr, &buffer_DMA[0], num_remaining_samples));
num_samples_transferred = num_samples_transferred + num_remaining_samples;
num_remaining_samples = 0;
}
}
@ -126,6 +118,7 @@ void send_tracking_gps_input_samples(FILE *rx_signal_file,
close(dma_descr);
}
// thread that sends the samples to the FPGA
void thread(gr::top_block_sptr top_block, const char * file_name)
{
@ -151,6 +144,7 @@ void thread(gr::top_block_sptr top_block, const char * file_name)
fclose(rx_signal_file);
}
// ######## GNURADIO BLOCK MESSAGE RECEVER #########
class GpsL1CADllPllTrackingTestFpga_msg_rx;
@ -158,6 +152,7 @@ typedef boost::shared_ptr<GpsL1CADllPllTrackingTestFpga_msg_rx> GpsL1CADllPllTra
GpsL1CADllPllTrackingTestFpga_msg_rx_sptr GpsL1CADllPllTrackingTestFpga_msg_rx_make();
class GpsL1CADllPllTrackingTestFpga_msg_rx : public gr::block
{
private:
@ -170,12 +165,14 @@ public:
~GpsL1CADllPllTrackingTestFpga_msg_rx(); //!< Default destructor
};
GpsL1CADllPllTrackingTestFpga_msg_rx_sptr GpsL1CADllPllTrackingTestFpga_msg_rx_make()
{
return GpsL1CADllPllTrackingTestFpga_msg_rx_sptr(
new GpsL1CADllPllTrackingTestFpga_msg_rx());
}
void GpsL1CADllPllTrackingTestFpga_msg_rx::msg_handler_events(pmt::pmt_t msg)
{
try
@ -190,6 +187,7 @@ void GpsL1CADllPllTrackingTestFpga_msg_rx::msg_handler_events(pmt::pmt_t msg)
}
}
GpsL1CADllPllTrackingTestFpga_msg_rx::GpsL1CADllPllTrackingTestFpga_msg_rx() :
gr::block("GpsL1CADllPllTrackingTestFpga_msg_rx",
gr::io_signature::make(0, 0, 0),
@ -203,9 +201,10 @@ GpsL1CADllPllTrackingTestFpga_msg_rx::GpsL1CADllPllTrackingTestFpga_msg_rx() :
rx_message = 0;
}
GpsL1CADllPllTrackingTestFpga_msg_rx::~GpsL1CADllPllTrackingTestFpga_msg_rx()
{
}
{}
// ###########################################################
@ -254,6 +253,7 @@ public:
size_t item_size;
};
int GpsL1CADllPllTrackingTestFpga::configure_generator()
{
// Configure signal generator
@ -267,22 +267,20 @@ int GpsL1CADllPllTrackingTestFpga::configure_generator()
}
else
{
p2 = std::string("-obs_pos_file=")
+ std::string(FLAGS_dynamic_position);
p2 = std::string("-obs_pos_file=") + std::string(FLAGS_dynamic_position);
}
p3 = std::string("-rinex_obs_file=") + FLAGS_filename_rinex_obs; // RINEX 2.10 observation file output
p4 = std::string("-sig_out_file=") + FLAGS_filename_raw_data; // Baseband signal output file. Will be stored in int8_t IQ multiplexed samples
p5 = std::string("-sampling_freq=")
+ std::to_string(baseband_sampling_freq); //Baseband sampling frequency [MSps]
p5 = std::string("-sampling_freq=") + std::to_string(baseband_sampling_freq); //Baseband sampling frequency [MSps]
return 0;
}
int GpsL1CADllPllTrackingTestFpga::generate_signal()
{
int child_status;
char * const parmList[] =
{ &generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0],
char * const parmList[] = { &generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0],
&p4[0], &p5[0], NULL };
int pid;
@ -291,18 +289,17 @@ int GpsL1CADllPllTrackingTestFpga::generate_signal()
else if (pid == 0)
{
execv(&generator_binary[0], parmList);
std::cout << "Return not expected. Must be an execv err."
<< std::endl;
std::cout << "Return not expected. Must be an execv err." << std::endl;
std::terminate();
}
waitpid(pid, &child_status, 0);
std::cout << "Signal and Observables RINEX and RAW files created."
<< std::endl;
std::cout << "Signal and Observables RINEX and RAW files created." << std::endl;
return 0;
}
void GpsL1CADllPllTrackingTestFpga::configure_receiver()
{
gnss_synchro.Channel_ID = 0;
@ -327,6 +324,7 @@ void GpsL1CADllPllTrackingTestFpga::configure_receiver()
config->set_property("Tracking_1C.device_base", "1");
}
void GpsL1CADllPllTrackingTestFpga::check_results_doppler(arma::vec & true_time_s,
arma::vec & true_value, arma::vec & meas_time_s, arma::vec & meas_value)
{
@ -358,12 +356,13 @@ void GpsL1CADllPllTrackingTestFpga::check_results_doppler(arma::vec & true_time_
//5. report
std::streamsize ss = std::cout.precision();
std::cout << std::setprecision(10) << "TRK Doppler RMSE=" << rmse
<< ", mean=" << error_mean << ", stdev=" << sqrt(error_var)
<< " (max,min)=" << max_error << "," << min_error << " [Hz]"
<< std::endl;
<< ", mean=" << error_mean << ", stdev=" << sqrt(error_var)
<< " (max,min)=" << max_error << "," << min_error << " [Hz]"
<< std::endl;
std::cout.precision (ss);
}
void GpsL1CADllPllTrackingTestFpga::check_results_acc_carrier_phase(
arma::vec & true_time_s, arma::vec & true_value, arma::vec & meas_time_s,
arma::vec & meas_value)
@ -396,12 +395,13 @@ void GpsL1CADllPllTrackingTestFpga::check_results_acc_carrier_phase(
//5. report
std::streamsize ss = std::cout.precision();
std::cout << std::setprecision(10) << "TRK acc carrier phase RMSE=" << rmse
<< ", mean=" << error_mean << ", stdev=" << sqrt(error_var)
<< " (max,min)=" << max_error << "," << min_error << " [Hz]"
<< std::endl;
<< ", mean=" << error_mean << ", stdev=" << sqrt(error_var)
<< " (max,min)=" << max_error << "," << min_error << " [Hz]"
<< std::endl;
std::cout.precision (ss);
}
void GpsL1CADllPllTrackingTestFpga::check_results_codephase(
arma::vec & true_time_s, arma::vec & true_value, arma::vec & meas_time_s,
arma::vec & meas_value)
@ -433,12 +433,13 @@ void GpsL1CADllPllTrackingTestFpga::check_results_codephase(
//5. report
std::streamsize ss = std::cout.precision();
std::cout << std::setprecision(10) << "TRK code phase RMSE=" << rmse
<< ", mean=" << error_mean << ", stdev=" << sqrt(error_var)
<< " (max,min)=" << max_error << "," << min_error << " [Chips]"
<< std::endl;
<< ", mean=" << error_mean << ", stdev=" << sqrt(error_var)
<< " (max,min)=" << max_error << "," << min_error << " [Chips]"
<< std::endl;
std::cout.precision (ss);
}
TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga)
{
configure_generator();
@ -446,9 +447,8 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga)
// DO not generate signal raw signal samples and observations RINEX file by default
//generate_signal();
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
configure_receiver();
@ -468,12 +468,9 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga)
})<< "Failure opening true observables file" << std::endl;
top_block = gr::make_top_block("Tracking test");
std::shared_ptr<GpsL1CaDllPllCAidTrackingFpga> tracking = std::make_shared
< GpsL1CaDllPllCAidTrackingFpga
> (config.get(), "Tracking_1C", 1, 1);
std::shared_ptr<GpsL1CaDllPllCAidTrackingFpga> tracking = std::make_shared<GpsL1CaDllPllCAidTrackingFpga> (config.get(), "Tracking_1C", 1, 1);
boost::shared_ptr<GpsL1CADllPllTrackingTestFpga_msg_rx> msg_rx =
GpsL1CADllPllTrackingTestFpga_msg_rx_make();
boost::shared_ptr<GpsL1CADllPllTrackingTestFpga_msg_rx> msg_rx = GpsL1CADllPllTrackingTestFpga_msg_rx_make();
// load acquisition data based on the first epoch of the true observations
ASSERT_NO_THROW(
@ -488,8 +485,9 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga)
true_obs_data.restart();
std::cout << "Initial Doppler [Hz]=" << true_obs_data.doppler_l1_hz
<< " Initial code delay [Chips]=" << true_obs_data.prn_delay_chips
<< std::endl;
<< " Initial code delay [Chips]=" << true_obs_data.prn_delay_chips
<< std::endl;
gnss_synchro.Acq_delay_samples = (GPS_L1_CA_CODE_LENGTH_CHIPS
- true_obs_data.prn_delay_chips / GPS_L1_CA_CODE_LENGTH_CHIPS)
* baseband_sampling_freq * GPS_L1_CA_CODE_PERIOD;
@ -530,12 +528,11 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga)
EXPECT_NO_THROW(
{
gettimeofday(&tv, NULL);
begin = tv.tv_sec * 1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
tracking->reset();// unlock the channel
gettimeofday(&tv, NULL);
end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
})<< "Failure running the top_block." << std::endl;
// wait until child thread terminates
@ -556,8 +553,7 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga)
while (true_obs_data.read_binary_obs())
{
true_timestamp_s(epoch_counter) = true_obs_data.signal_timestamp_s;
true_acc_carrier_phase_cycles(epoch_counter) =
true_obs_data.acc_carrier_phase_cycles;
true_acc_carrier_phase_cycles(epoch_counter) = true_obs_data.acc_carrier_phase_cycles;
true_Doppler_Hz(epoch_counter) = true_obs_data.doppler_l1_hz;
true_prn_delay_chips(epoch_counter) = true_obs_data.prn_delay_chips;
true_tow_s(epoch_counter) = true_obs_data.tow;
@ -585,21 +581,14 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga)
epoch_counter = 0;
while (trk_dump.read_binary_obs())
{
trk_timestamp_s(epoch_counter) =
static_cast<double>(trk_dump.PRN_start_sample_count)
trk_timestamp_s(epoch_counter) = static_cast<double>(trk_dump.PRN_start_sample_count)
/ static_cast<double>(baseband_sampling_freq);
trk_acc_carrier_phase_cycles(epoch_counter) =
trk_dump.acc_carrier_phase_rad / GPS_TWO_PI;
trk_acc_carrier_phase_cycles(epoch_counter) = trk_dump.acc_carrier_phase_rad / GPS_TWO_PI;
trk_Doppler_Hz(epoch_counter) = trk_dump.carrier_doppler_hz;
double delay_chips =
GPS_L1_CA_CODE_LENGTH_CHIPS
- GPS_L1_CA_CODE_LENGTH_CHIPS
* (fmod(
(static_cast<double>(trk_dump.PRN_start_sample_count)
+ trk_dump.aux1)
/ static_cast<double>(baseband_sampling_freq),
1.0e-3) / 1.0e-3);
double delay_chips = GPS_L1_CA_CODE_LENGTH_CHIPS - GPS_L1_CA_CODE_LENGTH_CHIPS
* (fmod( (static_cast<double>(trk_dump.PRN_start_sample_count) + trk_dump.aux1)
/ static_cast<double>(baseband_sampling_freq), 1.0e-3) / 1.0e-3);
trk_prn_delay_chips(epoch_counter) = delay_chips;
epoch_counter++;
@ -607,27 +596,18 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga)
//Align initial measurements and cut the tracking pull-in transitory
double pull_in_offset_s = 1.0;
arma::uvec initial_meas_point = arma::find(
trk_timestamp_s >= (true_timestamp_s(0) + pull_in_offset_s), 1,
"first");
arma::uvec initial_meas_point = arma::find( trk_timestamp_s >= (true_timestamp_s(0) + pull_in_offset_s), 1, "first");
trk_timestamp_s = trk_timestamp_s.subvec(initial_meas_point(0),
trk_timestamp_s.size() - 1);
trk_acc_carrier_phase_cycles = trk_acc_carrier_phase_cycles.subvec(
initial_meas_point(0), trk_acc_carrier_phase_cycles.size() - 1);
trk_Doppler_Hz = trk_Doppler_Hz.subvec(initial_meas_point(0),
trk_Doppler_Hz.size() - 1);
trk_prn_delay_chips = trk_prn_delay_chips.subvec(initial_meas_point(0),
trk_prn_delay_chips.size() - 1);
trk_timestamp_s = trk_timestamp_s.subvec(initial_meas_point(0), trk_timestamp_s.size() - 1);
trk_acc_carrier_phase_cycles = trk_acc_carrier_phase_cycles.subvec(initial_meas_point(0), trk_acc_carrier_phase_cycles.size() - 1);
trk_Doppler_Hz = trk_Doppler_Hz.subvec(initial_meas_point(0), trk_Doppler_Hz.size() - 1);
trk_prn_delay_chips = trk_prn_delay_chips.subvec(initial_meas_point(0), trk_prn_delay_chips.size() - 1);
check_results_doppler(true_timestamp_s, true_Doppler_Hz, trk_timestamp_s,
trk_Doppler_Hz);
check_results_codephase(true_timestamp_s, true_prn_delay_chips,
trk_timestamp_s, trk_prn_delay_chips);
check_results_doppler(true_timestamp_s, true_Doppler_Hz, trk_timestamp_s, trk_Doppler_Hz);
check_results_codephase(true_timestamp_s, true_prn_delay_chips, trk_timestamp_s, trk_prn_delay_chips);
check_results_acc_carrier_phase(true_timestamp_s,
true_acc_carrier_phase_cycles, trk_timestamp_s,
trk_acc_carrier_phase_cycles);
std::cout << "Signal tracking completed in " << (end - begin)
<< " microseconds" << std::endl;
std::cout << "Signal tracking completed in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}

View File

@ -31,7 +31,7 @@
*/
#include <ctime>
#include <chrono>
#include <iostream>
#include <gnuradio/top_block.h>
#include <gnuradio/blocks/file_source.h>
@ -148,11 +148,11 @@ void GpsL2MDllPllTrackingTest::init()
config->set_property("Tracking_2S.dll_bw_hz", "0.5");
}
TEST_F(GpsL2MDllPllTrackingTest, ValidationOfResults)
{
struct timeval tv;
long long int begin = 0;
long long int end = 0;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
int fs_in = 5000000;
int nsamples = fs_in*9;
@ -195,14 +195,13 @@ TEST_F(GpsL2MDllPllTrackingTest, ValidationOfResults)
tracking->start_tracking();
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec *1000000 + tv.tv_usec;
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec *1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block." << std::endl;
// TODO: Verify tracking results
std::cout << "Tracked " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
std::cout << "Tracked " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
}

View File

@ -29,7 +29,7 @@
* -------------------------------------------------------------------------
*/
#include <ctime>
#include <chrono>
#include <complex>
#include <thread>
#include <cuda.h>
@ -52,20 +52,22 @@ void run_correlator_gpu(cuda_multicorrelator* correlator,
int d_n_correlator_taps)
{
for(int k = 0; k < FLAGS_cpu_multicorrelator_iterations_test; k++)
{
correlator->Carrier_wipeoff_multicorrelator_resampler_cuda(d_rem_carrier_phase_rad,
d_carrier_phase_step_rad,
d_code_phase_step_chips,
d_rem_code_phase_chips,
correlation_size,
d_n_correlator_taps);
}
{
correlator->Carrier_wipeoff_multicorrelator_resampler_cuda(d_rem_carrier_phase_rad,
d_carrier_phase_step_rad,
d_code_phase_step_chips,
d_rem_code_phase_chips,
correlation_size,
d_n_correlator_taps);
}
}
TEST(GpuMulticorrelatorTest, MeasureExecutionTime)
{
struct timeval tv;
int max_threads=FLAGS_gpu_multicorrelator_max_threads_test;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
int max_threads = FLAGS_gpu_multicorrelator_max_threads_test;
std::vector<std::thread> thread_pool;
cuda_multicorrelator* correlator_pool[max_threads];
unsigned int correlation_sizes [3] = { 2048, 4096, 8192};
@ -75,8 +77,8 @@ TEST(GpuMulticorrelatorTest, MeasureExecutionTime)
gr_complex* in_gpu;
gr_complex* d_correlator_outs;
int d_n_correlator_taps=3;
int d_vector_length=correlation_sizes[2]; //max correlation size to allocate all the necessary memory
int d_n_correlator_taps = 3;
int d_vector_length = correlation_sizes[2]; //max correlation size to allocate all the necessary memory
float* d_local_code_shift_chips;
// Set GPU flags
cudaSetDeviceFlags(cudaDeviceMapHost);
@ -96,61 +98,60 @@ TEST(GpuMulticorrelatorTest, MeasureExecutionTime)
// generate local reference (1 sample per chip)
gps_l1_ca_code_gen_complex(d_ca_code, 1, 0);
// generate inut signal
for (int n=0;n<2*d_vector_length;n++)
{
in_gpu[n]=std::complex<float>(static_cast <float> (rand())/static_cast<float>(RAND_MAX),static_cast <float> (rand())/static_cast<float>(RAND_MAX));
}
for (int n = 0; n < 2 * d_vector_length; n++)
{
in_gpu[n] = std::complex<float>(static_cast<float>(rand()) / static_cast<float>(RAND_MAX), static_cast<float>(rand()) / static_cast<float>(RAND_MAX));
}
// Set TAPs delay values [chips]
float d_early_late_spc_chips=0.5;
float d_early_late_spc_chips = 0.5;
d_local_code_shift_chips[0] = - d_early_late_spc_chips;
d_local_code_shift_chips[1] = 0.0;
d_local_code_shift_chips[2] = d_early_late_spc_chips;
for (int n=0;n<max_threads;n++)
{
correlator_pool[n] = new cuda_multicorrelator();
correlator_pool[n]->init_cuda_integrated_resampler(d_vector_length, GPS_L1_CA_CODE_LENGTH_CHIPS, d_n_correlator_taps);
correlator_pool[n]->set_input_output_vectors(d_correlator_outs, in_gpu);
}
for (int n = 0; n < max_threads; n++)
{
correlator_pool[n] = new cuda_multicorrelator();
correlator_pool[n]->init_cuda_integrated_resampler(d_vector_length, GPS_L1_CA_CODE_LENGTH_CHIPS, d_n_correlator_taps);
correlator_pool[n]->set_input_output_vectors(d_correlator_outs, in_gpu);
}
float d_rem_carrier_phase_rad=0.0;
float d_carrier_phase_step_rad=0.1;
float d_code_phase_step_chips=0.3;
float d_rem_code_phase_chips=0.4;
float d_rem_carrier_phase_rad = 0.0;
float d_carrier_phase_step_rad = 0.1;
float d_code_phase_step_chips = 0.3;
float d_rem_code_phase_chips = 0.4;
EXPECT_NO_THROW(
for(int correlation_sizes_idx = 0; correlation_sizes_idx < 3; correlation_sizes_idx++)
{
for(int current_max_threads=1; current_max_threads<(max_threads+1); current_max_threads++)
for(int correlation_sizes_idx = 0; correlation_sizes_idx < 3; correlation_sizes_idx++)
{
std::cout<<"Running "<<current_max_threads<<" concurrent correlators"<<std::endl;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
//create the concurrent correlator threads
for (int current_thread=0;current_thread<current_max_threads;current_thread++)
{
//cudaProfilerStart();
thread_pool.push_back(std::thread(run_correlator_gpu,
correlator_pool[current_thread],
d_rem_carrier_phase_rad,
d_carrier_phase_step_rad,
d_code_phase_step_chips,
d_rem_code_phase_chips,
correlation_sizes[correlation_sizes_idx],
d_n_correlator_taps));
//cudaProfilerStop();
}
//wait the threads to finish they work and destroy the thread objects
for(auto &t : thread_pool){
t.join();
}
thread_pool.clear();
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
execution_times[correlation_sizes_idx] = static_cast<double>(end - begin) / (1000000.0 * static_cast<double>(FLAGS_gpu_multicorrelator_iterations_test));
std::cout << "GPU Multicorrelator execution time for length=" << correlation_sizes[correlation_sizes_idx] << " : " << execution_times[correlation_sizes_idx] << " [s]" << std::endl;
for(int current_max_threads = 1; current_max_threads < (max_threads+1); current_max_threads++)
{
std::cout << "Running " << current_max_threads << " concurrent correlators" << std::endl;
start = std::chrono::system_clock::now();
//create the concurrent correlator threads
for (int current_thread = 0; current_thread < current_max_threads; current_thread++)
{
//cudaProfilerStart();
thread_pool.push_back(std::thread(run_correlator_gpu,
correlator_pool[current_thread],
d_rem_carrier_phase_rad,
d_carrier_phase_step_rad,
d_code_phase_step_chips,
d_rem_code_phase_chips,
correlation_sizes[correlation_sizes_idx],
d_n_correlator_taps));
//cudaProfilerStop();
}
//wait the threads to finish they work and destroy the thread objects
for(auto &t : thread_pool)
{
t.join();
}
thread_pool.clear();
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
execution_times[correlation_sizes_idx] = elapsed_seconds.count() / static_cast<double>(FLAGS_gpu_multicorrelator_iterations_test);
std::cout << "GPU Multicorrelator execution time for length=" << correlation_sizes[correlation_sizes_idx] << " : " << execution_times[correlation_sizes_idx] << " [s]" << std::endl;
}
}
}
);
cudaFreeHost(in_gpu);
@ -158,11 +159,8 @@ TEST(GpuMulticorrelatorTest, MeasureExecutionTime)
cudaFreeHost(d_local_code_shift_chips);
cudaFreeHost(d_ca_code);
for (int n=0;n<max_threads;n++)
{
correlator_pool[n]->free_cuda();
}
for (int n = 0; n < max_threads; n++)
{
correlator_pool[n]->free_cuda();
}
}

View File

@ -31,7 +31,6 @@
#include "front_end_cal.h"
#include <cmath>
#include <ctime>
#include <memory>
#include <exception>
#include <boost/filesystem.hpp>

View File

@ -33,7 +33,8 @@
#endif
#include <stdlib.h>
#include <ctime>
#include <chrono>
#include <ctime> // for ctime
#include <exception>
#include <memory>
#include <queue>
@ -410,9 +411,9 @@ int main(int argc, char** argv)
boost::thread ch_thread;
// record startup time
struct timeval tv;
gettimeofday(&tv, NULL);
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
start = std::chrono::system_clock::now();
bool start_msg = true;
@ -469,10 +470,10 @@ int main(int argc, char** argv)
std::cout << "]" << std::endl;
// report the elapsed time
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
std::cout << "Total signal acquisition run time "
<< ((double)(end - begin))/1000000.0
<< elapsed_seconds.count()
<< " [seconds]" << std::endl;
//6. find TOW from SUPL assistance