[Beignet] [PATCH 1/8] BDW: Fix Pointer argument curbe alloce size.

Yang Rong rong.r.yang at intel.com
Sun Sep 28 22:38:30 PDT 2014


Because kernel will write 64bits address when reloc, so when reloc argument
in the curbe bo, the pointer need 8 byte curbe.

Signed-off-by: Yang Rong <rong.r.yang at intel.com>
---
 backend/src/backend/gen8_context.hpp | 2 ++
 backend/src/backend/gen_context.cpp  | 9 +++++----
 backend/src/backend/gen_context.hpp  | 2 ++
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/backend/src/backend/gen8_context.hpp b/backend/src/backend/gen8_context.hpp
index 3269eeb..684a366 100644
--- a/backend/src/backend/gen8_context.hpp
+++ b/backend/src/backend/gen8_context.hpp
@@ -47,6 +47,8 @@ namespace gbe
       //Because the allocate is use uint16_t, so clamp it, need refine
       return std::min(GEN8_SCRATCH_SIZE, 0x7fff);
     }
+    /*! Get the pointer argument size for curbe alloc */
+    virtual uint32_t getPointerSize(void) { return 8; }
 
   protected:
     virtual GenEncoder* generateEncoder(void) {
diff --git a/backend/src/backend/gen_context.cpp b/backend/src/backend/gen_context.cpp
index 1d0cf10..81758eb 100644
--- a/backend/src/backend/gen_context.cpp
+++ b/backend/src/backend/gen_context.cpp
@@ -1794,7 +1794,7 @@ namespace gbe
   }
 
   void GenContext::buildPatchList(void) {
-    const uint32_t ptrSize = unit.getPointerSize() == ir::POINTER_32_BITS ? 4u : 8u;
+    const uint32_t ptrSize = this->getPointerSize();
     kernel->curbeSize = 0u;
     auto &stackUse = dag->getUse(ir::ocl::stackptr);
 
@@ -1816,12 +1816,13 @@ namespace gbe
       // For pointers and values, we have nothing to do. We just push the values
       if (arg.type == ir::FunctionArgument::GLOBAL_POINTER ||
           arg.type == ir::FunctionArgument::LOCAL_POINTER ||
-          arg.type == ir::FunctionArgument::CONSTANT_POINTER ||
-          arg.type == ir::FunctionArgument::VALUE ||
+          arg.type == ir::FunctionArgument::CONSTANT_POINTER)
+        this->insertCurbeReg(arg.reg, this->newCurbeEntry(GBE_CURBE_KERNEL_ARGUMENT, argID, ptrSize, ptrSize));
+      if (arg.type == ir::FunctionArgument::VALUE ||
           arg.type == ir::FunctionArgument::STRUCTURE ||
           arg.type == ir::FunctionArgument::IMAGE ||
           arg.type == ir::FunctionArgument::SAMPLER)
-        this->insertCurbeReg(arg.reg, this->newCurbeEntry(GBE_CURBE_KERNEL_ARGUMENT, argID, arg.size, ptrSize));
+        this->insertCurbeReg(arg.reg, this->newCurbeEntry(GBE_CURBE_KERNEL_ARGUMENT, argID, arg.size, arg.size));
     }
 
     // Go over all the instructions and find the special register we need
diff --git a/backend/src/backend/gen_context.hpp b/backend/src/backend/gen_context.hpp
index 0e0e728..0be225a 100644
--- a/backend/src/backend/gen_context.hpp
+++ b/backend/src/backend/gen_context.hpp
@@ -76,6 +76,8 @@ namespace gbe
     virtual uint32_t alignScratchSize(uint32_t size);
     /*! Get the device's max srcatch size */
     virtual uint32_t getScratchSize(void) { return GEN7_SCRATCH_SIZE; }
+    /*! Get the pointer argument size for curbe alloc */
+    virtual uint32_t getPointerSize(void) { return 4; }
     /*! Function we emit code for */
     INLINE const ir::Function &getFunction(void) const { return fn; }
     /*! Simd width chosen for the current function */
-- 
1.8.3.2



More information about the Beignet mailing list