diff --git a/CMakeLists.txt b/CMakeLists.txt
index 055afd415..7f509c1da 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -955,6 +955,20 @@ else(ENABLE_OSMOSDR)
message(STATUS "Enable it with 'cmake -DENABLE_OSMOSDR=ON ../' to add support for OsmoSDR and other front-ends (HackRF, bladeRF, Realtek's RTL2832U-based USB dongles, etc.)" )
endif(ENABLE_OSMOSDR)
+if($ENV{CUDA_GPU_ACCEL})
+ message(STATUS "CUDA_GPU_ACCEL environment variable found." )
+ set(ENABLE_CUDA ON)
+endif($ENV{CUDA_GPU_ACCEL})
+
+if(ENABLE_CUDA)
+ message(STATUS "NVIDIA CUDA GPU Acceleration will be enabled." )
+ message(STATUS "You can disable it with 'cmake -DENABLE_CUDA=OFF ../'" )
+else(ENABLE_CUDA)
+ message(STATUS "NVIDIA CUDA GPU Acceleration will is not enabled." )
+ message(STATUS "Enable it with 'cmake -DENABLE_CUDA=ON ../' to add support for the Teleorbit Flexiband front-end." )
+endif(ENABLE_CUDA)
+
+
if($ENV{FLEXIBAND_DRIVER})
message(STATUS "FLEXIBAND_DRIVER environment variable found." )
set(ENABLE_FLEXIBAND ON)
diff --git a/conf/gnss-sdr_GPS_L1_gr_complex_gpu.conf b/conf/gnss-sdr_GPS_L1_gr_complex_gpu.conf
new file mode 100644
index 000000000..6bfc9bb6c
--- /dev/null
+++ b/conf/gnss-sdr_GPS_L1_gr_complex_gpu.conf
@@ -0,0 +1,305 @@
+; Default configuration file
+; You can define your own receiver and invoke it by doing
+; gnss-sdr --config_file=my_GNSS_SDR_configuration.conf
+;
+
+[GNSS-SDR]
+
+;######### GLOBAL OPTIONS ##################
+;internal_fs_hz: Internal signal sampling frequency after the signal conditioning stage [Hz].
+GNSS-SDR.internal_fs_hz=4000000
+
+;######### CONTROL_THREAD CONFIG ############
+ControlThread.wait_for_flowgraph=false
+
+;######### SIGNAL_SOURCE CONFIG ############
+;#implementation: Use [File_Signal_Source] or [UHD_Signal_Source] or [GN3S_Signal_Source] (experimental)
+SignalSource.implementation=File_Signal_Source
+
+;#filename: path to file with the captured GNSS signal samples to be processed
+SignalSource.filename=/home/javier/signals/4msps.dat
+
+;#item_type: Type and resolution for each of the signal samples. Use only gr_complex in this version.
+SignalSource.item_type=gr_complex
+
+;#sampling_frequency: Original Signal sampling frequency in [Hz]
+SignalSource.sampling_frequency=4000000
+
+;#freq: RF front-end center frequency in [Hz]
+SignalSource.freq=1575420000
+
+;#gain: Front-end Gain in [dB]
+SignalSource.gain=60
+
+;#subdevice: UHD subdevice specification (for USRP1 use A:0 or B:0)
+SignalSource.subdevice=B:0
+
+;#samples: Number of samples to be processed. Notice that 0 indicates the entire file.
+SignalSource.samples=0
+
+;#repeat: Repeat the processing file. Disable this option in this version
+SignalSource.repeat=false
+
+;#dump: Dump the Signal source data to a file. Disable this option in this version
+SignalSource.dump=false
+
+SignalSource.dump_filename=../data/signal_source.dat
+
+
+;#enable_throttle_control: Enabling this option tells the signal source to keep the delay between samples in post processing.
+; it helps to not overload the CPU, but the processing time will be longer.
+SignalSource.enable_throttle_control=false
+
+
+;######### SIGNAL_CONDITIONER CONFIG ############
+;## It holds blocks to change data type, filter and resample input data.
+
+;#implementation: Use [Pass_Through] or [Signal_Conditioner]
+;#[Pass_Through] disables this block and the [DataTypeAdapter], [InputFilter] and [Resampler] blocks
+;#[Signal_Conditioner] enables this block. Then you have to configure [DataTypeAdapter], [InputFilter] and [Resampler] blocks
+;SignalConditioner.implementation=Signal_Conditioner
+SignalConditioner.implementation=Pass_Through
+
+;######### DATA_TYPE_ADAPTER CONFIG ############
+;## Changes the type of input data. Please disable it in this version.
+;#implementation: [Pass_Through] disables this block
+DataTypeAdapter.implementation=Pass_Through
+
+;######### INPUT_FILTER CONFIG ############
+;## Filter the input data. Can be combined with frequency translation for IF signals
+
+;#implementation: Use [Pass_Through] or [Fir_Filter] or [Freq_Xlating_Fir_Filter]
+;#[Pass_Through] disables this block
+;#[Fir_Filter] enables a FIR Filter
+;#[Freq_Xlating_Fir_Filter] enables FIR filter and a composite frequency translation that shifts IF down to zero Hz.
+
+;InputFilter.implementation=Fir_Filter
+;InputFilter.implementation=Freq_Xlating_Fir_Filter
+InputFilter.implementation=Pass_Through
+
+;#dump: Dump the filtered data to a file.
+InputFilter.dump=false
+
+;#dump_filename: Log path and filename.
+InputFilter.dump_filename=../data/input_filter.dat
+
+;#The following options are used in the filter design of Fir_Filter and Freq_Xlating_Fir_Filter implementation.
+;#These options are based on parameters of gnuradio's function: gr_remez.
+;#These function calculates the optimal (in the Chebyshev/minimax sense) FIR filter inpulse reponse given a set of band edges, the desired reponse on those bands, and the weight given to the error in those bands.
+
+;#input_item_type: Type and resolution for input signal samples. Use only gr_complex in this version.
+InputFilter.input_item_type=gr_complex
+
+;#outut_item_type: Type and resolution for output filtered signal samples. Use only gr_complex in this version.
+InputFilter.output_item_type=gr_complex
+
+;#taps_item_type: Type and resolution for the taps of the filter. Use only float in this version.
+InputFilter.taps_item_type=float
+
+;#number_of_taps: Number of taps in the filter. Increasing this parameter increases the processing time
+InputFilter.number_of_taps=5
+
+;#number_of _bands: Number of frequency bands in the filter.
+InputFilter.number_of_bands=2
+
+;#bands: frequency at the band edges [ b1 e1 b2 e2 b3 e3 ...].
+;#Frequency is in the range [0, 1], with 1 being the Nyquist frequency (Fs/2)
+;#The number of band_begin and band_end elements must match the number of bands
+
+InputFilter.band1_begin=0.0
+InputFilter.band1_end=0.45
+InputFilter.band2_begin=0.55
+InputFilter.band2_end=1.0
+
+;#ampl: desired amplitude at the band edges [ a(b1) a(e1) a(b2) a(e2) ...].
+;#The number of ampl_begin and ampl_end elements must match the number of bands
+
+InputFilter.ampl1_begin=1.0
+InputFilter.ampl1_end=1.0
+InputFilter.ampl2_begin=0.0
+InputFilter.ampl2_end=0.0
+
+;#band_error: weighting applied to each band (usually 1).
+;#The number of band_error elements must match the number of bands
+InputFilter.band1_error=1.0
+InputFilter.band2_error=1.0
+
+;#filter_type: one of "bandpass", "hilbert" or "differentiator"
+InputFilter.filter_type=bandpass
+
+;#grid_density: determines how accurately the filter will be constructed.
+;The minimum value is 16; higher values are slower to compute the filter.
+InputFilter.grid_density=16
+
+;#The following options are used only in Freq_Xlating_Fir_Filter implementation.
+;#InputFilter.IF is the intermediate frequency (in Hz) shifted down to zero Hz
+
+InputFilter.sampling_frequency=4000000
+InputFilter.IF=0
+
+
+
+;######### RESAMPLER CONFIG ############
+;## Resamples the input data.
+
+;#implementation: Use [Pass_Through] or [Direct_Resampler]
+;#[Pass_Through] disables this block
+;#[Direct_Resampler] enables a resampler that implements a nearest neigbourhood interpolation
+;Resampler.implementation=Direct_Resampler
+Resampler.implementation=Pass_Through
+
+;#dump: Dump the resamplered data to a file.
+Resampler.dump=false
+;#dump_filename: Log path and filename.
+Resampler.dump_filename=../data/resampler.dat
+
+;#item_type: Type and resolution for each of the signal samples. Use only gr_complex in this version.
+Resampler.item_type=gr_complex
+
+;#sample_freq_in: the sample frequency of the input signal
+Resampler.sample_freq_in=8000000
+
+;#sample_freq_out: the desired sample frequency of the output signal
+Resampler.sample_freq_out=4000000
+
+
+;######### CHANNELS GLOBAL CONFIG ############
+;#count: Number of available GPS satellite channels.
+Channels_GPS.count=1
+;#count: Number of available Galileo satellite channels.
+Channels_Galileo.count=0
+;#in_acquisition: Number of channels simultaneously acquiring for the whole receiver
+Channels.in_acquisition=1
+;#system: GPS, GLONASS, GALILEO, SBAS or COMPASS
+;#if the option is disabled by default is assigned GPS
+Channel.system=GPS
+
+;#if the option is disabled by default is assigned "1C" GPS L1 C/A
+Channel.signal=1C
+
+
+;######### SPECIFIC CHANNELS CONFIG ######
+;#The following options are specific to each channel and overwrite the generic options
+
+;######### CHANNEL 0 CONFIG ############
+
+;Channel0.system=GPS
+;Channel0.signal=1C
+
+;#satellite: Satellite PRN ID for this channel. Disable this option to random search
+;Channel0.satellite=11
+
+;######### CHANNEL 1 CONFIG ############
+
+;Channel1.system=GPS
+;Channel1.signal=1C
+;Channel1.satellite=18
+
+;######### ACQUISITION GLOBAL CONFIG ############
+
+;#dump: Enable or disable the acquisition internal data file logging [true] or [false]
+Acquisition_GPS.dump=false
+;#filename: Log path and filename
+Acquisition_GPS.dump_filename=./acq_dump.dat
+;#item_type: Type and resolution for each of the signal samples. Use only gr_complex in this version.
+Acquisition_GPS.item_type=gr_complex
+;#if: Signal intermediate frequency in [Hz]
+Acquisition_GPS.if=0
+;#sampled_ms: Signal block duration for the acquisition signal detection [ms]
+Acquisition_GPS.sampled_ms=1
+;#implementation: Acquisition algorithm selection for this channel: [GPS_L1_CA_PCPS_Acquisition] or [Galileo_E1_PCPS_Ambiguous_Acquisition]
+Acquisition_GPS.implementation=GPS_L1_CA_PCPS_Acquisition
+;#threshold: Acquisition threshold
+Acquisition_GPS.threshold=0.005
+;#pfa: Acquisition false alarm probability. This option overrides the threshold option. Only use with implementations: [GPS_L1_CA_PCPS_Acquisition] or [Galileo_E1_PCPS_Ambiguous_Acquisition]
+;Acquisition_GPS.pfa=0.01
+;#doppler_max: Maximum expected Doppler shift [Hz]
+Acquisition_GPS.doppler_max=10000
+;#doppler_max: Doppler step in the grid search [Hz]
+Acquisition_GPS.doppler_step=500
+
+;######### TRACKING GLOBAL CONFIG ############
+
+;#implementation: Selected tracking algorithm: [GPS_L1_CA_DLL_PLL_Tracking] or [GPS_L1_CA_DLL_FLL_PLL_Tracking] or [GPS_L1_CA_TCP_CONNECTOR_Tracking] or [Galileo_E1_DLL_PLL_VEML_Tracking]
+Tracking_GPS.implementation=GPS_L1_CA_DLL_PLL_Tracking_GPU
+;#item_type: Type and resolution for each of the signal samples. Use only [gr_complex] in this version.
+Tracking_GPS.item_type=gr_complex
+
+;#sampling_frequency: Signal Intermediate Frequency in [Hz]
+Tracking_GPS.if=0
+
+;#dump: Enable or disable the Tracking internal binary data file logging [true] or [false]
+Tracking_GPS.dump=true
+
+;#dump_filename: Log path and filename. Notice that the tracking channel will add "x.dat" where x is the channel number.
+Tracking_GPS.dump_filename=../data/epl_tracking_ch_
+
+;#pll_bw_hz: PLL loop filter bandwidth [Hz]
+Tracking_GPS.pll_bw_hz=55.0;
+
+;#dll_bw_hz: DLL loop filter bandwidth [Hz]
+Tracking_GPS.dll_bw_hz=1.5
+
+;#fll_bw_hz: FLL loop filter bandwidth [Hz]
+Tracking_GPS.fll_bw_hz=10.0;
+
+;#order: PLL/DLL loop filter order [2] or [3]
+Tracking_GPS.order=3;
+
+;######### TELEMETRY DECODER GPS CONFIG ############
+;#implementation: Use [GPS_L1_CA_Telemetry_Decoder] for GPS L1 C/A
+TelemetryDecoder_GPS.implementation=GPS_L1_CA_Telemetry_Decoder
+TelemetryDecoder_GPS.dump=false
+;#decimation factor
+TelemetryDecoder_GPS.decimation_factor=1;
+
+;######### OBSERVABLES CONFIG ############
+;#implementation: Use [GPS_L1_CA_Observables] for GPS L1 C/A.
+Observables.implementation=GPS_L1_CA_Observables
+
+;#dump: Enable or disable the Observables internal binary data file logging [true] or [false]
+Observables.dump=false
+
+;#dump_filename: Log path and filename.
+Observables.dump_filename=./observables.dat
+
+
+;######### PVT CONFIG ############
+;#implementation: Position Velocity and Time (PVT) implementation algorithm: Use [GPS_L1_CA_PVT] in this version.
+PVT.implementation=GPS_L1_CA_PVT
+
+;#averaging_depth: Number of PVT observations in the moving average algorithm
+PVT.averaging_depth=100
+
+;#flag_average: Enables the PVT averaging between output intervals (arithmetic mean) [true] or [false]
+PVT.flag_averaging=false
+
+;#output_rate_ms: Period between two PVT outputs. Notice that the minimum period is equal to the tracking integration time (for GPS CA L1 is 1ms) [ms]
+PVT.output_rate_ms=10
+
+;#display_rate_ms: Position console print (std::out) interval [ms]. Notice that output_rate_ms<=display_rate_ms.
+PVT.display_rate_ms=500
+
+;# RINEX, KML, and NMEA output configuration
+
+;#dump_filename: Log path and filename without extension. Notice that PVT will add ".dat" to the binary dump and ".kml" to GoogleEarth dump.
+PVT.dump_filename=./PVT
+
+;#nmea_dump_filename: NMEA log path and filename
+PVT.nmea_dump_filename=./gnss_sdr_pvt.nmea;
+
+;#flag_nmea_tty_port: Enable or disable the NMEA log to a serial TTY port (Can be used with real hardware or virtual one)
+PVT.flag_nmea_tty_port=false;
+
+;#nmea_dump_devname: serial device descriptor for NMEA logging
+PVT.nmea_dump_devname=/dev/pts/4
+
+
+;#dump: Enable or disable the PVT internal binary data file logging [true] or [false]
+PVT.dump=false
+
+;######### OUTPUT_FILTER CONFIG ############
+;# Receiver output filter: Leave this block disabled in this version
+OutputFilter.implementation=Null_Sink_Output_Filter
+OutputFilter.filename=data/gnss-sdr.dat
+OutputFilter.item_type=gr_complex
diff --git a/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_bin_file_III_1a.conf b/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_bin_file_III_1a.conf
index d412bb82d..3e835d2d3 100644
--- a/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_bin_file_III_1a.conf
+++ b/conf/gnss-sdr_multichannel_GPS_L1_Flexiband_bin_file_III_1a.conf
@@ -29,13 +29,13 @@ GNSS-SDR.SUPL_CI=0x31b0
SignalSource.implementation=Flexiband_Signal_Source
SignalSource.flag_read_file=true
-SignalSource.signal_file=/datalogger/captures/eclipse/eclipse_IIIa_2.bin
+SignalSource.signal_file=/datalogger/L125_III1b_210s.usb
;#item_type: Type and resolution for each of the signal samples. Use only gr_complex in this version.
SignalSource.item_type=gr_complex
;# FPGA firmware file
-SignalSource.firmware_file=flexiband_III-1a.bit
+SignalSource.firmware_file=flexiband_III-1b.bit
;#RF_channels: Number of RF channels present in the frontend device, must agree the FPGA firmware file
SignalSource.RF_channels=1
diff --git a/conf/gnss-sdr_multichannel_GPS_L1_L2_Galileo_E1B_Flexiband_realtime_III_1b.conf b/conf/gnss-sdr_multichannel_GPS_L1_L2_Galileo_E1B_Flexiband_realtime_III_1b.conf
index 0177fef62..019c0abcc 100644
--- a/conf/gnss-sdr_multichannel_GPS_L1_L2_Galileo_E1B_Flexiband_realtime_III_1b.conf
+++ b/conf/gnss-sdr_multichannel_GPS_L1_L2_Galileo_E1B_Flexiband_realtime_III_1b.conf
@@ -28,9 +28,9 @@ GNSS-SDR.SUPL_CI=0x31b0
;#implementation: Use [File_Signal_Source] or [UHD_Signal_Source] or [GN3S_Signal_Source] (experimental)
SignalSource.implementation=Flexiband_Signal_Source
-SignalSource.flag_read_file=false
-#SignalSource.signal_file=/datalogger/signals/Fraunhofer/L125_III1b_210s.usb
-SignalSource.signal_file=/datalogger/captures/flexiband_III_1b_cap1.usb
+SignalSource.flag_read_file=true
+SignalSource.signal_file=/datalogger/L125_III1b_210s.usb
+#SignalSource.signal_file=/datalogger/captures/flexiband_III_1b_cap1.usb
;#item_type: Type and resolution for each of the signal samples. Use only gr_complex in this version.
SignalSource.item_type=gr_complex
@@ -136,8 +136,8 @@ InputFilter0.grid_density=16
InputFilter0.sampling_frequency=20000000
;# IF deviation due to front-end LO inaccuracies [HZ]
;# WARNING: Fraunhofer front-end hardwareconfigurations can difer. Signals available on http://www.iis.fraunhofer.de/de/ff/lok/leist/test/flexiband.html are centered on 0 Hz, ALL BANDS.
-InputFilter0.IF=-205000
-;#InputFilter0.IF=0
+;#InputFilter0.IF=-205000
+InputFilter0.IF=0
;# Decimation factor after the frequency tranaslating block
InputFilter0.decimation_factor=8
@@ -230,8 +230,8 @@ InputFilter1.grid_density=16
InputFilter1.sampling_frequency=20000000
;# IF deviation due to front-end LO inaccuracies [HZ]
;# WARNING: Fraunhofer front-end hardwareconfigurations can difer. Signals available on http://www.iis.fraunhofer.de/de/ff/lok/leist/test/flexiband.html are centered on 0 Hz, ALL BANDS.
-InputFilter1.IF=100000
-;#InputFilter1.IF=0
+;#InputFilter1.IF=100000
+InputFilter1.IF=0
;# Decimation factor after the frequency tranaslating block
InputFilter1.decimation_factor=8
@@ -272,7 +272,7 @@ Resampler2.implementation=Pass_Through
;#count: Number of available GPS satellite channels.
Channels_1C.count=8
Channels_1B.count=1
-Channels_2S.count=8
+Channels_2S.count=1
;#count: Number of available Galileo satellite channels.
;Channels_Galileo.count=0
;#in_acquisition: Number of channels simultaneously acquiring for the whole receiver
@@ -378,13 +378,13 @@ Acquisition_1C.max_dwells=1
;#implementation: Selected tracking algorithm: [GPS_L1_CA_DLL_PLL_Tracking] or [GPS_L1_CA_DLL_FLL_PLL_Tracking]
-Tracking_1C.implementation=GPS_L1_CA_DLL_PLL_Tracking
+Tracking_1C.implementation=GPS_L1_CA_DLL_PLL_Tracking_GPU
Tracking_1C.item_type=gr_complex
Tracking_1C.if=0
-Tracking_1C.dump=true
-Tracking_1C.dump_filename=./tracking_ch_
+Tracking_1C.dump=false
+Tracking_1C.dump_filename=../data/epl_tracking_ch_
Tracking_1C.pll_bw_hz=40.0;
-Tracking_1C.dll_bw_hz=3.0;
+Tracking_1C.dll_bw_hz=1.5;
Tracking_1C.fll_bw_hz=10.0;
Tracking_1C.order=3;
Tracking_1C.early_late_space_chips=0.5;
@@ -405,7 +405,7 @@ Acquisition_2S.max_dwells=1
Tracking_2S.implementation=GPS_L2_M_DLL_PLL_Tracking
Tracking_2S.item_type=gr_complex
Tracking_2S.if=0
-Tracking_2S.dump=true
+Tracking_2S.dump=false
Tracking_2S.dump_filename=./tracking_ch_
Tracking_2S.pll_bw_hz=1.5;
Tracking_2S.dll_bw_hz=0.3;
@@ -447,7 +447,7 @@ Tracking_1B.item_type=gr_complex
Tracking_1B.if=0
;#dump: Enable or disable the Tracking internal binary data file logging [true] or [false]
-Tracking_1B.dump=true
+Tracking_1B.dump=false
;#dump_filename: Log path and filename. Notice that the tracking channel will add "x.dat" where x is the channel number.
Tracking_1B.dump_filename=./veml_tracking_ch_
@@ -497,7 +497,7 @@ TelemetryDecoder_1B.decimation_factor=5;
Observables.implementation=Mixed_Observables
;#dump: Enable or disable the Observables internal binary data file logging [true] or [false]
-Observables.dump=true
+Observables.dump=false
;#dump_filename: Log path and filename.
Observables.dump_filename=./observables.dat
diff --git a/conf/gnss-sdr_multichannel_GPS_L2_M_Flexiband_bin_file_III_1a.conf b/conf/gnss-sdr_multichannel_GPS_L2_M_Flexiband_bin_file_III_1a.conf
index 4b26ea9e4..debff1ae1 100644
--- a/conf/gnss-sdr_multichannel_GPS_L2_M_Flexiband_bin_file_III_1a.conf
+++ b/conf/gnss-sdr_multichannel_GPS_L2_M_Flexiband_bin_file_III_1a.conf
@@ -135,7 +135,8 @@ InputFilter0.grid_density=16
; i.e. using front-end-cal as reported here:http://www.cttc.es/publication/turning-a-television-into-a-gnss-receiver/
InputFilter0.sampling_frequency=20000000
;# IF deviation due to front-end LO inaccuracies [HZ]
-InputFilter0.IF=-205000
+;#InputFilter0.IF=-205000
+InputFilter0.IF=0
;# Decimation factor after the frequency tranaslating block
InputFilter0.decimation_factor=4
diff --git a/src/algorithms/signal_source/adapters/CMakeLists.txt b/src/algorithms/signal_source/adapters/CMakeLists.txt
index 14284f6e1..4df888a98 100644
--- a/src/algorithms/signal_source/adapters/CMakeLists.txt
+++ b/src/algorithms/signal_source/adapters/CMakeLists.txt
@@ -58,7 +58,7 @@ if(ENABLE_FLEXIBAND)
if(OS_IS_MACOSX)
set(MACOSX_ARGS "-DCMAKE_CXX_COMPILER=/usr/bin/clang++")
endif(OS_IS_MACOSX)
- find_package(teleorbit REQUIRED)
+ find_package(Teleorbit REQUIRED)
if(NOT TELEORBIT_FOUND)
message(FATAL_ERROR "Teleorbit Flexiband GNURadio driver required to build gnss-sdr with the optional FLEXIBAND adapter")
endif(NOT TELEORBIT_FOUND)
diff --git a/src/algorithms/tracking/adapters/CMakeLists.txt b/src/algorithms/tracking/adapters/CMakeLists.txt
index fda0724a7..c712cd981 100644
--- a/src/algorithms/tracking/adapters/CMakeLists.txt
+++ b/src/algorithms/tracking/adapters/CMakeLists.txt
@@ -16,6 +16,10 @@
# along with GNSS-SDR. If not, see .
#
+if(ENABLE_CUDA)
+ FIND_PACKAGE(CUDA REQUIRED)
+ set(OPT_TRACKING_ADAPTERS ${OPT_TRACKING_ADAPTERS} gps_l1_ca_dll_pll_tracking_gpu.cc)
+endif(ENABLE_CUDA)
set(TRACKING_ADAPTER_SOURCES
galileo_e1_dll_pll_veml_tracking.cc
@@ -27,6 +31,7 @@ set(TRACKING_ADAPTER_SOURCES
gps_l1_ca_tcp_connector_tracking.cc
galileo_e5a_dll_pll_tracking.cc
gps_l2_m_dll_pll_tracking.cc
+ ${OPT_TRACKING_ADAPTERS}
)
include_directories(
@@ -40,6 +45,7 @@ include_directories(
${GLOG_INCLUDE_DIRS}
${GFlags_INCLUDE_DIRS}
${GNURADIO_RUNTIME_INCLUDE_DIRS}
+ ${CUDA_INCLUDE_DIRS}
)
file(GLOB TRACKING_ADAPTER_HEADERS "*.h")
diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_gpu.cc b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_gpu.cc
new file mode 100644
index 000000000..4ae8864b0
--- /dev/null
+++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_gpu.cc
@@ -0,0 +1,158 @@
+/*!
+ * \file gps_l1_ca_dll_pll_tracking_gpu.cc
+ * \brief Implementation of an adapter of a DLL+PLL tracking loop block using GPU accelerated functions
+ * for GPS L1 C/A to a TrackingInterface
+ * \author Javier Arribas, 2015. jarribas(at)cttc.es
+ *
+ * Code DLL + carrier PLL according to the algorithms described in:
+ * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen,
+ * A Software-Defined GPS and Galileo Receiver. A Single-Frequency
+ * Approach, Birkhauser, 2007
+ *
+ * -------------------------------------------------------------------------
+ *
+ * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
+ *
+ * GNSS-SDR is a software defined Global Navigation
+ * Satellite Systems receiver
+ *
+ * This file is part of GNSS-SDR.
+ *
+ * GNSS-SDR is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GNSS-SDR is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNSS-SDR. If not, see .
+ *
+ * -------------------------------------------------------------------------
+ */
+
+
+#include "gps_l1_ca_dll_pll_tracking_gpu.h"
+#include
+#include "GPS_L1_CA.h"
+#include "configuration_interface.h"
+
+
+using google::LogMessage;
+
+GpsL1CaDllPllTrackingGPU::GpsL1CaDllPllTrackingGPU(
+ ConfigurationInterface* configuration, std::string role,
+ unsigned int in_streams, unsigned int out_streams,
+ boost::shared_ptr queue) :
+ role_(role), in_streams_(in_streams), out_streams_(out_streams),
+ queue_(queue)
+{
+ DLOG(INFO) << "role " << role;
+ //################# CONFIGURATION PARAMETERS ########################
+ int fs_in;
+ int vector_length;
+ int f_if;
+ bool dump;
+ std::string dump_filename;
+ std::string item_type;
+ std::string default_item_type = "gr_complex";
+ float pll_bw_hz;
+ float dll_bw_hz;
+ float early_late_space_chips;
+ item_type = configuration->property(role + ".item_type", default_item_type);
+ //vector_length = configuration->property(role + ".vector_length", 2048);
+ fs_in = configuration->property("GNSS-SDR.internal_fs_hz", 2048000);
+ f_if = configuration->property(role + ".if", 0);
+ dump = configuration->property(role + ".dump", false);
+ pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0);
+ dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0);
+ early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5);
+ std::string default_dump_filename = "./track_ch";
+ dump_filename = configuration->property(role + ".dump_filename",
+ default_dump_filename); //unused!
+ vector_length = std::round(fs_in / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS));
+
+ //################# MAKE TRACKING GNURadio object ###################
+ if (item_type.compare("gr_complex") == 0)
+ {
+ item_size_ = sizeof(gr_complex);
+ tracking_ = gps_l1_ca_dll_pll_make_tracking_gpu_cc(
+ f_if,
+ fs_in,
+ vector_length,
+ queue_,
+ dump,
+ dump_filename,
+ pll_bw_hz,
+ dll_bw_hz,
+ early_late_space_chips);
+ }
+ else
+ {
+ item_size_ = sizeof(gr_complex);
+ LOG(WARNING) << item_type << " unknown tracking item type.";
+ }
+ channel_ = 0;
+ channel_internal_queue_ = 0;
+ DLOG(INFO) << "tracking(" << tracking_->unique_id() << ")";
+}
+
+
+GpsL1CaDllPllTrackingGPU::~GpsL1CaDllPllTrackingGPU()
+{}
+
+
+void GpsL1CaDllPllTrackingGPU::start_tracking()
+{
+ tracking_->start_tracking();
+}
+
+/*
+ * Set tracking channel unique ID
+ */
+void GpsL1CaDllPllTrackingGPU::set_channel(unsigned int channel)
+{
+ channel_ = channel;
+ tracking_->set_channel(channel);
+}
+
+/*
+ * Set tracking channel internal queue
+ */
+void GpsL1CaDllPllTrackingGPU::set_channel_queue(
+ concurrent_queue *channel_internal_queue)
+{
+ channel_internal_queue_ = channel_internal_queue;
+ tracking_->set_channel_queue(channel_internal_queue_);
+}
+
+void GpsL1CaDllPllTrackingGPU::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro)
+{
+ tracking_->set_gnss_synchro(p_gnss_synchro);
+}
+
+void GpsL1CaDllPllTrackingGPU::connect(gr::top_block_sptr top_block)
+{
+ if(top_block) { /* top_block is not null */};
+ //nothing to connect, now the tracking uses gr_sync_decimator
+}
+
+void GpsL1CaDllPllTrackingGPU::disconnect(gr::top_block_sptr top_block)
+{
+ if(top_block) { /* top_block is not null */};
+ //nothing to disconnect, now the tracking uses gr_sync_decimator
+}
+
+gr::basic_block_sptr GpsL1CaDllPllTrackingGPU::get_left_block()
+{
+ return tracking_;
+}
+
+gr::basic_block_sptr GpsL1CaDllPllTrackingGPU::get_right_block()
+{
+ return tracking_;
+}
+
diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_gpu.h b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_gpu.h
new file mode 100644
index 000000000..22bbe5d15
--- /dev/null
+++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_gpu.h
@@ -0,0 +1,113 @@
+/*!
+ * \file gps_l1_ca_dll_pll_tracking_gpu.h
+ * \brief Implementation of an adapter of a DLL+PLL tracking loop block using GPU accelerated functions
+ * for GPS L1 C/A to a TrackingInterface
+ * \author Javier Arribas, 2015. jarribas(at)cttc.es
+ *
+ * Code DLL + carrier PLL according to the algorithms described in:
+ * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen,
+ * A Software-Defined GPS and Galileo Receiver. A Single-Frequency
+ * Approach, Birkha user, 2007
+ *
+ * -------------------------------------------------------------------------
+ *
+ * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
+ *
+ * GNSS-SDR is a software defined Global Navigation
+ * Satellite Systems receiver
+ *
+ * This file is part of GNSS-SDR.
+ *
+ * GNSS-SDR is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GNSS-SDR is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNSS-SDR. If not, see .
+ *
+ * -------------------------------------------------------------------------
+ */
+
+#ifndef GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_GPU_H_
+#define GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_GPU_H_
+
+#include
+#include
+#include "tracking_interface.h"
+#include "gps_l1_ca_dll_pll_tracking_gpu_cc.h"
+
+
+class ConfigurationInterface;
+
+/*!
+ * \brief This class implements a code DLL + carrier PLL tracking loop using GPU accelerated functions
+ */
+class GpsL1CaDllPllTrackingGPU : public TrackingInterface
+{
+public:
+
+ GpsL1CaDllPllTrackingGPU(ConfigurationInterface* configuration,
+ std::string role,
+ unsigned int in_streams,
+ unsigned int out_streams,
+ boost::shared_ptr queue);
+
+ virtual ~GpsL1CaDllPllTrackingGPU();
+
+ std::string role()
+ {
+ return role_;
+ }
+
+ //! Returns "GPS_L1_CA_DLL_PLL_Tracking"
+ std::string implementation()
+ {
+ return "GPS_L1_CA_DLL_PLL_Tracking_GPU";
+ }
+ size_t item_size()
+ {
+ return item_size_;
+ }
+
+ void connect(gr::top_block_sptr top_block);
+ void disconnect(gr::top_block_sptr top_block);
+ gr::basic_block_sptr get_left_block();
+ gr::basic_block_sptr get_right_block();
+
+
+ /*!
+ * \brief Set tracking channel unique ID
+ */
+ void set_channel(unsigned int channel);
+
+ /*!
+ * \brief Set acquisition/tracking common Gnss_Synchro object pointer
+ * to efficiently exchange synchronization data between acquisition and tracking blocks
+ */
+ void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro);
+
+ /*!
+ * \brief Set tracking channel internal queue
+ */
+ void set_channel_queue(concurrent_queue *channel_internal_queue);
+
+ void start_tracking();
+
+private:
+ gps_l1_ca_dll_pll_tracking_gpu_cc_sptr tracking_;
+ size_t item_size_;
+ unsigned int channel_;
+ std::string role_;
+ unsigned int in_streams_;
+ unsigned int out_streams_;
+ boost::shared_ptr queue_;
+ concurrent_queue *channel_internal_queue_;
+};
+
+#endif // GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_GPU_H_
diff --git a/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt b/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt
index 268e1f9b5..a018fe10e 100644
--- a/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt
+++ b/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt
@@ -16,6 +16,12 @@
# along with GNSS-SDR. If not, see .
#
+
+if(ENABLE_CUDA)
+ FIND_PACKAGE(CUDA REQUIRED)
+ set(OPT_TRACKING_BLOCKS ${OPT_TRACKING_BLOCKS} gps_l1_ca_dll_pll_tracking_gpu_cc.cc)
+endif(ENABLE_CUDA)
+
set(TRACKING_GR_BLOCKS_SOURCES
galileo_e1_dll_pll_veml_tracking_cc.cc
galileo_volk_e1_dll_pll_veml_tracking_cc.cc
@@ -26,6 +32,7 @@ set(TRACKING_GR_BLOCKS_SOURCES
gps_l1_ca_tcp_connector_tracking_cc.cc
galileo_e5a_dll_pll_tracking_cc.cc
gps_l2_m_dll_pll_tracking_cc.cc
+ ${OPT_TRACKING_BLOCKS}
)
include_directories(
@@ -40,6 +47,8 @@ include_directories(
${Boost_INCLUDE_DIRS}
${GNURADIO_RUNTIME_INCLUDE_DIRS}
${VOLK_GNSSSDR_INCLUDE_DIRS}
+ ${CUDA_INCLUDE_DIRS}
+ ${CMAKE_SOURCE_DIR}/src/algorithms/tracking/libs/cudahelpers
)
if(ENABLE_GENERIC_ARCH)
@@ -49,7 +58,8 @@ endif(ENABLE_GENERIC_ARCH)
file(GLOB TRACKING_GR_BLOCKS_HEADERS "*.h")
add_library(tracking_gr_blocks ${TRACKING_GR_BLOCKS_SOURCES} ${TRACKING_GR_BLOCKS_HEADERS})
source_group(Headers FILES ${TRACKING_GR_BLOCKS_HEADERS})
-target_link_libraries(tracking_gr_blocks tracking_lib ${GNURADIO_RUNTIME_LIBRARIES} gnss_sp_libs ${Boost_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES} ${ORC_LIBRARIES} )
+
+target_link_libraries(tracking_gr_blocks tracking_lib ${GNURADIO_RUNTIME_LIBRARIES} gnss_sp_libs ${Boost_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES} ${ORC_LIBRARIES} ${CUDA_LIBRARIES})
if(NOT VOLK_GNSSSDR_FOUND)
add_dependencies(tracking_gr_blocks volk_gnsssdr_module)
endif(NOT VOLK_GNSSSDR_FOUND)
diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc
index 85d63f54c..3193d335e 100644
--- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc
+++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc
@@ -594,7 +594,8 @@ int Gps_L1_Ca_Dll_Pll_Tracking_cc::general_work (int noutput_items, gr_vector_in
// carrier and code frequency
d_dump_file.write(reinterpret_cast(&d_carrier_doppler_hz), sizeof(float));
- d_dump_file.write(reinterpret_cast(&d_code_freq_chips), sizeof(float));
+ tmp_float=d_code_freq_chips;
+ d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float));
//PLL commands
d_dump_file.write(reinterpret_cast(&carr_error_hz), sizeof(float));
diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc
new file mode 100644
index 000000000..1cf5d038e
--- /dev/null
+++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc
@@ -0,0 +1,610 @@
+/*!
+ * \file gps_l1_ca_dll_pll_tracking_gpu_cc.cc
+ * \brief Implementation of a code DLL + carrier PLL tracking block, GPU ACCELERATED
+ * \author Javier Arribas, 2015. jarribas(at)cttc.es
+ *
+ * Code DLL + carrier PLL according to the algorithms described in:
+ * [1] K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen,
+ * A Software-Defined GPS and Galileo Receiver. A Single-Frequency
+ * Approach, Birkhauser, 2007
+ *
+ * -------------------------------------------------------------------------
+ *
+ * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
+ *
+ * GNSS-SDR is a software defined Global Navigation
+ * Satellite Systems receiver
+ *
+ * This file is part of GNSS-SDR.
+ *
+ * GNSS-SDR is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GNSS-SDR is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNSS-SDR. If not, see .
+ *
+ * -------------------------------------------------------------------------
+ */
+
+#include "gps_l1_ca_dll_pll_tracking_gpu_cc.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "gnss_synchro.h"
+#include "gps_sdr_signal_processing.h"
+#include "tracking_discriminators.h"
+#include "lock_detectors.h"
+#include "GPS_L1_CA.h"
+#include "control_message_factory.h"
+#include //volk_alignement
+// includes
+#include
+#include // helper for shared functions common to CUDA Samples
+#include // helper functions for CUDA error checking and initialization
+
+/*!
+ * \todo Include in definition header file
+ */
+#define CN0_ESTIMATION_SAMPLES 20
+#define MINIMUM_VALID_CN0 25
+#define MAXIMUM_LOCK_FAIL_COUNTER 50
+#define CARRIER_LOCK_THRESHOLD 0.85
+
+
+using google::LogMessage;
+
+gps_l1_ca_dll_pll_tracking_gpu_cc_sptr
+gps_l1_ca_dll_pll_make_tracking_gpu_cc(
+ long if_freq,
+ long fs_in,
+ unsigned int vector_length,
+ boost::shared_ptr queue,
+ bool dump,
+ std::string dump_filename,
+ float pll_bw_hz,
+ float dll_bw_hz,
+ float early_late_space_chips)
+{
+ return gps_l1_ca_dll_pll_tracking_gpu_cc_sptr(new Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc(if_freq,
+ fs_in, vector_length, queue, dump, dump_filename, pll_bw_hz, dll_bw_hz, early_late_space_chips));
+}
+
+
+void Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::forecast (int noutput_items,
+ gr_vector_int &ninput_items_required)
+{
+ ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call
+}
+
+
+
+Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc(
+ long if_freq,
+ long fs_in,
+ unsigned int vector_length,
+ boost::shared_ptr queue,
+ bool dump,
+ std::string dump_filename,
+ float pll_bw_hz,
+ float dll_bw_hz,
+ float early_late_space_chips) :
+ gr::block("Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)),
+ gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)))
+{
+ // initialize internal vars
+ d_queue = queue;
+ d_dump = dump;
+ d_if_freq = if_freq;
+ d_fs_in = fs_in;
+ d_vector_length = vector_length;
+ d_dump_filename = dump_filename;
+
+ // Initialize tracking ==========================================
+ d_code_loop_filter.set_DLL_BW(dll_bw_hz);
+ d_carrier_loop_filter.set_PLL_BW(pll_bw_hz);
+
+ //--- DLL variables --------------------------------------------------------
+ d_early_late_spc_chips = early_late_space_chips; // Define early-late offset (in chips)
+
+ // Initialization of local code replica
+ // Get space for a vector with the C/A code replica sampled 1x/chip
+ //d_ca_code = static_cast(volk_malloc((GPS_L1_CA_CODE_LENGTH_CHIPS + 2) * sizeof(gr_complex), volk_get_alignment()));
+ d_ca_code = static_cast(volk_malloc((GPS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_get_alignment()));
+
+ multicorrelator_gpu = new cuda_multicorrelator();
+ int N_CORRELATORS=3;
+ //local code resampler on CPU (old)
+ //multicorrelator_gpu->init_cuda(0, NULL, 2 * d_vector_length , 2 * d_vector_length , N_CORRELATORS);
+
+ //local code resampler on GPU (new)
+ multicorrelator_gpu->init_cuda_integrated_resampler(0, NULL, 2 * d_vector_length , GPS_L1_CA_CODE_LENGTH_CHIPS , N_CORRELATORS);
+
+ // Get space for the resampled early / prompt / late local replicas
+ checkCudaErrors(cudaHostAlloc((void**)&d_local_code_shift_chips, N_CORRELATORS * sizeof(float), cudaHostAllocMapped ));
+
+
+ //allocate host memory
+ //pinned memory mode - use special function to get OS-pinned memory
+ checkCudaErrors(cudaHostAlloc((void**)&in_gpu, 2 * d_vector_length * sizeof(gr_complex), cudaHostAllocMapped ));
+
+ //old local codes vector
+ //checkCudaErrors(cudaHostAlloc((void**)&d_local_codes_gpu, (V_LEN * sizeof(gr_complex))*N_CORRELATORS, cudaHostAllocWriteCombined ));
+
+ //new integrated shifts
+ //checkCudaErrors(cudaHostAlloc((void**)&d_local_codes_gpu, (2 * d_vector_length * sizeof(gr_complex)), cudaHostAllocWriteCombined ));
+
+ // correlator outputs (scalar)
+ checkCudaErrors(cudaHostAlloc((void**)&d_corr_outs_gpu ,sizeof(gr_complex)*N_CORRELATORS, cudaHostAllocWriteCombined ));
+ //map to EPL pointers
+ d_Early = &d_corr_outs_gpu[0];
+ d_Prompt = &d_corr_outs_gpu[1];
+ d_Late = &d_corr_outs_gpu[2];
+
+ //--- Perform initializations ------------------------------
+ // define initial code frequency basis of NCO
+ d_code_freq_chips = GPS_L1_CA_CODE_RATE_HZ;
+ // define residual code phase (in chips)
+ d_rem_code_phase_samples = 0.0;
+ // define residual carrier phase
+ d_rem_carr_phase_rad = 0.0;
+
+ // sample synchronization
+ d_sample_counter = 0;
+ //d_sample_counter_seconds = 0;
+ d_acq_sample_stamp = 0;
+
+ d_enable_tracking = false;
+ d_pull_in = false;
+ d_last_seg = 0;
+
+ d_current_prn_length_samples = static_cast(d_vector_length);
+
+ // CN0 estimation and lock detector buffers
+ d_cn0_estimation_counter = 0;
+ d_Prompt_buffer = new gr_complex[CN0_ESTIMATION_SAMPLES];
+ d_carrier_lock_test = 1;
+ d_CN0_SNV_dB_Hz = 0;
+ d_carrier_lock_fail_counter = 0;
+ d_carrier_lock_threshold = CARRIER_LOCK_THRESHOLD;
+
+ systemName["G"] = std::string("GPS");
+ systemName["S"] = std::string("SBAS");
+
+
+ set_relative_rate(1.0/((double)d_vector_length*2));
+
+ d_channel_internal_queue = 0;
+ d_acquisition_gnss_synchro = 0;
+ d_channel = 0;
+ d_acq_code_phase_samples = 0.0;
+ d_acq_carrier_doppler_hz = 0.0;
+ d_carrier_doppler_hz = 0.0;
+ d_acc_carrier_phase_rad = 0.0;
+ d_code_phase_samples = 0.0;
+ d_acc_code_phase_secs = 0.0;
+ //set_min_output_buffer((long int)300);
+}
+
+
+void Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::start_tracking()
+{
+ /*
+ * correct the code phase according to the delay between acq and trk
+ */
+ d_acq_code_phase_samples = d_acquisition_gnss_synchro->Acq_delay_samples;
+ d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz;
+ d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples;
+
+ long int acq_trk_diff_samples;
+ float acq_trk_diff_seconds;
+ acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp);//-d_vector_length;
+ DLOG(INFO) << "Number of samples between Acquisition and Tracking =" << acq_trk_diff_samples;
+ acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / static_cast(d_fs_in);
+ //doppler effect
+ // Fd=(C/(C+Vr))*F
+ float radial_velocity = (GPS_L1_FREQ_HZ + d_acq_carrier_doppler_hz) / GPS_L1_FREQ_HZ;
+ // new chip and prn sequence periods based on acq Doppler
+ float T_chip_mod_seconds;
+ float T_prn_mod_seconds;
+ float T_prn_mod_samples;
+ d_code_freq_chips = radial_velocity * GPS_L1_CA_CODE_RATE_HZ;
+ T_chip_mod_seconds = 1/d_code_freq_chips;
+ T_prn_mod_seconds = T_chip_mod_seconds * GPS_L1_CA_CODE_LENGTH_CHIPS;
+ T_prn_mod_samples = T_prn_mod_seconds * static_cast(d_fs_in);
+
+ d_current_prn_length_samples = round(T_prn_mod_samples);
+
+ float T_prn_true_seconds = GPS_L1_CA_CODE_LENGTH_CHIPS / GPS_L1_CA_CODE_RATE_HZ;
+ float T_prn_true_samples = T_prn_true_seconds * static_cast(d_fs_in);
+ float T_prn_diff_seconds= T_prn_true_seconds - T_prn_mod_seconds;
+ float N_prn_diff = acq_trk_diff_seconds / T_prn_true_seconds;
+ float corrected_acq_phase_samples, delay_correction_samples;
+ corrected_acq_phase_samples = fmod((d_acq_code_phase_samples + T_prn_diff_seconds * N_prn_diff * static_cast(d_fs_in)), T_prn_true_samples);
+ if (corrected_acq_phase_samples < 0)
+ {
+ corrected_acq_phase_samples = T_prn_mod_samples + corrected_acq_phase_samples;
+ }
+ delay_correction_samples = d_acq_code_phase_samples - corrected_acq_phase_samples;
+
+ d_acq_code_phase_samples = corrected_acq_phase_samples;
+
+ d_carrier_doppler_hz = d_acq_carrier_doppler_hz;
+
+ // DLL/PLL filter initialization
+ d_carrier_loop_filter.initialize(); // initialize the carrier filter
+ d_code_loop_filter.initialize(); // initialize the code filter
+
+ // generate local reference ALWAYS starting at chip 1 (1 sample per chip)
+ gps_l1_ca_code_gen_complex(d_ca_code, d_acquisition_gnss_synchro->PRN, 0);
+
+ 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;
+
+ multicorrelator_gpu->set_local_code_and_taps(GPS_L1_CA_CODE_LENGTH_CHIPS,d_ca_code, d_local_code_shift_chips,3);
+
+ d_carrier_lock_fail_counter = 0;
+ d_rem_code_phase_samples = 0;
+ d_rem_carr_phase_rad = 0;
+ d_acc_carrier_phase_rad = 0;
+ d_acc_code_phase_secs = 0;
+
+ d_code_phase_samples = d_acq_code_phase_samples;
+
+ std::string sys_ = &d_acquisition_gnss_synchro->System;
+ sys = sys_.substr(0,1);
+
+ // DEBUG OUTPUT
+ std::cout << "Tracking start on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl;
+ LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel;
+
+
+ // enable tracking
+ d_pull_in = true;
+ d_enable_tracking = true;
+
+ LOG(INFO) << "PULL-IN Doppler [Hz]=" << d_carrier_doppler_hz
+ << " Code Phase correction [samples]=" << delay_correction_samples
+ << " PULL-IN Code Phase [samples]=" << d_acq_code_phase_samples;
+}
+
+
+Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::~Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc()
+{
+ d_dump_file.close();
+
+ cudaFreeHost(in_gpu);
+ cudaFreeHost(d_carr_sign_gpu);
+ cudaFreeHost(d_corr_outs_gpu);
+ cudaFreeHost(d_local_code_shift_chips);
+
+ multicorrelator_gpu->free_cuda();
+ delete(multicorrelator_gpu);
+
+ volk_free(d_ca_code);
+
+ delete[] d_Prompt_buffer;
+}
+
+
+
+int Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::general_work (int noutput_items, gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
+{
+ // process vars
+ float carr_error_hz=0.0;
+ float carr_error_filt_hz=0.0;
+ float code_error_chips=0.0;
+ float code_error_filt_chips=0.0;
+
+ // Block input data and block output stream pointers
+ const gr_complex* in = (gr_complex*) input_items[0];
+ Gnss_Synchro **out = (Gnss_Synchro **) &output_items[0];
+
+ // GNSS_SYNCHRO OBJECT to interchange data between tracking->telemetry_decoder
+ Gnss_Synchro current_synchro_data = Gnss_Synchro();
+
+ if (d_enable_tracking == true)
+ {
+ // Receiver signal alignment
+ if (d_pull_in == true)
+ {
+ int samples_offset;
+ int acq_to_trk_delay_samples;
+ acq_to_trk_delay_samples = d_sample_counter - d_acq_sample_stamp;
+ samples_offset = round(d_acq_code_phase_samples)+d_current_prn_length_samples - acq_to_trk_delay_samples%d_current_prn_length_samples;
+ d_sample_counter = d_sample_counter + samples_offset; //count for the processed samples
+ d_pull_in = false;
+ // Fill the acquisition data
+ current_synchro_data = *d_acquisition_gnss_synchro;
+ *out[0] = current_synchro_data;
+ consume_each(samples_offset); //shift input to perform alignment with local replica
+ return 1;
+ }
+
+ // Fill the acquisition data
+ current_synchro_data = *d_acquisition_gnss_synchro;
+
+ // UPDATE NCO COMMAND
+ float phase_step_rad = static_cast(GPS_TWO_PI) * d_carrier_doppler_hz / static_cast(d_fs_in);
+
+ //code resampler on GPU (new)
+ float code_phase_step_chips = static_cast(d_code_freq_chips) / static_cast(d_fs_in);
+ float rem_code_phase_chips = d_rem_code_phase_samples * (d_code_freq_chips / d_fs_in);
+
+ cudaProfilerStart();
+ multicorrelator_gpu->Carrier_wipeoff_multicorrelator_resampler_cuda(
+ d_corr_outs_gpu,
+ in,
+ d_rem_carr_phase_rad,
+ phase_step_rad,
+ code_phase_step_chips,
+ rem_code_phase_chips,
+ d_current_prn_length_samples,
+ 3);
+ cudaProfilerStop();
+
+ // ################## PLL ##########################################################
+ // PLL discriminator
+ carr_error_hz = pll_cloop_two_quadrant_atan(*d_Prompt) / static_cast(GPS_TWO_PI);
+ // Carrier discriminator filter
+ carr_error_filt_hz = d_carrier_loop_filter.get_carrier_nco(carr_error_hz);
+ // New carrier Doppler frequency estimation
+ d_carrier_doppler_hz = d_acq_carrier_doppler_hz + carr_error_filt_hz;
+ // New code Doppler frequency estimation
+ d_code_freq_chips = GPS_L1_CA_CODE_RATE_HZ + ((d_carrier_doppler_hz * GPS_L1_CA_CODE_RATE_HZ) / GPS_L1_FREQ_HZ);
+ //carrier phase accumulator for (K) doppler estimation
+ d_acc_carrier_phase_rad = d_acc_carrier_phase_rad + GPS_TWO_PI * d_carrier_doppler_hz * GPS_L1_CA_CODE_PERIOD;
+ //remanent carrier phase to prevent overflow in the code NCO
+ d_rem_carr_phase_rad = d_rem_carr_phase_rad + GPS_TWO_PI * d_carrier_doppler_hz * GPS_L1_CA_CODE_PERIOD;
+ d_rem_carr_phase_rad = fmod(d_rem_carr_phase_rad, GPS_TWO_PI);
+
+ // ################## DLL ##########################################################
+ // DLL discriminator
+ code_error_chips = dll_nc_e_minus_l_normalized(*d_Early, *d_Late); //[chips/Ti]
+ // Code discriminator filter
+ code_error_filt_chips = d_code_loop_filter.get_code_nco(code_error_chips); //[chips/second]
+ //Code phase accumulator
+ float code_error_filt_secs;
+ code_error_filt_secs = (GPS_L1_CA_CODE_PERIOD * code_error_filt_chips) / GPS_L1_CA_CODE_RATE_HZ; //[seconds]
+ d_acc_code_phase_secs = d_acc_code_phase_secs + code_error_filt_secs;
+
+ // ################## CARRIER AND CODE NCO BUFFER ALIGNEMENT #######################
+ // keep alignment parameters for the next input buffer
+ double T_chip_seconds;
+ double T_prn_seconds;
+ double T_prn_samples;
+ double K_blk_samples;
+ // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation
+ T_chip_seconds = 1 / static_cast(d_code_freq_chips);
+ T_prn_seconds = T_chip_seconds * GPS_L1_CA_CODE_LENGTH_CHIPS;
+ T_prn_samples = T_prn_seconds * static_cast(d_fs_in);
+ K_blk_samples = T_prn_samples + d_rem_code_phase_samples + static_cast(code_error_filt_secs) * static_cast(d_fs_in);
+ //d_rem_code_phase_samples = K_blk_samples - d_current_prn_length_samples; //rounding error < 1 sample
+
+ // ####### CN0 ESTIMATION AND LOCK DETECTORS ######
+ if (d_cn0_estimation_counter < CN0_ESTIMATION_SAMPLES)
+ {
+ // fill buffer with prompt correlator output values
+ d_Prompt_buffer[d_cn0_estimation_counter] = *d_Prompt;
+ d_cn0_estimation_counter++;
+ }
+ else
+ {
+ d_cn0_estimation_counter = 0;
+ // Code lock indicator
+ d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES, d_fs_in, GPS_L1_CA_CODE_LENGTH_CHIPS);
+ // Carrier lock indicator
+ d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES);
+ // Loss of lock detection
+ if (d_carrier_lock_test < d_carrier_lock_threshold or d_CN0_SNV_dB_Hz < MINIMUM_VALID_CN0)
+ {
+ d_carrier_lock_fail_counter++;
+ }
+ else
+ {
+ if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--;
+ }
+ if (d_carrier_lock_fail_counter > MAXIMUM_LOCK_FAIL_COUNTER)
+ {
+ std::cout << "Loss of lock in channel " << d_channel << "!" << std::endl;
+ LOG(INFO) << "Loss of lock in channel " << d_channel << "!";
+ std::unique_ptr cmf(new ControlMessageFactory());
+ if (d_queue != gr::msg_queue::sptr())
+ {
+ d_queue->handle(cmf->GetQueueMessage(d_channel, 2));
+ }
+ d_carrier_lock_fail_counter = 0;
+ d_enable_tracking = false; // TODO: check if disabling tracking is consistent with the channel state machine
+ }
+ }
+ // ########### Output the tracking data to navigation and PVT ##########
+ current_synchro_data.Prompt_I = static_cast((*d_Prompt).real());
+ current_synchro_data.Prompt_Q = static_cast((*d_Prompt).imag());
+
+ // Tracking_timestamp_secs is aligned with the NEXT PRN start sample (Hybridization problem!)
+ //compute remnant code phase samples BEFORE the Tracking timestamp
+ //d_rem_code_phase_samples = K_blk_samples - d_current_prn_length_samples; //rounding error < 1 sample
+ //current_synchro_data.Tracking_timestamp_secs = ((double)d_sample_counter + (double)d_current_prn_length_samples + (double)d_rem_code_phase_samples)/static_cast(d_fs_in);
+
+ // Tracking_timestamp_secs is aligned with the CURRENT PRN start sample (Hybridization OK!, but some glitches??)
+ current_synchro_data.Tracking_timestamp_secs = (static_cast(d_sample_counter) + static_cast(d_rem_code_phase_samples)) / static_cast(d_fs_in);
+ //compute remnant code phase samples AFTER the Tracking timestamp
+ d_rem_code_phase_samples = K_blk_samples - d_current_prn_length_samples; //rounding error < 1 sample
+
+ //current_synchro_data.Tracking_timestamp_secs = ((double)d_sample_counter)/static_cast(d_fs_in);
+ // This tracking block aligns the Tracking_timestamp_secs with the start sample of the PRN, thus, Code_phase_secs=0
+ current_synchro_data.Code_phase_secs = 0;
+ current_synchro_data.Carrier_phase_rads = static_cast(d_acc_carrier_phase_rad);
+ current_synchro_data.Carrier_Doppler_hz = static_cast(d_carrier_doppler_hz);
+ current_synchro_data.CN0_dB_hz = static_cast(d_CN0_SNV_dB_Hz);
+ current_synchro_data.Flag_valid_pseudorange = false;
+ *out[0] = current_synchro_data;
+
+ // ########## DEBUG OUTPUT
+ /*!
+ * \todo The stop timer has to be moved to the signal source!
+ */
+ // debug: Second counter in channel 0
+ if (d_channel == 0)
+ {
+ if (floor(d_sample_counter / d_fs_in) != d_last_seg)
+ {
+ d_last_seg = floor(d_sample_counter / d_fs_in);
+ std::cout << "Current input signal time = " << d_last_seg << " [s]" << std::endl;
+ DLOG(INFO) << "GPS L1 C/A Tracking CH " << d_channel << ": Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN)
+ << ", CN0 = " << d_CN0_SNV_dB_Hz << " [dB-Hz]" << std::endl;
+ //if (d_last_seg==5) d_carrier_lock_fail_counter=500; //DEBUG: force unlock!
+ }
+ }
+ else
+ {
+ if (floor(d_sample_counter / d_fs_in) != d_last_seg)
+ {
+ d_last_seg = floor(d_sample_counter / d_fs_in);
+ DLOG(INFO) << "Tracking CH " << d_channel << ": Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN)
+ << ", CN0 = " << d_CN0_SNV_dB_Hz << " [dB-Hz]";
+ }
+ }
+ }
+ else
+ {
+ // ########## DEBUG OUTPUT (TIME ONLY for channel 0 when tracking is disabled)
+ /*!
+ * \todo The stop timer has to be moved to the signal source!
+ */
+ // stream to collect cout calls to improve thread safety
+ std::stringstream tmp_str_stream;
+ if (floor(d_sample_counter / d_fs_in) != d_last_seg)
+ {
+ d_last_seg = floor(d_sample_counter / d_fs_in);
+
+ if (d_channel == 0)
+ {
+ // debug: Second counter in channel 0
+ tmp_str_stream << "Current input signal time = " << d_last_seg << " [s]" << std::endl << std::flush;
+ std::cout << tmp_str_stream.rdbuf() << std::flush;
+ }
+ }
+ *d_Early = gr_complex(0,0);
+ *d_Prompt = gr_complex(0,0);
+ *d_Late = gr_complex(0,0);
+
+ current_synchro_data.System = {'G'};
+ current_synchro_data.Flag_valid_pseudorange = false;
+ *out[0] = current_synchro_data;
+ }
+
+ if(d_dump)
+ {
+ // MULTIPLEXED FILE RECORDING - Record results to file
+ float prompt_I;
+ float prompt_Q;
+ float tmp_E, tmp_P, tmp_L;
+ float tmp_float;
+ double tmp_double;
+ prompt_I = (*d_Prompt).real();
+ prompt_Q = (*d_Prompt).imag();
+ tmp_E = std::abs(*d_Early);
+ tmp_P = std::abs(*d_Prompt);
+ tmp_L = std::abs(*d_Late);
+ try
+ {
+ // EPR
+ d_dump_file.write(reinterpret_cast(&tmp_E), sizeof(float));
+ d_dump_file.write(reinterpret_cast(&tmp_P), sizeof(float));
+ d_dump_file.write(reinterpret_cast(&tmp_L), sizeof(float));
+ // PROMPT I and Q (to analyze navigation symbols)
+ d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float));
+ d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float));
+ // PRN start sample stamp
+ //tmp_float=(float)d_sample_counter;
+ d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int));
+ // accumulated carrier phase
+ d_dump_file.write(reinterpret_cast(&d_acc_carrier_phase_rad), sizeof(float));
+
+ // carrier and code frequency
+ d_dump_file.write(reinterpret_cast(&d_carrier_doppler_hz), sizeof(float));
+ tmp_float=d_code_freq_chips;
+ d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float));
+
+ //PLL commands
+ d_dump_file.write(reinterpret_cast(&carr_error_hz), sizeof(float));
+ d_dump_file.write(reinterpret_cast(&carr_error_filt_hz), sizeof(float));
+
+ //DLL commands
+ d_dump_file.write(reinterpret_cast(&code_error_chips), sizeof(float));
+ d_dump_file.write(reinterpret_cast(&code_error_filt_chips), sizeof(float));
+
+ // CN0 and carrier lock test
+ d_dump_file.write(reinterpret_cast(&d_CN0_SNV_dB_Hz), sizeof(float));
+ d_dump_file.write(reinterpret_cast(&d_carrier_lock_test), sizeof(float));
+
+ // AUX vars (for debug purposes)
+ tmp_float = d_rem_code_phase_samples;
+ d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float));
+ tmp_double = static_cast(d_sample_counter + d_current_prn_length_samples);
+ d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double));
+ }
+ catch (std::ifstream::failure e)
+ {
+ LOG(WARNING) << "Exception writing trk dump file " << e.what();
+ }
+ }
+
+ consume_each(d_current_prn_length_samples); // this is necessary in gr::block derivates
+ d_sample_counter += d_current_prn_length_samples; //count for the processed samples
+ //LOG(INFO)<<"GPS tracking output end on CH="<d_channel << " SAMPLE STAMP="<(d_channel));
+ d_dump_filename.append(".dat");
+ d_dump_file.exceptions (std::ifstream::failbit | std::ifstream::badbit);
+ d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary);
+ LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl;
+ }
+ catch (std::ifstream::failure e)
+ {
+ LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what() << std::endl;
+ }
+ }
+ }
+}
+
+
+
+void Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::set_channel_queue(concurrent_queue *channel_internal_queue)
+{
+ d_channel_internal_queue = channel_internal_queue;
+}
+
+
+void Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro)
+{
+ d_acquisition_gnss_synchro = p_gnss_synchro;
+}
diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.h b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.h
new file mode 100644
index 000000000..644751ed7
--- /dev/null
+++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.h
@@ -0,0 +1,191 @@
+/*!
+ * \file gps_l1_ca_dll_pll_tracking_gpu_cc.h
+ * \brief Implementation of a code DLL + carrier PLL tracking block, GPU ACCELERATED
+ * \author Javier Arribas, 2015. jarribas(at)cttc.es
+ *
+ * Code DLL + carrier PLL according to the algorithms described in:
+ * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen,
+ * A Software-Defined GPS and Galileo Receiver. A Single-Frequency Approach,
+ * Birkhauser, 2007
+ *
+ * -------------------------------------------------------------------------
+ *
+ * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
+ *
+ * GNSS-SDR is a software defined Global Navigation
+ * Satellite Systems receiver
+ *
+ * This file is part of GNSS-SDR.
+ *
+ * GNSS-SDR is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GNSS-SDR is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNSS-SDR. If not, see .
+ *
+ * -------------------------------------------------------------------------
+ */
+
+#ifndef GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_GPU_CC_H
+#define GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_GPU_CC_H
+
+#include
+#include
+#include