Hello Tony Gutierrez,

I'd like you to do a code review. Please visit

    https://gem5-review.googlesource.com/c/public/gem5/+/29964

to review the following change.


Change subject: arch-gcn3: Fix roundNearestEven for V_RNDNE_F64 and V_RNDNE_F32
......................................................................

arch-gcn3: Fix roundNearestEven for V_RNDNE_F64 and V_RNDNE_F32

roundNearestEven is an inst_util function that RNDNE_F64 and F32
call, including both VOP1 and VOP3 formats. IEEE 754 spec says this
function should round inputs to the nearest integer but round ties
to the nearest even integer. Prior to this patch it was rounding all
inputs to nearest even, not just the ties. It was probably implemented
this way originally because the language in the ISA manual is ambiguous
although it provided the correct logic.

Fixed roundNearestEven to use the semantics originally described in
the GCN3 ISA manual.

Change-Id: I83ecb1d516fcf5bdf17e54ddf409b447a129a9a7
---
M src/arch/gcn3/insts/inst_util.hh
1 file changed, 7 insertions(+), 1 deletion(-)



diff --git a/src/arch/gcn3/insts/inst_util.hh b/src/arch/gcn3/insts/inst_util.hh
index b40e890..15ffe9a 100644
--- a/src/arch/gcn3/insts/inst_util.hh
+++ b/src/arch/gcn3/insts/inst_util.hh
@@ -258,7 +258,13 @@
     template <typename T>
     inline T roundNearestEven(T val)
     {
-        T nearest_round = std::round(val * 0.5) * 2.0;
+        T int_part = 0;
+        T nearest_round = std::floor(val + 0.5);
+        if ((int)std::floor(val) % 2 == 0
+            && std::modf(std::abs(val), &int_part) == 0.5) {
+          nearest_round = nearest_round - 1;
+        }
+
         return nearest_round;
     }


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/29964
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I83ecb1d516fcf5bdf17e54ddf409b447a129a9a7
Gerrit-Change-Number: 29964
Gerrit-PatchSet: 1
Gerrit-Owner: Anthony Gutierrez <anthony.gutier...@amd.com>
Gerrit-Reviewer: Tony Gutierrez <anthony.gutier...@amd.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to