From: Junyan He <junyan...@linux.intel.com> We will use SLM to store the value to broadcast and the map between real hw thread and logical workgroup thread. These two values give the offset in the SLM.
Signed-off-by: Junyan He <junyan...@linux.intel.com> --- backend/src/ir/function.cpp | 3 ++- backend/src/ir/function.hpp | 10 ++++++++++ backend/src/llvm/llvm_gen_backend.cpp | 16 ++++++++-------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/backend/src/ir/function.cpp b/backend/src/ir/function.cpp index f87f23a..00fe97c 100644 --- a/backend/src/ir/function.cpp +++ b/backend/src/ir/function.cpp @@ -43,7 +43,8 @@ namespace ir { /////////////////////////////////////////////////////////////////////////// Function::Function(const std::string &name, const Unit &unit, Profile profile) : - name(name), unit(unit), profile(profile), simdWidth(0), useSLM(false), slmSize(0), stackSize(0) + name(name), unit(unit), profile(profile), simdWidth(0), useSLM(false), slmSize(0), stackSize(0), + wgBroadcastSLM(-1), tidMapSLM(-1) { initProfile(*this); samplerSet = GBE_NEW(SamplerSet); diff --git a/backend/src/ir/function.hpp b/backend/src/ir/function.hpp index 265fdc3..ba589a3 100644 --- a/backend/src/ir/function.hpp +++ b/backend/src/ir/function.hpp @@ -453,6 +453,14 @@ namespace ir { block->foreach(functor); } } + /*! Get wgBroadcastSLM in this function */ + int32_t getwgBroadcastSLM(void) const { return wgBroadcastSLM; } + /*! Set wgBroadcastSLM for this function */ + void setwgBroadcastSLM(int32_t v) { wgBroadcastSLM = v; } + /*! Get tidMapSLM in this function */ + int32_t gettidMapSLM(void) const { return tidMapSLM; } + /*! Set tidMapSLM for this function */ + void settidMapSLM(int32_t v) { tidMapSLM = v; } /*! Does it use SLM */ INLINE bool getUseSLM(void) const { return this->useSLM; } /*! Change the SLM config for the function */ @@ -524,6 +532,8 @@ namespace ir { size_t compileWgSize[3]; //!< required work group size specified by // __attribute__((reqd_work_group_size(X, Y, Z))). std::string functionAttributes; //!< function attribute qualifiers combined. + int32_t wgBroadcastSLM; //!< Used for broadcast the workgroup value. + int32_t tidMapSLM; //!< Used to store the map between groupid and hw thread. GBE_CLASS(Function); //!< Use custom allocator }; diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp index b782d33..38da76b 100644 --- a/backend/src/llvm/llvm_gen_backend.cpp +++ b/backend/src/llvm/llvm_gen_backend.cpp @@ -470,7 +470,6 @@ namespace gbe /*! legacyMode is for hardware before BDW, * which do not support stateless memory access */ bool legacyMode; - int32_t wgBroadcastSLM; public: static char ID; explicit GenWriter(ir::Unit &unit) @@ -481,8 +480,7 @@ namespace gbe LI(0), TheModule(0), btiBase(BTI_RESERVED_NUM), - legacyMode(true), - wgBroadcastSLM(-1) + legacyMode(true) { #if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >=7 initializeLoopInfoWrapperPassPass(*PassRegistry::getPassRegistry()); @@ -3695,16 +3693,18 @@ namespace gbe } void GenWriter::emitWorkGroupInst(CallInst &I, CallSite &CS, ir::WorkGroupOps opcode) { - if (wgBroadcastSLM < 0 && opcode == ir::WORKGROUP_OP_BROADCAST) { - ir::Function &f = ctx.getFunction(); + ir::Function &f = ctx.getFunction(); + + if (f.getwgBroadcastSLM() < 0 && opcode == ir::WORKGROUP_OP_BROADCAST) { uint32_t mapSize = 8; f.setUseSLM(true); uint32_t oldSlm = f.getSLMSize(); f.setSLMSize(oldSlm + mapSize); - wgBroadcastSLM = oldSlm; - GBE_ASSERT(wgBroadcastSLM >= 0); + f.setwgBroadcastSLM(oldSlm); + GBE_ASSERT(f.getwgBroadcastSLM() >= 0); } + CallSite::arg_iterator AI = CS.arg_begin(); CallSite::arg_iterator AE = CS.arg_end(); GBE_ASSERT(AI != AE); @@ -3721,7 +3721,7 @@ namespace gbe src[i] = this->getRegister(*(AI++)); } const ir::Tuple srcTuple = ctx.arrayTuple(&src[0], argNum); - ctx.WORKGROUP(ir::WORKGROUP_OP_BROADCAST, (uint32_t)wgBroadcastSLM, getRegister(&I), srcTuple, argNum, + ctx.WORKGROUP(ir::WORKGROUP_OP_BROADCAST, (uint32_t)f.getwgBroadcastSLM(), getRegister(&I), srcTuple, argNum, getType(ctx, (*CS.arg_begin())->getType())); } else { const ir::Register src = this->getRegister(*(AI++)); -- 1.7.9.5 _______________________________________________ Beignet mailing list Beignet@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/beignet