Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

-O3 and exp() and ln()

erling_andersen
New Contributor I
438 Views

We have some C code that employs exp() and ln() a lot for some test data. Now if we switch the optimization level from O2 to O3, then the code does not work in some cases. It is like the ln() and exp() is less accurate.

In cases where exp() and ln() are not used it works with O3. Is that to be expected?

Erling

 

 

 

 

 

 

0 Kudos
2 Replies
jimdempseyatthecove
Honored Contributor III
438 Views

Try adding the floating point options that favor precision over speed

Look at /fp:<name> as well as selecting NOT fast transcendentals /Qfast-transcendentals-

/Qimf-absolute-error:value[:funclist]
          define the maximum allowable absolute error for math library
          function results
            value    - a positive, floating-point number conforming to the
                       format [digits][.digits][{e|E}[sign]digits]
            funclist - optional comma separated list of one or more math
                       library functions to which the attribute should be
                       applied
[press RETURN to continue]

/Qimf-accuracy-bits:bits[:funclist]
          define the relative error, measured by the number of correct bits,
          for math library function results
            bits     - a positive, floating-point number
            funclist - optional comma separated list of one or more math
                       library functions to which the attribute should be
                       applied

/Qimf-arch-consistency:value[:funclist]
          ensures that the math library functions produce consistent results
          across different implementations of the same architecture
            value    - true or false
            funclist - optional comma separated list of one or more math
                       library functions to which the attribute should be
                       applied

/Qimf-max-error:ulps[:funclist]
          defines the maximum allowable relative error, measured in ulps, for
          math library function results
            ulps     - a positive, floating-point number conforming to the
                       format [digits][.digits][{e|E}[sign]digits]
            funclist - optional comma separated list of one or more math
                       library functions to which the attribute should be
[press RETURN to continue]
                       applied

/Qimf-precision:value[:funclist]
          defines the accuracy (precision) for math library functions
            value    - defined as one of the following values
                       high   - equivalent to max-error = 0.6
                       medium - equivalent to max-error = 4 (DEFAULT)
                       low    - equivalent to accuracy-bits = 11 (single
                                precision); accuracy-bits = 26 (double
                                precision)
            funclist - optional comma separated list of one or more math
                       library functions to which the attribute should be

Jim Dempsey

 

 

0 Kudos
erling_andersen
New Contributor I
438 Views

I tried adding 

    /Qfast-transcendentals-

but it did not change anything. Does O3 choose fast transdendentals and O2 not? I mean was does O3 actually do with floating points?

Is that documented?

Changing the other parameters is bit like a needle in the haystack approach. I guess I will stick with /O2 then. 

 

 

 

 

 

 

0 Kudos
Reply