#pragma once #include #include #include #include struct FuncInfo; struct LoopGraph; struct ShadowNode; struct CommonBlock; typedef enum node : int { PARALLEL_DIR = 0, FUNCTION_CALL, PROCEDURE_CALL, STOP, START, END } nodeType; struct ShadowElement { std::vector> bounds; std::map origNameByProc; bool corner; ShadowElement() { } ShadowElement(const std::vector>& bounds, const std::pair& origName, bool corner) : bounds(bounds), corner(corner) { origNameByProc[origName.first] = origName.second; } bool operator==(const ShadowElement& left) const { return bounds == left.bounds && origNameByProc == left.origNameByProc && corner == left.corner; } }; struct NextNode { ShadowNode* shNode; std::set writeTo; bool isBackWard; bool hasRealigns; NextNode() { } NextNode(ShadowNode* shNode, const std::set& writeTo, bool hasRealigns = false) : shNode(shNode), writeTo(writeTo), isBackWard(false), hasRealigns(hasRealigns) { } bool operator==(const NextNode& left) const { return (shNode == left.shNode) && (writeTo == left.writeTo); } bool operator<(const NextNode& left) const { return shNode < left.shNode; } }; struct PrevNode { ShadowNode* shNode; bool* isBackWard; bool* hasRealigns; PrevNode() { } PrevNode(ShadowNode* shNode, bool* isBackWard = NULL, bool* hasRealigns = NULL) : shNode(shNode), isBackWard(isBackWard), hasRealigns(hasRealigns) { } bool operator==(const PrevNode& left) const { return shNode == left.shNode; } }; struct ShadowNode { void *info; nodeType type; //file and line std::pair location; std::map> shadows; std::map> newShadows; std::vector next; //std::vector prev; ShadowNode(void* info, nodeType type, FuncInfo* func, int line) : info(info), type(type), location(std::make_pair(func, line)) { } void MoveShadow(const std::pair>& shadowAdd) { for (auto& elem : shadowAdd.second) newShadows[shadowAdd.first].push_back(elem); } void MergeNewShadowElements() { for (auto& elemByArray : newShadows) { ShadowElement newElems; for (int z = 0; z < elemByArray.second.size(); ++z) { if (z == 0) newElems = elemByArray.second[0]; else { newElems.corner |= elemByArray.second[z].corner; for (auto& fElem : elemByArray.second[z].origNameByProc) newElems.origNameByProc[fElem.first] = fElem.second; int k = 0; for (auto& bound : elemByArray.second[z].bounds) { newElems.bounds[k].first = std::max(newElems.bounds[k].first, bound.first); newElems.bounds[k].second = std::max(newElems.bounds[k].second, bound.second); ++k; } } } if (elemByArray.second.size()) { elemByArray.second.clear(); elemByArray.second.push_back(newElems); } } } void addNext(const NextNode& nextNode) { bool exist = false; for (int z = 0; z < next.size() && !exist; ++z) if (next[z] == nextNode) exist = true; if (!exist) next.push_back(nextNode); } }; void GroupShadow(const std::map>& funcs, const std::map>& loops, const DIST::Arrays& allArrays, const std::map>& arrayLinksByFuncCalls, const std::map& commonBlocks); void clearAllocatedShadowNodes(); void devourShadowByRemote(void* file, const std::map& allFuncs, const std::vector& loops, const std::map>& arrayLinksByFuncCalls); void transformShadowIfFull(void* file, const std::map>& arrayLinksByFuncCalls);