This is an archive of the discontinued LLVM Phabricator instance.

AMDGPU: Document denormal behavior
ClosedPublic

Authored by arsenm on Dec 6 2022, 1:22 PM.

Details

Reviewers
t-tye
foad
Group Reviewers
Restricted Project
Summary

Not sure this is the right place for it next to the table.

Diff Detail

Event Timeline

arsenm created this revision.Dec 6 2022, 1:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 6 2022, 1:22 PM
arsenm requested review of this revision.Dec 6 2022, 1:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 6 2022, 1:22 PM
Herald added a subscriber: wdng. · View Herald Transcript
artem.tamazov added a subscriber: artem.tamazov.EditedDec 14 2022, 2:28 PM

Just in case, am I correct that the compiler engages output modifiers only when "denormal-fp-math"="positive-zero"? AFAIU this is necessary because output modifiers force -0 to +0.

Just in case, am I correct that the compiler engages output modifiers only when "denormal-fp-math"="positive-zero"? AFAIU this is necessary because output modifiers force -0 to +0.

We have preserve-sign behavior and ignore positive-zero mode entirely. Also the modifiers are silently ignored for ieee mode =0. I don't remember what the wrong behavior depending on the denormal mode was, beyond don't use these without flushing

We have preserve-sign behavior and ignore positive-zero mode entirely. Also the modifiers are silently ignored for ieee mode =0. I don't remember what the wrong behavior depending on the denormal mode was, beyond don't use these without flushing

I see. What I would like to emphasize is that the compiler should NOT use output modifiers for optimization when "denormal-fp-math"="preserve-sign" (in spite of modifiers will work in this mode), because output modifiers break sign preservation behavior. The compiler should use output modifiers only in "denormal-fp-math"="positive-zero" mode.

We have preserve-sign behavior and ignore positive-zero mode entirely. Also the modifiers are silently ignored for ieee mode =0. I don't remember what the wrong behavior depending on the denormal mode was, beyond don't use these without flushing

I see. What I would like to emphasize is that the compiler should NOT use output modifiers for optimization when "denormal-fp-math"="preserve-sign" (in spite of modifiers will work in this mode), because output modifiers break sign preservation behavior. The compiler should use output modifiers only in "denormal-fp-math"="positive-zero" mode.

The whole point of this change is to document that the hardware has preserve sign denormal behavior and we do not support positive-zero mode. We only apply output modifiers with nsz and don't consider the denormal mode

foad accepted this revision.Feb 20 2023, 1:20 AM
foad added a subscriber: foad.

Seems like an obvious incremental improvement to mention this, irrespective of any nits in the wording.

llvm/docs/AMDGPUUsage.rst
4596

If we can't implement flushing-to-positive-zero then surely we should treat "denormal-fp-math"="positive-zero" the same as "denormal-fp-math"="ieee", since according to LangRef "it is not mandated that flushing to zero occurs" at all. So I don't see where undefined behaviour comes into it.

This revision is now accepted and ready to land.Feb 20 2023, 1:20 AM
arsenm added inline comments.Feb 20 2023, 3:37 AM
llvm/docs/AMDGPUUsage.rst
4596

It's informative of the mode, and we can be a bit lax on the outputs. However, for the input treatment, this acts more like a constraint (e.g. you can't introduce a divide by 0 for a denormal input)