LoopTreeNode* LoopBlocking:: ApplyBlocking( const CompSliceDepGraphNode::FullNestInfo& nestInfo, LoopTreeDepComp& comp, DependenceHoisting &op, LoopTreeNode *&top) { const CompSliceNest& slices = *nestInfo.GetNest(); if (DebugLoop()) { std::cerr << "\n Blocking slices: " << slices.toString() << "\n"; } LoopTreeNode *head = 0; AstInterface& fa = LoopTransformInterface::getAstInterface(); for (int j = FirstIndex(); j >= 0; j = NextIndex(j)) { top = op.Transform( comp, slices[j], top); SymbolicVal b = BlockSize(j); if (DebugLoop()) { std::cerr << "\n after slice " << j << " : \n"; //top->DumpTree(); comp.DumpTree(); comp.DumpDep(); std::cerr << "\n blocking size for this loop is " << b.toString() << "\n"; } if (!(b == 1)) { LoopTreeNode *n = LoopTreeBlockLoop()( top, SymbolicVar(fa.NewVar(fa.GetType("int")), AST_NULL), b); if (DebugLoop()) { std::cerr << "\n after tiling loop with size " << b.toString() << " : \n"; //top->DumpTree(); comp.DumpTree(); comp.DumpDep(); } if (head == 0) head = n; else { while (n->FirstChild() != head) LoopTreeSwapNodePos()( n->Parent(), n); } } } return head; }
LoopTreeNode* LoopBlocking:: ApplyBlocking( const CompSliceDepGraphNode::FullNestInfo& nestInfo, LoopTreeDepComp& comp, DependenceHoisting &op, LoopTreeNode *&top) { const CompSliceNest& slices = *nestInfo.GetNest(); LoopTreeNode *head = 0; AstInterface& fa = LoopTransformInterface::getAstInterface(); for (int j = FirstIndex(); j >= 0; j = NextIndex(j)) { top = op.Transform( comp, slices[j], top); SymbolicVal b = BlockSize(j); if (!(b == 1)) { LoopTreeNode *n = LoopTreeBlockLoop()( top, SymbolicVar(fa.NewVar(fa.GetType("int")), AST_NULL), b); if (head == 0) head = n; else { while (n->FirstChild() != head) LoopTreeSwapNodePos()( n->Parent(), n); } } } return head; }