From 9114441fbfeda85abc432cf1749057ac797a4bc9 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Sun, 22 Jan 2017 14:16:10 +0100 Subject: [PATCH 1/5] fixed test for avx2 in cmake --- cmake/modules/FindSSE.cmake | 65 ++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/cmake/modules/FindSSE.cmake b/cmake/modules/FindSSE.cmake index 36be09ea4..89c7d8c19 100644 --- a/cmake/modules/FindSSE.cmake +++ b/cmake/modules/FindSSE.cmake @@ -40,11 +40,21 @@ if (ENABLE_SSE) set(CMAKE_REQUIRED_FLAGS "-mavx") check_c_source_runs(" #include - int main() { - __m256i a = _mm256_setzero_si256(); - return 0; + __m256 a, b, c; + const float src[8] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }; + float dst[8]; + a = _mm256_loadu_ps( src ); + b = _mm256_loadu_ps( src ); + c = _mm256_add_ps( a, b ); + _mm256_storeu_ps( dst, c ); + for( int i = 0; i < 8; i++ ){ + if( ( src[i] + src[i] ) != dst[i] ){ + return -1; + } + } + return 0; }" HAVE_AVX) endif() @@ -54,29 +64,38 @@ if (ENABLE_SSE) endif() endif() - if (ENABLE_AVX2) + if (ENABLE_AVX2) - # - # Check compiler for AVX intrinsics - # - if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG ) - set(CMAKE_REQUIRED_FLAGS "-mavx2") - check_c_source_runs(" - #include - - int main() - { - __m256i a = _mm256_setzero_si256(); - __m256i b = _mm256_abs_epi16(a); + # + # Check compiler for AVX intrinsics + # + if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG ) + set(CMAKE_REQUIRED_FLAGS "-mavx2") + check_c_source_runs(" + #include + int main() + { + __m256i a, b, c; + const int src[8] = { 1, 2, 3, 4, 5, 6, 7, 8 }; + int dst[8]; + a = _mm256_loadu_si256( (__m256i*)src ); + b = _mm256_loadu_si256( (__m256i*)src ); + c = _mm256_add_epi32( a, b ); + _mm256_storeu_si256( (__m256i*)dst, c ); + for( int i = 0; i < 8; i++ ){ + if( ( src[i] + src[i] ) != dst[i] ){ + return -1; + } + } return 0; - }" - HAVE_AVX2) - endif() + }" + HAVE_AVX2) + endif() - if (HAVE_AVX2) - message(STATUS "AVX2 is enabled - target CPU must support it") - endif() - endif() + if (HAVE_AVX2) + message(STATUS "AVX2 is enabled - target CPU must support it") + endif() + endif() endif() From b2f889081fe60ddf90ab3e47f34aaa0c6d650b13 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Sun, 22 Jan 2017 14:26:54 +0100 Subject: [PATCH 2/5] fixed test for avx2 in cmake --- cmake/modules/FindSSE.cmake | 3 --- 1 file changed, 3 deletions(-) diff --git a/cmake/modules/FindSSE.cmake b/cmake/modules/FindSSE.cmake index 89c7d8c19..7b258f70f 100644 --- a/cmake/modules/FindSSE.cmake +++ b/cmake/modules/FindSSE.cmake @@ -1,6 +1,3 @@ -if (NOT CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|^i[3,9]86$") - return() -endif() include(CheckCSourceRuns) From 5615df0fee14eb85b7c9a54f1fbefcdddd414070 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Sun, 22 Jan 2017 14:38:43 +0100 Subject: [PATCH 3/5] fixed mem alignment in lut simd operation segfaulting in avx --- srslte/lib/utils/vector_simd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srslte/lib/utils/vector_simd.c b/srslte/lib/utils/vector_simd.c index 1612f2c07..8fee71f21 100644 --- a/srslte/lib/utils/vector_simd.c +++ b/srslte/lib/utils/vector_simd.c @@ -223,8 +223,8 @@ void srslte_vec_lut_sss_simd(short *x, unsigned short *lut, short *y, uint32_t l __m128i xVal, lutVal; for(;number < points; number++){ - xVal = _mm_load_si128(xPtr); - lutVal = _mm_load_si128(lutPtr); + xVal = _mm_loadu_si128(xPtr); + lutVal = _mm_loadu_si128(lutPtr); for (int i=0;i<8;i++) { int16_t x = (int16_t) _mm_extract_epi16(xVal, i); From 808fc2db08b16dd1a3c41f4701183f76e8fbcc8a Mon Sep 17 00:00:00 2001 From: Paul Sutton Date: Wed, 25 Jan 2017 22:38:02 +0000 Subject: [PATCH 4/5] Adding fftw include path from mkl --- srslte/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/srslte/CMakeLists.txt b/srslte/CMakeLists.txt index d4f336d57..afb6060e7 100644 --- a/srslte/CMakeLists.txt +++ b/srslte/CMakeLists.txt @@ -46,6 +46,7 @@ add_custom_target (add_srslte_headers SOURCES ${HEADERS_ALL}) find_package(MKL) if(MKL_FOUND) include_directories(${MKL_INCLUDE_DIRS}) + include_directories(${MKL_INCLUDE_DIRS}/fftw) link_directories(${MKL_LIBRARY_DIRS}) else(MKL_FOUND) find_package(FFTW3F REQUIRED) From 9cbaad2c3a8efaafb43f1019e90c824158797049 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Thu, 26 Jan 2017 00:35:02 +0100 Subject: [PATCH 5/5] Check maximum EARFCN --- srslte/lib/common/phy_common.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/srslte/lib/common/phy_common.c b/srslte/lib/common/phy_common.c index 68532ebeb..4717c6ca7 100644 --- a/srslte/lib/common/phy_common.c +++ b/srslte/lib/common/phy_common.c @@ -439,15 +439,21 @@ int srslte_band_get_band(uint32_t earfcn) { } float srslte_band_fd(uint32_t earfcn) { + if (earfcn > lte_bands[SRSLTE_NOF_LTE_BANDS-1].earfcn_max) { + return -1; + } uint32_t i = SRSLTE_NOF_LTE_BANDS-1; while(i > 0 && lte_bands[i].earfcn_offset>earfcn) { i--; } - return get_fd(<e_bands[i], earfcn); + return get_fd(<e_bands[i], earfcn); } float srslte_band_fu(uint32_t earfcn) { + if (earfcn > lte_bands[SRSLTE_NOF_LTE_BANDS-1].earfcn_max) { + return -1; + } uint32_t i = SRSLTE_NOF_LTE_BANDS-1; while(i > 0 && lte_bands[i].earfcn_offset>earfcn) { i--;