[Beignet] [Printf][PATCH 02/11] Add PrintfLog structure.

Yan Wang yan.wang at linux.intel.com
Wed Jan 20 19:28:37 PST 2016


Contributor: Junyan He <junyan.he at linux.intel.com>
Signed-off-by: Yan Wang <yan.wang at linux.intel.com>
---
 backend/src/ir/printf.hpp | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/backend/src/ir/printf.hpp b/backend/src/ir/printf.hpp
index def6331..6b2b741 100644
--- a/backend/src/ir/printf.hpp
+++ b/backend/src/ir/printf.hpp
@@ -144,6 +144,31 @@ namespace gbe
       }
     };
 
+    struct PrintfLog {
+      uint32_t magic;  // 0xAABBCCDD as magic for ASSERT.
+      uint32_t size;  // Size of this printf log, include header.
+      uint32_t statementNum; // which printf within one kernel.
+      const char* content;
+
+      PrintfLog(const char* p) {
+        GBE_ASSERT(*((uint32_t *)p) == 0xAABBCCDD);
+        magic = *((uint32_t *)p);
+        p += sizeof(uint32_t);
+        size = *((uint32_t *)p);
+        p += sizeof(uint32_t);
+        statementNum = *((uint32_t *)p);
+        p += sizeof(uint32_t);
+        content = p;
+      }
+
+      template <typename T>
+      T getData(void) {
+        T D = *((T *)content);
+        content += sizeof(T);
+        return D;
+      }
+    };
+
     class Context;
 
     class PrintfSet //: public Serializable
-- 
2.4.3



More information about the Beignet mailing list