Bill, > On Jul 23, 2015, at 5:16 AM, Bill Somerville <g4...@classdesign.com> wrote: > > 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. >
Thanks for the interesting background. In view of the potential complications, it’s probably not worth bothering with it then. Using -ffast-math decreases execution time by about 25% on my I7/SSD laptop where it doesn’t really matter because the decoder is plenty fast. On a RaspberryPi where a speedup would really be noticed I found (just tonight) that there is no benefit at all from -ffast-math. Never mind... > 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>”) This is what I was looking for. > >> Steve k9an > 73 > Bill > G4WJS. > > ------------------------------------------------------------------------------ > _______________________________________________ > wsjt-devel mailing list > wsjt-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wsjt-devel ------------------------------------------------------------------------------ _______________________________________________ wsjt-devel mailing list wsjt-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wsjt-devel