[Beignet] [PATCH 02/15] Backend: Add StoreProfiling and CalcTimestamp instructions

Luo, Xionghu xionghu.luo at intel.com
Wed Aug 12 18:32:05 PDT 2015



Luo Xionghu
Best Regards

-----Original Message-----
From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of junyan.he at inbox.com
Sent: Wednesday, August 12, 2015 4:49 PM
To: beignet at lists.freedesktop.org
Cc: Junyan He
Subject: [Beignet] [PATCH 02/15] Backend: Add StoreProfiling and CalcTimestamp instructions

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

Add two instructions for profiling usage. CalcTimestamp will calculate the timestamps and update the timestamp in the according slot. StoreProfiling will store the information to buffer and generate logs.

Signed-off-by: Junyan He <junyan.he at linux.intel.com>
---
 backend/src/ir/instruction.cpp |   98 +++++++++++++++++++++++++++++++++++++++-
 backend/src/ir/instruction.hpp |   26 +++++++++++
 backend/src/ir/instruction.hxx |    2 +
 3 files changed, 125 insertions(+), 1 deletion(-)

diff --git a/backend/src/ir/instruction.cpp b/backend/src/ir/instruction.cpp index f93c528..8dabc32 100644
--- a/backend/src/ir/instruction.cpp
+++ b/backend/src/ir/instruction.cpp
@@ -677,6 +677,60 @@ namespace ir {
       static const uint32_t dstNum = 1;
     };
 
+    class ALIGNED_INSTRUCTION CalcTimestampInstruction :
+      public BasePolicy,
+      public NSrcPolicy<CalcTimestampInstruction, 0>,
+      public NDstPolicy<CalcTimestampInstruction, 0>
+    {
+    public:
+      CalcTimestampInstruction(uint32_t pointNum, uint32_t timestampType) {
+        this->opcode = OP_CALC_TIMESTAMP;
+        this->timestampType = static_cast<uint8_t>(timestampType);
+        this->pointNum = static_cast<uint8_t>(pointNum);
+      }
+
+      INLINE bool wellFormed(const Function &fn, std::string &why) const;
+      INLINE void out(std::ostream &out, const Function &fn) const {
+        this->outOpcode(out);
+        out << "TimeStamp pointer " << static_cast<uint32_t>(pointNum)
+          << " (Type " << static_cast<uint32_t>(timestampType) << ")";
+      }
+      uint32_t getPointNum(void) const { return this->pointNum; }
+      uint32_t getTimestamptType(void) const { return this->timestampType; }
+      uint8_t timestampType;       //!< Type of the time stamp, 16bits or 32bits, eg.
+      uint8_t pointNum;            //!< The insert point number.
+      Register dst[0], src[0];
+    };
+
+    class ALIGNED_INSTRUCTION StoreProfilingInstruction :
+      public BasePolicy,
+      public NSrcPolicy<StoreProfilingInstruction, 1>,
+      public NDstPolicy<StoreProfilingInstruction, 0>
+    {
+    public:
+      StoreProfilingInstruction(Register ptr, uint32_t bti, uint32_t profilingType) {
+        this->opcode = OP_STORE_PROFILING;
+	this->profilingType = static_cast<uint8_t>(profilingType);
+	this->bti = static_cast<uint8_t>(bti);
+        this->src[0] = ptr;
+      }
+
+      INLINE bool wellFormed(const Function &fn, std::string &why) const;
+      INLINE void out(std::ostream &out, const Function &fn) const {
+        this->outOpcode(out);
+        out << "Store Profiling at %" << src[0]
+          << " BTI " << static_cast<uint32_t>(this->bti)
+          << " (Type " << static_cast<uint32_t>(this->profilingType) << ")";
+      }
+
+      uint32_t getProfilingType(void) const { return this->profilingType; }
+      uint32_t getBTI(void) const { return this->bti; }
+      uint8_t profilingType;     //!< Type format of profiling, 16bits or 32bits, eg.
+      uint8_t bti;
+      Register src[1];
+      Register dst[0];
+    };
+
     class ALIGNED_INSTRUCTION LoadImmInstruction :
       public BasePolicy,
       public NSrcPolicy<LoadImmInstruction, 0>, @@ -1226,6 +1280,26 @@ namespace ir {
       return true;
     }
 
+    INLINE bool CalcTimestampInstruction::wellFormed(const Function &fn, std::string &whyNot) const {
+      if (UNLIKELY(this->timestampType != 1)) {
+        whyNot = "Wrong time stamp type";
+        return false;
+      }
+      if (UNLIKELY(this->pointNum >= 20 && this->pointNum != 0xff && this->pointNum != 0xfe)) {
>>>> this condition is unreasonable. 

+        whyNot = "To much Insert pointer";
+        return false;
+      }
+      return true;
+    }
+
+    INLINE bool StoreProfilingInstruction::wellFormed(const Function &fn, std::string &whyNot) const {
+      if (UNLIKELY(this->profilingType != 1)) {
+        whyNot = "Wrong profiling format";
+        return false;
+      }
+      return true;
+    }
+
 #undef CHECK_TYPE
 
     /////////////////////////////////////////////////////////////////////////
@@ -1466,6 +1540,14 @@ START_INTROSPECTION(GetImageInfoInstruction)
 #include "ir/instruction.hxx"
 END_INTROSPECTION(GetImageInfoInstruction)
 
+START_INTROSPECTION(CalcTimestampInstruction)
+#include "ir/instruction.hxx"
+END_INTROSPECTION(CalcTimestampInstruction)
+
+START_INTROSPECTION(StoreProfilingInstruction)
+#include "ir/instruction.hxx"
+END_INTROSPECTION(StoreProfilingInstruction)
+
 START_INTROSPECTION(LoadImmInstruction)
 #include "ir/instruction.hxx"
 END_INTROSPECTION(LoadImmInstruction)
@@ -1645,7 +1727,9 @@ END_FUNCTION(Instruction, Register)
     return opcode == OP_STORE ||
            opcode == OP_TYPED_WRITE ||
            opcode == OP_SYNC ||
-           opcode == OP_ATOMIC;
+           opcode == OP_ATOMIC ||
+           opcode == OP_CALC_TIMESTAMP ||
+           opcode == OP_STORE_PROFILING;
   }
 
 #define DECL_MEM_FN(CLASS, RET, PROTOTYPE, CALL) \ @@ -1699,6 +1783,10 @@ DECL_MEM_FN(TypedWriteInstruction, Type, getCoordType(void), getCoordType())  DECL_MEM_FN(TypedWriteInstruction, uint8_t, getImageIndex(void), getImageIndex())  DECL_MEM_FN(GetImageInfoInstruction, uint32_t, getInfoType(void), getInfoType())  DECL_MEM_FN(GetImageInfoInstruction, uint8_t, getImageIndex(void), getImageIndex())
+DECL_MEM_FN(CalcTimestampInstruction, uint32_t, getPointNum(void), 
+getPointNum()) DECL_MEM_FN(CalcTimestampInstruction, uint32_t, 
+getTimestamptType(void), getTimestamptType()) 
+DECL_MEM_FN(StoreProfilingInstruction, uint32_t, 
+getProfilingType(void), getProfilingType()) 
+DECL_MEM_FN(StoreProfilingInstruction, uint32_t, getBTI(void), 
+getBTI())
 
 #undef DECL_MEM_FN
 
@@ -1940,6 +2028,14 @@ DECL_MEM_FN(GetImageInfoInstruction, uint8_t, getImageIndex(void), getImageIndex
     return internal::GetImageInfoInstruction(infoType, dst, imageIndex, infoReg).convert();
   }
 
+  Instruction CALC_TIMESTAMP(uint32_t pointNum, uint32_t tsType) {
+    return internal::CalcTimestampInstruction(pointNum, 
+ tsType).convert();  }
+
+  Instruction STORE_PROFILING(Register ptr, uint32_t bti, uint32_t profilingType) {
+    return internal::StoreProfilingInstruction(ptr, bti, 
+ profilingType).convert();  }
+
   std::ostream &operator<< (std::ostream &out, const Instruction &insn) {
     const Function &fn = insn.getFunction();
     const BasicBlock *bb = insn.getParent(); diff --git a/backend/src/ir/instruction.hpp b/backend/src/ir/instruction.hpp index cf8d839..da486a0 100644
--- a/backend/src/ir/instruction.hpp
+++ b/backend/src/ir/instruction.hpp
@@ -440,6 +440,28 @@ namespace ir {
     static bool isClassOf(const Instruction &insn);
   };
 
+  /*! calculate the exec time and store it. */  class 
+ CalcTimestampInstruction : public Instruction {
+  public:
+    /*! Return true if the given instruction is an instance of this class */
+    static bool isClassOf(const Instruction &insn);
+    /*! Get the point number of timestamp point */
+    uint32_t getPointNum(void) const;
+    /*! Get the timestamp type */
+    uint32_t getTimestamptType(void) const;  };
+
+  /*! store the profiling information. */  class 
+ StoreProfilingInstruction : public Instruction {
+  public:
+    /*! Return true if the given instruction is an instance of this class */
+    static bool isClassOf(const Instruction &insn);
+    /*! Get the profiling info type */
+    uint32_t getProfilingType(void) const;
+    /*! Get the BTI index*/
+    uint32_t getBTI(void) const;
+  };
+
   /*! Branch instruction is the unified way to branch (with or without
    *  predicate)
    */
@@ -757,6 +779,10 @@ namespace ir {
   Instruction SAMPLE(uint8_t imageIndex, Tuple dst, Tuple src, uint8_t srcNum, bool dstIsFloat, bool srcIsFloat, uint8_t sampler, uint8_t samplerOffset);
   /*! get image information , such as width/height/depth/... */
   Instruction GET_IMAGE_INFO(int infoType, Register dst, uint8_t imageIndex, Register infoReg);
+  /*! calculate the execute timestamp for profiling */  Instruction 
+ CALC_TIMESTAMP(uint32_t pointNum, uint32_t tsType);  /*! calculate the 
+ execute timestamp for profiling */  Instruction 
+ STORE_PROFILING(Register ptr, uint32_t bti, uint32_t Type);
   /*! label labelIndex */
   Instruction LABEL(LabelIndex labelIndex);
 
diff --git a/backend/src/ir/instruction.hxx b/backend/src/ir/instruction.hxx index 81548c9..207356e 100644
--- a/backend/src/ir/instruction.hxx
+++ b/backend/src/ir/instruction.hxx
@@ -106,3 +106,5 @@ DECL_INSN(IF, BranchInstruction)  DECL_INSN(ENDIF, BranchInstruction)  DECL_INSN(ELSE, BranchInstruction)  DECL_INSN(WHILE, BranchInstruction)
+DECL_INSN(CALC_TIMESTAMP, CalcTimestampInstruction) 
+DECL_INSN(STORE_PROFILING, StoreProfilingInstruction)
--
1.7.9.5

_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list