[Beignet] [PATCH] Backend: Fix barrier placement in workgroup reduce/scan

grigore.lupescu at intel.com grigore.lupescu at intel.com
Fri Apr 1 09:58:49 UTC 2016


From: Grigore Lupescu <grigore.lupescu at intel.com>

Signed-off-by: Grigore Lupescu <grigore.lupescu at intel.com>
---
 backend/src/backend/gen_context.cpp        | 15 +++++++++++----
 backend/src/backend/gen_insn_selection.cpp |  1 -
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/backend/src/backend/gen_context.cpp b/backend/src/backend/gen_context.cpp
index c5c27c6..764c1cb 100644
--- a/backend/src/backend/gen_context.cpp
+++ b/backend/src/backend/gen_context.cpp
@@ -2620,6 +2620,7 @@ namespace gbe
     GenRegister partialData = GenRegister::toUniform(threadData, dst.type);
     GenRegister threadId = ra->genReg(insn.src(0));
     GenRegister threadLoop = ra->genReg(insn.src(1));
+    GenRegister barrierId = ra->genReg(GenRegister::ud1grf(ir::ocl::barrierid));
 
     uint32_t wg_op = insn.extra.workgroupOp;
     uint32_t simd = p->curr.execWidth;
@@ -2688,10 +2689,16 @@ namespace gbe
     /* Init partialData register, it will hold the final result */
     initValue(p, partialData, wg_op);
 
-    p->FENCE(msgData);
-    p->MOV(msgData, msgData);
-    p->FENCE(msgData);
-    p->MOV(msgData, msgData);
+    /* Add call to barrier */
+    p->push();
+      p->curr.execWidth = 8;
+      p->curr.physicalFlag = 0;
+      p->curr.noMask = 1;
+      p->AND(msgData, barrierId, GenRegister::immud(0x0f000000));
+      p->BARRIER(msgData);
+      p->curr.execWidth = 1;
+      p->WAIT();
+    p->pop();
 
     /* Perform a loop, based on thread count (which is now multiple of 4) */
     p->push();{
diff --git a/backend/src/backend/gen_insn_selection.cpp b/backend/src/backend/gen_insn_selection.cpp
index 3fe0465..96cc215 100644
--- a/backend/src/backend/gen_insn_selection.cpp
+++ b/backend/src/backend/gen_insn_selection.cpp
@@ -6474,7 +6474,6 @@ namespace gbe
       sel.MOV(slmOff, GenRegister::immud(insn.getSlmAddr()));
 
       /* barrier for syn prior to workgroup */
-      sel.BARRIER(GenRegister::ud8grf(sel.reg(FAMILY_DWORD)), sel.selReg(sel.reg(FAMILY_DWORD)), syncLocalBarrier);
       sel.WORKGROUP_OP(workGroupOp, dst, src, data, threadId, threadN, tmp, slmOff, msg);
 
       return true;
-- 
2.5.0



More information about the Beignet mailing list