[Insight-developers] numerics code optimization issue

Simon Warfield warfield at bwh.harvard.edu
Fri Aug 12 19:59:04 EDT 2005


Simon Warfield wrote:

> Miller, James V (Research) wrote:
>
>> Simon,
>> Problems in netlib with respect to optimization has been a long 
>> standing issue.  I tracked down one of these issues a while back and 
>> turned off optimization for the Microsoft compiler in slamch.c with a 
>> pragma
>>
>> #if defined(_MSC_VER)
>> # pragma optimize("", off)
>> #endif
>>
>> I did not do this is dlamch.c (probably an oversight on my part on 
>> what the the netlib naming conventions are).  This probably points to 
>> a bigger issue of a lack of tests.
>>
>> Which intel compiler were you using? Linux of Windows?
>>
>> I think CMake may have the capability to specify compile flags on a per
>> file basis.  I think the vxl guys wanted such a capability. I would 
>> lean to putting in pragmas to turn off optimization for the offending 
>> compilers in those files if possible.
>>
>> To do it in CMake, it looks like we would need to do something like:
>>
>> IF(CMAKE_COMPILER_IS_GNUCC)
>>  SET_SOURCE_FILES_PROPERTIES(gpfa5f.c PROPERTIES COMPILE_FLAGS -O0)
>>  SET_SOURCE_FILES_PROPERTIES(dgpfa5f.c PROPERTIES COMPILE_FLAGS -O0)
>>  SET_SOURCE_FILES_PROPERTIES(zlarfx.c PROPERTIES COMPILE_FLAGS -Os)
>>  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
>> ENDIF(CMAKE_COMPILER_IS_GNUCC)
>>
>> So we'd need to switch on each compiler and specify the COMPILE_FLAGS 
>> for each
>> suspect file.  Not sure this is any easier than using pragmas.  But 
>> it may be
>> necessary if we cannot turn off optimization from within the source 
>> file.
>>
>> Are slamch.c and dlamch.c the only ones that need to be compiled 
>> non-optimized?
>> Or does slarfg.c also need it?
>>
>> Jim
>>
>>  
>>
> I was using the Intel compiler on linux.
>
> I found setting file specific properties in CMakeLists.txt such as :
> SET_SOURCE_FILES_PROPERTIES(slamch.c PROPERTIES COMPILE_FLAGS -O0)
> SET_SOURCE_FILES_PROPERTIES(dlamch.c PROPERTIES COMPILE_FLAGS -O0)
>
>  wasn't effective because these flags precede the flags associated 
> with the build type rather than replace any other specified flags.
>
> What was effective was using a pragma:
> #if defined(__INTEL_COMPILER)
> # pragma optimize("", off)
> #endif
>
> This turns of optimization until the end of the current source file or 
> the next occurrence of
> # pragma optimize("", on)
>
> Keeping optimization off in the slamch.c and dlamch.c file solves the 
> issue.  slarfg.c was failing only because the results from slamch.c 
> were wrong, and it doesn't need fixing.
> Attached are two fixed files, but the solution is basically to add the 
> three above lines near the top of each of the files.
>
> It would be great if the fix made it into the CVS repository.
> -- 
> Simon

The list rejected my email because it was too big with the attachments.  
Here it is again with no attachments.
--
Simon


More information about the Insight-developers mailing list