/*! Free the given register file piece */
void deallocate(int16_t offset);
+ /*! Spilt a block into 2 blocks */
+ void splitBlock(int16_t offset, int16_t subOffset);
+
private:
/*! May need to make that run-time in the future */
static const int16_t RegisterFileSize = 4*KB;
}
}
+ void RegisterFilePartitioner::splitBlock(int16_t offset, int16_t subOffset) {
+ // Retrieve the size in the allocation map
+ auto it = allocatedBlocks.find(offset);
+ GBE_ASSERT(it != allocatedBlocks.end());
+
+ while(subOffset > it->second) {
+ subOffset -= it->second;
+ offset += it->second;
+ it = allocatedBlocks.find(offset);
+ GBE_ASSERT(it != allocatedBlocks.end());
+ }
+
+ if(subOffset == 0)
+ return;
+ int16_t size = it->second;
+ allocatedBlocks.erase(it);
+ // Track the allocation to retrieve the size later
+ allocatedBlocks.insert(std::make_pair(offset, subOffset));
+ allocatedBlocks.insert(std::make_pair(offset + subOffset, size - subOffset));
+ }
+
static int
alignScratchSize(int size){
int i = 0;
void Context::deallocate(int16_t offset) { partitioner->deallocate(offset); }
+ void Context::splitBlock(int16_t offset, int16_t subOffset) {
+ partitioner->splitBlock(offset, subOffset);
+ }
+
int32_t Context::allocConstBuf(uint32_t argID) {
GBE_ASSERT(kernel->args[argID].type == GBE_ARG_CONSTANT_PTR);
int16_t allocate(int16_t size, int16_t alignment);
/*! Deallocate previously allocated memory */
void deallocate(int16_t offset);
+ /*! Spilt a block into 2 blocks, for some registers allocate together but deallocate seperate */
+ void splitBlock(int16_t offset, int16_t subOffset);
/* allocate curbe for constant ptr argument */
int32_t allocConstBuf(uint32_t argID);
/* allocate a new entry for a specific image's information */
const Function &fn = ctx.getFunction();
GBE_ASSERT(fn.getProfile() == PROFILE_OCL);
const Function::PushMap &pushMap = fn.getPushMap();
- for (const auto &pushed : pushMap) {
- const uint32_t argID = pushed.second.argID;
+ for (auto rit = pushMap.rbegin(); rit != pushMap.rend(); ++rit) {
+ const uint32_t argID = rit->second.argID;
const FunctionArgument arg = fn.getArg(argID);
- const uint32_t subOffset = pushed.second.offset;
- const Register reg = pushed.second.getRegister();
+ const uint32_t subOffset = rit->second.offset;
+ const Register reg = rit->second.getRegister();
auto it = this->ctx.curbeRegs.find(arg.reg);
assert(it != ctx.curbeRegs.end());
allocatePayloadReg(reg, it->second, subOffset);
+ ctx.splitBlock(it->second, subOffset);
}
}