void DepCompCopyArrayToBuffer:: ApplyCopyArray( DepCompCopyArrayCollect& collect, const DepCompAstRefGraphCreate& refDep) { const DepCompAstRefAnal& stmtorder = collect.get_stmtref_info(); for (DepCompCopyArrayCollect::iterator arrays = collect.begin(); arrays != collect.end(); ++arrays) { DepCompCopyArrayCollect::CopyArrayUnit& curarray = *arrays; if (DebugCopyConfig()) std::cerr << IteratorToString2(curarray.refs.begin()) << std::endl; const DepCompAstRefGraphNode* initcut = 0, *savecut = 0; ComputeCutBoundary(refDep, stmtorder, curarray, initcut, savecut); CopyArrayConfig curconfig = ComputeCopyConfig(stmtorder, curarray, initcut); LoopTreeNode* repl = curarray.root; assert(repl != 0); LoopTreeNode* init = initcut->GetInfo().stmt; LoopTreeNode* save = savecut->GetInfo().stmt; CopyArrayOpt opt = curconfig.get_opt(); if (init != 0) { if (opt & SHIFT_COPY) init = curarray.root; else for ( ; init->Parent() != curarray.root; init=init->Parent()); } if ( (opt & SHIFT_COPY) && (init != 0 || save != 0)) save = curarray.root->LastChild(); else if (save != 0) for (; save->Parent()!=curarray.root; save=save->Parent()); ApplyXform(curarray, curconfig, repl, init,save); } }
LoopTreeNode* DepCompCopyArrayCollect:: OutmostCopyRoot( CopyArrayUnit& unit, DepCompAstRefGraphCreate& refDep, LoopTreeNode* treeroot) { LoopTreeNode* origroot = unit.root; while (unit.root != 0) { DepCompCopyArrayCollect::CopyArrayUnit::CrossGraph crossgraph(&refDep, unit); GraphEdgeIterator<DepCompCopyArrayCollect::CopyArrayUnit::CrossGraph> edges(&crossgraph); if (!edges.ReachEnd()) break; DepCompCopyArrayCollect::CopyArrayUnit::InsideGraph insidegraph(&refDep, unit); GraphEdgeIterator<DepCompCopyArrayCollect::CopyArrayUnit::InsideGraph> ep(&insidegraph); for ( ; !ep.ReachEnd(); ++ep) { if (!(*ep)->GetInfo().is_precise()) { break; } } if (!ep.ReachEnd()) break; LoopTreeInterface interface; unit.root = GetEnclosingLoop(unit.root, interface); } LoopTreeNode* res = unit.root; if (res == 0) res = treeroot; else if (res->LoopLevel() +1 == origroot->LoopLevel() && origroot->Parent()->ChildCount() == 1) { res = origroot->Parent(); } unit.root = origroot; return res; }
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; }