public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/105246] New: [amdgcn] Use library call for SQRT with -ffast-math + provide additional option to use single-precsion opcode Date: Tue, 12 Apr 2022 17:29:06 +0000 [thread overview] Message-ID: <bug-105246-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105246 Bug ID: 105246 Summary: [amdgcn] Use library call for SQRT with -ffast-math + provide additional option to use single-precsion opcode Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: documentation, wrong-code Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org CC: ams at gcc dot gnu.org Target Milestone: --- Target: amdgcn-amdhsa AMD GCN hardware has opcodes which operate on double-precision variables as input/output but internally only do single-precision operation. This affects (currently) only "sqrt" which for -funsafe-math-optimizations (implied by -Ofast / -ffast-math) uses AMDGCN's "v_sqrt". Namely gcc/config/gcn/gcn-valu.md has: (define_insn "sqrt<mode>2<exec>" ... "flag_unsafe_math_optimizations" "v_sqrt%i0\t%0, %1" Thus: while "v_sqrt" works on double-precision variables, it only calculates with 23bits (as with float32) instead of 52bits (as float64 provides) for the fractional part of the floating-point number. PROBLEM: In many cases, this loss of precision by an order of 100,000,000 (10⁸ / 2²⁹) is very unexpected and too much for code which requires double precision. An ULP of 4 is expected not an ULP of 10⁸! In particular: In order to permit several optimizations, -Ofast or --fast-math is commonly recommended and the precision loss is unexpected. In terms of testsuites, OvO's sqrt examples are effected, requiring a way higher OVO_TOL_ULP to pass (→ https://github.com/TApplencourt/OvO ) But the issue really came up when discussion with HPC code users. EXPECTED: - By default, with -ffast-math, do the double-precision operation by a library call - Provide some (GCN-specific) -m... flag to do those calculations in single precision. For instance something like: -mpermit-reduced-precision Use hardware intrinsics instead of library even if they provide a much reduced precision. Example: use v_sqrt with double-precision variables even though the hardware only provides single-precision results for the fractional part of the floating-point variable. (Default: disabled)
next reply other threads:[~2022-04-12 17:29 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-04-12 17:29 burnus at gcc dot gnu.org [this message] 2022-04-13 6:35 ` [Bug target/105246] " rguenth at gcc dot gnu.org 2022-04-13 8:29 ` ams at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-105246-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).