mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-18 21:23:02 +00:00
Fix for compilers using C++11: the std::plus template without class T specified is only available since C++14
This commit is contained in:
parent
3bc8595dfe
commit
f8656ca9d8
@ -460,6 +460,17 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Availability of std::plus without class specifier
|
||||
if(CMAKE_CXX_STANDARD VERSION_GREATER 11)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.4.0)
|
||||
set(HAVE_STD_PLUS ON)
|
||||
endif()
|
||||
else()
|
||||
set(HAVE_STD_PLUS ON)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
|
@ -238,6 +238,10 @@ if(ARMADILLO_VERSION_STRING VERSION_GREATER 8.400)
|
||||
add_definitions(-DARMADILLO_HAVE_MVNRND=1)
|
||||
endif()
|
||||
|
||||
if(HAVE_STD_PLUS)
|
||||
add_definitions(-DCOMPILER_HAS_STD_PLUS=1)
|
||||
endif()
|
||||
|
||||
find_package(Gnuplot)
|
||||
if(GNUPLOT_FOUND)
|
||||
add_definitions(-DGNUPLOT_EXECUTABLE="${GNUPLOT_EXECUTABLE}")
|
||||
|
@ -103,5 +103,10 @@ macro(add_benchmark)
|
||||
endmacro()
|
||||
|
||||
add_benchmark(benchmark_copy)
|
||||
add_benchmark(benchmark_detector core_system_parameters)
|
||||
add_benchmark(benchmark_preamble core_system_parameters)
|
||||
add_benchmark(benchmark_detector core_system_parameters)
|
||||
|
||||
|
||||
if(HAVE_STD_PLUS)
|
||||
target_compile_definitions(benchmark_detector PRIVATE -DCOMPILER_HAS_STD_PLUS=1)
|
||||
endif()
|
||||
|
@ -83,7 +83,7 @@ void bm_accumulate(benchmark::State& state)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if COMPILER_HAS_STD_PLUS
|
||||
void bm_inner_product(benchmark::State& state)
|
||||
{
|
||||
std::vector<float> d_symbol_history(GPS_CA_PREAMBLE_LENGTH_SYMBOLS, 0.0);
|
||||
@ -108,9 +108,11 @@ void bm_inner_product(benchmark::State& state)
|
||||
[&](float a, float b) { return (std::signbit(a) ? -b : b); });
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
BENCHMARK(bm_forloop);
|
||||
BENCHMARK(bm_accumulate);
|
||||
#if COMPILER_HAS_STD_PLUS
|
||||
BENCHMARK(bm_inner_product);
|
||||
#endif
|
||||
BENCHMARK_MAIN();
|
||||
|
@ -84,6 +84,7 @@ TEST(PreambleCorrelationTest, TestMethods)
|
||||
}
|
||||
end2 = std::chrono::system_clock::now();
|
||||
|
||||
#if COMPILER_HAS_STD_PLUS
|
||||
// Compute correlation, method 3
|
||||
start3 = std::chrono::system_clock::now();
|
||||
for (int64_t iter = 0; iter < n_iter; iter++)
|
||||
@ -97,16 +98,20 @@ TEST(PreambleCorrelationTest, TestMethods)
|
||||
sum_corr3 += corr_value3;
|
||||
}
|
||||
end3 = std::chrono::system_clock::now();
|
||||
EXPECT_EQ(corr_value, corr_value2);
|
||||
std::chrono::duration<double> elapsed_seconds3 = end3 - start3;
|
||||
EXPECT_EQ(corr_value, corr_value3);
|
||||
EXPECT_EQ(sum_corr1, sum_corr2);
|
||||
EXPECT_EQ(sum_corr1, sum_corr3);
|
||||
#endif
|
||||
|
||||
EXPECT_EQ(corr_value, corr_value2);
|
||||
EXPECT_EQ(sum_corr1, sum_corr2);
|
||||
|
||||
std::chrono::duration<double> elapsed_seconds = end - start;
|
||||
std::chrono::duration<double> elapsed_seconds2 = end2 - start2;
|
||||
std::chrono::duration<double> elapsed_seconds3 = end3 - start3;
|
||||
|
||||
std::cout << "Correlation computed with 'C for' : done in " << elapsed_seconds.count() * 1.0e9 / n_iter << " nanoseconds" << std::endl;
|
||||
std::cout << "Correlation computed with accumulate : done in " << elapsed_seconds2.count() * 1.0e9 / n_iter << " nanoseconds" << std::endl;
|
||||
#if COMPILER_HAS_STD_PLUS
|
||||
std::cout << "Correlation computed with inner_product : done in " << elapsed_seconds3.count() * 1.0e9 / n_iter << " nanoseconds" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user