[Beignet] [PATCH 17/21 V3] Backend: Add ADD_ and SUB_ timestamps help functions.

junyan.he at inbox.com junyan.he at inbox.com
Mon Nov 16 15:40:19 PST 2015


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

The timestamps are calculated by Long type. Before BDW,
there is no Long type support and we use i32 operations
to implement them.

Signed-off-by: Junyan He <junyan.he at linux.intel.com>
---
 backend/src/backend/gen8_context.cpp |   21 +++++++++++++++
 backend/src/backend/gen8_context.hpp |    2 ++
 backend/src/backend/gen_context.cpp  |   49 +++++++++++++++++++++++++++++-----
 backend/src/backend/gen_context.hpp  |    2 ++
 4 files changed, 67 insertions(+), 7 deletions(-)

diff --git a/backend/src/backend/gen8_context.cpp b/backend/src/backend/gen8_context.cpp
index 5b1529d..71d900f 100644
--- a/backend/src/backend/gen8_context.cpp
+++ b/backend/src/backend/gen8_context.cpp
@@ -1151,6 +1151,27 @@ namespace gbe
     p->pop();
   }
 
+  void Gen8Context::subTimestamps(GenRegister& t0, GenRegister& t1, GenRegister& tmp)
+  {
+    p->push(); {
+      p->curr.execWidth = 1;
+      p->curr.predicate = GEN_PREDICATE_NONE;
+      p->curr.noMask = 1;
+      p->ADD(GenRegister::retype(t0, GEN_TYPE_UL), GenRegister::retype(t0, GEN_TYPE_UL),
+          GenRegister::negate(GenRegister::retype(t1, GEN_TYPE_UL)));
+    } p->pop();
+  }
+
+  void Gen8Context::addTimestamps(GenRegister& t0, GenRegister& t1, GenRegister& tmp) {
+    p->push(); {
+      p->curr.execWidth = 1;
+      p->curr.predicate = GEN_PREDICATE_NONE;
+      p->curr.noMask = 1;
+      p->ADD(GenRegister::retype(t0, GEN_TYPE_UL), GenRegister::retype(t0, GEN_TYPE_UL),
+          GenRegister::retype(t1, GEN_TYPE_UL));
+    } p->pop();
+  }
+
   void ChvContext::newSelection(void) {
     this->sel = GBE_NEW(SelectionChv, *this);
   }
diff --git a/backend/src/backend/gen8_context.hpp b/backend/src/backend/gen8_context.hpp
index 386f7f3..537aef5 100644
--- a/backend/src/backend/gen8_context.hpp
+++ b/backend/src/backend/gen8_context.hpp
@@ -78,6 +78,8 @@ namespace gbe
 
   protected:
     virtual void setA0Content(uint16_t new_a0[16], uint16_t max_offset = 0, int sz = 0);
+    virtual void subTimestamps(GenRegister& t0, GenRegister& t1, GenRegister& tmp);
+    virtual void addTimestamps(GenRegister& t0, GenRegister& t1, GenRegister& tmp);
     virtual GenEncoder* generateEncoder(void) {
       return GBE_NEW(Gen8Encoder, this->simdWidth, 8, deviceID);
     }
diff --git a/backend/src/backend/gen_context.cpp b/backend/src/backend/gen_context.cpp
index 6627d14..422e52f 100644
--- a/backend/src/backend/gen_context.cpp
+++ b/backend/src/backend/gen_context.cpp
@@ -2474,13 +2474,7 @@ namespace gbe
   void GenContext::profilingProlog(void) {
     // record the prolog, globalXYZ and lasttimestamp at the very beginning.
     GenRegister profilingReg2, profilingReg3, profilingReg4;
-    GenRegister tmArf = GenRegister(GEN_ARCHITECTURE_REGISTER_FILE,
-        0xc0,
-        0,
-        GEN_TYPE_UW,
-        GEN_VERTICAL_STRIDE_4,
-        GEN_WIDTH_4,
-        GEN_HORIZONTAL_STRIDE_1);
+    GenRegister tmArf = GenRegister::tm0();
     if (this->simdWidth == 16) {
       profilingReg2 = ra->genReg(GenRegister::ud16grf(ir::ocl::profilingts1));
       profilingReg3 = GenRegister::offset(profilingReg2, 1);
@@ -2527,6 +2521,47 @@ namespace gbe
     return;
   }
 
+  void GenContext::subTimestamps(GenRegister& t0, GenRegister& t1, GenRegister& tmp)
+  {
+    p->push(); {
+      p->curr.execWidth = 1;
+      p->curr.predicate = GEN_PREDICATE_NONE;
+      p->curr.noMask = 1;
+      p->SUBB(GenRegister::retype(t0, GEN_TYPE_UD),
+          GenRegister::retype(t0, GEN_TYPE_UD), GenRegister::retype(t1, GEN_TYPE_UD));
+      /* FIXME We can not get the acc register's value correctly by set simd = 1. */
+      p->curr.execWidth = 8;
+      p->MOV(tmp, GenRegister::retype(GenRegister::acc(), GEN_TYPE_UD));
+      p->curr.execWidth = 1;
+      p->ADD(GenRegister::retype(GenRegister::offset(t0, 0, sizeof(uint32_t)), GEN_TYPE_UD),
+          GenRegister::retype(GenRegister::offset(t0, 0, sizeof(uint32_t)), GEN_TYPE_UD),
+          GenRegister::negate(GenRegister::toUniform(tmp, GEN_TYPE_UD)));
+      p->ADD(GenRegister::retype(GenRegister::offset(t0, 0, sizeof(uint32_t)), GEN_TYPE_UD),
+          GenRegister::retype(GenRegister::offset(t0, 0, sizeof(uint32_t)), GEN_TYPE_UD),
+          GenRegister::negate(GenRegister::retype(GenRegister::offset(t1, 0, sizeof(uint32_t)), GEN_TYPE_UD)));
+    } p->pop();
+  }
+
+  void GenContext::addTimestamps(GenRegister& t0, GenRegister& t1, GenRegister& tmp)
+  {
+    p->push(); {
+      p->curr.execWidth = 1;
+      p->curr.predicate = GEN_PREDICATE_NONE;
+      p->curr.noMask = 1;
+      p->ADDC(GenRegister::retype(t0, GEN_TYPE_UD),
+          GenRegister::retype(t0, GEN_TYPE_UD), GenRegister::retype(t1, GEN_TYPE_UD));
+      p->curr.execWidth = 8;
+      p->MOV(tmp, GenRegister::retype(GenRegister::acc(), GEN_TYPE_UD));
+      p->curr.execWidth = 1;
+      p->ADD(GenRegister::retype(GenRegister::offset(t0, 0, sizeof(uint32_t)), GEN_TYPE_UD),
+          GenRegister::retype(GenRegister::offset(t0, 0, sizeof(uint32_t)), GEN_TYPE_UD),
+          GenRegister::offset(GenRegister::toUniform(tmp, GEN_TYPE_UD), 0, 6*sizeof(uint32_t)));
+      p->ADD(GenRegister::retype(GenRegister::offset(t0, 0, sizeof(uint32_t)), GEN_TYPE_UD),
+          GenRegister::retype(GenRegister::offset(t0, 0, sizeof(uint32_t)), GEN_TYPE_UD),
+          GenRegister::retype(GenRegister::offset(t1, 0, sizeof(uint32_t)), GEN_TYPE_UD));
+    } p->pop();
+  }
+
   void GenContext::emitCalcTimestampInstruction(const SelectionInstruction &insn) {
 
   }
diff --git a/backend/src/backend/gen_context.hpp b/backend/src/backend/gen_context.hpp
index 087e186..af252ed 100644
--- a/backend/src/backend/gen_context.hpp
+++ b/backend/src/backend/gen_context.hpp
@@ -225,6 +225,8 @@ namespace gbe
 
     virtual void setA0Content(uint16_t new_a0[16], uint16_t max_offset = 0, int sz = 0);
     void calcGlobalXYZRange(GenRegister& reg, GenRegister& tmp, int flag, int subFlag);
+    virtual void subTimestamps(GenRegister& t0, GenRegister& t1, GenRegister& tmp);
+    virtual void addTimestamps(GenRegister& t0, GenRegister& t1, GenRegister& tmp);
 
   private:
     CompileErrorCode errCode;
-- 
1.7.9.5





More information about the Beignet mailing list