Anthony Gutierrez has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/29955 )

Change subject: arch-gcn3: fixed scale,fixup,fmas f64 ops
......................................................................

arch-gcn3: fixed scale,fixup,fmas f64 ops

Change-Id: Ie13794554db8a958fda1f7103ec18058fda2e66d
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/29955
Maintainer: Anthony Gutierrez <anthony.gutier...@amd.com>
Tested-by: kokoro <noreply+kok...@google.com>
Reviewed-by: Matt Sinclair <mattdsincl...@gmail.com>
---
M src/arch/gcn3/insts/instructions.cc
1 file changed, 65 insertions(+), 17 deletions(-)

Approvals:
  Matt Sinclair: Looks good to me, approved
  Anthony Gutierrez: Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/arch/gcn3/insts/instructions.cc b/src/arch/gcn3/insts/instructions.cc
index a7b8923..a25ec17 100644
--- a/src/arch/gcn3/insts/instructions.cc
+++ b/src/arch/gcn3/insts/instructions.cc
@@ -28952,22 +28952,34 @@

         for (int lane = 0; lane < NumVecElemPerVecReg; ++lane) {
             if (wf->execMask(lane)) {
-                if (std::fpclassify(src1[lane]) == FP_ZERO) {
-                    if (std::signbit(src1[lane])) {
-                        vdst[lane] = -INFINITY;
-                    } else {
-                        vdst[lane] = +INFINITY;
-                    }
- } else if (std::isnan(src2[lane]) || std::isnan(src1[lane])) {
-                    vdst[lane] = NAN;
-                } else if (std::isinf(src1[lane])) {
-                    if (std::signbit(src1[lane])) {
-                        vdst[lane] = -INFINITY;
-                    } else {
-                        vdst[lane] = +INFINITY;
-                    }
+                int signOut = std::signbit(src1[lane]) ^
+                              std::signbit(src2[lane]);
+                int exp1, exp2;
+                std::frexp(src1[lane],&exp1);
+                std::frexp(src2[lane],&exp2);
+                if (std::isnan(src2[lane])) {
+                    vdst[lane] = src2[lane];
+                } else if (std::isnan(src1[lane])) {
+                    vdst[lane] = src1[lane];
+                } else if (src1[lane] == 0.0 && src2[lane] == 0.0) {
+                    vdst[lane] = -NAN;
+ } else if (std::isinf(src1[lane]) && std::isinf(src2[lane])) {
+                    vdst[lane] = -NAN;
+                } else if (src1[lane] == 0.0 || std::isinf(src2[lane])) {
+                    vdst[lane] = signOut ? -INFINITY : +INFINITY;
+                } else if (src2[lane] == 0.0 || std::isinf(src1[lane])) {
+                    vdst[lane] = signOut ? -0.0 : +0.0;
+                } else if (exp2 - exp1 < -1075) {
+                    warn_once("fixup_f64 unimplemented case:"
+                              "exp2 - ex1 < -1075");
+                    vdst[lane] = src0[lane];
+                } else if (exp1 == 2047) {
+                    warn_once("fixup_f64 unimplemented case:"
+                              "exp1 == 2047");
+                    vdst[lane] = src0[lane];
                 } else {
-                    vdst[lane] = src2[lane] / src1[lane];
+                    vdst[lane] = ((uint64_t)signOut<<63) |
+                        ((uint64_t)src0[lane] & 0x7fffffffffffffffULL);
                 }
             }
         }
@@ -29077,8 +29089,37 @@

         for (int lane = 0; lane < NumVecElemPerVecReg; ++lane) {
             if (wf->execMask(lane)) {
-                vdst[lane] = src0[lane];
+                int exp1, exp2;
+                std::frexp(src1[lane],&exp1);
+                std::frexp(src2[lane],&exp2);
                 vcc.setBit(lane, 0);
+                if (src2[lane] == 0 || src1[lane] == 0) {
+                    vdst[lane] = NAN;
+                } else if (exp2 - exp1 >= 768) {
+                    vcc.setBit(lane, 1);
+                    if (src0[lane] == src1[lane]) {
+                        vdst[lane] = std::ldexp(src0[lane],128);
+                    }
+                } else if (exp1 == 0) {
+                    vdst[lane] = std::ldexp(src0[lane],128);
+                } else if (exp1 >= 0x7fd && exp2 - exp1 <= -768) {
+                    vcc.setBit(lane, 1);
+                    if (src0[lane] == src1[lane]) {
+                        vdst[lane] = std::ldexp(src0[lane],-128);
+                    }
+                } else if (exp1 >= 0x7fd) {
+                    vdst[lane] = std::ldexp(src0[lane],-128);
+                } else if (exp2 - exp1 <= -768) {
+                    vcc.setBit(lane, 1);
+                    if (src0[lane] != src2[lane]) {
+                        vdst[lane] = std::ldexp(src0[lane],128);
+                    }
+                } else if (exp2 <= 53) {
+                    vdst[lane] = std::ldexp(src0[lane],128);
+                }
+                else {
+                    vdst[lane] = src0[lane];
+                }
             }
         }

@@ -29171,10 +29212,12 @@
         ConstVecOperandF64 src1(gpuDynInst, extData.SRC1);
         ConstVecOperandF64 src2(gpuDynInst, extData.SRC2);
         VecOperandF64 vdst(gpuDynInst, instData.VDST);
+        ConstScalarOperandU64 vcc(gpuDynInst, REG_VCC_LO);

         src0.readSrc();
         src1.readSrc();
         src2.readSrc();
+        vcc.read();

         if (instData.ABS & 0x1) {
             src0.absModifier();
@@ -29202,7 +29245,12 @@

         for (int lane = 0; lane < NumVecElemPerVecReg; ++lane) {
             if (wf->execMask(lane)) {
-                vdst[lane] = std::fma(src0[lane], src1[lane], src2[lane]);
+                if (bits(vcc.rawData(), lane)) {
+                    vdst[lane] = pow(2,64) *
+                        std::fma(src0[lane], src1[lane], src2[lane]);
+                } else {
+ vdst[lane] = std::fma(src0[lane], src1[lane], src2[lane]);
+                }
             }
         }


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/29955
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: Ie13794554db8a958fda1f7103ec18058fda2e66d
Gerrit-Change-Number: 29955
Gerrit-PatchSet: 7
Gerrit-Owner: Anthony Gutierrez <anthony.gutier...@amd.com>
Gerrit-Reviewer: Anthony Gutierrez <anthony.gutier...@amd.com>
Gerrit-Reviewer: Matt Sinclair <mattdsincl...@gmail.com>
Gerrit-Reviewer: Tony Gutierrez <anthony.gutier...@amd.com>
Gerrit-Reviewer: Tuan Ta <q...@cornell.edu>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
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