public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/36821]  New: Flush denormals to Zero Flag
@ 2008-07-14 10:27 J dot Hogg at rl dot ac dot uk
  2008-07-14 11:21 ` [Bug fortran/36821] " rguenth at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: J dot Hogg at rl dot ac dot uk @ 2008-07-14 10:27 UTC (permalink / raw)
  To: gcc-bugs

On current x86 and x86_64 processors denormal numbers are handled as a special
case and very slowly. This can have a detrimental impact on the performance of
numerical programs. A common fix for this problem, at the cost of some
numerical stability, is to set the processor flag to flush denormals to zero.

This can be achieved in C with the following on SSE machines:
   _MM_SET_FLUSH_ZERO_MODE (_MM_FLUSH_ZERO_ON);

However it is not desirable to include C in a fortran program or library. Other
compiler tackle this by adding flags (ifort, NAG f95) or environment variables
(g95) which set this flush mode during program initialization. It would be good
if gfortran offered a similar facility (I have not been able to locate any
reference to one at the moment).


-- 
           Summary: Flush denormals to Zero Flag
           Product: gcc
           Version: 4.3.1
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: J dot Hogg at rl dot ac dot uk


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36821


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/36821] Flush denormals to Zero Flag
  2008-07-14 10:27 [Bug fortran/36821] New: Flush denormals to Zero Flag J dot Hogg at rl dot ac dot uk
@ 2008-07-14 11:21 ` rguenth at gcc dot gnu dot org
  2008-07-14 11:35 ` J dot Hogg at rl dot ac dot uk
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-07-14 11:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2008-07-14 11:21 -------
Compiling with -ffast-math will automatically do that at program startup time
via linking against crtfastmath.o.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36821


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/36821] Flush denormals to Zero Flag
  2008-07-14 10:27 [Bug fortran/36821] New: Flush denormals to Zero Flag J dot Hogg at rl dot ac dot uk
  2008-07-14 11:21 ` [Bug fortran/36821] " rguenth at gcc dot gnu dot org
@ 2008-07-14 11:35 ` J dot Hogg at rl dot ac dot uk
  2010-04-09  3:43 ` [Bug target/36821] " nick2893 at hotmail dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: J dot Hogg at rl dot ac dot uk @ 2008-07-14 11:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from J dot Hogg at rl dot ac dot uk  2008-07-14 11:34 -------
-ffast-math also enables other (even more unsafe?) optimizations which may not
be desirable.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36821


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/36821] Flush denormals to Zero Flag
  2008-07-14 10:27 [Bug fortran/36821] New: Flush denormals to Zero Flag J dot Hogg at rl dot ac dot uk
  2008-07-14 11:21 ` [Bug fortran/36821] " rguenth at gcc dot gnu dot org
  2008-07-14 11:35 ` J dot Hogg at rl dot ac dot uk
@ 2010-04-09  3:43 ` nick2893 at hotmail dot com
  2010-04-09  6:26 ` ubizjak at gmail dot com
  2010-04-09 15:31 ` nick2893 at hotmail dot com
  4 siblings, 0 replies; 9+ messages in thread
From: nick2893 at hotmail dot com @ 2010-04-09  3:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from nick2893 at hotmail dot com  2010-04-09 03:42 -------
I am looking for both Optimized like O2 and FTZ.  I have a large Fortran
program.  Without FTZ it gets weird crashes that should not be happening (no
problems on any other compilers!)  Without optimization it runs way too slow.

Any optimization overrides any attempts at FTZ, such as

_MM_SET_FLUSH_ZERO_MODE (_MM_FLUSH_ZERO_ON); 
-ffast-math

The tradeoff of "either FTZ or Optimized" I think will not work for me.


-- 

nick2893 at hotmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nick2893 at hotmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36821


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/36821] Flush denormals to Zero Flag
  2008-07-14 10:27 [Bug fortran/36821] New: Flush denormals to Zero Flag J dot Hogg at rl dot ac dot uk
                   ` (2 preceding siblings ...)
  2010-04-09  3:43 ` [Bug target/36821] " nick2893 at hotmail dot com
@ 2010-04-09  6:26 ` ubizjak at gmail dot com
  2010-04-09 15:31 ` nick2893 at hotmail dot com
  4 siblings, 0 replies; 9+ messages in thread
From: ubizjak at gmail dot com @ 2010-04-09  6:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from ubizjak at gmail dot com  2010-04-09 06:26 -------
(In reply to comment #3)

> The tradeoff of "either FTZ or Optimized" I think will not work for me.

Find crtfastmath.o in gcc build directory and link it to your final executable.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36821


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/36821] Flush denormals to Zero Flag
  2008-07-14 10:27 [Bug fortran/36821] New: Flush denormals to Zero Flag J dot Hogg at rl dot ac dot uk
                   ` (3 preceding siblings ...)
  2010-04-09  6:26 ` ubizjak at gmail dot com
@ 2010-04-09 15:31 ` nick2893 at hotmail dot com
  4 siblings, 0 replies; 9+ messages in thread
From: nick2893 at hotmail dot com @ 2010-04-09 15:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from nick2893 at hotmail dot com  2010-04-09 15:30 -------
I'm still not getting FTZ ... unless I misunderstood your suggestion, here's
what I did after compiling with -O2:

root@nick-desktop:/home/test408# gfortran -o test4f
/usr/lib/gcc/i486-linux-gnu/4.4.0/crtfastmath.o TEST4SRC1.o TEST4SRC2.o
TEST4SRCU.o


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36821


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/36821] Flush denormals to Zero Flag
       [not found] <bug-36821-4@http.gcc.gnu.org/bugzilla/>
  2022-12-26  1:12 ` cvs-commit at gcc dot gnu.org
  2022-12-26  2:13 ` kargl at gcc dot gnu.org
@ 2022-12-26  2:18 ` crazylht at gmail dot com
  2 siblings, 0 replies; 9+ messages in thread
From: crazylht at gmail dot com @ 2022-12-26  2:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36821

Hongtao.liu <crazylht at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |crazylht at gmail dot com

--- Comment #8 from Hongtao.liu <crazylht at gmail dot com> ---
> Does -mdaz-ftz actually activate all of -ffast-math and/or
> -funsafe-math-optimizations?

No, -mdaz-ftz only set DAZ and FTZ bits.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/36821] Flush denormals to Zero Flag
       [not found] <bug-36821-4@http.gcc.gnu.org/bugzilla/>
  2022-12-26  1:12 ` cvs-commit at gcc dot gnu.org
@ 2022-12-26  2:13 ` kargl at gcc dot gnu.org
  2022-12-26  2:18 ` crazylht at gmail dot com
  2 siblings, 0 replies; 9+ messages in thread
From: kargl at gcc dot gnu.org @ 2022-12-26  2:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36821

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #7 from kargl at gcc dot gnu.org ---
(In reply to CVS Commits from comment #6)
> The master branch has been updated by hongtao Liu <liuhongt@gcc.gnu.org>:
> 
> https://gcc.gnu.org/g:e54375d85d4aa5889869c2672158083b2106b623
> 
> commit r13-4891-ge54375d85d4aa5889869c2672158083b2106b623
> Author: liuhongt <hongtao.liu@intel.com>
> Date:   Mon Dec 12 15:43:58 2022 +0800
> 
>     x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR.
>     
>     if (mdaz-ftz)
>       link crtfastmath.o
>     else if ((Ofast || ffast-math || funsafe-math-optimizations)
>              && !shared && !mno-daz-ftz)
>       link crtfastmath.o
>     else
>       Don't link crtfastmath.o
>     
>     gcc/ChangeLog:
>     
>             PR target/55522
>             PR target/36821
>             * config/i386/gnu-user-common.h (GNU_USER_TARGET_MATHFILE_SPEC):
>             Link crtfastmath.o whenever -mdaz-ftz is specified. Don't link
>             crtfastmath.o when -share or -mno-daz-ftz is specified.
>             * config/i386/i386.opt (mdaz-ftz): New option.
>             * doc/invoke.texi (x86 options): Document mftz-daz.

Does -mdaz-ftz actually activate all of -ffast-math and/or
-funsafe-math-optimizations?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/36821] Flush denormals to Zero Flag
       [not found] <bug-36821-4@http.gcc.gnu.org/bugzilla/>
@ 2022-12-26  1:12 ` cvs-commit at gcc dot gnu.org
  2022-12-26  2:13 ` kargl at gcc dot gnu.org
  2022-12-26  2:18 ` crazylht at gmail dot com
  2 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-12-26  1:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36821

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by hongtao Liu <liuhongt@gcc.gnu.org>:

https://gcc.gnu.org/g:e54375d85d4aa5889869c2672158083b2106b623

commit r13-4891-ge54375d85d4aa5889869c2672158083b2106b623
Author: liuhongt <hongtao.liu@intel.com>
Date:   Mon Dec 12 15:43:58 2022 +0800

    x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR.

    if (mdaz-ftz)
      link crtfastmath.o
    else if ((Ofast || ffast-math || funsafe-math-optimizations)
             && !shared && !mno-daz-ftz)
      link crtfastmath.o
    else
      Don't link crtfastmath.o

    gcc/ChangeLog:

            PR target/55522
            PR target/36821
            * config/i386/gnu-user-common.h (GNU_USER_TARGET_MATHFILE_SPEC):
            Link crtfastmath.o whenever -mdaz-ftz is specified. Don't link
            crtfastmath.o when -share or -mno-daz-ftz is specified.
            * config/i386/i386.opt (mdaz-ftz): New option.
            * doc/invoke.texi (x86 options): Document mftz-daz.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-12-26  2:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-14 10:27 [Bug fortran/36821] New: Flush denormals to Zero Flag J dot Hogg at rl dot ac dot uk
2008-07-14 11:21 ` [Bug fortran/36821] " rguenth at gcc dot gnu dot org
2008-07-14 11:35 ` J dot Hogg at rl dot ac dot uk
2010-04-09  3:43 ` [Bug target/36821] " nick2893 at hotmail dot com
2010-04-09  6:26 ` ubizjak at gmail dot com
2010-04-09 15:31 ` nick2893 at hotmail dot com
     [not found] <bug-36821-4@http.gcc.gnu.org/bugzilla/>
2022-12-26  1:12 ` cvs-commit at gcc dot gnu.org
2022-12-26  2:13 ` kargl at gcc dot gnu.org
2022-12-26  2:18 ` crazylht at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).