<div dir="auto"><div dir="auto">I think v_mad always flushes denorms.</div><div dir="auto"><br></div>I would just ignore this failure. It's not required to fix every silly test on the planet. If you opencode v_max, you'll have the same problem, and then you'd have to fix v_cmp. It's just silly.<div dir="auto"><br></div><div dir="auto">Marek</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Jan 12, 2017 11:59 AM, "Nicolai Hähnle" <<a href="mailto:nhaehnle@gmail.com">nhaehnle@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 12.01.2017 09:24, Samuel Pitoiset wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
On 01/12/2017 02:12 AM, Marek Olšák wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Thu, Jan 12, 2017 at 12:33 AM, Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu" target="_blank">imirkin@alum.mit.edu</a>><br>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Wed, Jan 11, 2017 at 4:00 PM, Roland Scheidegger<br>
<<a href="mailto:sroland@vmware.com" target="_blank">sroland@vmware.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Am 11.01.2017 um 21:08 schrieb Samuel Pitoiset:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
On 01/11/2017 07:00 PM, Roland Scheidegger wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I don't think there's any glsl, es or otherwise, specification which<br>
would require denorms (since obviously lots of hw can't do it, d3d10<br>
forbids them), with any precision qualifier. Hence these look like<br>
bugs<br>
of the test suite to me?<br>
(Irrespective if it's a good idea or not to enable denormals, which I<br>
don't realy know.)<br>
</blockquote>
<br>
That test works on NVIDIA hw (both with blob and nouveau) and IIRC it<br>
also works on Intel hw. I don't think it's buggy there.<br>
</blockquote>
The question then is why it needs denorms on radeons...<br>
</blockquote>
<br>
I spent some time with Samuel looking at this. So, this is pretty<br>
funny... (or at least feels that way after staring at floating point<br>
for a while)<br>
<br>
dEQP is, in fact, feeding denorms to the min/max functions. But it's<br>
smart enough to know that flushing denorms to 0 is OK, and so it<br>
treats a 0 as a pass. (And obviously it treats the "right answer" as a<br>
pass.) So that's why enabling denorm processing fixes it - that causes<br>
the hw to return the proper correct answer and all is well.<br>
<br>
However the issue is that without denorm processing, the hw is<br>
returning the *wrong* answer. At first I thought that max was being<br>
lowered into something like<br>
<br>
if (a > b) { x = a; } else { x = b; }<br>
<br>
which would end up with potentially wrong results if a and b are being<br>
flushed as inputs into the comparison but not into the assignments.<br>
But that's not (explicitly) what's happening - the v_max_f32_e32<br>
instruction is being used. Perhaps that's what it does internally? If<br>
so, that means that results of affected float functions in LLVM need<br>
explicit flushing before being stored into results.<br>
<br>
FWIW the specific values triggering the issue are:<br>
<br>
in0=-0x0.000002p-126, in1=-0x0.fffffep-126, out0=-0x0.fffffep-126 -><br>
FAIL<br>
<br>
With denorm processing, it correctly reports out0=-0x0.000002p-126,<br>
while nouveau with denorm flushing enabled reports out0=0.0 which also<br>
passes.<br>
</blockquote>
<br>
The denorm configuration has 2 bits:<br>
- flush (0) or allow (1) input denorms<br>
- flush (0) or allow (1) output denorms<br>
<br>
In the case of v_max, it looks like output denorms are not flushed and<br>
it behaves almost like you said:<br>
<br>
if (a >= b) { x = a; } else { x = b; }<br>
</blockquote>
<br>
Should we adjust the denorm mode with s_setreg for v_max_f32/v_min_f32?<br>
</blockquote>
<br>
That might eliminate some optimization opportunities, so let's first see if another fix is possible?<br>
<br>
I haven't run the test, but from the description the most plausible explanation is that v_max_f32/v_min_f32 flushes input denorms, but doesn't flush output denorms for some stupid reason. Perhaps we could change the fp_denorm setting to<br>
<br>
- allow input denorms<br>
- flush output denorms<br>
<br>
Then min/max will preserve the denorms, but other operations will flush denorms to zero.<br>
<br>
Do you know how that affects v_mad_f32? If we just change the register without telling LLVM about it, LLVM will still happily emit v_mad_f32, and perhaps that produces incorrect results when denorms are passed in from uniforms?<br>
<br>
If this register setting doesn't work, then yes, looks like s_setreg may be needed. Unless there's a cheap way to flush denorms from loads as well? But I don't think there is.<br>
<br>
Nicolai<br>
<br>
<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Marek<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
<br>
</blockquote>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</blockquote>
</blockquote></div></div>