The whole patchset LGTM. Thanks! -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Zhigang Gong Sent: Wednesday, November 13, 2013 8:35 AM To: [email protected] Cc: Zhigang Gong Subject: [Beignet] [PATCH 2/2] GBE: fix the constant data allocation.
From: Zhigang Gong <[email protected]> Need to keep consistency between the constant data allocation and the constant register allocation. So we need to skip the unused constant data at the constant data allocation stage. To avoid possible mismatching, add a new assert in the constant register(address) allocation stage to make sure the address register match the eaxct constant data. Also modify the constant utest slightly to hit this code path. Signed-off-by: Zhigang Gong <[email protected]> --- backend/src/llvm/llvm_gen_backend.cpp | 2 ++ kernels/compiler_global_constant.cl | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp index a104df4..5421fdc 100644 --- a/backend/src/llvm/llvm_gen_backend.cpp +++ b/backend/src/llvm/llvm_gen_backend.cpp @@ -681,6 +681,7 @@ namespace gbe const Module::GlobalListType &globalList = TheModule->getGlobalList(); for(auto i = globalList.begin(); i != globalList.end(); i ++) { const GlobalVariable &v = *i; + if(!v.isConstantUsed()) continue; const char *name = v.getName().data(); unsigned addrSpace = v.getType()->getAddressSpace(); if(addrSpace == ir::AddressSpace::MEM_CONSTANT) { @@ -1380,6 +1381,7 @@ namespace gbe this->newRegister(const_cast<GlobalVariable*>(&v)); ir::Register reg = regTranslator.getScalar(const_cast<GlobalVariable*>(&v), 0); ir::Constant &con = unit.getConstantSet().getConstant(j ++); + GBE_ASSERT(con.getName() == v.getName()); ctx.LOADI(ir::TYPE_S32, reg, ctx.newIntegerImmediate(con.getOffset(), ir::TYPE_S32)); } else { GBE_ASSERT(0); diff --git a/kernels/compiler_global_constant.cl b/kernels/compiler_global_constant.cl index 53e24b3..c0e23d1 100644 --- a/kernels/compiler_global_constant.cl +++ b/kernels/compiler_global_constant.cl @@ -1,5 +1,5 @@ constant int m[3] = {71,72,73}; -constant int n = 1; +const constant int n = 1; constant int o[3] = {3, 2, 1}; constant int4 a= {1, 2, 3, 4}; -- 1.7.9.5 _______________________________________________ Beignet mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/beignet _______________________________________________ Beignet mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/beignet
