diff options
author | Junyan He <junyan.he@linux.intel.com> | 2015-12-01 16:10:29 +0800 |
---|---|---|
committer | Yang Rong <rong.r.yang@intel.com> | 2015-12-14 15:11:21 +0800 |
commit | 6a9f7bd276285d1ceaffb2abc3963c006313c317 (patch) | |
tree | 760a5033d5d313ca9a7b4f9a0c38514b534d7faa | |
parent | 1bdab2377bb0597bb92a8006233f49c8341e5ea3 (diff) |
Backend: Add tidMapSLM and wgBroadcastSLM to each function.
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.he@linux.intel.com>
Reviewed-by: Yang Rong <rong.r.yang@intel.com>
-rw-r--r-- | backend/src/ir/function.cpp | 3 | ||||
-rw-r--r-- | backend/src/ir/function.hpp | 10 | ||||
-rw-r--r-- | 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 f87f23af..00fe97c2 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 cbaa2083..78250cfe 100644 --- a/backend/src/ir/function.hpp +++ b/backend/src/ir/function.hpp @@ -479,6 +479,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 */ @@ -550,6 +558,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 c335b43c..e04f8517 100644 --- a/backend/src/llvm/llvm_gen_backend.cpp +++ b/backend/src/llvm/llvm_gen_backend.cpp @@ -513,7 +513,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) @@ -524,8 +523,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()); @@ -3807,16 +3805,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); @@ -3833,7 +3833,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++)); |