On 23/07/2015 03:13, Steven Franke wrote:
> Hi all,
Hi Steve,
> While playing with an alternative to the Fano decoder over here I discovered 
> that using -O3 -ffast-math significantly decreases execution time of the 
> decoder on my linux and OS X platforms. Near as I can tell, cmake is 
> currently using -O2 for Debug and -O3 for Release versions. I need advice on 
> the right way to modify CMakeLists.txt to make sure that (only) the wsprd 
> sources are compiled with -O3 -ffast-math.
Only release code should be optimized as debugging optimized code is 
problematic.

I'm not sure I fully understand your question, if release code is 
optimized to -O3 already what are you asking?

We take the CMake defaults for optimization, that means -O3 for release 
code when using gcc/g++ or Clang/Clang++.

If you are asking how to enable -ffast-math for wsprd code then I need 
to do some checks to ensure that the generated code is portable i.e. is 
code generated with fast-math OK to distribute for running on a 
different CPU from which it is compiled. I think it is but I want to be 
sure. Also IIRC in the past I have found that code where NaN or other 
special floating point values are not correctly handled can cause big 
slowdowns so it is also worth checking that FP variables are correctly 
initialized where FP operations may be applied before valid values are 
assigned. For example this can happen when dealing with arrays of values 
when a generic algorithm is applied to a whole array but only some of 
the array is used. The slowdown happens in routines, probably library 
routines, where FP exceptions are trapped and handled which is a very 
slow path.

To change the compiler options for a specific target you use the 
target_compile_options() command for example:

target_compile_options (wsprd PRIVATE -ffast-math)

Note that this is problematic if we wish to support compilers other than 
gcc/clang since the -ffast-math option is not necessarily supported by 
other compilers. The target_compile_options() command supports CMake 
generator expressions to deal with this sort of issue. Currently there 
are other parts of the CMake script that are not compiler agnostic but I 
am wary of adding yet more potential issues. So a more proper command 
would be:

target_compile_options (wsprd PRIVATE 
"$<$<OR:$<C_COMPILER_ID:GNU>,$<C_COMPILER_ID:Clang>>:-ffast-math>")

> Steve k9an
73
Bill
G4WJS.

------------------------------------------------------------------------------
_______________________________________________
wsjt-devel mailing list
wsjt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wsjt-devel

Reply via email to