1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-10-31 15:23:04 +00:00

Fixes compilation issues on Mac OS X. Now it builds successfully against gnuradio installed by Macports and using gcc 4.8. Upgrade version of Gtest. Some fixes and updates in documentation and code cleaning.

git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@423 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
Carles Fernandez
2013-10-18 18:26:06 +00:00
parent 806af3e98f
commit 2972272b3e
23 changed files with 12691 additions and 387 deletions

View File

@@ -56,11 +56,19 @@ gps_l1_ca_make_pvt_cc(unsigned int nchannels, boost::shared_ptr<gr::msg_queue> q
}
gps_l1_ca_pvt_cc::gps_l1_ca_pvt_cc(unsigned int nchannels, boost::shared_ptr<gr::msg_queue> queue, bool dump, std::string dump_filename, int averaging_depth, bool flag_averaging, int output_rate_ms, int display_rate_ms, bool flag_nmea_tty_port, std::string nmea_dump_filename, std::string nmea_dump_devname) :
gr::block("gps_l1_ca_pvt_cc", gr::io_signature::make(nchannels, nchannels, sizeof(Gnss_Synchro)),
gr::io_signature::make(1, 1, sizeof(gr_complex)))
gps_l1_ca_pvt_cc::gps_l1_ca_pvt_cc(unsigned int nchannels,
boost::shared_ptr<gr::msg_queue> queue,
bool dump, std::string dump_filename,
int averaging_depth,
bool flag_averaging,
int output_rate_ms,
int display_rate_ms,
bool flag_nmea_tty_port,
std::string nmea_dump_filename,
std::string nmea_dump_devname) :
gr::block("gps_l1_ca_pvt_cc", gr::io_signature::make(nchannels, nchannels, sizeof(Gnss_Synchro)),
gr::io_signature::make(1, 1, sizeof(gr_complex)) )
{
d_output_rate_ms = output_rate_ms;
d_display_rate_ms = display_rate_ms;
d_queue = queue;
@@ -186,7 +194,7 @@ int gps_l1_ca_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_ite
if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.end())
{
rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second,d_rx_time);
rp->rinex_nav_header(rp->navFile,d_ls_pvt->gps_iono, d_ls_pvt->gps_utc_model);
rp->rinex_nav_header(rp->navFile, d_ls_pvt->gps_iono, d_ls_pvt->gps_utc_model);
b_rinex_header_writen = true; // do not write header anymore
}
}
@@ -194,10 +202,10 @@ int gps_l1_ca_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_ite
{
// Limit the RINEX navigation output rate to 1/6 seg
// Notice that d_sample_counter period is 1ms (for GPS correlators)
if ((d_sample_counter-d_last_sample_nav_output)>=6000)
if ((d_sample_counter - d_last_sample_nav_output) >= 6000)
{
rp->log_rinex_nav(rp->navFile, d_ls_pvt->gps_ephemeris_map);
d_last_sample_nav_output=d_sample_counter;
d_last_sample_nav_output = d_sample_counter;
}
std::map<int,Gps_Ephemeris>::iterator gps_ephemeris_iter;
gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.begin();
@@ -219,7 +227,7 @@ int gps_l1_ca_pvt_cc::general_work (int noutput_items, gr_vector_int &ninput_ite
std::cout << "Dilution of Precision at " << boost::posix_time::to_simple_string(d_ls_pvt->d_position_UTC_time)
<< " is HDOP = " << d_ls_pvt->d_HDOP << " VDOP = " <<
d_ls_pvt->d_VDOP <<" TDOP = " << d_ls_pvt->d_TDOP <<
" GDOP = " << d_ls_pvt->d_GDOP <<std::endl;
" GDOP = " << d_ls_pvt->d_GDOP << std::endl;
}
// MULTIPLEXED FILE RECORDING - Record results to file
if(d_dump == true)

View File

@@ -50,11 +50,17 @@ include_directories(
${GNURADIO_RUNTIME_INCLUDE_DIRS}
)
if(OPENCL_FOUND)
include_directories( ${OPENCL_INCLUDE_DIRS} )
set(OPT_LIBRARIES ${OPT_LIBRARIES} ${OPENCL_LIBRARIES})
if(OS_IS_MACOSX)
set(OPT_LIBRARIES ${OPT_LIBRARIES} "-framework OpenCL")
else(OS_IS_MACOSX)
set(OPT_LIBRARIES ${OPT_LIBRARIES} ${OPENCL_LIBRARIES})
endif(OS_IS_MACOSX)
endif(OPENCL_FOUND)
add_library(acq_gr_blocks ${ACQ_GR_BLOCKS_SOURCES})
target_link_libraries(acq_gr_blocks gnss_sp_libs gnss_system_parameters ${GNURADIO_RUNTIME_LIBRARIES} ${GNURADIO_FFT_LIBRARIES} ${VOLK_LIBRARIES} ${OPT_LIBRARIES})

View File

@@ -103,7 +103,7 @@ pcps_opencl_acquisition_cc::pcps_opencl_acquisition_cc(
d_well_count = 0;
d_doppler_max = doppler_max;
d_fft_size = d_sampled_ms * d_samples_per_ms;
d_fft_size_pow2 = pow(2,ceil(log2(2*d_fft_size)));
d_fft_size_pow2 = pow(2, ceil(log2(2*d_fft_size)));
d_mag = 0;
d_input_power = 0.0;
d_num_doppler_bins = 0;
@@ -235,7 +235,7 @@ int pcps_opencl_acquisition_cc::init_opencl_environment(std::string kernel_filen
(std::istreambuf_iterator<char>()));
kernel_file.close();
// std::cout << "Kernel code: \n" << kernel_code << std::endl;
// std::cout << "Kernel code: \n" << kernel_code << std::endl;
cl::Program::Sources sources;
@@ -308,22 +308,22 @@ void pcps_opencl_acquisition_cc::init()
d_cl_buffer_grid_doppler_wipeoffs = new cl::Buffer*[d_num_doppler_bins];
}
for (unsigned int doppler_index=0;doppler_index<d_num_doppler_bins;doppler_index++)
for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
{
if (posix_memalign((void**)&(d_grid_doppler_wipeoffs[doppler_index]), 16,
d_fft_size * sizeof(gr_complex)) == 0){};
int doppler=-(int)d_doppler_max+d_doppler_step*doppler_index;
int doppler= -(int)d_doppler_max + d_doppler_step*doppler_index;
complex_exp_gen_conj(d_grid_doppler_wipeoffs[doppler_index],
d_freq + doppler, d_fs_in, d_fft_size);
if (d_opencl == 0)
{
d_cl_buffer_grid_doppler_wipeoffs[doppler_index] =
new cl::Buffer(d_cl_context,CL_MEM_READ_WRITE,sizeof(gr_complex)*d_fft_size);
new cl::Buffer(d_cl_context, CL_MEM_READ_WRITE, sizeof(gr_complex)*d_fft_size);
d_cl_queue->enqueueWriteBuffer(*(d_cl_buffer_grid_doppler_wipeoffs[doppler_index]),
CL_TRUE,0,sizeof(gr_complex)*d_fft_size,
CL_TRUE, 0, sizeof(gr_complex)*d_fft_size,
d_grid_doppler_wipeoffs[doppler_index]);
}
}
@@ -331,8 +331,8 @@ void pcps_opencl_acquisition_cc::init()
// zero padding in buffer_1 (FFT input)
if (d_opencl == 0)
{
d_cl_queue->enqueueWriteBuffer(*d_cl_buffer_1,CL_TRUE,sizeof(gr_complex)*d_fft_size,
sizeof(gr_complex)*(d_fft_size_pow2-d_fft_size),d_zero_vector);
d_cl_queue->enqueueWriteBuffer(*d_cl_buffer_1, CL_TRUE, sizeof(gr_complex)*d_fft_size,
sizeof(gr_complex)*(d_fft_size_pow2 - d_fft_size), d_zero_vector);
}
}
@@ -340,14 +340,14 @@ void pcps_opencl_acquisition_cc::set_local_code(std::complex<float> * code)
{
if(d_opencl == 0)
{
d_cl_queue->enqueueWriteBuffer(*d_cl_buffer_2,CL_TRUE,0,
d_cl_queue->enqueueWriteBuffer(*d_cl_buffer_2, CL_TRUE, 0,
sizeof(gr_complex)*d_fft_size, code);
d_cl_queue->enqueueWriteBuffer(*d_cl_buffer_2,CL_TRUE,sizeof(gr_complex)*d_fft_size,
d_cl_queue->enqueueWriteBuffer(*d_cl_buffer_2, CL_TRUE, sizeof(gr_complex)*d_fft_size,
sizeof(gr_complex)*(d_fft_size_pow2 - 2*d_fft_size),
d_zero_vector);
d_cl_queue->enqueueWriteBuffer(*d_cl_buffer_2,CL_TRUE,sizeof(gr_complex)
d_cl_queue->enqueueWriteBuffer(*d_cl_buffer_2, CL_TRUE, sizeof(gr_complex)
*(d_fft_size_pow2 - d_fft_size),
sizeof(gr_complex)*d_fft_size, code);
@@ -356,10 +356,10 @@ void pcps_opencl_acquisition_cc::set_local_code(std::complex<float> * code)
0, NULL, NULL);
//Conjucate the local code
cl::Kernel kernel=cl::Kernel(d_cl_program,"conj_vector");
kernel.setArg(0,*d_cl_buffer_2); //input
kernel.setArg(1,*d_cl_buffer_fft_codes); //output
d_cl_queue->enqueueNDRangeKernel(kernel,cl::NullRange,cl::NDRange(d_fft_size_pow2),cl::NullRange);
cl::Kernel kernel = cl::Kernel(d_cl_program, "conj_vector");
kernel.setArg(0, *d_cl_buffer_2); //input
kernel.setArg(1, *d_cl_buffer_fft_codes); //output
d_cl_queue->enqueueNDRangeKernel(kernel, cl::NullRange, cl::NDRange(d_fft_size_pow2), cl::NullRange);
}
else
{
@@ -370,11 +370,11 @@ void pcps_opencl_acquisition_cc::set_local_code(std::complex<float> * code)
//Conjugate the local code
if (is_unaligned())
{
volk_32fc_conjugate_32fc_u(d_fft_codes,d_fft_if->get_outbuf(),d_fft_size);
volk_32fc_conjugate_32fc_u(d_fft_codes, d_fft_if->get_outbuf(), d_fft_size);
}
else
{
volk_32fc_conjugate_32fc_a(d_fft_codes,d_fft_if->get_outbuf(),d_fft_size);
volk_32fc_conjugate_32fc_a(d_fft_codes, d_fft_if->get_outbuf(), d_fft_size);
}
}
}
@@ -406,11 +406,11 @@ void pcps_opencl_acquisition_cc::acquisition_core_volk()
d_input_power /= (float)d_fft_size;
// 2- Doppler frequency search loop
for (unsigned int doppler_index=0;doppler_index<d_num_doppler_bins;doppler_index++)
for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
{
// doppler search steps
doppler=-(int)d_doppler_max+d_doppler_step*doppler_index;
doppler = -(int)d_doppler_max + d_doppler_step*doppler_index;
volk_32fc_x2_multiply_32fc_a(d_fft_if->get_inbuf(), in,
@@ -517,7 +517,7 @@ void pcps_opencl_acquisition_cc::acquisition_core_opencl()
d_mag = 0.0;
// write input vector in buffer of OpenCL device
d_cl_queue->enqueueWriteBuffer(*d_cl_buffer_in,CL_TRUE,0,sizeof(gr_complex)*d_fft_size,in);
d_cl_queue->enqueueWriteBuffer(*d_cl_buffer_in, CL_TRUE, 0, sizeof(gr_complex)*d_fft_size, in);
d_well_count++;
@@ -529,7 +529,7 @@ void pcps_opencl_acquisition_cc::acquisition_core_opencl()
// begin = tv.tv_sec *1e6 + tv.tv_usec;
DLOG(INFO) << "Channel: " << d_channel
<< " , doing acquisition of satellite: " << d_gnss_synchro->System << " "<< d_gnss_synchro->PRN
<< " , doing acquisition of satellite: " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN
<< " ,sample stamp: " << d_sample_counter << ", threshold: "
<< d_threshold << ", doppler_max: " << d_doppler_max
<< ", doppler_step: " << d_doppler_step;
@@ -542,17 +542,17 @@ void pcps_opencl_acquisition_cc::acquisition_core_opencl()
cl::Kernel kernel;
// 2- Doppler frequency search loop
for (unsigned int doppler_index=0;doppler_index<d_num_doppler_bins;doppler_index++)
for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
{
// doppler search steps
doppler=-(int)d_doppler_max+d_doppler_step*doppler_index;
doppler = -(int)d_doppler_max + d_doppler_step*doppler_index;
//Multiply input signal with doppler wipe-off
kernel = cl::Kernel(d_cl_program,"mult_vectors");
kernel.setArg(0,*d_cl_buffer_in); //input 1
kernel.setArg(1,*d_cl_buffer_grid_doppler_wipeoffs[doppler_index]); //input 2
kernel.setArg(2,*d_cl_buffer_1); //output
kernel = cl::Kernel(d_cl_program, "mult_vectors");
kernel.setArg(0, *d_cl_buffer_in); //input 1
kernel.setArg(1, *d_cl_buffer_grid_doppler_wipeoffs[doppler_index]); //input 2
kernel.setArg(2, *d_cl_buffer_1); //output
d_cl_queue->enqueueNDRangeKernel(kernel,cl::NullRange, cl::NDRange(d_fft_size),
cl::NullRange);
@@ -566,10 +566,10 @@ void pcps_opencl_acquisition_cc::acquisition_core_opencl()
// Multiply carrier wiped--off, Fourier transformed incoming signal
// with the local FFT'd code reference
kernel = cl::Kernel(d_cl_program,"mult_vectors");
kernel.setArg(0,*d_cl_buffer_2); //input 1
kernel.setArg(1,*d_cl_buffer_fft_codes); //input 2
kernel.setArg(2,*d_cl_buffer_2); //output
kernel = cl::Kernel(d_cl_program, "mult_vectors");
kernel.setArg(0, *d_cl_buffer_2); //input 1
kernel.setArg(1, *d_cl_buffer_fft_codes); //input 2
kernel.setArg(2, *d_cl_buffer_2); //output
d_cl_queue->enqueueNDRangeKernel(kernel, cl::NullRange, cl::NDRange(d_fft_size_pow2),
cl::NullRange);
@@ -579,9 +579,9 @@ void pcps_opencl_acquisition_cc::acquisition_core_opencl()
0, NULL, NULL);
// Compute magnitude
kernel = cl::Kernel(d_cl_program,"magnitude_squared");
kernel.setArg(0,*d_cl_buffer_2); //input 1
kernel.setArg(1,*d_cl_buffer_magnitude); //output
kernel = cl::Kernel(d_cl_program, "magnitude_squared");
kernel.setArg(0, *d_cl_buffer_2); //input 1
kernel.setArg(1, *d_cl_buffer_magnitude); //output
d_cl_queue->enqueueNDRangeKernel(kernel, cl::NullRange, cl::NDRange(d_fft_size),
cl::NullRange);
@@ -628,7 +628,7 @@ void pcps_opencl_acquisition_cc::acquisition_core_opencl()
std::streamsize n = 2 * sizeof(float) * (d_fft_size); // complex file write
filename.str("");
filename << "../data/test_statistics_" << d_gnss_synchro->System
<<"_" << d_gnss_synchro->Signal << "_sat_"
<< "_" << d_gnss_synchro->Signal << "_sat_"
<< d_gnss_synchro->PRN << "_doppler_" << doppler << ".dat";
d_dump_file.open(filename.str().c_str(), std::ios::out | std::ios::binary);
d_dump_file.write((char*)d_ifft->get_outbuf(), n); //write directly |abs(x)|^2 in this Doppler bin?

View File

@@ -63,8 +63,8 @@
#include "fft_internal.h"
#include "gnss_synchro.h"
#ifdef APPLE
#include <OpenCL/cl.hpp>
#ifdef __APPLE__
#include "cl.hpp"
#else
#include <CL/cl.hpp>
#endif

View File

@@ -16,17 +16,6 @@
# along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
#
#if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
#set(GNSS_SPLIBS_SOURCES
# galileo_e1_signal_processing.cc
# gnss_sdr_valve.cc
# gnss_signal_processing.cc
# gps_sdr_signal_processing.cc
# pass_through.cc
#)
#else(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
#endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(OPENCL_FOUND)
set(GNSS_SPLIBS_SOURCES
galileo_e1_signal_processing.cc
@@ -62,7 +51,11 @@ include_directories(
if(OPENCL_FOUND)
include_directories( ${OPENCL_INCLUDE_DIRS} )
set(OPT_LIBRARIES ${OPT_LIBRARIES} ${OPENCL_LIBRARIES})
if(OS_IS_MACOSX)
set(OPT_LIBRARIES ${OPT_LIBRARIES} "-framework OpenCL")
else(OS_IS_MACOSX)
set(OPT_LIBRARIES ${OPT_LIBRARIES} ${OPENCL_LIBRARIES})
endif(OS_IS_MACOSX)
endif(OPENCL_FOUND)
add_library(gnss_sp_libs ${GNSS_SPLIBS_SOURCES})

12305
src/algorithms/libs/cl.hpp Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -55,8 +55,8 @@ extern "C" {
#include <stdio.h>
#ifdef APPLE
#include <OpenCL/cl.h>
#ifdef __APPLE__
#include <OpenCL/opencl.h>
#else
#include <CL/cl.h>
#endif

View File

@@ -77,7 +77,6 @@ public:
gr::basic_block_sptr get_right_block();
private:
//gr_block_sptr sink_;
gr::blocks::null_sink::sptr sink_;
size_t item_size_;
std::string item_type_;

View File

@@ -157,7 +157,6 @@ FileSignalSource::FileSignalSource(ConfigurationInterface* configuration,
if (dump_)
{
//sink_ = gr_make_file_sink(item_size_, dump_filename_.c_str());
sink_ = gr::blocks::file_sink::make(item_size_, dump_filename_.c_str());
DLOG(INFO) << "file_sink(" << sink_->unique_id() << ")";
}
@@ -298,7 +297,6 @@ void FileSignalSource::disconnect(gr::top_block_sptr top_block)
gr::basic_block_sptr FileSignalSource::get_left_block()
{
LOG_AT_LEVEL(WARNING) << "Left block of a signal source should not be retrieved";
//return gr_block_sptr();
return gr::blocks::file_source::sptr();
}

View File

@@ -46,8 +46,9 @@
#include "gnss_synchro.h"
#ifndef _lrotl
#define _lrotl(X,N) ((X << N) ^ (X >> (32-N))) // Used in the parity check algorithm
#endif
using google::LogMessage;
/*!