[Beignet] [PATCH 12/13] Backend: Add reduce add to gen_context.

junyan.he at inbox.com junyan.he at inbox.com
Tue Dec 1 00:10:39 PST 2015


From: Junyan He <junyan.he at linux.intel.com>

Signed-off-by: Junyan He <junyan.he at linux.intel.com>
---
 backend/src/backend/gen_context.cpp |   24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/backend/src/backend/gen_context.cpp b/backend/src/backend/gen_context.cpp
index d099920..c8f0713 100644
--- a/backend/src/backend/gen_context.cpp
+++ b/backend/src/backend/gen_context.cpp
@@ -2856,7 +2856,10 @@ namespace gbe
         cond = GEN_CONDITIONAL_GE;
 
       p->SEL_CMP(cond, msgData, threadData, msgData);
+    } else if (wg_op == ir::WORKGROUP_OP_REDUCE_ADD) {
+      p->ADD(msgData, threadData, msgData);
     }
+
     p->pop();
   }
 
@@ -2867,7 +2870,8 @@ namespace gbe
         p->MOV(dataReg, GenRegister::immud(0xFFFFFFFF));
       } else {
         GBE_ASSERT(wg_op == ir::WORKGROUP_OP_REDUCE_MAX || wg_op == ir::WORKGROUP_OP_INCLUSIVE_MAX
-             || wg_op == ir::WORKGROUP_OP_EXCLUSIVE_MAX);
+             || wg_op == ir::WORKGROUP_OP_EXCLUSIVE_MAX || wg_op == ir::WORKGROUP_OP_REDUCE_ADD
+             || wg_op == ir::WORKGROUP_OP_INCLUSIVE_ADD || wg_op == ir::WORKGROUP_OP_EXCLUSIVE_ADD);
         p->MOV(dataReg, GenRegister::immud(0));
       }
     } else if (dataReg.type == GEN_TYPE_F) {
@@ -2877,6 +2881,10 @@ namespace gbe
       } else if (wg_op == ir::WORKGROUP_OP_REDUCE_MAX || wg_op == ir::WORKGROUP_OP_INCLUSIVE_MAX
           || wg_op == ir::WORKGROUP_OP_EXCLUSIVE_MAX) {
         p->MOV(GenRegister::retype(dataReg, GEN_TYPE_UD), GenRegister::immud(0xFF800000)); // -inf
+      } else {
+        GBE_ASSERT(wg_op == ir::WORKGROUP_OP_REDUCE_ADD || wg_op == ir::WORKGROUP_OP_INCLUSIVE_ADD
+            || wg_op == ir::WORKGROUP_OP_EXCLUSIVE_ADD);
+        p->MOV(GenRegister::retype(dataReg, GEN_TYPE_UD), GenRegister::immud(0x0));
       }
     } else {
       GBE_ASSERT(0);
@@ -2928,6 +2936,17 @@ namespace gbe
           }
         }
       }
+    } else if (wg_op == ir::WORKGROUP_OP_REDUCE_ADD) {
+      GBE_ASSERT(tmp.type == theVal.type);
+      GenRegister v = GenRegister::toUniform(tmp, theVal.type);
+      for (uint32_t i = 0; i < simd; i++) {
+        p->ADD(threadData, threadData, v);
+        v.subnr += typeSize(theVal.type);
+        if (v.subnr == 32) {
+          v.subnr = 0;
+          v.nr++;
+        }
+      }
     }
 
     p->pop();
@@ -3082,7 +3101,8 @@ do { \
     } p->pop();
 
     /* Broadcast the result. */
-    if (wg_op == ir::WORKGROUP_OP_REDUCE_MIN || wg_op == ir::WORKGROUP_OP_REDUCE_MAX) {
+    if (wg_op == ir::WORKGROUP_OP_REDUCE_MIN || wg_op == ir::WORKGROUP_OP_REDUCE_MAX
+        || wg_op == ir::WORKGROUP_OP_REDUCE_ADD) {
       p->push(); {
         p->curr.predicate = GEN_PREDICATE_NORMAL;
         p->curr.noMask = 1;
-- 
1.7.9.5





More information about the Beignet mailing list