From 6d216fa5a1ed5a006ce91181d23261a662b170ef Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 16 Nov 2017 19:45:15 +0100 Subject: [PATCH 1/4] Add volk_gnsssdr_16ic_conjugate_16ic kernel --- .../volk_gnsssdr_16ic_conjugate_16ic.h | 377 ++++++++++++++++++ .../volk_gnsssdr/lib/kernel_tests.h | 1 + 2 files changed, 378 insertions(+) create mode 100644 src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h new file mode 100644 index 000000000..bf7608413 --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h @@ -0,0 +1,377 @@ +/*! + * \file volk_gnsssdr_16ic_conjugate_16ic.h + * \brief VOLK_GNSSSDR kernel: calculates the conjugate of a 16 bits vector. + * \authors + * + * VOLK_GNSSSDR kernel that calculates the conjugate of a + * 16 bits vector (8 bits the real part and 8 bits the imaginary part) + * + * ------------------------------------------------------------------------- + * + * 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 . + * + * ------------------------------------------------------------------------- + */ + +/*! + * \page volk_gnsssdr_16ic_conjugate_16ic + * + * \b Overview + * + * Takes the conjugate of a complex unsigned char vector. + * + * Dispatcher Prototype + * \code + * void volk_gnsssdr_16ic_conjugate_16ic(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points); + * \endcode + * + * \b Inputs + * \li aVector: Vector of complex items to be conjugated + * \li num_points: The number of complex data points. + * + * \b Outputs + * \li cVector: The vector where the result will be stored + * + */ + +#ifndef INCLUDED_volk_gnsssdr_16ic_conjugate_16ic_H +#define INCLUDED_volk_gnsssdr_16ic_conjugate_16ic_H + +#include + + +//#ifdef LV_HAVE_AVX2 +//#include +// +//static inline void volk_gnsssdr_16ic_conjugate_16ic_u_avx2(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +//{ +// const unsigned int avx2_iters = num_points / 16; +// unsigned int i; +// lv_16sc_t* c = cVector; +// const lv_16sc_t* a = aVector; +// +// __m256i tmp; +// __m256i conjugator = _mm256_setr_epi8(1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1); +// +// for (i = 0; i < avx2_iters; ++i) +// { +// tmp = _mm256_loadu_si256((__m256i*)a); +// tmp = _mm256_sign_epi8(tmp, conjugator); +// _mm256_storeu_si256((__m256i*)c, tmp); +// +// a += 16; +// c += 16; +// } +// +// for (i = avx2_iters * 16; i < num_points; ++i) +// { +// *c++ = lv_conj(*a++); +// } +//} +//#endif /* LV_HAVE_AVX2 */ + + +//#ifdef LV_HAVE_AVX +//#include +//static inline void volk_gnsssdr_16ic_conjugate_16ic_u_avx(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +//{ +// const unsigned int sse_iters = num_points / 8; +// unsigned int i; +// lv_16sc_t* c = cVector; +// const lv_16sc_t* a = aVector; +// +// __m256i tmp; +// //__m128i tmp128lo, tmp128hi; +// //__m256 conjugator1 = _mm256_castsi256_ps(_mm256_setr_epi16(0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF)); +// //__m128i conjugator2 = _mm_setr_epi16(0, -1, 0, -1, 0, -1, 0, -1); +// __m256i conjugator = _mm256_setr_ps(0, -1, 0, -1, 0, -1, 0, -1); +// +// for (i = 0; i < sse_iters; ++i) +// { +// tmp = _mm256_loadu_si256((__m256i*)a); +// tmp = _mm256_xor_si256(tmp, conjugator); +// //tmp128lo = _mm256_castsi256_si128(_mm256_castps_si256(tmp)); +// //tmp128lo = _mm_add_epi16(tmp128lo, conjugator2); +// //tmp128hi = _mm256_extractf128_si256(_mm256_castps_si256(tmp),1); +// //tmp128hi = _mm_add_epi16(tmp128hi, conjugator2); +// //tmp = _mm256_set_m128i(tmp128hi , tmp128lo); //not defined in some versions of immintrin.h +// //tmp = _mm256_castsi256_ps(_mm256_insertf128_si256(_mm256_castsi128_si256(tmp128lo),(tmp128hi),1)); +// _mm256_storeu_si256((__m256i*)c, tmp); +// +// a += 8; +// c += 8; +// } +// +// for (i = sse_iters * 8; i < num_points; ++i) +// { +// *c++ = lv_conj(*a++); +// } +//} +//#endif /* LV_HAVE_AVX */ + + +#ifdef LV_HAVE_SSSE3 +#include + +static inline void volk_gnsssdr_16ic_conjugate_16ic_u_ssse3(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +{ + const unsigned int sse_iters = num_points / 4; + unsigned int i; + lv_16sc_t* c = cVector; + const lv_16sc_t* a = aVector; + __m128i tmp; + + __m128i conjugator = _mm_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1); + + for (i = 0; i < sse_iters; ++i) + { + tmp = _mm_lddqu_si128((__m128i*)a); + tmp = _mm_sign_epi16(tmp, conjugator); + _mm_storeu_si128((__m128i*)c, tmp); + a += 4; + c += 4; + } + + for (i = sse_iters * 4; i < num_points; ++i) + { + *c++ = lv_conj(*a++); + } +} + +#endif /* LV_HAVE_SSSE3 */ +// +// +//#ifdef LV_HAVE_SSE3 +//#include +// +//static inline void volk_gnsssdr_16ic_conjugate_16ic_u_sse3(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +//{ +// const unsigned int sse_iters = num_points / 8; +// unsigned int i; +// lv_16sc_t* c = cVector; +// const lv_16sc_t* a = aVector; +// __m128i tmp; +// +// __m128i conjugator1 = _mm_setr_epi8(0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF); +// __m128i conjugator2 = _mm_setr_epi8(0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1); +// +// for (i = 0; i < sse_iters; ++i) +// { +// tmp = _mm_lddqu_si128((__m128i*)a); +// tmp = _mm_xor_si128(tmp, conjugator1); +// tmp = _mm_add_epi8(tmp, conjugator2); +// _mm_storeu_si128((__m128i*)c, tmp); +// a += 8; +// c += 8; +// } +// +// for (i = sse_iters * 8; i < num_points; ++i) +// { +// *c++ = lv_conj(*a++); +// } +// +//} +//#endif /* LV_HAVE_SSE3 */ + + +#ifdef LV_HAVE_GENERIC + +static inline void volk_gnsssdr_16ic_conjugate_16ic_generic(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +{ + lv_16sc_t* cPtr = cVector; + const lv_16sc_t* aPtr = aVector; + unsigned int number; + + for(number = 0; number < num_points; number++) + { + *cPtr++ = lv_conj(*aPtr++); + } +} +#endif /* LV_HAVE_GENERIC */ + + +//#ifdef LV_HAVE_AVX +//#include +// +//static inline void volk_gnsssdr_16ic_conjugate_16ic_a_avx(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +//{ +// const unsigned int sse_iters = num_points / 16; +// unsigned int i; +// lv_16sc_t* c = cVector; +// const lv_16sc_t* a = aVector; +// +// __m256 tmp; +// __m128i tmp128lo, tmp128hi; +// __m256 conjugator1 = _mm256_castsi256_ps(_mm256_setr_epi8(0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF)); +// __m128i conjugator2 = _mm_setr_epi8(0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1); +// +// for (i = 0; i < sse_iters; ++i) +// { +// tmp = _mm256_load_ps((float*)a); +// tmp = _mm256_xor_ps(tmp, conjugator1); +// tmp128lo = _mm256_castsi256_si128(_mm256_castps_si256(tmp)); +// tmp128lo = _mm_add_epi8(tmp128lo, conjugator2); +// tmp128hi = _mm256_extractf128_si256(_mm256_castps_si256(tmp),1); +// tmp128hi = _mm_add_epi8(tmp128hi, conjugator2); +// //tmp = _mm256_set_m128i(tmp128hi , tmp128lo); //not defined in some versions of immintrin.h +// tmp = _mm256_castsi256_ps(_mm256_insertf128_si256(_mm256_castsi128_si256(tmp128lo),(tmp128hi),1)); +// _mm256_store_ps((float*)c, tmp); +// +// a += 16; +// c += 16; +// } +// +// for (i = sse_iters * 16; i < num_points; ++i) +// { +// *c++ = lv_conj(*a++); +// } +//} +//#endif /* LV_HAVE_AVX */ +// +// +//#ifdef LV_HAVE_AVX2 +//#include +// +//static inline void volk_gnsssdr_16ic_conjugate_16ic_a_avx2(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +//{ +// const unsigned int avx2_iters = num_points / 16; +// unsigned int i; +// lv_16sc_t* c = cVector; +// const lv_16sc_t* a = aVector; +// +// __m256i tmp; +// __m256i conjugator = _mm256_setr_epi8(1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1); +// +// for (i = 0; i < avx2_iters; ++i) +// { +// tmp = _mm256_load_si256((__m256i*)a); +// tmp = _mm256_sign_epi8(tmp, conjugator); +// _mm256_store_si256((__m256i*)c, tmp); +// +// a += 16; +// c += 16; +// } +// +// for (i = avx2_iters * 16; i < num_points; ++i) +// { +// *c++ = lv_conj(*a++); +// } +//} +//#endif /* LV_HAVE_AVX2 */ +// +// +#ifdef LV_HAVE_SSSE3 +#include + +static inline void volk_gnsssdr_16ic_conjugate_16ic_a_ssse3(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +{ + const unsigned int sse_iters = num_points / 4; + unsigned int i; + lv_16sc_t* c = cVector; + const lv_16sc_t* a = aVector; + __m128i tmp; + __m128i conjugator = _mm_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1); + + for (i = 0; i < sse_iters; ++i) + { + tmp = _mm_load_si128((__m128i*)a); + tmp = _mm_sign_epi16(tmp, conjugator); + _mm_store_si128((__m128i*)c, tmp); + a += 4; + c += 4; + } + + for (i = sse_iters * 4; i < num_points; ++i) + { + *c++ = lv_conj(*a++); + } +} + +#endif /* LV_HAVE_SSSE3 */ +// +// +//#ifdef LV_HAVE_SSE3 +//#include +// +//static inline void volk_gnsssdr_16ic_conjugate_16ic_a_sse3(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +//{ +// const unsigned int sse_iters = num_points / 8; +// unsigned int i; +// lv_16sc_t* c = cVector; +// const lv_16sc_t* a = aVector; +// __m128i tmp; +// +// __m128i conjugator1 = _mm_setr_epi8(0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF); +// __m128i conjugator2 = _mm_setr_epi8(0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1); +// +// for (i = 0; i < sse_iters; ++i) +// { +// tmp = _mm_load_si128((__m128i*)a); +// tmp = _mm_xor_si128(tmp, conjugator1); +// tmp = _mm_add_epi8(tmp, conjugator2); +// _mm_store_si128((__m128i*)c, tmp); +// a += 8; +// c += 8; +// } +// +// for (i = sse_iters * 8; i < num_points; ++i) +// { +// *c++ = lv_conj(*a++); +// } +// +//} +//#endif /* LV_HAVE_SSE3 */ +// +// +// +// +//#ifdef LV_HAVE_NEON +//#include +// +//static inline void volk_gnsssdr_16ic_conjugate_16ic_neon(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +//{ +// const unsigned int sse_iters = num_points / 4; +// unsigned int i; +// lv_16sc_t* c = cVector; +// const lv_16sc_t* a = aVector; +// int16x4x2_t a_val; +// +// for (i = 0; i < sse_iters; ++i) +// { +// a_val = vld2_s16((const int16_t*)a); +// __VOLK_GNSSSDR_PREFETCH(a + 16); +// a_val.val[1] = vneg_s16(a_val.val[1]); +// vst2_s16((int16_t*)c, a_val); +// a += 4; +// c += 4; +// } +// +// for (i = sse_iters * 4; i < num_points; ++i) +// { +// *c++ = lv_conj(*a++); +// } +//} +//#endif /* LV_HAVE_NEON */ + +#endif /* INCLUDED_volk_gnsssdr_16ic_conjugate_16ic_H */ + diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/kernel_tests.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/kernel_tests.h index da0b2f0f8..e7fa4e62b 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/kernel_tests.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/kernel_tests.h @@ -84,6 +84,7 @@ std::vector init_test_list(volk_gnsssdr_test_params_t (VOLK_INIT_TEST(volk_gnsssdr_16ic_x2_dot_prod_16ic, test_params)) (VOLK_INIT_TEST(volk_gnsssdr_16ic_x2_multiply_16ic, test_params_more_iters)) (VOLK_INIT_TEST(volk_gnsssdr_16ic_convert_32fc, test_params_more_iters)) + (VOLK_INIT_TEST(volk_gnsssdr_16ic_conjugate_16ic, test_params_more_iters)) (VOLK_INIT_PUPP(volk_gnsssdr_s32f_sincospuppet_32fc, volk_gnsssdr_s32f_sincos_32fc, test_params_inacc2)) (VOLK_INIT_PUPP(volk_gnsssdr_16ic_rotatorpuppet_16ic, volk_gnsssdr_16ic_s32fc_x2_rotator_16ic, test_params_int1)) (VOLK_INIT_PUPP(volk_gnsssdr_16ic_resamplerfastpuppet_16ic, volk_gnsssdr_16ic_resampler_fast_16ic, test_params)) From eecfa6c582c744aaf97e3090e179c8a1916b4bfb Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 16 Nov 2017 19:51:15 +0100 Subject: [PATCH 2/4] Add AVX2 --- .../volk_gnsssdr_16ic_conjugate_16ic.h | 117 +++++++++--------- 1 file changed, 59 insertions(+), 58 deletions(-) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h index bf7608413..8745b40d3 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h @@ -60,35 +60,35 @@ #include -//#ifdef LV_HAVE_AVX2 -//#include -// -//static inline void volk_gnsssdr_16ic_conjugate_16ic_u_avx2(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) -//{ -// const unsigned int avx2_iters = num_points / 16; -// unsigned int i; -// lv_16sc_t* c = cVector; -// const lv_16sc_t* a = aVector; -// -// __m256i tmp; -// __m256i conjugator = _mm256_setr_epi8(1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1); -// -// for (i = 0; i < avx2_iters; ++i) -// { -// tmp = _mm256_loadu_si256((__m256i*)a); -// tmp = _mm256_sign_epi8(tmp, conjugator); -// _mm256_storeu_si256((__m256i*)c, tmp); -// -// a += 16; -// c += 16; -// } -// -// for (i = avx2_iters * 16; i < num_points; ++i) -// { -// *c++ = lv_conj(*a++); -// } -//} -//#endif /* LV_HAVE_AVX2 */ +#ifdef LV_HAVE_AVX2 +#include + +static inline void volk_gnsssdr_16ic_conjugate_16ic_u_avx2(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +{ + const unsigned int avx2_iters = num_points / 8; + unsigned int i; + lv_16sc_t* c = cVector; + const lv_16sc_t* a = aVector; + + __m256i tmp; + __m256i conjugator = _mm256_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1); + + for (i = 0; i < avx2_iters; ++i) + { + tmp = _mm256_loadu_si256((__m256i*)a); + tmp = _mm256_sign_epi16(tmp, conjugator); + _mm256_storeu_si256((__m256i*)c, tmp); + + a += 8; + c += 8; + } + + for (i = avx2_iters * 8; i < num_points; ++i) + { + *c++ = lv_conj(*a++); + } +} +#endif /* LV_HAVE_AVX2 */ //#ifdef LV_HAVE_AVX @@ -249,35 +249,36 @@ static inline void volk_gnsssdr_16ic_conjugate_16ic_generic(lv_16sc_t* cVector, //#endif /* LV_HAVE_AVX */ // // -//#ifdef LV_HAVE_AVX2 -//#include -// -//static inline void volk_gnsssdr_16ic_conjugate_16ic_a_avx2(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) -//{ -// const unsigned int avx2_iters = num_points / 16; -// unsigned int i; -// lv_16sc_t* c = cVector; -// const lv_16sc_t* a = aVector; -// -// __m256i tmp; -// __m256i conjugator = _mm256_setr_epi8(1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1); -// -// for (i = 0; i < avx2_iters; ++i) -// { -// tmp = _mm256_load_si256((__m256i*)a); -// tmp = _mm256_sign_epi8(tmp, conjugator); -// _mm256_store_si256((__m256i*)c, tmp); -// -// a += 16; -// c += 16; -// } -// -// for (i = avx2_iters * 16; i < num_points; ++i) -// { -// *c++ = lv_conj(*a++); -// } -//} -//#endif /* LV_HAVE_AVX2 */ +#ifdef LV_HAVE_AVX2 +#include + +static inline void volk_gnsssdr_16ic_conjugate_16ic_a_avx2(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +{ + const unsigned int avx2_iters = num_points / 8; + unsigned int i; + lv_16sc_t* c = cVector; + const lv_16sc_t* a = aVector; + + __m256i tmp; + __m256i conjugator = _mm256_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1); + + for (i = 0; i < avx2_iters; ++i) + { + tmp = _mm256_load_si256((__m256i*)a); + tmp = _mm256_sign_epi16(tmp, conjugator); + _mm256_store_si256((__m256i*)c, tmp); + + a += 8; + c += 8; + } + + for (i = avx2_iters * 8; i < num_points; ++i) + { + *c++ = lv_conj(*a++); + } +} + +#endif /* LV_HAVE_AVX2 */ // // #ifdef LV_HAVE_SSSE3 From fe241c8b2d8375ba40771d4b1bba75e9247bab67 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 16 Nov 2017 20:54:04 +0100 Subject: [PATCH 3/4] clean kernel --- .../volk_gnsssdr_16ic_conjugate_16ic.h | 376 ++++++------------ 1 file changed, 116 insertions(+), 260 deletions(-) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h index 8745b40d3..5aae17266 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h @@ -1,16 +1,16 @@ /*! * \file volk_gnsssdr_16ic_conjugate_16ic.h - * \brief VOLK_GNSSSDR kernel: calculates the conjugate of a 16 bits vector. + * \brief VOLK_GNSSSDR kernel: returns the conjugate of a 16 bits complex vector. * \authors
    - *
  • Andres Cecilia, 2014. a.cecilia.luque(at)gmail.com + *
  • Carles Fernandez Prades 2017 cfernandez at cttc dot cat *
* * VOLK_GNSSSDR kernel that calculates the conjugate of a - * 16 bits vector (8 bits the real part and 8 bits the imaginary part) + * 16 bits complex vector (16 bits the real part and 16 bits the imaginary part) * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -38,7 +38,7 @@ * * \b Overview * - * Takes the conjugate of a complex unsigned char vector. + * Takes the conjugate of a complex signed 16-bit integer vector. * * Dispatcher Prototype * \code @@ -60,6 +60,116 @@ #include +#ifdef LV_HAVE_GENERIC + +static inline void volk_gnsssdr_16ic_conjugate_16ic_generic(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +{ + lv_16sc_t* cPtr = cVector; + const lv_16sc_t* aPtr = aVector; + unsigned int number; + + for(number = 0; number < num_points; number++) + { + *cPtr++ = lv_conj(*aPtr++); + } +} + +#endif /* LV_HAVE_GENERIC */ + + +#ifdef LV_HAVE_SSSE3 +#include + +static inline void volk_gnsssdr_16ic_conjugate_16ic_u_ssse3(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +{ + const unsigned int sse_iters = num_points / 4; + unsigned int i; + lv_16sc_t* c = cVector; + const lv_16sc_t* a = aVector; + __m128i tmp; + + __m128i conjugator = _mm_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1); + + for (i = 0; i < sse_iters; ++i) + { + tmp = _mm_lddqu_si128((__m128i*)a); + tmp = _mm_sign_epi16(tmp, conjugator); + _mm_storeu_si128((__m128i*)c, tmp); + a += 4; + c += 4; + } + + for (i = sse_iters * 4; i < num_points; ++i) + { + *c++ = lv_conj(*a++); + } +} + +#endif /* LV_HAVE_SSSE3 */ + + +#ifdef LV_HAVE_SSSE3 +#include + +static inline void volk_gnsssdr_16ic_conjugate_16ic_a_ssse3(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +{ + const unsigned int sse_iters = num_points / 4; + unsigned int i; + lv_16sc_t* c = cVector; + const lv_16sc_t* a = aVector; + __m128i tmp; + __m128i conjugator = _mm_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1); + + for (i = 0; i < sse_iters; ++i) + { + tmp = _mm_load_si128((__m128i*)a); + tmp = _mm_sign_epi16(tmp, conjugator); + _mm_store_si128((__m128i*)c, tmp); + a += 4; + c += 4; + } + + for (i = sse_iters * 4; i < num_points; ++i) + { + *c++ = lv_conj(*a++); + } +} + +#endif /* LV_HAVE_SSSE3 */ + + +#ifdef LV_HAVE_AVX2 +#include + +static inline void volk_gnsssdr_16ic_conjugate_16ic_a_avx2(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +{ + const unsigned int avx2_iters = num_points / 8; + unsigned int i; + lv_16sc_t* c = cVector; + const lv_16sc_t* a = aVector; + + __m256i tmp; + __m256i conjugator = _mm256_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1); + + for (i = 0; i < avx2_iters; ++i) + { + tmp = _mm256_load_si256((__m256i*)a); + tmp = _mm256_sign_epi16(tmp, conjugator); + _mm256_store_si256((__m256i*)c, tmp); + + a += 8; + c += 8; + } + + for (i = avx2_iters * 8; i < num_points; ++i) + { + *c++ = lv_conj(*a++); + } +} + +#endif /* LV_HAVE_AVX2 */ + + #ifdef LV_HAVE_AVX2 #include @@ -90,260 +200,6 @@ static inline void volk_gnsssdr_16ic_conjugate_16ic_u_avx2(lv_16sc_t* cVector, c } #endif /* LV_HAVE_AVX2 */ - -//#ifdef LV_HAVE_AVX -//#include -//static inline void volk_gnsssdr_16ic_conjugate_16ic_u_avx(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) -//{ -// const unsigned int sse_iters = num_points / 8; -// unsigned int i; -// lv_16sc_t* c = cVector; -// const lv_16sc_t* a = aVector; -// -// __m256i tmp; -// //__m128i tmp128lo, tmp128hi; -// //__m256 conjugator1 = _mm256_castsi256_ps(_mm256_setr_epi16(0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF)); -// //__m128i conjugator2 = _mm_setr_epi16(0, -1, 0, -1, 0, -1, 0, -1); -// __m256i conjugator = _mm256_setr_ps(0, -1, 0, -1, 0, -1, 0, -1); -// -// for (i = 0; i < sse_iters; ++i) -// { -// tmp = _mm256_loadu_si256((__m256i*)a); -// tmp = _mm256_xor_si256(tmp, conjugator); -// //tmp128lo = _mm256_castsi256_si128(_mm256_castps_si256(tmp)); -// //tmp128lo = _mm_add_epi16(tmp128lo, conjugator2); -// //tmp128hi = _mm256_extractf128_si256(_mm256_castps_si256(tmp),1); -// //tmp128hi = _mm_add_epi16(tmp128hi, conjugator2); -// //tmp = _mm256_set_m128i(tmp128hi , tmp128lo); //not defined in some versions of immintrin.h -// //tmp = _mm256_castsi256_ps(_mm256_insertf128_si256(_mm256_castsi128_si256(tmp128lo),(tmp128hi),1)); -// _mm256_storeu_si256((__m256i*)c, tmp); -// -// a += 8; -// c += 8; -// } -// -// for (i = sse_iters * 8; i < num_points; ++i) -// { -// *c++ = lv_conj(*a++); -// } -//} -//#endif /* LV_HAVE_AVX */ - - -#ifdef LV_HAVE_SSSE3 -#include - -static inline void volk_gnsssdr_16ic_conjugate_16ic_u_ssse3(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) -{ - const unsigned int sse_iters = num_points / 4; - unsigned int i; - lv_16sc_t* c = cVector; - const lv_16sc_t* a = aVector; - __m128i tmp; - - __m128i conjugator = _mm_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1); - - for (i = 0; i < sse_iters; ++i) - { - tmp = _mm_lddqu_si128((__m128i*)a); - tmp = _mm_sign_epi16(tmp, conjugator); - _mm_storeu_si128((__m128i*)c, tmp); - a += 4; - c += 4; - } - - for (i = sse_iters * 4; i < num_points; ++i) - { - *c++ = lv_conj(*a++); - } -} - -#endif /* LV_HAVE_SSSE3 */ -// -// -//#ifdef LV_HAVE_SSE3 -//#include -// -//static inline void volk_gnsssdr_16ic_conjugate_16ic_u_sse3(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) -//{ -// const unsigned int sse_iters = num_points / 8; -// unsigned int i; -// lv_16sc_t* c = cVector; -// const lv_16sc_t* a = aVector; -// __m128i tmp; -// -// __m128i conjugator1 = _mm_setr_epi8(0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF); -// __m128i conjugator2 = _mm_setr_epi8(0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1); -// -// for (i = 0; i < sse_iters; ++i) -// { -// tmp = _mm_lddqu_si128((__m128i*)a); -// tmp = _mm_xor_si128(tmp, conjugator1); -// tmp = _mm_add_epi8(tmp, conjugator2); -// _mm_storeu_si128((__m128i*)c, tmp); -// a += 8; -// c += 8; -// } -// -// for (i = sse_iters * 8; i < num_points; ++i) -// { -// *c++ = lv_conj(*a++); -// } -// -//} -//#endif /* LV_HAVE_SSE3 */ - - -#ifdef LV_HAVE_GENERIC - -static inline void volk_gnsssdr_16ic_conjugate_16ic_generic(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) -{ - lv_16sc_t* cPtr = cVector; - const lv_16sc_t* aPtr = aVector; - unsigned int number; - - for(number = 0; number < num_points; number++) - { - *cPtr++ = lv_conj(*aPtr++); - } -} -#endif /* LV_HAVE_GENERIC */ - - -//#ifdef LV_HAVE_AVX -//#include -// -//static inline void volk_gnsssdr_16ic_conjugate_16ic_a_avx(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) -//{ -// const unsigned int sse_iters = num_points / 16; -// unsigned int i; -// lv_16sc_t* c = cVector; -// const lv_16sc_t* a = aVector; -// -// __m256 tmp; -// __m128i tmp128lo, tmp128hi; -// __m256 conjugator1 = _mm256_castsi256_ps(_mm256_setr_epi8(0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF)); -// __m128i conjugator2 = _mm_setr_epi8(0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1); -// -// for (i = 0; i < sse_iters; ++i) -// { -// tmp = _mm256_load_ps((float*)a); -// tmp = _mm256_xor_ps(tmp, conjugator1); -// tmp128lo = _mm256_castsi256_si128(_mm256_castps_si256(tmp)); -// tmp128lo = _mm_add_epi8(tmp128lo, conjugator2); -// tmp128hi = _mm256_extractf128_si256(_mm256_castps_si256(tmp),1); -// tmp128hi = _mm_add_epi8(tmp128hi, conjugator2); -// //tmp = _mm256_set_m128i(tmp128hi , tmp128lo); //not defined in some versions of immintrin.h -// tmp = _mm256_castsi256_ps(_mm256_insertf128_si256(_mm256_castsi128_si256(tmp128lo),(tmp128hi),1)); -// _mm256_store_ps((float*)c, tmp); -// -// a += 16; -// c += 16; -// } -// -// for (i = sse_iters * 16; i < num_points; ++i) -// { -// *c++ = lv_conj(*a++); -// } -//} -//#endif /* LV_HAVE_AVX */ -// -// -#ifdef LV_HAVE_AVX2 -#include - -static inline void volk_gnsssdr_16ic_conjugate_16ic_a_avx2(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) -{ - const unsigned int avx2_iters = num_points / 8; - unsigned int i; - lv_16sc_t* c = cVector; - const lv_16sc_t* a = aVector; - - __m256i tmp; - __m256i conjugator = _mm256_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1); - - for (i = 0; i < avx2_iters; ++i) - { - tmp = _mm256_load_si256((__m256i*)a); - tmp = _mm256_sign_epi16(tmp, conjugator); - _mm256_store_si256((__m256i*)c, tmp); - - a += 8; - c += 8; - } - - for (i = avx2_iters * 8; i < num_points; ++i) - { - *c++ = lv_conj(*a++); - } -} - -#endif /* LV_HAVE_AVX2 */ -// -// -#ifdef LV_HAVE_SSSE3 -#include - -static inline void volk_gnsssdr_16ic_conjugate_16ic_a_ssse3(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) -{ - const unsigned int sse_iters = num_points / 4; - unsigned int i; - lv_16sc_t* c = cVector; - const lv_16sc_t* a = aVector; - __m128i tmp; - __m128i conjugator = _mm_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1); - - for (i = 0; i < sse_iters; ++i) - { - tmp = _mm_load_si128((__m128i*)a); - tmp = _mm_sign_epi16(tmp, conjugator); - _mm_store_si128((__m128i*)c, tmp); - a += 4; - c += 4; - } - - for (i = sse_iters * 4; i < num_points; ++i) - { - *c++ = lv_conj(*a++); - } -} - -#endif /* LV_HAVE_SSSE3 */ -// -// -//#ifdef LV_HAVE_SSE3 -//#include -// -//static inline void volk_gnsssdr_16ic_conjugate_16ic_a_sse3(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) -//{ -// const unsigned int sse_iters = num_points / 8; -// unsigned int i; -// lv_16sc_t* c = cVector; -// const lv_16sc_t* a = aVector; -// __m128i tmp; -// -// __m128i conjugator1 = _mm_setr_epi8(0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF); -// __m128i conjugator2 = _mm_setr_epi8(0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1); -// -// for (i = 0; i < sse_iters; ++i) -// { -// tmp = _mm_load_si128((__m128i*)a); -// tmp = _mm_xor_si128(tmp, conjugator1); -// tmp = _mm_add_epi8(tmp, conjugator2); -// _mm_store_si128((__m128i*)c, tmp); -// a += 8; -// c += 8; -// } -// -// for (i = sse_iters * 8; i < num_points; ++i) -// { -// *c++ = lv_conj(*a++); -// } -// -//} -//#endif /* LV_HAVE_SSE3 */ -// -// // // //#ifdef LV_HAVE_NEON @@ -360,7 +216,7 @@ static inline void volk_gnsssdr_16ic_conjugate_16ic_a_ssse3(lv_16sc_t* cVector, // for (i = 0; i < sse_iters; ++i) // { // a_val = vld2_s16((const int16_t*)a); -// __VOLK_GNSSSDR_PREFETCH(a + 16); +// __VOLK_GNSSSDR_PREFETCH(a + 4); // a_val.val[1] = vneg_s16(a_val.val[1]); // vst2_s16((int16_t*)c, a_val); // a += 4; From d20902d6883310a39cd1fe77c7b95b7e40bee4ed Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 17 Nov 2017 09:21:03 +0100 Subject: [PATCH 4/4] Add mechanisms for inverted spectrum --- .../data_type_adapter/adapters/CMakeLists.txt | 1 + .../adapters/ibyte_to_cbyte.cc | 55 +++++++++++++++-- .../adapters/ibyte_to_cbyte.h | 3 + .../adapters/ibyte_to_complex.cc | 56 +++++++++++++++--- .../adapters/ibyte_to_complex.h | 5 +- .../adapters/ibyte_to_cshort.cc | 52 +++++++++++++--- .../adapters/ibyte_to_cshort.h | 3 + .../adapters/ishort_to_complex.cc | 54 ++++++++++++++--- .../adapters/ishort_to_complex.h | 3 + .../adapters/ishort_to_cshort.cc | 54 ++++++++++++++--- .../adapters/ishort_to_cshort.h | 3 + src/algorithms/libs/CMakeLists.txt | 3 + src/algorithms/libs/conjugate_cc.cc | 29 +++++++++ src/algorithms/libs/conjugate_cc.h | 59 +++++++++++++++++++ src/algorithms/libs/conjugate_ic.cc | 29 +++++++++ src/algorithms/libs/conjugate_ic.h | 59 +++++++++++++++++++ src/algorithms/libs/conjugate_sc.cc | 29 +++++++++ src/algorithms/libs/conjugate_sc.h | 59 +++++++++++++++++++ src/algorithms/libs/pass_through.cc | 57 +++++++++++++++++- src/algorithms/libs/pass_through.h | 14 +++-- .../adapter/pass_through_test.cc | 3 - 21 files changed, 583 insertions(+), 47 deletions(-) create mode 100644 src/algorithms/libs/conjugate_cc.cc create mode 100644 src/algorithms/libs/conjugate_cc.h create mode 100644 src/algorithms/libs/conjugate_ic.cc create mode 100644 src/algorithms/libs/conjugate_ic.h create mode 100644 src/algorithms/libs/conjugate_sc.cc create mode 100644 src/algorithms/libs/conjugate_sc.h diff --git a/src/algorithms/data_type_adapter/adapters/CMakeLists.txt b/src/algorithms/data_type_adapter/adapters/CMakeLists.txt index a88ffd3e9..d18c83b04 100644 --- a/src/algorithms/data_type_adapter/adapters/CMakeLists.txt +++ b/src/algorithms/data_type_adapter/adapters/CMakeLists.txt @@ -31,6 +31,7 @@ include_directories( ${CMAKE_SOURCE_DIR}/src/core/system_parameters ${CMAKE_SOURCE_DIR}/src/core/interfaces ${CMAKE_SOURCE_DIR}/src/algorithms/data_type_adapter/gnuradio_blocks + ${CMAKE_SOURCE_DIR}/src/algorithms/libs ${GLOG_INCLUDE_DIRS} ${GFlags_INCLUDE_DIRS} ${GNURADIO_RUNTIME_INCLUDE_DIRS} diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.cc b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.cc index 8dc47c8ad..e91455a23 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.cc +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.cc @@ -51,6 +51,7 @@ IbyteToCbyte::IbyteToCbyte(ConfigurationInterface* configuration, std::string ro dump_ = config_->property(role_ + ".dump", false); dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename); + inverted_spectrum = configuration->property(role + ".inverted_spectrum", false); size_t item_size = sizeof(lv_8sc_t); @@ -63,6 +64,10 @@ IbyteToCbyte::IbyteToCbyte(ConfigurationInterface* configuration, std::string ro DLOG(INFO) << "Dumping output into file " << dump_filename_; file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str()); } + if(inverted_spectrum) + { + conjugate_ic_ = make_conjugate_ic(); + } } @@ -74,7 +79,26 @@ void IbyteToCbyte::connect(gr::top_block_sptr top_block) { if (dump_) { - top_block->connect(ibyte_to_cbyte_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->connect(ibyte_to_cbyte_, 0, conjugate_ic_, 0); + top_block->connect(conjugate_ic_, 0, file_sink_, 0); + } + else + { + top_block->connect(ibyte_to_cbyte_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->connect(ibyte_to_cbyte_, 0, conjugate_ic_, 0); + } + else + { + DLOG(INFO) << "Nothing to connect internally"; + } } } @@ -83,21 +107,40 @@ void IbyteToCbyte::disconnect(gr::top_block_sptr top_block) { if (dump_) { - top_block->disconnect(ibyte_to_cbyte_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->disconnect(ibyte_to_cbyte_, 0, conjugate_ic_, 0); + top_block->disconnect(conjugate_ic_, 0, file_sink_, 0); + } + else + { + top_block->disconnect(ibyte_to_cbyte_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->disconnect(ibyte_to_cbyte_, 0, conjugate_ic_, 0); + } } } - gr::basic_block_sptr IbyteToCbyte::get_left_block() { return ibyte_to_cbyte_; } - gr::basic_block_sptr IbyteToCbyte::get_right_block() { - return ibyte_to_cbyte_; + if(inverted_spectrum) + { + return conjugate_ic_; + } + else + { + return ibyte_to_cbyte_; + } } - diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h index 2aa0d1197..c40d85286 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h @@ -34,6 +34,7 @@ #include #include +#include "conjugate_ic.h" #include "gnss_block_interface.h" #include "interleaved_byte_to_complex_byte.h" @@ -85,6 +86,8 @@ private: unsigned int in_streams_; unsigned int out_streams_; gr::blocks::file_sink::sptr file_sink_; + conjugate_ic_sptr conjugate_ic_; + bool inverted_spectrum; }; #endif diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.cc b/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.cc index 6119ebd9f..83b6fd6c5 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.cc +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.cc @@ -49,6 +49,7 @@ IbyteToComplex::IbyteToComplex(ConfigurationInterface* configuration, std::strin dump_ = config_->property(role_ + ".dump", false); dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename); + inverted_spectrum = configuration->property(role + ".inverted_spectrum", false); size_t item_size = sizeof(gr_complex); @@ -56,6 +57,10 @@ IbyteToComplex::IbyteToComplex(ConfigurationInterface* configuration, std::strin DLOG(INFO) << "data_type_adapter_(" << gr_interleaved_char_to_complex_->unique_id() << ")"; + if (inverted_spectrum) + { + conjugate_cc_ = make_conjugate_cc(); + } if (dump_) { DLOG(INFO) << "Dumping output into file " << dump_filename_; @@ -72,7 +77,26 @@ void IbyteToComplex::connect(gr::top_block_sptr top_block) { if (dump_) { - top_block->connect(gr_interleaved_char_to_complex_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->connect(gr_interleaved_char_to_complex_, 0, conjugate_cc_, 0); + top_block->connect(conjugate_cc_, 0, file_sink_, 0); + } + else + { + top_block->connect(gr_interleaved_char_to_complex_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->connect(gr_interleaved_char_to_complex_, 0, conjugate_cc_, 0); + } + else + { + DLOG(INFO) << "Nothing to connect internally"; + } } } @@ -81,22 +105,40 @@ void IbyteToComplex::disconnect(gr::top_block_sptr top_block) { if (dump_) { - top_block->disconnect(gr_interleaved_char_to_complex_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->disconnect(gr_interleaved_char_to_complex_, 0, conjugate_cc_, 0); + top_block->disconnect(conjugate_cc_, 0, file_sink_, 0); + } + else + { + top_block->disconnect(gr_interleaved_char_to_complex_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->disconnect(gr_interleaved_char_to_complex_, 0, conjugate_cc_, 0); + } } } - gr::basic_block_sptr IbyteToComplex::get_left_block() { return gr_interleaved_char_to_complex_; } - gr::basic_block_sptr IbyteToComplex::get_right_block() { - return gr_interleaved_char_to_complex_; + if(inverted_spectrum) + { + return conjugate_cc_; + } + else + { + return gr_interleaved_char_to_complex_; + } } - - diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.h b/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.h index 50b38f37e..3c379d7ba 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.h +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.h @@ -34,8 +34,9 @@ #include #include #include -#include "gnss_synchro.h" +#include "conjugate_cc.h" #include "gnss_block_interface.h" +#include "gnss_synchro.h" class ConfigurationInterface; @@ -85,6 +86,8 @@ private: unsigned int in_streams_; unsigned int out_streams_; gr::blocks::file_sink::sptr file_sink_; + conjugate_cc_sptr conjugate_cc_; + bool inverted_spectrum; }; #endif diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.cc b/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.cc index 206f824cc..59ac82042 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.cc +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.cc @@ -51,6 +51,7 @@ IbyteToCshort::IbyteToCshort(ConfigurationInterface* configuration, std::string dump_ = config_->property(role_ + ".dump", false); dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename); + inverted_spectrum = configuration->property(role + ".inverted_spectrum", false); size_t item_size = sizeof(lv_16sc_t); @@ -63,6 +64,10 @@ IbyteToCshort::IbyteToCshort(ConfigurationInterface* configuration, std::string DLOG(INFO) << "Dumping output into file " << dump_filename_; file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str()); } + if(inverted_spectrum) + { + conjugate_sc_ = make_conjugate_sc(); + } } @@ -74,7 +79,22 @@ void IbyteToCshort::connect(gr::top_block_sptr top_block) { if (dump_) { - top_block->connect(interleaved_byte_to_complex_short_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->connect(interleaved_byte_to_complex_short_, 0, conjugate_sc_, 0); + top_block->connect(conjugate_sc_, 0, file_sink_, 0); + } + else + { + top_block->connect(interleaved_byte_to_complex_short_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->connect(interleaved_byte_to_complex_short_, 0, conjugate_sc_, 0); + } } } @@ -83,22 +103,40 @@ void IbyteToCshort::disconnect(gr::top_block_sptr top_block) { if (dump_) { - top_block->disconnect(interleaved_byte_to_complex_short_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->disconnect(interleaved_byte_to_complex_short_, 0, conjugate_sc_, 0); + top_block->disconnect(conjugate_sc_, 0, file_sink_, 0); + } + else + { + top_block->disconnect(interleaved_byte_to_complex_short_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->disconnect(interleaved_byte_to_complex_short_, 0, conjugate_sc_, 0); + } } } - gr::basic_block_sptr IbyteToCshort::get_left_block() { return interleaved_byte_to_complex_short_; } - gr::basic_block_sptr IbyteToCshort::get_right_block() { - return interleaved_byte_to_complex_short_; + if(inverted_spectrum) + { + return conjugate_sc_; + } + else + { + return interleaved_byte_to_complex_short_; + } } - - diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.h b/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.h index 71829d6a3..2de7089ac 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.h +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.h @@ -34,6 +34,7 @@ #include #include #include "gnss_block_interface.h" +#include "conjugate_sc.h" #include "interleaved_byte_to_complex_short.h" @@ -85,6 +86,8 @@ private: unsigned int in_streams_; unsigned int out_streams_; gr::blocks::file_sink::sptr file_sink_; + conjugate_sc_sptr conjugate_sc_; + bool inverted_spectrum; }; #endif diff --git a/src/algorithms/data_type_adapter/adapters/ishort_to_complex.cc b/src/algorithms/data_type_adapter/adapters/ishort_to_complex.cc index e87dc1f59..cb9d3c6df 100644 --- a/src/algorithms/data_type_adapter/adapters/ishort_to_complex.cc +++ b/src/algorithms/data_type_adapter/adapters/ishort_to_complex.cc @@ -49,6 +49,7 @@ IshortToComplex::IshortToComplex(ConfigurationInterface* configuration, std::str dump_ = config_->property(role_ + ".dump", false); dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename); + inverted_spectrum = configuration->property(role + ".inverted_spectrum", false); size_t item_size = sizeof(gr_complex); @@ -56,6 +57,10 @@ IshortToComplex::IshortToComplex(ConfigurationInterface* configuration, std::str DLOG(INFO) << "data_type_adapter_(" << gr_interleaved_short_to_complex_->unique_id() << ")"; + if (inverted_spectrum) + { + conjugate_cc_ = make_conjugate_cc(); + } if (dump_) { DLOG(INFO) << "Dumping output into file " << dump_filename_; @@ -72,11 +77,26 @@ void IshortToComplex::connect(gr::top_block_sptr top_block) { if (dump_) { - top_block->connect(gr_interleaved_short_to_complex_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->connect(gr_interleaved_short_to_complex_, 0, conjugate_cc_, 0); + top_block->connect(conjugate_cc_, 0, file_sink_, 0); + } + else + { + top_block->connect(gr_interleaved_short_to_complex_, 0, file_sink_, 0); + } } else { - DLOG(INFO) << "Nothing to connect internally"; + if(inverted_spectrum) + { + top_block->connect(gr_interleaved_short_to_complex_, 0, conjugate_cc_, 0); + } + else + { + DLOG(INFO) << "Nothing to connect internally"; + } } } @@ -85,22 +105,40 @@ void IshortToComplex::disconnect(gr::top_block_sptr top_block) { if (dump_) { - top_block->disconnect(gr_interleaved_short_to_complex_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->disconnect(gr_interleaved_short_to_complex_, 0, conjugate_cc_, 0); + top_block->disconnect(conjugate_cc_, 0, file_sink_, 0); + } + else + { + top_block->disconnect(gr_interleaved_short_to_complex_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->disconnect(gr_interleaved_short_to_complex_, 0, conjugate_cc_, 0); + } } } - gr::basic_block_sptr IshortToComplex::get_left_block() { return gr_interleaved_short_to_complex_; } - gr::basic_block_sptr IshortToComplex::get_right_block() { - return gr_interleaved_short_to_complex_; + if(inverted_spectrum) + { + return conjugate_cc_; + } + else + { + return gr_interleaved_short_to_complex_; + } } - - diff --git a/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h b/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h index 79a2d7162..57cf7283e 100644 --- a/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h +++ b/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h @@ -34,6 +34,7 @@ #include #include #include +#include "conjugate_cc.h" #include "gnss_block_interface.h" @@ -84,6 +85,8 @@ private: unsigned int in_streams_; unsigned int out_streams_; gr::blocks::file_sink::sptr file_sink_; + conjugate_cc_sptr conjugate_cc_; + bool inverted_spectrum; }; #endif diff --git a/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.cc b/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.cc index 503341d08..96a87abe2 100644 --- a/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.cc +++ b/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.cc @@ -51,6 +51,7 @@ IshortToCshort::IshortToCshort(ConfigurationInterface* configuration, std::strin dump_ = config_->property(role_ + ".dump", false); dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename); + inverted_spectrum = configuration->property(role + ".inverted_spectrum", false); size_t item_size = sizeof(lv_16sc_t); @@ -63,6 +64,10 @@ IshortToCshort::IshortToCshort(ConfigurationInterface* configuration, std::strin DLOG(INFO) << "Dumping output into file " << dump_filename_; file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str()); } + if(inverted_spectrum) + { + conjugate_sc_ = make_conjugate_sc(); + } } @@ -74,11 +79,26 @@ void IshortToCshort::connect(gr::top_block_sptr top_block) { if (dump_) { - top_block->connect(interleaved_short_to_complex_short_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->connect(interleaved_short_to_complex_short_, 0, conjugate_sc_, 0); + top_block->connect(conjugate_sc_, 0, file_sink_, 0); + } + else + { + top_block->connect(interleaved_short_to_complex_short_, 0, file_sink_, 0); + } } else { - DLOG(INFO) << "Nothing to connect internally"; + if(inverted_spectrum) + { + top_block->connect(interleaved_short_to_complex_short_, 0, conjugate_sc_, 0); + } + else + { + DLOG(INFO) << "Nothing to connect internally"; + } } } @@ -87,22 +107,40 @@ void IshortToCshort::disconnect(gr::top_block_sptr top_block) { if (dump_) { - top_block->disconnect(interleaved_short_to_complex_short_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->disconnect(interleaved_short_to_complex_short_, 0, conjugate_sc_, 0); + top_block->disconnect(conjugate_sc_, 0, file_sink_, 0); + } + else + { + top_block->disconnect(interleaved_short_to_complex_short_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->disconnect(interleaved_short_to_complex_short_, 0, conjugate_sc_, 0); + } } } - gr::basic_block_sptr IshortToCshort::get_left_block() { return interleaved_short_to_complex_short_; } - gr::basic_block_sptr IshortToCshort::get_right_block() { - return interleaved_short_to_complex_short_; + if(inverted_spectrum) + { + return conjugate_sc_; + } + else + { + return interleaved_short_to_complex_short_; + } } - - diff --git a/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.h b/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.h index cb8080e40..685373a6a 100644 --- a/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.h +++ b/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.h @@ -33,6 +33,7 @@ #include #include +#include "conjugate_sc.h" #include "gnss_block_interface.h" #include "interleaved_short_to_complex_short.h" @@ -85,6 +86,8 @@ private: unsigned int in_streams_; unsigned int out_streams_; gr::blocks::file_sink::sptr file_sink_; + conjugate_sc_sptr conjugate_sc_; + bool inverted_spectrum; }; #endif diff --git a/src/algorithms/libs/CMakeLists.txt b/src/algorithms/libs/CMakeLists.txt index e7d8b60bd..cc085ae75 100644 --- a/src/algorithms/libs/CMakeLists.txt +++ b/src/algorithms/libs/CMakeLists.txt @@ -32,6 +32,9 @@ set(GNSS_SPLIBS_SOURCES cshort_to_float_x2.cc short_x2_to_cshort.cc complex_float_to_complex_byte.cc + conjugate_cc.cc + conjugate_sc.cc + conjugate_ic.cc ) diff --git a/src/algorithms/libs/conjugate_cc.cc b/src/algorithms/libs/conjugate_cc.cc new file mode 100644 index 000000000..60063473a --- /dev/null +++ b/src/algorithms/libs/conjugate_cc.cc @@ -0,0 +1,29 @@ +#include "conjugate_cc.h" +#include +#include + + +conjugate_cc_sptr make_conjugate_cc() +{ + return conjugate_cc_sptr(new conjugate_cc()); +} + + +conjugate_cc::conjugate_cc() : gr::sync_block("conjugate_cc", + gr::io_signature::make (1, 1, sizeof(gr_complex)), + gr::io_signature::make (1, 1, sizeof(gr_complex))) +{ + const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex); + set_alignment(std::max(1, alignment_multiple)); +} + + +int conjugate_cc::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const gr_complex *in = reinterpret_cast(input_items[0]); + gr_complex *out = reinterpret_cast(output_items[0]); + volk_32fc_conjugate_32fc(out, in, noutput_items); + return noutput_items; +} diff --git a/src/algorithms/libs/conjugate_cc.h b/src/algorithms/libs/conjugate_cc.h new file mode 100644 index 000000000..556f79c6d --- /dev/null +++ b/src/algorithms/libs/conjugate_cc.h @@ -0,0 +1,59 @@ +/*! + * \file conjugate_cc.h + * \brief Conjugate + * \author Carles Fernandez Prades, cfernandez(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (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_CONJUGATE_CC_H_ +#define GNSS_SDR_CONJUGATE_CC_H_ + +#include +#include + +class conjugate_cc; + +typedef boost::shared_ptr conjugate_cc_sptr; + +conjugate_cc_sptr make_conjugate_cc(); + +/*! + * \brief This class adapts a std::complex stream + * into two 32-bits (float) streams + */ +class conjugate_cc : public gr::sync_block +{ +private: + friend conjugate_cc_sptr make_conjugate_cc(); +public: + conjugate_cc(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif diff --git a/src/algorithms/libs/conjugate_ic.cc b/src/algorithms/libs/conjugate_ic.cc new file mode 100644 index 000000000..b1f85e39f --- /dev/null +++ b/src/algorithms/libs/conjugate_ic.cc @@ -0,0 +1,29 @@ +#include "conjugate_ic.h" +#include +#include + + +conjugate_ic_sptr make_conjugate_ic() +{ + return conjugate_ic_sptr(new conjugate_ic()); +} + + +conjugate_ic::conjugate_ic() : gr::sync_block("conjugate_ic", + gr::io_signature::make (1, 1, sizeof(lv_8sc_t)), + gr::io_signature::make (1, 1, sizeof(lv_8sc_t))) +{ + const int alignment_multiple = volk_gnsssdr_get_alignment() / sizeof(lv_8sc_t); + set_alignment(std::max(1, alignment_multiple)); +} + + +int conjugate_ic::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const lv_8sc_t *in = reinterpret_cast(input_items[0]); + lv_8sc_t *out = reinterpret_cast(output_items[0]); + volk_gnsssdr_8ic_conjugate_8ic(out, in, noutput_items); + return noutput_items; +} diff --git a/src/algorithms/libs/conjugate_ic.h b/src/algorithms/libs/conjugate_ic.h new file mode 100644 index 000000000..38eb21a35 --- /dev/null +++ b/src/algorithms/libs/conjugate_ic.h @@ -0,0 +1,59 @@ +/*! + * \file conjugate_ic.h + * \brief Adapts a std::complex stream into two float streams + * \author Carles Fernandez Prades, cfernandez(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (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_CONJUGATE_IC_H_ +#define GNSS_SDR_CONJUGATE_IC_H_ + +#include +#include + +class conjugate_ic; + +typedef boost::shared_ptr conjugate_ic_sptr; + +conjugate_ic_sptr make_conjugate_ic(); + +/*! + * \brief This class adapts a std::complex stream + * into two 32-bits (float) streams + */ +class conjugate_ic : public gr::sync_block +{ +private: + friend conjugate_ic_sptr make_conjugate_ic(); +public: + conjugate_ic(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif diff --git a/src/algorithms/libs/conjugate_sc.cc b/src/algorithms/libs/conjugate_sc.cc new file mode 100644 index 000000000..ac22d7723 --- /dev/null +++ b/src/algorithms/libs/conjugate_sc.cc @@ -0,0 +1,29 @@ +#include "conjugate_sc.h" +#include +#include + + +conjugate_sc_sptr make_conjugate_sc() +{ + return conjugate_sc_sptr(new conjugate_sc()); +} + + +conjugate_sc::conjugate_sc() : gr::sync_block("conjugate_sc", + gr::io_signature::make (1, 1, sizeof(lv_16sc_t)), + gr::io_signature::make (1, 1, sizeof(lv_16sc_t))) +{ + const int alignment_multiple = volk_gnsssdr_get_alignment() / sizeof(lv_16sc_t); + set_alignment(std::max(1, alignment_multiple)); +} + + +int conjugate_sc::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const lv_16sc_t *in = reinterpret_cast(input_items[0]); + lv_16sc_t *out = reinterpret_cast(output_items[0]); + volk_gnsssdr_16ic_conjugate_16ic(out, in, noutput_items); + return noutput_items; +} diff --git a/src/algorithms/libs/conjugate_sc.h b/src/algorithms/libs/conjugate_sc.h new file mode 100644 index 000000000..b26a66c79 --- /dev/null +++ b/src/algorithms/libs/conjugate_sc.h @@ -0,0 +1,59 @@ +/*! + * \file conjugate_sc.h + * \brief Adapts a std::complex stream into two float streams + * \author Carles Fernandez Prades, cfernandez(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (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_CONJUGATE_SC_H_ +#define GNSS_SDR_CONJUGATE_SC_H_ + +#include +#include + +class conjugate_sc; + +typedef boost::shared_ptr conjugate_sc_sptr; + +conjugate_sc_sptr make_conjugate_sc(); + +/*! + * \brief This class adapts a std::complex stream + * into two 32-bits (float) streams + */ +class conjugate_sc : public gr::sync_block +{ +private: + friend conjugate_sc_sptr make_conjugate_sc(); +public: + conjugate_sc(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif diff --git a/src/algorithms/libs/pass_through.cc b/src/algorithms/libs/pass_through.cc index 94394866e..87f2b1be6 100644 --- a/src/algorithms/libs/pass_through.cc +++ b/src/algorithms/libs/pass_through.cc @@ -57,7 +57,7 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro } item_type_ = configuration->property(role + ".item_type", input_type); - vector_size_ = configuration->property(role + ".vector_size", 1); + inverted_spectrum = configuration->property(role + ".inverted_spectrum", false); if(item_type_.compare("float") == 0) { @@ -66,6 +66,10 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro else if(item_type_.compare("gr_complex") == 0) { item_size_ = sizeof(gr_complex); + if(inverted_spectrum) + { + conjugate_cc_ = make_conjugate_cc(); + } } else if(item_type_.compare("short") == 0) { @@ -78,6 +82,10 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro else if(item_type_.compare("cshort") == 0) { item_size_ = sizeof(lv_16sc_t); + if(inverted_spectrum) + { + conjugate_sc_ = make_conjugate_sc(); + } } else if(item_type_.compare("byte") == 0) { @@ -90,12 +98,17 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro else if(item_type_.compare("cbyte") == 0) { item_size_ = sizeof(lv_8sc_t); + if(inverted_spectrum) + { + conjugate_ic_ = make_conjugate_ic(); + } } else { LOG(WARNING) << item_type_ << " unrecognized item type. Using float"; item_size_ = sizeof(float); } + kludge_copy_ = gr::blocks::copy::make(item_size_); DLOG(INFO) << "kludge_copy(" << kludge_copy_->unique_id() << ")"; } @@ -125,6 +138,27 @@ void Pass_Through::disconnect(gr::top_block_sptr top_block) gr::basic_block_sptr Pass_Through::get_left_block() { + if(inverted_spectrum) + { + if(item_type_.compare("gr_complex") == 0) + { + return conjugate_cc_; + } + else if(item_type_.compare("cshort") == 0) + { + return conjugate_sc_; + } + else if(item_type_.compare("cbyte") == 0) + { + return conjugate_ic_; + } + else + { + LOG(WARNING) << "Setting inverted_spectrum to true with item_type " + << item_type_ << " is not defined and has no effect."; + } + } + return kludge_copy_; } @@ -132,5 +166,26 @@ gr::basic_block_sptr Pass_Through::get_left_block() gr::basic_block_sptr Pass_Through::get_right_block() { + if(inverted_spectrum) + { + if(item_type_.compare("gr_complex") == 0) + { + return conjugate_cc_; + } + else if(item_type_.compare("cshort") == 0) + { + return conjugate_sc_; + } + else if(item_type_.compare("cbyte") == 0) + { + return conjugate_ic_; + } + else + { + DLOG(WARNING) << "Setting inverted_spectrum to true with item_type " + << item_type_ << " is not defined and has no effect."; + } + } + return kludge_copy_; } diff --git a/src/algorithms/libs/pass_through.h b/src/algorithms/libs/pass_through.h index 02cc1647f..39d4c5468 100644 --- a/src/algorithms/libs/pass_through.h +++ b/src/algorithms/libs/pass_through.h @@ -37,6 +37,10 @@ #include #include #include "gnss_block_interface.h" +#include "conjugate_cc.h" +#include "conjugate_sc.h" +#include "conjugate_ic.h" + class ConfigurationInterface; @@ -69,11 +73,6 @@ public: return item_type_; } - inline size_t vector_size() const - { - return vector_size_; - } - inline size_t item_size() override { return item_size_; @@ -86,13 +85,16 @@ public: private: std::string item_type_; - size_t vector_size_; std::string role_; unsigned int in_streams_; unsigned int out_streams_; //gr_kludge_copy_sptr kludge_copy_; gr::blocks::copy::sptr kludge_copy_; size_t item_size_; + conjugate_cc_sptr conjugate_cc_; + conjugate_sc_sptr conjugate_sc_; + conjugate_ic_sptr conjugate_ic_; + bool inverted_spectrum; }; #endif /*GNSS_SDR_PASS_THROUGH_H_*/ diff --git a/src/tests/unit-tests/signal-processing-blocks/adapter/pass_through_test.cc b/src/tests/unit-tests/signal-processing-blocks/adapter/pass_through_test.cc index 656a0d688..070196fe6 100644 --- a/src/tests/unit-tests/signal-processing-blocks/adapter/pass_through_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/adapter/pass_through_test.cc @@ -41,9 +41,6 @@ TEST(PassThroughTest, Instantiate) { std::shared_ptr config = std::make_shared(); config->set_property("Test.item_type", "gr_complex"); - config->set_property("Test.vector_size", "2"); std::shared_ptr signal_conditioner = std::make_shared(config.get(), "Test", 1, 1); EXPECT_STREQ("gr_complex", signal_conditioner->item_type().c_str()); - unsigned int expected2 = 2; - EXPECT_EQ(expected2, signal_conditioner->vector_size()); }