summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorghostop14 <ghostop14@gmail.com>2020-01-23 12:44:15 -0500
committerMartin Braun <martin.braun@ettus.com>2020-01-27 23:18:19 -0800
commit785a889ae877c5e4bb6086b3742a3ab13921919b (patch)
tree9bcd4b552ef38f881d3a3ce8e03d9a46582d4a7e
parent540d9bf734fd9f257559a93c80205298070ea7cb (diff)
Improve complex math speed by disabling NaN/Inf checks
This patch globally applies the -fcx-limited-range compiler flag, which skips checks on complex multiplication. This compiler flag is currently only available on gcc, for other compilers, there are no changes. The effect of this flag is that range reduction and Inf/NaN checks are skipped. This is not a problem for most complex data stemming from real-life signals. Only when we have to expect Inf/NaN values, or complex numbers that can cause numerical overflows, is this switch a problem. For GNU Radio, the new standard will be to set the flag, and to enable extra checking only for special cases (the default is to perform checks on every multiplication/division by default). Regions of code that require extra checking can use the #pragma STDC CX_LIMITED_RANGE OFF preprocessor command to enable range checks. For well-behaved data, removing the checks is significantly faster. Benchmark improvements of up to a factor of 6 have been observed in the wild.
-rw-r--r--CMakeLists.txt8
1 files changed, 8 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3db2dd78d1..3dc3787518 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -437,6 +437,14 @@ message(STATUS " Override with -DENABLE_INTERNAL_VOLK=ON/OFF")
find_package(LOG4CPP REQUIRED)
########################################################################
+# Disable complex math NaN/INFO range checking for performance
+########################################################################
+check_cxx_compiler_flag(-fcx-limited-range HAVE_CX_LIMITED_RANGE)
+if(HAVE_CX_LIMITED_RANGE)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcx-limited-range")
+endif(HAVE_CX_LIMITED_RANGE)
+
+########################################################################
# Distribute the README file
########################################################################
install(