Compare commits
1 Commits
analyze_lo
...
aec4ddab67
| Author | SHA1 | Date | |
|---|---|---|---|
| aec4ddab67 |
129
CMakeLists.txt
129
CMakeLists.txt
@@ -27,13 +27,6 @@ set(libpred_sources projects/libpredictor/src/)
|
|||||||
set(libpred_include projects/libpredictor/include/)
|
set(libpred_include projects/libpredictor/include/)
|
||||||
|
|
||||||
include_directories(src)
|
include_directories(src)
|
||||||
include_directories(src/Utils)
|
|
||||||
include_directories(src/SgUtils)
|
|
||||||
include_directories(src/Distribution)
|
|
||||||
include_directories(src/GraphCall)
|
|
||||||
include_directories(src/GraphLoop)
|
|
||||||
include_directories(src/Transformations/ExpressionSubstitution)
|
|
||||||
|
|
||||||
#Sage lib includes
|
#Sage lib includes
|
||||||
include_directories(${fdvm_include})
|
include_directories(${fdvm_include})
|
||||||
include_directories(${sage_include_1})
|
include_directories(${sage_include_1})
|
||||||
@@ -120,13 +113,7 @@ set(OMEGA src/SageAnalysisTool/OmegaForSage/add-assert.cpp
|
|||||||
src/SageAnalysisTool/set.cpp)
|
src/SageAnalysisTool/set.cpp)
|
||||||
|
|
||||||
set(PRIV src/PrivateAnalyzer/private_analyzer.cpp
|
set(PRIV src/PrivateAnalyzer/private_analyzer.cpp
|
||||||
src/PrivateAnalyzer/private_analyzer.h
|
src/PrivateAnalyzer/private_analyzer.h)
|
||||||
src/PrivateAnalyzer/private_arrays_search.cpp
|
|
||||||
src/PrivateAnalyzer/private_arrays_search.h
|
|
||||||
src/PrivateAnalyzer/range_structures.cpp
|
|
||||||
src/PrivateAnalyzer/range_structures.h
|
|
||||||
src/PrivateAnalyzer/region.cpp
|
|
||||||
src/PrivateAnalyzer/region.h)
|
|
||||||
|
|
||||||
set(FDVM ${fdvm_sources}/acc.cpp
|
set(FDVM ${fdvm_sources}/acc.cpp
|
||||||
${fdvm_sources}/acc_across.cpp
|
${fdvm_sources}/acc_across.cpp
|
||||||
@@ -161,47 +148,40 @@ set(PARALLEL_REG src/ParallelizationRegions/ParRegions.cpp
|
|||||||
src/ParallelizationRegions/resolve_par_reg_conflicts.cpp
|
src/ParallelizationRegions/resolve_par_reg_conflicts.cpp
|
||||||
src/ParallelizationRegions/resolve_par_reg_conflicts.h)
|
src/ParallelizationRegions/resolve_par_reg_conflicts.h)
|
||||||
|
|
||||||
set(TR_DEAD_CODE src/Transformations/DeadCodeRemoving/dead_code.cpp
|
set(TR_DEAD_CODE src/Transformations/dead_code.cpp
|
||||||
src/Transformations/DeadCodeRemoving/dead_code.h)
|
src/Transformations/dead_code.h)
|
||||||
set(TR_CP src/Transformations/CheckPoints/checkpoints.cpp
|
set(TR_CP src/Transformations/checkpoints.cpp
|
||||||
src/Transformations/CheckPoints/checkpoints.h)
|
src/Transformations/checkpoints.h)
|
||||||
set(TR_VECTOR src/Transformations/VectorAssignToLoop/array_assign_to_loop.cpp
|
set(TR_VECTOR src/Transformations/array_assign_to_loop.cpp
|
||||||
src/Transformations/VectorAssignToLoop/array_assign_to_loop.h)
|
src/Transformations/array_assign_to_loop.h)
|
||||||
set(TR_ENDDO_LOOP src/Transformations/LoopEndDoConverter/enddo_loop_converter.cpp
|
set(TR_ENDDO_LOOP src/Transformations/enddo_loop_converter.cpp
|
||||||
src/Transformations/LoopEndDoConverter/enddo_loop_converter.h)
|
src/Transformations/enddo_loop_converter.h)
|
||||||
set(TR_LOOP_NEST src/Transformations/LoopNesting/loop_transform.cpp
|
set(TR_LOOP_NEST src/Transformations/loop_transform.cpp
|
||||||
src/Transformations/LoopNesting/loop_transform.h)
|
src/Transformations/loop_transform.h)
|
||||||
set(TR_LOOP_COMB src/Transformations/LoopCombining/loops_combiner.cpp
|
set(TR_LOOP_COMB src/Transformations/loops_combiner.cpp
|
||||||
src/Transformations/LoopCombining/loops_combiner.h)
|
src/Transformations/loops_combiner.h)
|
||||||
set(TR_LOOP_SPLIT src/Transformations/LoopSplitting/loops_splitter.cpp
|
set(TR_LOOP_SPLIT src/Transformations/loops_splitter.cpp
|
||||||
src/Transformations/LoopSplitting/loops_splitter.h)
|
src/Transformations/loops_splitter.h)
|
||||||
set(TR_LOOP_UNROLL src/Transformations/LoopUnrolling/loops_unrolling.cpp
|
set(TR_LOOP_UNROLL src/Transformations/loops_unrolling.cpp
|
||||||
src/Transformations/LoopUnrolling/loops_unrolling.h)
|
src/Transformations/loops_unrolling.h)
|
||||||
set(TR_PRIV_BR src/Transformations/PrivateArrayResizing/private_arrays_resizing.cpp
|
set(TR_PRIV_BR src/Transformations/private_arrays_resizing.cpp
|
||||||
src/Transformations/PrivateArrayResizing/private_arrays_resizing.h)
|
src/Transformations/private_arrays_resizing.h)
|
||||||
set(TR_PRIV_DEL src/Transformations/PrivateArrayRemoving/private_removing.cpp
|
set(TR_PRIV_DEL src/Transformations/private_removing.cpp
|
||||||
src/Transformations/PrivateArrayRemoving/private_removing.h)
|
src/Transformations/private_removing.h)
|
||||||
set(TR_SWAP_ARR_DIMS src/Transformations/ArrayDimsSwapping/swap_array_dims.cpp
|
set(TR_SWAP_ARR_DIMS src/Transformations/swap_array_dims.cpp
|
||||||
src/Transformations/ArrayDimsSwapping/swap_array_dims.h)
|
src/Transformations/swap_array_dims.h)
|
||||||
set(TR_FUNC_DUP src/Transformations/FunctionDuplication/uniq_call_chain_dup.cpp
|
set(TR_FUNC_DUP src/Transformations/uniq_call_chain_dup.cpp
|
||||||
src/Transformations/FunctionDuplication/uniq_call_chain_dup.h)
|
src/Transformations/uniq_call_chain_dup.h)
|
||||||
set(TR_FUNC_PURE src/Transformations/FunctionPurifying/function_purifying.cpp
|
set(TR_FUNC_PURE src/Transformations/function_purifying.cpp
|
||||||
src/Transformations/FunctionPurifying/function_purifying.h)
|
src/Transformations/function_purifying.h)
|
||||||
set(TR_GV src/Transformations/GlobalVariables/fix_common_blocks.cpp
|
set(TR_GV src/Transformations/fix_common_blocks.cpp
|
||||||
src/Transformations/GlobalVariables/fix_common_blocks.h)
|
src/Transformations/fix_common_blocks.h)
|
||||||
set(TR_CONV src/Transformations/ConvertToC/convert_to_c.cpp
|
set(TR_CONV src/Transformations/convert_to_c.cpp
|
||||||
src/Transformations/ConvertToC/convert_to_c.h)
|
src/Transformations/convert_to_c.h)
|
||||||
set(TR_IMPLICIT_NONE src/Transformations/SetImplicitNone/set_implicit_none.cpp
|
set(TR_IMPLICIT_NONE src/Transformations/set_implicit_none.cpp
|
||||||
src/Transformations/SetImplicitNone/set_implicit_none.h)
|
src/Transformations/set_implicit_none.h)
|
||||||
set(TR_REPLACE_ARRAYS_IN_IO src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.cpp
|
set(TR_REPLACE_ARRAYS_IN_IO src/Transformations/replace_dist_arrays_in_io.cpp
|
||||||
src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.h)
|
src/Transformations/replace_dist_arrays_in_io.h)
|
||||||
set(TR_EXPR_TRANSFORM src/Transformations/ExpressionSubstitution/control_flow_graph_part.cpp
|
|
||||||
src/Transformations/ExpressionSubstitution/expr_transform.cpp
|
|
||||||
src/Transformations/ExpressionSubstitution/expr_transform.h)
|
|
||||||
set(TR_INLINER src/Transformations/FunctionInlining/inliner.cpp
|
|
||||||
src/Transformations/FunctionInlining/inliner.h)
|
|
||||||
set(TR_RENAME_SYMBOLS src/Transformations/RenameSymbols/rename_symbols.cpp
|
|
||||||
src/Transformations/RenameSymbols/rename_symbols.h)
|
|
||||||
|
|
||||||
set(TRANSFORMS
|
set(TRANSFORMS
|
||||||
${TR_DEAD_CODE}
|
${TR_DEAD_CODE}
|
||||||
@@ -221,15 +201,10 @@ set(TRANSFORMS
|
|||||||
${TR_CONV}
|
${TR_CONV}
|
||||||
${TR_PRIV_DEL}
|
${TR_PRIV_DEL}
|
||||||
${TR_IMPLICIT_NONE}
|
${TR_IMPLICIT_NONE}
|
||||||
${TR_REPLACE_ARRAYS_IN_IO}
|
${TR_REPLACE_ARRAYS_IN_IO})
|
||||||
${TR_EXPR_TRANSFORM}
|
|
||||||
${TR_INLINER}
|
|
||||||
${TR_RENAME_SYMBOLS})
|
|
||||||
|
|
||||||
set(CFG src/CFGraph/IR.cpp
|
set(CFG src/CFGraph/IR.cpp
|
||||||
src/CFGraph/IR.h
|
src/CFGraph/IR.h
|
||||||
src/CFGraph/IR_domTree.cpp
|
|
||||||
src/CFGraph/IR_domTree.h
|
|
||||||
src/CFGraph/CFGraph.cpp
|
src/CFGraph/CFGraph.cpp
|
||||||
src/CFGraph/CFGraph.h
|
src/CFGraph/CFGraph.h
|
||||||
src/CFGraph/RD_subst.cpp
|
src/CFGraph/RD_subst.cpp
|
||||||
@@ -238,14 +213,14 @@ set(CFG src/CFGraph/IR.cpp
|
|||||||
src/CFGraph/live_variable_analysis.h
|
src/CFGraph/live_variable_analysis.h
|
||||||
src/CFGraph/private_variables_analysis.cpp
|
src/CFGraph/private_variables_analysis.cpp
|
||||||
src/CFGraph/private_variables_analysis.h
|
src/CFGraph/private_variables_analysis.h
|
||||||
src/CFGraph/IR_SSAForm.cpp
|
)
|
||||||
src/CFGraph/IR_SSAForm.h)
|
|
||||||
|
|
||||||
set(DATA_FLOW
|
set(DATA_FLOW
|
||||||
src/CFGraph/DataFlow/data_flow.h
|
src/CFGraph/DataFlow/data_flow.h
|
||||||
src/CFGraph/DataFlow/data_flow_impl.h
|
src/CFGraph/DataFlow/data_flow_impl.h
|
||||||
src/CFGraph/DataFlow/backward_data_flow.h
|
src/CFGraph/DataFlow/backward_data_flow.h
|
||||||
src/CFGraph/DataFlow/backward_data_flow_impl.h)
|
src/CFGraph/DataFlow/backward_data_flow_impl.h
|
||||||
|
)
|
||||||
|
|
||||||
set(CREATE_INTER_T src/CreateInterTree/CreateInterTree.cpp
|
set(CREATE_INTER_T src/CreateInterTree/CreateInterTree.cpp
|
||||||
src/CreateInterTree/CreateInterTree.h)
|
src/CreateInterTree/CreateInterTree.h)
|
||||||
@@ -307,6 +282,10 @@ set(DYNA src/DynamicAnalysis/createParallelRegions.cpp
|
|||||||
src/DynamicAnalysis/gcov_info.h
|
src/DynamicAnalysis/gcov_info.h
|
||||||
src/DynamicAnalysis/gCov_parser.cpp
|
src/DynamicAnalysis/gCov_parser.cpp
|
||||||
src/DynamicAnalysis/gCov_parser_func.h)
|
src/DynamicAnalysis/gCov_parser_func.h)
|
||||||
|
|
||||||
|
set(EXPR_TRANSFORM src/ExpressionTransform/control_flow_graph_part.cpp
|
||||||
|
src/ExpressionTransform/expr_transform.cpp
|
||||||
|
src/ExpressionTransform/expr_transform.h)
|
||||||
|
|
||||||
set(GR_CALL src/GraphCall/graph_calls.cpp
|
set(GR_CALL src/GraphCall/graph_calls.cpp
|
||||||
src/GraphCall/graph_calls.h
|
src/GraphCall/graph_calls.h
|
||||||
@@ -318,12 +297,17 @@ set(GR_LOOP src/GraphLoop/graph_loops_base.cpp
|
|||||||
src/GraphLoop/graph_loops.h
|
src/GraphLoop/graph_loops.h
|
||||||
src/GraphLoop/graph_loops_func.h)
|
src/GraphLoop/graph_loops_func.h)
|
||||||
|
|
||||||
|
set(INLINER src/Inliner/inliner.cpp
|
||||||
|
src/Inliner/inliner.h)
|
||||||
|
|
||||||
set(LOOP_ANALYZER src/LoopAnalyzer/allocations_prepoc.cpp
|
set(LOOP_ANALYZER src/LoopAnalyzer/allocations_prepoc.cpp
|
||||||
src/LoopAnalyzer/dep_analyzer.cpp
|
src/LoopAnalyzer/dep_analyzer.cpp
|
||||||
src/LoopAnalyzer/loop_analyzer.cpp
|
src/LoopAnalyzer/loop_analyzer.cpp
|
||||||
src/LoopAnalyzer/loop_analyzer.h
|
src/LoopAnalyzer/loop_analyzer.h)
|
||||||
src/LoopAnalyzer/implicit_loops_analyzer.cpp
|
|
||||||
src/LoopAnalyzer/implicit_loops_analyzer.h)
|
set(RENAME_SYMBOLS src/RenameSymbols/rename_symbols.cpp
|
||||||
|
src/RenameSymbols/rename_symbols.h)
|
||||||
|
|
||||||
|
|
||||||
set(MAIN src/Sapfor.cpp
|
set(MAIN src/Sapfor.cpp
|
||||||
src/Sapfor.h
|
src/Sapfor.h
|
||||||
@@ -414,9 +398,12 @@ set(SOURCE_EXE
|
|||||||
${DISTR}
|
${DISTR}
|
||||||
${DVMH_REG}
|
${DVMH_REG}
|
||||||
${DYNA}
|
${DYNA}
|
||||||
|
${EXPR_TRANSFORM}
|
||||||
${GR_CALL}
|
${GR_CALL}
|
||||||
${GR_LOOP}
|
${GR_LOOP}
|
||||||
|
${INLINER}
|
||||||
${LOOP_ANALYZER}
|
${LOOP_ANALYZER}
|
||||||
|
${RENAME_SYMBOLS}
|
||||||
${TRANSFORMS}
|
${TRANSFORMS}
|
||||||
${PARALLEL_REG}
|
${PARALLEL_REG}
|
||||||
${PRIV}
|
${PRIV}
|
||||||
@@ -440,7 +427,7 @@ source_group (CFGraph FILES ${CFG})
|
|||||||
source_group (CFGraph\\DataFlow FILES ${DATA_FLOW})
|
source_group (CFGraph\\DataFlow FILES ${DATA_FLOW})
|
||||||
|
|
||||||
source_group (Transformations\\DeadCodeRemoving FILES ${TR_DEAD_CODE})
|
source_group (Transformations\\DeadCodeRemoving FILES ${TR_DEAD_CODE})
|
||||||
source_group (Transformations\\ExpressionSubstitution FILES ${TR_EXPR_TRANSFORM})
|
source_group (Transformations\\ExpressionSubstitution FILES ${EXPR_TRANSFORM})
|
||||||
source_group (Transformations\\CheckPoints FILES ${TR_CP})
|
source_group (Transformations\\CheckPoints FILES ${TR_CP})
|
||||||
source_group (Transformations\\LoopEndDoConverter FILES ${TR_ENDDO_LOOP})
|
source_group (Transformations\\LoopEndDoConverter FILES ${TR_ENDDO_LOOP})
|
||||||
source_group (Transformations\\LoopNesting FILES ${TR_LOOP_NEST})
|
source_group (Transformations\\LoopNesting FILES ${TR_LOOP_NEST})
|
||||||
@@ -448,13 +435,13 @@ source_group (Transformations\\LoopCombining FILES ${TR_LOOP_COMB})
|
|||||||
source_group (Transformations\\LoopSplitting FILES ${TR_LOOP_SPLIT})
|
source_group (Transformations\\LoopSplitting FILES ${TR_LOOP_SPLIT})
|
||||||
source_group (Transformations\\LoopUnrolling FILES ${TR_LOOP_UNROLL})
|
source_group (Transformations\\LoopUnrolling FILES ${TR_LOOP_UNROLL})
|
||||||
source_group (Transformations\\FunctionDuplication FILES ${TR_FUNC_DUP})
|
source_group (Transformations\\FunctionDuplication FILES ${TR_FUNC_DUP})
|
||||||
source_group (Transformations\\FunctionInlining FILES ${TR_INLINER})
|
source_group (Transformations\\FunctionInlining FILES ${INLINER})
|
||||||
source_group (Transformations\\FunctionPurifying FILES ${TR_FUNC_PURE})
|
source_group (Transformations\\FunctionPurifying FILES ${TR_FUNC_PURE})
|
||||||
source_group (Transformations\\ArrayDimsSwapping FILES ${TR_SWAP_ARR_DIMS})
|
source_group (Transformations\\ArrayDimsSwapping FILES ${TR_SWAP_ARR_DIMS})
|
||||||
source_group (Transformations\\PrivateArrayResizing FILES ${TR_PRIV_BR})
|
source_group (Transformations\\PrivateArrayResizing FILES ${TR_PRIV_BR})
|
||||||
source_group (Transformations\\PrivateArrayRemoving FILES ${TR_PRIV_DEL})
|
source_group (Transformations\\PrivateArrayRemoving FILES ${TR_PRIV_DEL})
|
||||||
source_group (Transformations\\VectorAssignToLoop FILES ${TR_VECTOR})
|
source_group (Transformations\\VectorAssignToLoop FILES ${TR_VECTOR})
|
||||||
source_group (Transformations\\RenameSymbols FILES ${TR_RENAME_SYMBOLS})
|
source_group (Transformations\\RenameSymbols FILES ${RENAME_SYMBOLS})
|
||||||
source_group (Transformations\\GlobalVariables FILES ${TR_GV})
|
source_group (Transformations\\GlobalVariables FILES ${TR_GV})
|
||||||
source_group (Transformations\\ConvertToC FILES ${TR_CONV})
|
source_group (Transformations\\ConvertToC FILES ${TR_CONV})
|
||||||
source_group (Transformations\\SetImplicitNone FILES ${TR_IMPLICIT_NONE})
|
source_group (Transformations\\SetImplicitNone FILES ${TR_IMPLICIT_NONE})
|
||||||
|
|||||||
Submodule projects/dvm updated: c550423b8e...a711f8ebfd
@@ -1,5 +1,5 @@
|
|||||||
#define _LEAK_
|
#define _LEAK_
|
||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -8,9 +8,9 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "CommonBlock.h"
|
#include "../Utils/CommonBlock.h"
|
||||||
#include "graph_calls.h"
|
#include "../GraphCall/graph_calls.h"
|
||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "IR.h"
|
#include "IR.h"
|
||||||
@@ -50,30 +50,12 @@ BBlock::BasicBlock(const BBlock& copyFrom)
|
|||||||
prev = copyFrom.prev;
|
prev = copyFrom.prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BBlock::addInstruction(IR_Block* item, bool pushFront)
|
void BBlock::addInstruction(IR_Block* item)
|
||||||
{
|
{
|
||||||
if (pushFront)
|
instructions.push_back(item);
|
||||||
instructions.insert(instructions.begin(), item);
|
|
||||||
else
|
|
||||||
instructions.push_back(item);
|
|
||||||
item->setBasicBlock(this);
|
item->setBasicBlock(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BBlock::addInstructionBefore(IR_Block* item, Instruction* before)
|
|
||||||
{
|
|
||||||
checkNull(before, convertFileName(__FILE__).c_str(), __LINE__);
|
|
||||||
checkNull(item, convertFileName(__FILE__).c_str(), __LINE__);
|
|
||||||
|
|
||||||
for (auto it = instructions.begin(); it != instructions.end(); ++it) {
|
|
||||||
if ((*it)->getInstruction() == before) {
|
|
||||||
instructions.insert(it, item);
|
|
||||||
item->setBasicBlock(this);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
|
||||||
}
|
|
||||||
|
|
||||||
int BBlock::removePrev(BBlock* removed)
|
int BBlock::removePrev(BBlock* removed)
|
||||||
{
|
{
|
||||||
auto it = std::remove(prev.begin(), prev.end(), removed);
|
auto it = std::remove(prev.begin(), prev.end(), removed);
|
||||||
@@ -530,7 +512,7 @@ static int buildReachingDefs(const vector<BBlock*>& CFG, const FuncInfo* currF,
|
|||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Kosaraju-Sharir algorithm
|
//Kosaraju<EFBFBD>Sharir algorithm
|
||||||
static vector<int> getStronglyConnectedComps(vector<vector<int>>& g) {
|
static vector<int> getStronglyConnectedComps(vector<vector<int>>& g) {
|
||||||
// 1. For each vertex u of the graph, mark u as unvisited. Let l be empty.
|
// 1. For each vertex u of the graph, mark u as unvisited. Let l be empty.
|
||||||
auto size = g.size();
|
auto size = g.size();
|
||||||
@@ -1167,22 +1149,9 @@ map<FuncInfo*, vector<BBlock*>> buildCFG(const map<string, CommonBlock*>& common
|
|||||||
if (settings.withRD)
|
if (settings.withRD)
|
||||||
buildReachingDefs(result, settings);
|
buildReachingDefs(result, settings);
|
||||||
|
|
||||||
if (settings.withDominators)
|
|
||||||
{
|
|
||||||
auto t = high_resolution_clock::now();
|
|
||||||
for (auto& [func, bblocks] : result)
|
|
||||||
SAPFOR::buildDominatorTree(bblocks);
|
|
||||||
|
|
||||||
auto msec = duration_cast<milliseconds>(high_resolution_clock::now() - t).count();
|
|
||||||
__spf_print(1, " dominator build time is %.3f sec\n", msec / 1000.);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SgFile::switchToFile(oldFile) == -1)
|
if (SgFile::switchToFile(oldFile) == -1)
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|
||||||
for (auto& [func, blocks] : result)
|
|
||||||
removedUnreachableBlocks(blocks);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1257,49 +1226,4 @@ map<FuncInfo*, vector<SAPFOR::BasicBlock*>>
|
|||||||
fileFuncInfoMap[callFrom->fileName].push_back(callFrom);
|
fileFuncInfoMap[callFrom->fileName].push_back(callFrom);
|
||||||
|
|
||||||
return buildCFG(commonBlocks, fileFuncInfoMap, settings);
|
return buildCFG(commonBlocks, fileFuncInfoMap, settings);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void removedUnreachableBlocks(vector<SAPFOR::BasicBlock*>& blocks)
|
|
||||||
{
|
|
||||||
set<SAPFOR::BasicBlock*> reachable;
|
|
||||||
|
|
||||||
for (auto& b : blocks)
|
|
||||||
if (b->getInstructions().front()->isHeader() ||
|
|
||||||
b->getInstructions().front()->getInstruction()->getOperation() == SAPFOR::CFG_OP::ENTRY)
|
|
||||||
reachable.insert(b);
|
|
||||||
|
|
||||||
set<SAPFOR::BasicBlock*> worklist = reachable;
|
|
||||||
while (worklist.size() != 0)
|
|
||||||
{
|
|
||||||
set<SAPFOR::BasicBlock*> to_insert;
|
|
||||||
|
|
||||||
for (auto& b : worklist)
|
|
||||||
for (auto& next : b->getNext())
|
|
||||||
if (reachable.insert(next).second)
|
|
||||||
to_insert.insert(next);
|
|
||||||
|
|
||||||
worklist = to_insert;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto remove_unreachable_it = remove_if(blocks.begin(), blocks.end(),
|
|
||||||
[&reachable](SAPFOR::BasicBlock* b)
|
|
||||||
{
|
|
||||||
if (reachable.find(b) == reachable.end())
|
|
||||||
{
|
|
||||||
for (auto& next : b->getNext())
|
|
||||||
if (reachable.find(next) != reachable.end())
|
|
||||||
next->removePrev(b);
|
|
||||||
|
|
||||||
delete b;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
reachable.clear();
|
|
||||||
|
|
||||||
blocks.erase(remove_unreachable_it, blocks.end());
|
|
||||||
}
|
}
|
||||||
@@ -6,11 +6,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "IR.h"
|
#include "IR.h"
|
||||||
#include "../Utils/errors.h"
|
|
||||||
#include "../Utils/utils.h"
|
|
||||||
#include "../Utils/CommonBlock.h"
|
|
||||||
#include "../GraphCall/graph_calls.h"
|
|
||||||
#include "IR_domTree.h"
|
|
||||||
|
|
||||||
namespace SAPFOR
|
namespace SAPFOR
|
||||||
{
|
{
|
||||||
@@ -29,7 +24,7 @@ namespace SAPFOR
|
|||||||
|
|
||||||
std::vector<BasicBlock*> next;
|
std::vector<BasicBlock*> next;
|
||||||
std::vector<BasicBlock*> prev;
|
std::vector<BasicBlock*> prev;
|
||||||
BasicBlock* directDominator = NULL;
|
|
||||||
//reaching definition
|
//reaching definition
|
||||||
std::map<SAPFOR::Argument*, std::set<int>> RD_in, RD_out;
|
std::map<SAPFOR::Argument*, std::set<int>> RD_in, RD_out;
|
||||||
|
|
||||||
@@ -39,17 +34,14 @@ namespace SAPFOR
|
|||||||
bool addLive(const std::map<SAPFOR::Argument*, std::vector<SAPFOR::BasicBlock*>>& to_add, bool in);
|
bool addLive(const std::map<SAPFOR::Argument*, std::vector<SAPFOR::BasicBlock*>>& to_add, bool in);
|
||||||
std::map<SAPFOR::Argument*, std::vector<SAPFOR::BasicBlock*>> getLive(bool in) const;
|
std::map<SAPFOR::Argument*, std::vector<SAPFOR::BasicBlock*>> getLive(bool in) const;
|
||||||
bool removeLive(SAPFOR::Argument* to_remove, bool in);
|
bool removeLive(SAPFOR::Argument* to_remove, bool in);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BasicBlock() { num = lastNumBlock++; }
|
BasicBlock() { num = lastNumBlock++; }
|
||||||
BasicBlock(IR_Block* item);
|
BasicBlock(IR_Block* item);
|
||||||
BasicBlock(const BasicBlock& copyFrom);
|
BasicBlock(const BasicBlock& copyFrom);
|
||||||
|
|
||||||
void addInstructionBefore(IR_Block* item, Instruction* istruction);
|
void addInstruction(IR_Block* item);
|
||||||
void addInstruction(IR_Block* item, bool pushFront = false);
|
|
||||||
void addPrev(BasicBlock* prev_) { prev.push_back(prev_); }
|
void addPrev(BasicBlock* prev_) { prev.push_back(prev_); }
|
||||||
void addNext(BasicBlock* next_) { next.push_back(next_); }
|
void addNext(BasicBlock* next_) { next.push_back(next_); }
|
||||||
void setDom(BasicBlock* dom) { directDominator = dom; }
|
|
||||||
|
|
||||||
int removePrev(BasicBlock* removed);
|
int removePrev(BasicBlock* removed);
|
||||||
int removeNext(BasicBlock* removed);
|
int removeNext(BasicBlock* removed);
|
||||||
@@ -77,11 +69,7 @@ namespace SAPFOR
|
|||||||
const std::vector<IR_Block*>& getInstructions() const { return instructions; }
|
const std::vector<IR_Block*>& getInstructions() const { return instructions; }
|
||||||
const std::vector<BasicBlock*>& getNext() const { return next; }
|
const std::vector<BasicBlock*>& getNext() const { return next; }
|
||||||
const std::vector<BasicBlock*>& getPrev() const { return prev; }
|
const std::vector<BasicBlock*>& getPrev() const { return prev; }
|
||||||
BasicBlock* getDom() const
|
|
||||||
{
|
|
||||||
return directDominator;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FOR LIVE ANALYSIS
|
* FOR LIVE ANALYSIS
|
||||||
*/
|
*/
|
||||||
@@ -117,15 +105,13 @@ namespace SAPFOR
|
|||||||
bool withDVM = false;
|
bool withDVM = false;
|
||||||
bool withCallsInBlocks = false; // separate each F_CALL to own BasicBlock
|
bool withCallsInBlocks = false; // separate each F_CALL to own BasicBlock
|
||||||
bool withCallFrom = true;
|
bool withCallFrom = true;
|
||||||
bool withDominators = true;
|
|
||||||
|
|
||||||
explicit CFG_Settings(int) { }
|
explicit CFG_Settings(int) { }
|
||||||
|
|
||||||
explicit CFG_Settings(bool atLeastOneIterInLoop = false, bool withRD = true, bool withRegisters = false,
|
explicit CFG_Settings(bool atLeastOneIterInLoop = false, bool withRD = true, bool withRegisters = false,
|
||||||
bool withDVM = false, bool withSPF = false, bool withCallsInBlocks = false,
|
bool withDVM = false, bool withSPF = false, bool withCallsInBlocks = false, bool withCallFrom = true) :
|
||||||
bool withCallFrom = true, bool withDominators = true) :
|
|
||||||
atLeastOneIterInLoop(atLeastOneIterInLoop), withRD(withRD), withRegisters(withRegisters), withDVM(withDVM), withSPF(withSPF),
|
atLeastOneIterInLoop(atLeastOneIterInLoop), withRD(withRD), withRegisters(withRegisters), withDVM(withDVM), withSPF(withSPF),
|
||||||
withCallsInBlocks(withCallsInBlocks), withCallFrom(withCallFrom), withDominators(withDominators)
|
withCallsInBlocks(withCallsInBlocks), withCallFrom(withCallFrom)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -160,6 +146,4 @@ static inline void deleteCFG(std::map<FuncInfo*, std::vector<SAPFOR::BasicBlock*
|
|||||||
byFunc.second.clear();
|
byFunc.second.clear();
|
||||||
}
|
}
|
||||||
cfg.clear();
|
cfg.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void removedUnreachableBlocks(std::vector<SAPFOR::BasicBlock*>& blocks);
|
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "SgUtils.h"
|
#include "../../Utils/SgUtils.h"
|
||||||
#include "../CFGraph.h"
|
#include "../CFGraph.h"
|
||||||
#include "../IR.h"
|
#include "../IR.h"
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "SgUtils.h"
|
#include "../../Utils/SgUtils.h"
|
||||||
#include "../CFGraph.h"
|
#include "../CFGraph.h"
|
||||||
#include "../IR.h"
|
#include "../IR.h"
|
||||||
#include "../RD_subst.h"
|
#include "../RD_subst.h"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include<vector>
|
#include<vector>
|
||||||
#include<set>
|
#include<set>
|
||||||
|
|
||||||
#include "SgUtils.h"
|
#include "../../Utils/SgUtils.h"
|
||||||
#include "../CFGraph.h"
|
#include "../CFGraph.h"
|
||||||
#include "../IR.h"
|
#include "../IR.h"
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include<vector>
|
#include<vector>
|
||||||
#include<set>
|
#include<set>
|
||||||
|
|
||||||
#include "SgUtils.h"
|
#include "../../Utils/SgUtils.h"
|
||||||
#include "../CFGraph.h"
|
#include "../CFGraph.h"
|
||||||
#include "../IR.h"
|
#include "../IR.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "CommonBlock.h"
|
#include "../Utils/CommonBlock.h"
|
||||||
#include "graph_calls.h"
|
#include "../GraphCall/graph_calls.h"
|
||||||
#include "expr_transform.h"
|
#include "../ExpressionTransform/expr_transform.h"
|
||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "IR.h"
|
#include "IR.h"
|
||||||
@@ -395,7 +395,7 @@ static SAPFOR::Argument* processExpression(SgExpression* ex, vector<IR_Block*>&
|
|||||||
if (ex)
|
if (ex)
|
||||||
{
|
{
|
||||||
const int var = ex->variant();
|
const int var = ex->variant();
|
||||||
if ((var == VAR_REF || var == CONST_REF || var == LABEL_REF) && !ex->lhs() && !ex->rhs()) // variable reference
|
if ((var == VAR_REF || var == CONST_REF || var == LABEL_REF) && !ex->lhs() && !ex->rhs()) // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
{
|
{
|
||||||
if (var == CONST_REF)
|
if (var == CONST_REF)
|
||||||
{
|
{
|
||||||
@@ -450,7 +450,7 @@ static SAPFOR::Argument* processExpression(SgExpression* ex, vector<IR_Block*>&
|
|||||||
return arg1;
|
return arg1;
|
||||||
|
|
||||||
auto reg = isLeft ? NULL : createRegister();
|
auto reg = isLeft ? NULL : createRegister();
|
||||||
Instruction* instr = new Instruction(isLeft ? CFG_OP::STORE : CFG_OP::LOAD, arg1, createConstArg(numArgs), isLeft ? isLeft : reg, NULL, ex);
|
Instruction* instr = new Instruction(isLeft ? CFG_OP::STORE : CFG_OP::LOAD, arg1, createConstArg(numArgs), isLeft ? isLeft : reg);
|
||||||
blocks.push_back(new IR_Block(instr));
|
blocks.push_back(new IR_Block(instr));
|
||||||
return reg;
|
return reg;
|
||||||
}
|
}
|
||||||
@@ -485,7 +485,7 @@ static SAPFOR::Argument* processExpression(SgExpression* ex, vector<IR_Block*>&
|
|||||||
auto arg1 = arrayRef ? arrayRef : createArrayArg(ref, blocks, func, numArgs, commonVars);
|
auto arg1 = arrayRef ? arrayRef : createArrayArg(ref, blocks, func, numArgs, commonVars);
|
||||||
|
|
||||||
auto reg = isLeft ? NULL : createRegister();
|
auto reg = isLeft ? NULL : createRegister();
|
||||||
instr = new Instruction(isLeft ? CFG_OP::STORE : CFG_OP::LOAD, arg1, createConstArg(1), isLeft ? isLeft : reg, NULL, ex);
|
instr = new Instruction(isLeft ? CFG_OP::STORE : CFG_OP::LOAD, arg1, createConstArg(1), isLeft ? isLeft : reg);
|
||||||
blocks.push_back(new IR_Block(instr));
|
blocks.push_back(new IR_Block(instr));
|
||||||
return reg;
|
return reg;
|
||||||
}
|
}
|
||||||
@@ -602,7 +602,7 @@ static SAPFOR::Argument* processExpression(SgExpression* ex, vector<IR_Block*>&
|
|||||||
{
|
{
|
||||||
if (returnReg == NULL)
|
if (returnReg == NULL)
|
||||||
{
|
{
|
||||||
Instruction* instr = new Instruction(CFG_OP::LOAD, arg, NULL, reg, NULL, ex);
|
Instruction* instr = new Instruction(CFG_OP::LOAD, arg, NULL, reg);
|
||||||
blocks.push_back(new IR_Block(instr));
|
blocks.push_back(new IR_Block(instr));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1572,7 +1572,7 @@ vector<IR_Block*> buildIR(SgStatement* function, const FuncInfo* func, const vec
|
|||||||
else
|
else
|
||||||
findReturn(0, blocks.size(), blocks, blocks.back()->getNumber());
|
findReturn(0, blocks.size(), blocks, blocks.back()->getNumber());
|
||||||
|
|
||||||
// adding links by GOTO and jumps
|
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> GOTO <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
for (int z = 0; z < blocks.size(); ++z)
|
for (int z = 0; z < blocks.size(); ++z)
|
||||||
{
|
{
|
||||||
auto op = blocks[z]->getInstruction()->getOperation();
|
auto op = blocks[z]->getInstruction()->getOperation();
|
||||||
@@ -1592,7 +1592,7 @@ vector<IR_Block*> buildIR(SgStatement* function, const FuncInfo* func, const vec
|
|||||||
|
|
||||||
blocks[z]->setJump(it->second);
|
blocks[z]->setJump(it->second);
|
||||||
|
|
||||||
// replacing the label with the instruction number
|
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
arg->setValue(to_string(it->second->getNumber()));
|
arg->setValue(to_string(it->second->getNumber()));
|
||||||
arg->setType(CFG_ARG_TYPE::INSTR);
|
arg->setType(CFG_ARG_TYPE::INSTR);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "CFGraph.h"
|
#include "CFGraph.h"
|
||||||
#include "CommonBlock.h"
|
#include "../Utils/CommonBlock.h"
|
||||||
|
|
||||||
namespace SAPFOR
|
namespace SAPFOR
|
||||||
{
|
{
|
||||||
@@ -42,7 +42,6 @@ namespace SAPFOR
|
|||||||
Argument() : number(lastNumArg++), type(CFG_ARG_TYPE::NONE), value(""), mType(CFG_MEM_TYPE::NONE_) { }
|
Argument() : number(lastNumArg++), type(CFG_ARG_TYPE::NONE), value(""), mType(CFG_MEM_TYPE::NONE_) { }
|
||||||
Argument(CFG_ARG_TYPE type, CFG_MEM_TYPE mType) : number(lastNumArg++), type(type), mType(mType), value("") { }
|
Argument(CFG_ARG_TYPE type, CFG_MEM_TYPE mType) : number(lastNumArg++), type(type), mType(mType), value("") { }
|
||||||
Argument(CFG_ARG_TYPE type, CFG_MEM_TYPE mType, const std::string& value) : number(lastNumArg++), type(type), mType(mType), value(value) { }
|
Argument(CFG_ARG_TYPE type, CFG_MEM_TYPE mType, const std::string& value) : number(lastNumArg++), type(type), mType(mType), value(value) { }
|
||||||
Argument(CFG_ARG_TYPE type, CFG_MEM_TYPE mType, const std::string& value, int num) : number(num), type(type), mType(mType), value(value) { }
|
|
||||||
Argument(CFG_ARG_TYPE type, const std::string& value) : number(lastNumArg++), type(type), mType(CFG_MEM_TYPE::NONE_), value(value)
|
Argument(CFG_ARG_TYPE type, const std::string& value) : number(lastNumArg++), type(type), mType(CFG_MEM_TYPE::NONE_), value(value)
|
||||||
{
|
{
|
||||||
if (type != CFG_ARG_TYPE::INSTR && type == CFG_ARG_TYPE::LAB &&
|
if (type != CFG_ARG_TYPE::INSTR && type == CFG_ARG_TYPE::LAB &&
|
||||||
@@ -51,9 +50,6 @@ namespace SAPFOR
|
|||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Argument(const Argument& other)
|
|
||||||
: number(other.number), type(other.type), mType(other.mType), value(other.value)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
void setType(CFG_ARG_TYPE newType) { type = newType; }
|
void setType(CFG_ARG_TYPE newType) { type = newType; }
|
||||||
CFG_ARG_TYPE getType() const { return type; }
|
CFG_ARG_TYPE getType() const { return type; }
|
||||||
|
|||||||
@@ -1,386 +0,0 @@
|
|||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <vector>
|
|
||||||
#include <set>
|
|
||||||
|
|
||||||
#include "../Utils/SgUtils.h"
|
|
||||||
#include "../Utils/CommonBlock.h"
|
|
||||||
#include "../GraphCall/graph_calls.h"
|
|
||||||
|
|
||||||
#include "dvm.h"
|
|
||||||
#include "IR.h"
|
|
||||||
#include "CFGraph.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace SAPFOR;
|
|
||||||
|
|
||||||
static const SAPFOR::Argument CONST_UNDEFINED_ARG(CFG_ARG_TYPE::CONST, CFG_MEM_TYPE::COMMON_, "-1");
|
|
||||||
|
|
||||||
template <typename T> static bool compareVectors(const vector<T>* vec1, const vector<T>* vec2)
|
|
||||||
{
|
|
||||||
if (vec1 == vec2)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (!vec1 || !vec2)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
vector<T> sortedVec1 = *vec1;
|
|
||||||
vector<T> sortedVec2 = *vec2;
|
|
||||||
|
|
||||||
sort(sortedVec1.begin(), sortedVec1.end());
|
|
||||||
sort(sortedVec2.begin(), sortedVec2.end());
|
|
||||||
|
|
||||||
return sortedVec1 == sortedVec2;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T> static vector<T>* getCommonElements(const vector<vector<T>>* vectors)
|
|
||||||
{
|
|
||||||
if (!vectors || vectors->empty())
|
|
||||||
return new vector<T>();
|
|
||||||
|
|
||||||
vector<T>* commonElements = new vector<T>((*vectors)[0]);
|
|
||||||
|
|
||||||
for (size_t i = 1; i < vectors->size(); ++i)
|
|
||||||
{
|
|
||||||
vector<T> tempCommon;
|
|
||||||
|
|
||||||
vector<T> sortedVec = (*vectors)[i];
|
|
||||||
sort(commonElements->begin(), commonElements->end());
|
|
||||||
sort(sortedVec.begin(), sortedVec.end());
|
|
||||||
|
|
||||||
set_intersection(
|
|
||||||
commonElements->begin(), commonElements->end(),
|
|
||||||
sortedVec.begin(), sortedVec.end(),
|
|
||||||
back_inserter(tempCommon)
|
|
||||||
);
|
|
||||||
|
|
||||||
*commonElements = tempCommon;
|
|
||||||
|
|
||||||
if (commonElements->empty())
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return commonElements;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static map<SAPFOR::BasicBlock*, vector<SAPFOR::BasicBlock*>> findDominators(const vector<SAPFOR::BasicBlock*>& blocks)
|
|
||||||
{
|
|
||||||
map<SAPFOR::BasicBlock*, vector<SAPFOR::BasicBlock*>> result;
|
|
||||||
|
|
||||||
bool changed = true;
|
|
||||||
while (changed)
|
|
||||||
{
|
|
||||||
changed = false;
|
|
||||||
|
|
||||||
for (auto& currentBlock : blocks)
|
|
||||||
{
|
|
||||||
auto pred = currentBlock->getPrev();
|
|
||||||
auto prevDominators = new vector<vector<SAPFOR::BasicBlock*>>();
|
|
||||||
|
|
||||||
for (auto predBlock : pred)
|
|
||||||
prevDominators->push_back(result.find(predBlock) != result.end() ? result[predBlock] : blocks);
|
|
||||||
|
|
||||||
auto currentBlockResult = getCommonElements(prevDominators);
|
|
||||||
currentBlockResult->push_back(currentBlock);
|
|
||||||
|
|
||||||
if (result.find(currentBlock) == result.end() || !compareVectors(currentBlockResult, &result[currentBlock]))
|
|
||||||
{
|
|
||||||
result[currentBlock] = *currentBlockResult;
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static map<SAPFOR::BasicBlock*, vector<SAPFOR::BasicBlock*>> findDominatorBorders(const vector<SAPFOR::BasicBlock*>& blocks)
|
|
||||||
{
|
|
||||||
map<SAPFOR::BasicBlock*, vector<SAPFOR::BasicBlock*>> result;
|
|
||||||
|
|
||||||
for (auto& block : blocks)
|
|
||||||
result[block] = *(new vector<SAPFOR::BasicBlock*>());
|
|
||||||
|
|
||||||
for (auto& block : blocks)
|
|
||||||
{
|
|
||||||
if (block->getPrev().size() > 1)
|
|
||||||
{
|
|
||||||
for (auto prev : block->getPrev())
|
|
||||||
{
|
|
||||||
auto tmpBlock = prev;
|
|
||||||
|
|
||||||
while (tmpBlock != block->getDom())
|
|
||||||
{
|
|
||||||
result[tmpBlock].push_back(block);
|
|
||||||
tmpBlock = tmpBlock->getDom();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static pair<set<SAPFOR::Argument*>, map<SAPFOR::Argument*, set<SAPFOR::BasicBlock*>>> getGlobalsAndVarBlocks(const vector<SAPFOR::BasicBlock*>& blocks)
|
|
||||||
{
|
|
||||||
set<SAPFOR::Argument*> globals;
|
|
||||||
map<SAPFOR::Argument*, set<SAPFOR::BasicBlock*>> varBlocks;
|
|
||||||
|
|
||||||
for (auto& block : blocks)
|
|
||||||
{
|
|
||||||
set<SAPFOR::Argument*> def;
|
|
||||||
const auto& instructions = block->getInstructions();
|
|
||||||
|
|
||||||
for (const auto& irBlock : instructions)
|
|
||||||
{
|
|
||||||
if (irBlock)
|
|
||||||
{
|
|
||||||
Instruction* instr = irBlock->getInstruction();
|
|
||||||
|
|
||||||
if (instr)
|
|
||||||
{
|
|
||||||
auto arg1 = instr->getArg1();
|
|
||||||
auto arg2 = instr->getArg2();
|
|
||||||
auto res = instr->getResult();
|
|
||||||
|
|
||||||
if (arg1 && arg1->getType() == CFG_ARG_TYPE::VAR && find(def.begin(), def.end(), arg1) == def.end())
|
|
||||||
globals.insert(arg1);
|
|
||||||
|
|
||||||
if (arg2 && arg2->getType() == CFG_ARG_TYPE::VAR && find(def.begin(), def.end(), arg2) == def.end())
|
|
||||||
globals.insert(arg2);
|
|
||||||
|
|
||||||
if (res && res->getType() == CFG_ARG_TYPE::VAR)
|
|
||||||
{
|
|
||||||
def.insert(res);
|
|
||||||
varBlocks[res].insert(block);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return make_pair(globals, varBlocks);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void getBlocksWithFiFunctions(const vector<SAPFOR::BasicBlock*> blocks, set<SAPFOR::Argument*>& globals,
|
|
||||||
map<SAPFOR::Argument*, set<SAPFOR::BasicBlock*>>& varBlocks,
|
|
||||||
map<SAPFOR::BasicBlock*, vector<SAPFOR::BasicBlock*>>& dominatorBorders)
|
|
||||||
{
|
|
||||||
vector<SAPFOR::BasicBlock*> blocksWithFiFunctions;
|
|
||||||
auto fiFunc = new SAPFOR::Argument(CFG_ARG_TYPE::FUNC, CFG_MEM_TYPE::NONE_, "FI_FUNCTION");
|
|
||||||
auto paramCount = new SAPFOR::Argument(CFG_ARG_TYPE::CONST, CFG_MEM_TYPE::LOCAL_, "0");
|
|
||||||
|
|
||||||
for (auto& var : globals)
|
|
||||||
{
|
|
||||||
auto worklist = varBlocks[var];
|
|
||||||
set<SAPFOR::BasicBlock*> hasFiFunction;
|
|
||||||
|
|
||||||
while (!worklist.empty())
|
|
||||||
{
|
|
||||||
auto block = *worklist.begin();
|
|
||||||
worklist.erase(block);
|
|
||||||
|
|
||||||
for (auto& dfBlock : dominatorBorders[block])
|
|
||||||
{
|
|
||||||
if (hasFiFunction.find(dfBlock) == hasFiFunction.end())
|
|
||||||
{
|
|
||||||
hasFiFunction.insert(dfBlock);
|
|
||||||
Instruction* phiInstruction = new Instruction(CFG_OP::F_CALL, new SAPFOR::Argument(*fiFunc), new SAPFOR::Argument(*paramCount), var, dfBlock->getInstructions()[0]->getInstruction()->getOperator());
|
|
||||||
|
|
||||||
IR_Block* phiBlock = new IR_Block(phiInstruction);
|
|
||||||
dfBlock->addInstruction(phiBlock, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void restoreConnections(const vector<SAPFOR::BasicBlock*>& originalBlocks, vector<SAPFOR::BasicBlock*>& copiedBlocks)
|
|
||||||
{
|
|
||||||
map<SAPFOR::BasicBlock*, SAPFOR::BasicBlock*> blockMapping;
|
|
||||||
for (size_t i = 0; i < originalBlocks.size(); ++i)
|
|
||||||
blockMapping[originalBlocks[i]] = copiedBlocks[i];
|
|
||||||
|
|
||||||
for (size_t i = 0; i < originalBlocks.size(); ++i)
|
|
||||||
{
|
|
||||||
SAPFOR::BasicBlock* originalBlock = originalBlocks[i];
|
|
||||||
SAPFOR::BasicBlock* copiedBlock = copiedBlocks[i];
|
|
||||||
|
|
||||||
auto prevCopy = copiedBlock->getPrev();
|
|
||||||
for (auto j : prevCopy)
|
|
||||||
copiedBlock->removePrev(j);
|
|
||||||
|
|
||||||
auto nextCopy = copiedBlock->getNext();
|
|
||||||
for (auto j : nextCopy)
|
|
||||||
copiedBlock->removeNext(j);
|
|
||||||
|
|
||||||
for (auto* succ : originalBlock->getNext())
|
|
||||||
copiedBlock->addNext(blockMapping[succ]);
|
|
||||||
|
|
||||||
for (auto* prev : originalBlock->getPrev())
|
|
||||||
copiedBlock->addPrev(blockMapping[prev]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static SAPFOR::Argument* newName(SAPFOR::Argument* var, map<string, int>& counter, map<string, stack<SAPFOR::Argument*>>& stack, int number) {
|
|
||||||
counter[var->getValue()]++;
|
|
||||||
|
|
||||||
SAPFOR::Argument* newName = new SAPFOR::Argument(var->getType(), var->getMemType(), var->getValue(), number);
|
|
||||||
stack[var->getValue()].push(newName);
|
|
||||||
return newName;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void renameFiFunctionResultVar(SAPFOR::BasicBlock* block, map<string, int>& counter, map<string, stack<SAPFOR::Argument*>>& stack) {
|
|
||||||
for (auto& irBlock : block->getInstructions())
|
|
||||||
{
|
|
||||||
auto instruction = irBlock->getInstruction();
|
|
||||||
if (instruction->getOperation() == CFG_OP::F_CALL && instruction->getArg1() != NULL &&
|
|
||||||
instruction->getArg1()->getValue() == "FI_FUNCTION" && instruction->getResult() != NULL)
|
|
||||||
{
|
|
||||||
instruction->setResult(newName(instruction->getResult(), counter, stack, instruction->getNumber()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void renameInstructionVars(SAPFOR::BasicBlock* block, map<string, int>& counter, map<string, stack<SAPFOR::Argument*>>& stack)
|
|
||||||
{
|
|
||||||
for (auto& irBlock : block->getInstructions())
|
|
||||||
{
|
|
||||||
auto instruction = irBlock->getInstruction();
|
|
||||||
|
|
||||||
if (instruction->getArg1() != NULL && instruction->getArg1()->getType() == CFG_ARG_TYPE::VAR)
|
|
||||||
instruction->setArg1(stack[instruction->getArg1()->getValue()].top());
|
|
||||||
|
|
||||||
if (instruction->getArg2() != NULL && instruction->getArg2()->getType() == CFG_ARG_TYPE::VAR)
|
|
||||||
instruction->setArg2(stack[instruction->getArg2()->getValue()].top());
|
|
||||||
|
|
||||||
if (instruction->getResult() != NULL && instruction->getResult()->getType() == CFG_ARG_TYPE::VAR)
|
|
||||||
instruction->setResult(newName(instruction->getResult(), counter, stack, instruction->getNumber()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void renameFiFunctionArgsVar(SAPFOR::BasicBlock* block, map<string, stack<SAPFOR::Argument*>>& stack)
|
|
||||||
{
|
|
||||||
auto size = block->getInstructions().size();
|
|
||||||
auto& instructions = block->getInstructions();
|
|
||||||
|
|
||||||
for (size_t i = 0; i < size; ++i)
|
|
||||||
{
|
|
||||||
auto irBlock = instructions[i];
|
|
||||||
auto instruction = irBlock->getInstruction();
|
|
||||||
if (instruction->getOperation() == CFG_OP::F_CALL && instruction->getArg1() != NULL &&
|
|
||||||
instruction->getArg1()->getValue() == "FI_FUNCTION" && instruction->getResult() != NULL &&
|
|
||||||
instruction->getArg2() != NULL)
|
|
||||||
{
|
|
||||||
Instruction* paramInstruction;
|
|
||||||
|
|
||||||
if (stack[instruction->getResult()->getValue()].size() > 0)
|
|
||||||
{
|
|
||||||
SAPFOR::Argument* tmp = new SAPFOR::Argument(CFG_ARG_TYPE::CONST, CFG_MEM_TYPE::COMMON_, to_string(stack[instruction->getResult()->getValue()].top()->getNumber()));
|
|
||||||
paramInstruction = new Instruction(CFG_OP::PARAM, tmp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SAPFOR::Argument* tmp = new SAPFOR::Argument(CFG_ARG_TYPE::CONST, CFG_MEM_TYPE::COMMON_, "-1");
|
|
||||||
paramInstruction = new Instruction(CFG_OP::PARAM, tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
paramInstruction->setOperator(block->getInstructions()[0]->getInstruction()->getOperator());
|
|
||||||
block->addInstructionBefore(new IR_Block(paramInstruction), instruction);
|
|
||||||
|
|
||||||
instruction->getArg2()->setValue(to_string(stoi(instruction->getArg2()->getValue()) + 1));
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static vector<SAPFOR::BasicBlock*> findBlocksWithValue(vector<SAPFOR::BasicBlock*>& blocks, SAPFOR::BasicBlock* x)
|
|
||||||
{
|
|
||||||
vector<SAPFOR::BasicBlock*> result;
|
|
||||||
|
|
||||||
for (auto& block : blocks)
|
|
||||||
if (block->getDom() == x)
|
|
||||||
result.push_back(block);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void renameIR(SAPFOR::BasicBlock* block, vector<SAPFOR::BasicBlock*>& blocks, map<string, int>& counter, map<string, stack<SAPFOR::Argument*>>& stack)
|
|
||||||
{
|
|
||||||
renameFiFunctionResultVar(block, counter, stack);
|
|
||||||
renameInstructionVars(block, counter, stack);
|
|
||||||
|
|
||||||
for (auto& successor : block->getNext())
|
|
||||||
renameFiFunctionArgsVar(successor, stack);
|
|
||||||
|
|
||||||
for (auto& child : findBlocksWithValue(blocks, block))
|
|
||||||
renameIR(child, blocks, counter, stack);
|
|
||||||
|
|
||||||
for (auto& irBlock : block->getInstructions())
|
|
||||||
{
|
|
||||||
auto instruction = irBlock->getInstruction();
|
|
||||||
if (instruction->getResult() != NULL && instruction->getResult()->getType() == CFG_ARG_TYPE::VAR)
|
|
||||||
{
|
|
||||||
string varName = instruction->getResult()->getValue();
|
|
||||||
stack[varName].pop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto& irBlock : block->getInstructions())
|
|
||||||
{
|
|
||||||
auto instruction = irBlock->getInstruction();
|
|
||||||
if (instruction->getOperation() == CFG_OP::F_CALL && instruction->getArg1() != NULL &&
|
|
||||||
instruction->getArg1()->getValue() == "FI_FUNCTION" && instruction->getResult() != NULL)
|
|
||||||
{
|
|
||||||
string varName = instruction->getResult()->getValue();
|
|
||||||
stack[varName].pop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void buildFuncIRSSAForm(FuncInfo* funcInfo, const std::vector<SAPFOR::BasicBlock*>& funcIRConst, std::map<FuncInfo*, std::vector<SAPFOR::BasicBlock*>>& result)
|
|
||||||
{
|
|
||||||
vector<SAPFOR::BasicBlock*> funcIR;
|
|
||||||
|
|
||||||
for (auto& i : funcIRConst)
|
|
||||||
funcIR.push_back(new SAPFOR::BasicBlock(*i));
|
|
||||||
|
|
||||||
restoreConnections(funcIRConst, funcIR);
|
|
||||||
|
|
||||||
SAPFOR::buildDominatorTree(funcIR);
|
|
||||||
|
|
||||||
auto dominatorBorders = findDominatorBorders(funcIR);
|
|
||||||
|
|
||||||
auto globalsAndVarBlocks = getGlobalsAndVarBlocks(funcIR);
|
|
||||||
auto globals = globalsAndVarBlocks.first;
|
|
||||||
auto varBlocks = globalsAndVarBlocks.second;
|
|
||||||
|
|
||||||
getBlocksWithFiFunctions(funcIR, globals, varBlocks, dominatorBorders);
|
|
||||||
|
|
||||||
map<string, int> count;
|
|
||||||
map<string, stack<SAPFOR::Argument*>> varStack;
|
|
||||||
|
|
||||||
for (auto& var : globals)
|
|
||||||
{
|
|
||||||
count[var->getValue()] = 0;
|
|
||||||
|
|
||||||
stack<SAPFOR::Argument*> tmp;
|
|
||||||
tmp.push(new SAPFOR::Argument(CONST_UNDEFINED_ARG));
|
|
||||||
varStack[var->getValue()] = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
renameIR(funcIR[0], funcIR, count, varStack);
|
|
||||||
|
|
||||||
result[funcInfo] = funcIR;
|
|
||||||
}
|
|
||||||
|
|
||||||
FuncInfo* getIRByFilename(const std::map<FuncInfo*, std::vector<SAPFOR::BasicBlock*>>& fullIR, const char* filename)
|
|
||||||
{
|
|
||||||
for (auto ir : fullIR)
|
|
||||||
if (ir.first->fileName == filename)
|
|
||||||
return ir.first;
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CFGraph.h"
|
|
||||||
#include "IR.h"
|
|
||||||
|
|
||||||
void buildFuncIRSSAForm(FuncInfo* funcInfo, const std::vector<SAPFOR::BasicBlock*>& fullIR, std::map<FuncInfo*, std::vector<SAPFOR::BasicBlock*>>& result);
|
|
||||||
|
|
||||||
FuncInfo* getIRByFilename(const std::map<FuncInfo*, std::vector<SAPFOR::BasicBlock*>>& fullIR, const char* filename);
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
#include "dvm.h"
|
|
||||||
#include "IR_domTree.h"
|
|
||||||
|
|
||||||
namespace SAPFOR {
|
|
||||||
void DominatorFinder::DFS(BasicBlock* v, int parent_num) {
|
|
||||||
dfs_num[v] = n;
|
|
||||||
vertex[n] = n;
|
|
||||||
semi[n] = n;
|
|
||||||
label[n] = n;
|
|
||||||
ancestor[n] = -1;
|
|
||||||
parent[n] = parent_num;
|
|
||||||
vertices[n++] = v;
|
|
||||||
|
|
||||||
for (const auto& w : v->getNext()) {
|
|
||||||
if (dfs_num[w] == -1)
|
|
||||||
DFS(w, dfs_num[v]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DominatorFinder::Compress(int v) {
|
|
||||||
if (ancestor[ancestor[v]] != -1) {
|
|
||||||
Compress(ancestor[v]);
|
|
||||||
|
|
||||||
if (semi[label[ancestor[v]]] < semi[label[v]])
|
|
||||||
label[v] = label[ancestor[v]];
|
|
||||||
ancestor[v] = ancestor[ancestor[v]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int DominatorFinder::Eval(int v) {
|
|
||||||
if (ancestor[v] == -1)
|
|
||||||
return v;
|
|
||||||
|
|
||||||
Compress(v);
|
|
||||||
return label[v];
|
|
||||||
}
|
|
||||||
|
|
||||||
void DominatorFinder::Link(int v, int w) {
|
|
||||||
ancestor[w] = v;
|
|
||||||
}
|
|
||||||
|
|
||||||
DominatorFinder::DominatorFinder(std::vector<BasicBlock*>& blocks) {
|
|
||||||
if (blocks.empty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
entry = blocks[0];
|
|
||||||
n = 0;
|
|
||||||
|
|
||||||
for (auto block : blocks)
|
|
||||||
dfs_num[block] = -1;
|
|
||||||
|
|
||||||
int max_size = blocks.size();
|
|
||||||
vertices.resize(max_size);
|
|
||||||
parent.assign(max_size, -1);
|
|
||||||
semi.assign(max_size, -1);
|
|
||||||
vertex.assign(max_size, -1);
|
|
||||||
ancestor.assign(max_size, -1);
|
|
||||||
label.assign(max_size, -1);
|
|
||||||
bucket.resize(max_size);
|
|
||||||
|
|
||||||
DFS(entry, -1);
|
|
||||||
|
|
||||||
for (int i = n - 1; i > 0; --i) {
|
|
||||||
int w = vertex[i];
|
|
||||||
|
|
||||||
for (BasicBlock* v : vertices[w]->getPrev()) {
|
|
||||||
if (dfs_num[v] == -1)
|
|
||||||
continue;
|
|
||||||
int u = Eval(dfs_num[v]);
|
|
||||||
|
|
||||||
if (semi[u] < semi[w])
|
|
||||||
semi[w] = semi[u];
|
|
||||||
}
|
|
||||||
|
|
||||||
bucket[vertex[semi[w]]].push_back(w);
|
|
||||||
Link(parent[w], w);
|
|
||||||
|
|
||||||
for (int v : bucket[parent[w]])
|
|
||||||
{
|
|
||||||
int u = Eval(v);
|
|
||||||
if (semi[u] < semi[v])
|
|
||||||
vertices[v]->setDom(vertices[u]);
|
|
||||||
else
|
|
||||||
vertices[v]->setDom(vertices[parent[w]]);
|
|
||||||
}
|
|
||||||
bucket[parent[w]].clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 1; i < n; ++i) {
|
|
||||||
int w = vertex[i];
|
|
||||||
|
|
||||||
if (vertices[w]->getDom() != vertices[vertex[semi[w]]])
|
|
||||||
vertices[w]->setDom(vertices[w]->getDom()->getDom());
|
|
||||||
}
|
|
||||||
|
|
||||||
entry->setDom(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void buildDominatorTree(std::vector<BasicBlock*>& blocks) {
|
|
||||||
DominatorFinder finder(blocks);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <map>
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
#include "CFGraph.h"
|
|
||||||
|
|
||||||
// Lengauer, Thomas. A fast algorithm for finding dominators in a flowgraph / Thomas Lengauer, Robert Endre Tarjan
|
|
||||||
// ACM Transactions on Programming Languages and Systems (TOPLAS). <20> 1979. <20> Vol. 1, no. 1. <20> Pp. 121<32>141.
|
|
||||||
|
|
||||||
namespace SAPFOR {
|
|
||||||
|
|
||||||
class BasicBlock;
|
|
||||||
|
|
||||||
class DominatorFinder {
|
|
||||||
private:
|
|
||||||
BasicBlock* entry;
|
|
||||||
std::vector<BasicBlock*> vertices;
|
|
||||||
std::unordered_map<BasicBlock*, int> dfs_num;
|
|
||||||
std::vector<int> parent, semi, vertex, ancestor, label;
|
|
||||||
std::vector<std::vector<int>> bucket;
|
|
||||||
int n;
|
|
||||||
|
|
||||||
void DFS(BasicBlock* v, int parent_num);
|
|
||||||
void Compress(int v);
|
|
||||||
int Eval(int v);
|
|
||||||
void Link(int v, int w);
|
|
||||||
|
|
||||||
public:
|
|
||||||
DominatorFinder(std::vector<BasicBlock*>& blocks);
|
|
||||||
};
|
|
||||||
|
|
||||||
void buildDominatorTree(std::vector<BasicBlock*>& blocks);
|
|
||||||
}
|
|
||||||
@@ -8,10 +8,10 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "CommonBlock.h"
|
#include "../Utils/CommonBlock.h"
|
||||||
#include "graph_calls.h"
|
#include "../GraphCall/graph_calls.h"
|
||||||
#include "expr_transform.h"
|
#include "../ExpressionTransform/expr_transform.h"
|
||||||
|
|
||||||
#define PRINT_PROF_INFO 0
|
#define PRINT_PROF_INFO 0
|
||||||
#define DEBUG_CHECKS 0
|
#define DEBUG_CHECKS 0
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
#include<unordered_map>
|
#include<unordered_map>
|
||||||
|
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "CommonBlock.h"
|
#include "../Utils/CommonBlock.h"
|
||||||
#include "graph_calls.h"
|
#include "../GraphCall/graph_calls.h"
|
||||||
|
|
||||||
#include "CFGraph.h"
|
#include "CFGraph.h"
|
||||||
#include "IR.h"
|
#include "IR.h"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "CFGraph.h"
|
#include "CFGraph.h"
|
||||||
|
|
||||||
namespace LIVE_VARIABLES
|
namespace LIVE_VARIABLES
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "private_variables_analysis.h"
|
#include "private_variables_analysis.h"
|
||||||
#include "graph_loops.h"
|
#include "../GraphLoop/graph_loops.h"
|
||||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||||
#include "../SageAnalysisTool/depGraph.h"
|
#include "../SageAnalysisTool/depGraph.h"
|
||||||
#include "../DirectiveProcessing/directive_parser.h"
|
#include "../DirectiveProcessing/directive_parser.h"
|
||||||
@@ -250,7 +250,7 @@ static set<SAPFOR::BasicBlock*> analyzeLoop(LoopGraph* loop, const set<SAPFOR::B
|
|||||||
const map<string, SgSymbol*>& commonArgs, FuncInfo* func,
|
const map<string, SgSymbol*>& commonArgs, FuncInfo* func,
|
||||||
map<string, vector<Messages>>& messages)
|
map<string, vector<Messages>>& messages)
|
||||||
{
|
{
|
||||||
if (!loop->isFor())
|
if (!loop->isFor)
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__); //should be called only with FOR loops
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__); //should be called only with FOR loops
|
||||||
|
|
||||||
SgStatement* loop_operator = loop->loop->GetOriginal();
|
SgStatement* loop_operator = loop->loop->GetOriginal();
|
||||||
@@ -450,7 +450,7 @@ static void recAnalyzeLoop(LoopGraph* loop, const set<SAPFOR::BasicBlock*>& bloc
|
|||||||
const map<string, SgSymbol*>& commonArgs,
|
const map<string, SgSymbol*>& commonArgs,
|
||||||
FuncInfo* func, map<string, vector<Messages>>& messages)
|
FuncInfo* func, map<string, vector<Messages>>& messages)
|
||||||
{
|
{
|
||||||
const auto& loop_body = loop->isFor() ? analyzeLoop(loop, blocks, commonVars, commonArgs, func, messages) : blocks;
|
const auto& loop_body = loop->isFor ? analyzeLoop(loop, blocks, commonVars, commonArgs, func, messages) : blocks;
|
||||||
|
|
||||||
for (const auto& inner_loop : loop->children)
|
for (const auto& inner_loop : loop->children)
|
||||||
recAnalyzeLoop(inner_loop, loop_body, commonVars, commonArgs, func, messages);
|
recAnalyzeLoop(inner_loop, loop_body, commonVars, commonArgs, func, messages);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "graph_loops.h"
|
#include "../GraphLoop/graph_loops.h"
|
||||||
#include "CFGraph.h"
|
#include "CFGraph.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "CreateInterTree.h"
|
#include "CreateInterTree.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "utils.h"
|
#include "../Utils/utils.h"
|
||||||
#include "graph_calls_func.h"
|
#include "../GraphCall/graph_calls_func.h"
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::wstring;
|
using std::wstring;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
|
|
||||||
#include "graph_loops_func.h"
|
#include "../GraphLoop/graph_loops_func.h"
|
||||||
|
|
||||||
struct SpfInterval
|
struct SpfInterval
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -16,9 +16,9 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "../Distribution/DvmhDirective.h"
|
#include "../Distribution/DvmhDirective.h"
|
||||||
#include "graph_loops.h"
|
#include "../GraphLoop/graph_loops.h"
|
||||||
#include "directive_analyzer.h"
|
#include "directive_analyzer.h"
|
||||||
#include "utils.h"
|
#include "../Utils/utils.h"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::map;
|
using std::map;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "graph_loops.h"
|
#include "../GraphLoop/graph_loops.h"
|
||||||
|
|
||||||
void UniteNestedDirectives(std::vector<LoopGraph*> &loopGraph);
|
void UniteNestedDirectives(std::vector<LoopGraph*> &loopGraph);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -15,18 +15,18 @@
|
|||||||
#include "../Distribution/Distribution.h"
|
#include "../Distribution/Distribution.h"
|
||||||
#include "../Distribution/DvmhDirective_func.h"
|
#include "../Distribution/DvmhDirective_func.h"
|
||||||
|
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||||
#include "directive_parser.h"
|
#include "directive_parser.h"
|
||||||
#include "directive_creator.h"
|
#include "directive_creator.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "../Sapfor.h"
|
#include "../Sapfor.h"
|
||||||
#include "graph_loops_func.h"
|
#include "../GraphLoop/graph_loops_func.h"
|
||||||
#include "../Transformations/LoopNesting/loop_transform.h"
|
#include "../Transformations/loop_transform.h"
|
||||||
#include "expr_transform.h"
|
#include "../ExpressionTransform/expr_transform.h"
|
||||||
#include "graph_calls_func.h"
|
#include "../GraphCall/graph_calls_func.h"
|
||||||
|
|
||||||
#include "AstWrapper.h"
|
#include "../Utils/AstWrapper.h"
|
||||||
|
|
||||||
#define PRINT_DIR_RESULT 0
|
#define PRINT_DIR_RESULT 0
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../Distribution/Distribution.h"
|
#include "../Distribution/Distribution.h"
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "graph_loops.h"
|
#include "../GraphLoop/graph_loops.h"
|
||||||
#include "types.h"
|
#include "../Utils/types.h"
|
||||||
|
|
||||||
void createParallelDirectives(const std::map<LoopGraph*, std::map<DIST::Array*, ArrayInfo*>> &loopInfo,
|
void createParallelDirectives(const std::map<LoopGraph*, std::map<DIST::Array*, ArrayInfo*>> &loopInfo,
|
||||||
const std::vector<ParallelRegion*>& regions,
|
const std::vector<ParallelRegion*>& regions,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -10,9 +10,9 @@
|
|||||||
|
|
||||||
#include "../ParallelizationRegions/ParRegions.h"
|
#include "../ParallelizationRegions/ParRegions.h"
|
||||||
#include "../Distribution/Arrays.h"
|
#include "../Distribution/Arrays.h"
|
||||||
#include "../Transformations/LoopNesting/loop_transform.h"
|
#include "../Transformations/loop_transform.h"
|
||||||
|
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "directive_parser.h"
|
#include "directive_parser.h"
|
||||||
#include "directive_creator.h"
|
#include "directive_creator.h"
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ static LoopGraph* createDirectiveForLoop(LoopGraph *currentLoop, MapToArray &mai
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
directive->parallel.push_back(currentLoop->loopSymbol());
|
directive->parallel.push_back(currentLoop->loopSymbol);
|
||||||
directive->arrayRef = mainArray.arrayRef;
|
directive->arrayRef = mainArray.arrayRef;
|
||||||
|
|
||||||
DIST::Array *tmp = mainArray.arrayRef;
|
DIST::Array *tmp = mainArray.arrayRef;
|
||||||
@@ -84,7 +84,7 @@ static LoopGraph* createDirectiveForLoop(LoopGraph *currentLoop, MapToArray &mai
|
|||||||
for (int i = 0; i < tmp->GetDimSize(); ++i)
|
for (int i = 0; i < tmp->GetDimSize(); ++i)
|
||||||
{
|
{
|
||||||
if (i == pos)
|
if (i == pos)
|
||||||
directive->on.push_back(make_pair(currentLoop->loopSymbol(), mainAccess));
|
directive->on.push_back(make_pair(currentLoop->loopSymbol, mainAccess));
|
||||||
else
|
else
|
||||||
directive->on.push_back(make_pair("*", make_pair(0, 0)));
|
directive->on.push_back(make_pair("*", make_pair(0, 0)));
|
||||||
}
|
}
|
||||||
@@ -808,7 +808,7 @@ void createParallelDirectives(const map<LoopGraph*, map<DIST::Array*, ArrayInfo*
|
|||||||
for (int i = 0; i < mainArrayOfLoop->GetDimSize(); ++i)
|
for (int i = 0; i < mainArrayOfLoop->GetDimSize(); ++i)
|
||||||
{
|
{
|
||||||
if (i == dimPos)
|
if (i == dimPos)
|
||||||
parDir->on2.push_back(make_pair(currLoop->loopSymbol(), mainAccess));
|
parDir->on2.push_back(make_pair(currLoop->loopSymbol, mainAccess));
|
||||||
else
|
else
|
||||||
parDir->on2.push_back(make_pair("*", make_pair(0, 0)));
|
parDir->on2.push_back(make_pair("*", make_pair(0, 0)));
|
||||||
}
|
}
|
||||||
@@ -1100,7 +1100,7 @@ static bool tryToResolveUnmatchedDims(const map<DIST::Array*, vector<bool>> &dim
|
|||||||
LoopGraph* tmpL = loop;
|
LoopGraph* tmpL = loop;
|
||||||
for (int z = 0; z < nested; ++z)
|
for (int z = 0; z < nested; ++z)
|
||||||
{
|
{
|
||||||
deprecateToMatch.insert(tmpL->loopSymbol());
|
deprecateToMatch.insert(tmpL->loopSymbol);
|
||||||
if (tmpL->children.size())
|
if (tmpL->children.size())
|
||||||
tmpL = tmpL->children[0];
|
tmpL = tmpL->children[0];
|
||||||
else if (z != nested - 1)
|
else if (z != nested - 1)
|
||||||
@@ -1113,7 +1113,7 @@ static bool tryToResolveUnmatchedDims(const map<DIST::Array*, vector<bool>> &dim
|
|||||||
tmpL = loop->parent;
|
tmpL = loop->parent;
|
||||||
while (tmpL)
|
while (tmpL)
|
||||||
{
|
{
|
||||||
if (tmpL->isWhile()) // TODO: need to add all inductive variables!
|
if (!tmpL->isFor) // TODO: need to add all inductive variables!
|
||||||
{
|
{
|
||||||
SgWhileStmt* dow = isSgWhileStmt(tmpL->loop->GetOriginal());
|
SgWhileStmt* dow = isSgWhileStmt(tmpL->loop->GetOriginal());
|
||||||
if (dow->conditional())
|
if (dow->conditional())
|
||||||
@@ -1124,7 +1124,7 @@ static bool tryToResolveUnmatchedDims(const map<DIST::Array*, vector<bool>> &dim
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
deprecateToMatch.insert(tmpL->loopSymbol());
|
deprecateToMatch.insert(tmpL->loopSymbol);
|
||||||
tmpL = tmpL->parent;
|
tmpL = tmpL->parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1601,7 +1601,7 @@ static bool matchParallelAndDist(const pair<DIST::Array*, const DistrVariant*>&
|
|||||||
parallelOn = NULL;
|
parallelOn = NULL;
|
||||||
for (auto& refOn : realRefs)
|
for (auto& refOn : realRefs)
|
||||||
{
|
{
|
||||||
linkWithTempl = refOn->GetLinksWithTemplate(regionId);
|
linkWithTempl = parallelOn->GetLinksWithTemplate(regionId);
|
||||||
int z = 0;
|
int z = 0;
|
||||||
for (int k = 0; k < linkWithTempl.size(); ++k)
|
for (int k = 0; k < linkWithTempl.size(); ++k)
|
||||||
if (linkWithTempl[k] != -1)
|
if (linkWithTempl[k] != -1)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
#include "directive_omp_parser.h"
|
#include "directive_omp_parser.h"
|
||||||
#include "directive_parser.h"
|
#include "directive_parser.h"
|
||||||
|
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::map;
|
using std::map;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
|
|
||||||
#define SPF_USER_DIR 777
|
#define SPF_USER_DIR 777
|
||||||
#define SPF_USER_DIR_COPY 999
|
#define SPF_USER_DIR_COPY 999
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@@ -12,10 +12,10 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "directive_parser.h"
|
#include "directive_parser.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||||
#include "AstWrapper.h"
|
#include "../Utils/AstWrapper.h"
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "AstWrapper.h"
|
#include "../Utils/AstWrapper.h"
|
||||||
#include "graph_loops.h"
|
#include "../GraphLoop/graph_loops.h"
|
||||||
#include "../Distribution/DvmhDirective.h"
|
#include "../Distribution/DvmhDirective.h"
|
||||||
|
|
||||||
struct DvmDirective
|
struct DvmDirective
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -16,13 +16,13 @@
|
|||||||
#include "../Distribution/Arrays.h"
|
#include "../Distribution/Arrays.h"
|
||||||
#include "../Distribution/Distribution.h"
|
#include "../Distribution/Distribution.h"
|
||||||
#include "../Distribution/DvmhDirective_func.h"
|
#include "../Distribution/DvmhDirective_func.h"
|
||||||
#include "graph_loops_func.h"
|
#include "../GraphLoop/graph_loops_func.h"
|
||||||
#include "graph_calls_func.h"
|
#include "../GraphCall/graph_calls_func.h"
|
||||||
|
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||||
#include "directive_parser.h"
|
#include "directive_parser.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "../Sapfor.h"
|
#include "../Sapfor.h"
|
||||||
#include "directive_creator.h"
|
#include "directive_creator.h"
|
||||||
#include "insert_directive.h"
|
#include "insert_directive.h"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -18,13 +18,13 @@
|
|||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||||
#include "types.h"
|
#include "../Utils/types.h"
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "../Distribution/Arrays.h"
|
#include "../Distribution/Arrays.h"
|
||||||
#include "graph_calls.h"
|
#include "../GraphCall/graph_calls.h"
|
||||||
#include "graph_calls_func.h"
|
#include "../GraphCall/graph_calls_func.h"
|
||||||
#include "graph_loops_func.h"
|
#include "../GraphLoop/graph_loops_func.h"
|
||||||
#include "remote_access.h"
|
#include "remote_access.h"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -17,8 +17,8 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "../Distribution/Arrays.h"
|
#include "../Distribution/Arrays.h"
|
||||||
#include "graph_calls.h"
|
#include "../GraphCall/graph_calls.h"
|
||||||
#include "graph_loops.h"
|
#include "../GraphLoop/graph_loops.h"
|
||||||
#include "../ParallelizationRegions/ParRegions.h"
|
#include "../ParallelizationRegions/ParRegions.h"
|
||||||
#include "remote_access.h"
|
#include "remote_access.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "utils.h"
|
#include "../Utils/utils.h"
|
||||||
#include "graph_loops_func.h"
|
#include "../GraphLoop/graph_loops_func.h"
|
||||||
#include "graph_calls.h"
|
#include "../GraphCall/graph_calls.h"
|
||||||
#include "graph_calls_func.h"
|
#include "../GraphCall/graph_calls_func.h"
|
||||||
#include "directive_parser.h"
|
#include "directive_parser.h"
|
||||||
#include "../Distribution/DvmhDirective_func.h"
|
#include "../Distribution/DvmhDirective_func.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "expr_transform.h"
|
#include "../ExpressionTransform/expr_transform.h"
|
||||||
|
|
||||||
#include "../CFGraph/CFGraph.h"
|
#include "../CFGraph/CFGraph.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -12,13 +12,13 @@
|
|||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "../Sapfor.h"
|
#include "../Sapfor.h"
|
||||||
#include "graph_loops.h"
|
#include "../GraphLoop/graph_loops.h"
|
||||||
#include "graph_calls_func.h"
|
#include "../GraphCall/graph_calls_func.h"
|
||||||
#include "../SageAnalysisTool/depInterfaceExt.h"
|
#include "../SageAnalysisTool/depInterfaceExt.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "directive_parser.h"
|
#include "directive_parser.h"
|
||||||
#include "expr_transform.h"
|
#include "../ExpressionTransform/expr_transform.h"
|
||||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||||
#include "../DirectiveProcessing/directive_omp_parser.h"
|
#include "../DirectiveProcessing/directive_omp_parser.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "Array.h"
|
#include "Array.h"
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "utils.h"
|
#include "../Utils/utils.h"
|
||||||
#include "graph_calls.h"
|
#include "../GraphCall/graph_calls.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,8 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include "DvmhDirectiveBase.h"
|
#include "DvmhDirectiveBase.h"
|
||||||
#include "utils.h"
|
#include "../Utils/utils.h"
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "json.hpp"
|
|
||||||
|
|
||||||
class Symbol;
|
class Symbol;
|
||||||
class Expression;
|
class Expression;
|
||||||
@@ -21,7 +20,6 @@ struct FuncInfo;
|
|||||||
#define MAP std::map
|
#define MAP std::map
|
||||||
#define SET std::set
|
#define SET std::set
|
||||||
#define TO_STR std::to_string
|
#define TO_STR std::to_string
|
||||||
#define JSON nlohmann::json
|
|
||||||
|
|
||||||
#if __SPF
|
#if __SPF
|
||||||
extern int sharedMemoryParallelization;
|
extern int sharedMemoryParallelization;
|
||||||
@@ -106,7 +104,7 @@ namespace Distribution
|
|||||||
MAP<STRING, SET<int>> usagePlaces;
|
MAP<STRING, SET<int>> usagePlaces;
|
||||||
|
|
||||||
VECTOR<bool> mappedDims;
|
VECTOR<bool> mappedDims;
|
||||||
VECTOR<bool> deprecateToDistribute;
|
VECTOR<bool> depracateToDistribute;
|
||||||
|
|
||||||
bool ompThreadPrivate;
|
bool ompThreadPrivate;
|
||||||
bool privateInLoop;
|
bool privateInLoop;
|
||||||
@@ -171,7 +169,7 @@ namespace Distribution
|
|||||||
sizes.resize(dimSize);
|
sizes.resize(dimSize);
|
||||||
sizesExpr.resize(dimSize);
|
sizesExpr.resize(dimSize);
|
||||||
mappedDims.resize(dimSize);
|
mappedDims.resize(dimSize);
|
||||||
deprecateToDistribute.resize(dimSize);
|
depracateToDistribute.resize(dimSize);
|
||||||
|
|
||||||
for (int z = 0; z < dimSize; ++z)
|
for (int z = 0; z < dimSize; ++z)
|
||||||
{
|
{
|
||||||
@@ -179,7 +177,7 @@ namespace Distribution
|
|||||||
PAIR<int, int> initVal = std::make_pair(0, 0);
|
PAIR<int, int> initVal = std::make_pair(0, 0);
|
||||||
sizesExpr[z] = std::make_pair(std::make_pair((Expression*)NULL, initVal), std::make_pair((Expression*)NULL, initVal));
|
sizesExpr[z] = std::make_pair(std::make_pair((Expression*)NULL, initVal), std::make_pair((Expression*)NULL, initVal));
|
||||||
mappedDims[z] = false;
|
mappedDims[z] = false;
|
||||||
deprecateToDistribute[z] = false;
|
depracateToDistribute[z] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GenUniqKey();
|
GenUniqKey();
|
||||||
@@ -214,7 +212,7 @@ namespace Distribution
|
|||||||
uniqKey = copy.uniqKey;
|
uniqKey = copy.uniqKey;
|
||||||
containsInRegions = copy.containsInRegions;
|
containsInRegions = copy.containsInRegions;
|
||||||
mappedDims = copy.mappedDims;
|
mappedDims = copy.mappedDims;
|
||||||
deprecateToDistribute = copy.deprecateToDistribute;
|
depracateToDistribute = copy.depracateToDistribute;
|
||||||
ompThreadPrivate = copy.ompThreadPrivate;
|
ompThreadPrivate = copy.ompThreadPrivate;
|
||||||
privateInLoop = copy.privateInLoop;
|
privateInLoop = copy.privateInLoop;
|
||||||
inEquivalence = copy.inEquivalence;
|
inEquivalence = copy.inEquivalence;
|
||||||
@@ -226,7 +224,7 @@ namespace Distribution
|
|||||||
int countToRem = 0;
|
int countToRem = 0;
|
||||||
for (int z = 0; z < dimSize; ++z)
|
for (int z = 0; z < dimSize; ++z)
|
||||||
{
|
{
|
||||||
if (!mappedDims[z] || deprecateToDistribute[z])
|
if (!mappedDims[z] || depracateToDistribute[z])
|
||||||
{
|
{
|
||||||
needToRemove = true;
|
needToRemove = true;
|
||||||
countToRem++;
|
countToRem++;
|
||||||
@@ -246,19 +244,19 @@ namespace Distribution
|
|||||||
|
|
||||||
for (int z = 0; z < dimSize; ++z)
|
for (int z = 0; z < dimSize; ++z)
|
||||||
{
|
{
|
||||||
if (mappedDims[z] && !deprecateToDistribute[z])
|
if (mappedDims[z] && !depracateToDistribute[z])
|
||||||
{
|
{
|
||||||
newSizes.push_back(sizes[z]);
|
newSizes.push_back(sizes[z]);
|
||||||
newSizesExpr.push_back(sizesExpr[z]);
|
newSizesExpr.push_back(sizesExpr[z]);
|
||||||
newMappedDims.push_back(mappedDims[z]);
|
newMappedDims.push_back(mappedDims[z]);
|
||||||
newDepr.push_back(deprecateToDistribute[z]);
|
newDepr.push_back(depracateToDistribute[z]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sizes = newSizes;
|
sizes = newSizes;
|
||||||
sizesExpr = newSizesExpr;
|
sizesExpr = newSizesExpr;
|
||||||
mappedDims = newMappedDims;
|
mappedDims = newMappedDims;
|
||||||
deprecateToDistribute = newDepr;
|
depracateToDistribute = newDepr;
|
||||||
dimSize = (int)sizes.size();
|
dimSize = (int)sizes.size();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -426,64 +424,48 @@ namespace Distribution
|
|||||||
|
|
||||||
void ClearShadowSpecs() { allShadowSpecs.clear(); }
|
void ClearShadowSpecs() { allShadowSpecs.clear(); }
|
||||||
|
|
||||||
JSON toJson()
|
STRING toString()
|
||||||
{
|
{
|
||||||
JSON retVal;
|
STRING retVal = "";
|
||||||
|
retVal += TO_STR(id);
|
||||||
|
retVal += "#" + name;
|
||||||
|
retVal += "#" + shortName;
|
||||||
|
retVal += "#" + TO_STR(dimSize);
|
||||||
|
retVal += "#" + TO_STR(typeSize);
|
||||||
|
retVal += "#" + TO_STR(isNonDistribute);
|
||||||
|
|
||||||
|
retVal += "#" + TO_STR(locationPos.first);
|
||||||
|
retVal += "#" + locationPos.second;
|
||||||
|
|
||||||
retVal["id"] = (int64_t)id;
|
retVal += "#" + TO_STR(sizes.size());
|
||||||
retVal["name"] = name;
|
|
||||||
retVal["shortName"] = shortName;
|
|
||||||
retVal["packedAddress"] = std::to_string((long long)this);
|
|
||||||
|
|
||||||
retVal["dimSize"] = dimSize;
|
|
||||||
retVal["typeSize"] = typeSize;
|
|
||||||
retVal["state"] = (int)isNonDistribute;
|
|
||||||
retVal["location"] = (int)locationPos.first;
|
|
||||||
retVal["locName"] = locationPos.second;
|
|
||||||
|
|
||||||
retVal["isTemplFlag"] = (int)isTemplFlag;
|
|
||||||
retVal["isLoopArrayFlag"] = (int)isLoopArrayFlag;
|
|
||||||
|
|
||||||
JSON deprToDist = nlohmann::json::array();
|
|
||||||
for (int i = 0; i < deprecateToDistribute.size(); ++i)
|
|
||||||
deprToDist.push_back((int)deprecateToDistribute[i]);
|
|
||||||
retVal["deprecateToDist"] = deprToDist;
|
|
||||||
|
|
||||||
JSON mappedDimsJ = nlohmann::json::array();
|
|
||||||
for (int i = 0; i < mappedDims.size(); ++i)
|
|
||||||
mappedDimsJ.push_back((int)mappedDims[i]);
|
|
||||||
retVal["mappedDims"] = mappedDimsJ;
|
|
||||||
|
|
||||||
JSON sizesJ = nlohmann::json::array();
|
|
||||||
for (int i = 0; i < sizes.size(); ++i)
|
for (int i = 0; i < sizes.size(); ++i)
|
||||||
{
|
retVal += "#" + TO_STR(sizes[i].first) + "#" + TO_STR(sizes[i].second);
|
||||||
JSON pair;
|
|
||||||
pair["key"] = sizes[i].first;
|
|
||||||
pair["value"] = sizes[i].second;
|
|
||||||
sizesJ.push_back(pair);
|
|
||||||
}
|
|
||||||
retVal["sizes"] = sizesJ;
|
|
||||||
|
|
||||||
JSON regions = nlohmann::json::array();
|
retVal += "#" + TO_STR(depracateToDistribute.size());
|
||||||
for (auto& reg : containsInRegions)
|
for (int i = 0; i < depracateToDistribute.size(); ++i)
|
||||||
regions.push_back(reg);
|
retVal += "#" + TO_STR((int)depracateToDistribute[i]);
|
||||||
retVal["regions"] = regions;
|
|
||||||
|
|
||||||
|
retVal += "#" + TO_STR(mappedDims.size());
|
||||||
|
for (int i = 0; i < mappedDims.size(); ++i)
|
||||||
|
retVal += "#" + TO_STR((int)mappedDims[i]);
|
||||||
|
|
||||||
JSON declPlacesJ = nlohmann::json::array();
|
retVal += "#" + TO_STR(templateInfo.size());
|
||||||
for (auto& place : declPlaces)
|
for (auto it = templateInfo.begin(); it != templateInfo.end(); ++it)
|
||||||
{
|
retVal += "#" + TO_STR(it->first) + it->second->toString();
|
||||||
JSON elem;
|
|
||||||
elem["file"] = place.first;
|
retVal += "#" + TO_STR((int)isTemplFlag);
|
||||||
elem["line"] = place.second;
|
retVal += "|" + TO_STR((int)isLoopArrayFlag);
|
||||||
|
retVal += "|" + TO_STR(declPlaces.size());
|
||||||
|
|
||||||
declPlacesJ.push_back(elem);
|
for (auto &place : declPlaces)
|
||||||
}
|
retVal += "|" + place.first + "|" + TO_STR(place.second);
|
||||||
retVal["declPlaces"] = declPlacesJ;
|
|
||||||
|
|
||||||
|
retVal += "|" + TO_STR(containsInRegions.size());
|
||||||
|
for (auto ® : containsInRegions)
|
||||||
|
retVal += "|" + reg;
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array* GetTemplateArray(const uint64_t regionId, bool withCheck = true)
|
Array* GetTemplateArray(const uint64_t regionId, bool withCheck = true)
|
||||||
{
|
{
|
||||||
TemplateLink *currLink = getTemlateInfo(regionId, withCheck);
|
TemplateLink *currLink = getTemlateInfo(regionId, withCheck);
|
||||||
@@ -605,13 +587,13 @@ namespace Distribution
|
|||||||
{
|
{
|
||||||
if (dim >= dimSize)
|
if (dim >= dimSize)
|
||||||
return;
|
return;
|
||||||
deprecateToDistribute[dim] = value;
|
depracateToDistribute[dim] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeprecateAllDims()
|
void DeprecateAllDims()
|
||||||
{
|
{
|
||||||
for (int dim = 0; dim < dimSize; ++dim)
|
for (int dim = 0; dim < dimSize; ++dim)
|
||||||
deprecateToDistribute[dim] = true;
|
depracateToDistribute[dim] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsDimDepracated(const int dim) const
|
bool IsDimDepracated(const int dim) const
|
||||||
@@ -621,9 +603,9 @@ namespace Distribution
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (templateDimsOrder.size() == 0)
|
if (templateDimsOrder.size() == 0)
|
||||||
return deprecateToDistribute[dim];
|
return depracateToDistribute[dim];
|
||||||
else
|
else
|
||||||
return deprecateToDistribute[templateDimsOrder[dim]];
|
return depracateToDistribute[templateDimsOrder[dim]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -631,11 +613,11 @@ namespace Distribution
|
|||||||
{
|
{
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
for (int z = 0; z < dimSize; ++z)
|
for (int z = 0; z < dimSize; ++z)
|
||||||
ret = ret && deprecateToDistribute[z];
|
ret = ret && depracateToDistribute[z];
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
const VECTOR<bool>& GetDeprecetedDims() const { return deprecateToDistribute; }
|
const VECTOR<bool>& GetDeprecetedDims() const { return depracateToDistribute; }
|
||||||
|
|
||||||
int GetTypeSize() const { return typeSize; }
|
int GetTypeSize() const { return typeSize; }
|
||||||
|
|
||||||
@@ -827,4 +809,4 @@ namespace Distribution
|
|||||||
#undef PAIR
|
#undef PAIR
|
||||||
#undef MAP
|
#undef MAP
|
||||||
#undef SET
|
#undef SET
|
||||||
#undef TO_STR
|
#undef TO_STR
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#include "Array.h"
|
#include "Array.h"
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "utils.h"
|
#include "../Utils/utils.h"
|
||||||
#include "graph_calls.h"
|
#include "../GraphCall/graph_calls.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "../DirectiveProcessing/directive_parser.h"
|
#include "../DirectiveProcessing/directive_parser.h"
|
||||||
#include "../DirectiveProcessing/directive_omp_parser.h"
|
#include "../DirectiveProcessing/directive_omp_parser.h"
|
||||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -14,9 +14,9 @@
|
|||||||
#include "GraphCSR.h"
|
#include "GraphCSR.h"
|
||||||
#include "Arrays.h"
|
#include "Arrays.h"
|
||||||
|
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "utils.h"
|
#include "../Utils/utils.h"
|
||||||
#include "graph_loops.h"
|
#include "../GraphLoop/graph_loops.h"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::set;
|
using std::set;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "graph_loops.h"
|
#include "../GraphLoop/graph_loops.h"
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
|
|
||||||
void createDistributionDirs(DIST::GraphCSR<int, double, attrType> &reducedG, DIST::Arrays<int> &allArrays,
|
void createDistributionDirs(DIST::GraphCSR<int, double, attrType> &reducedG, DIST::Arrays<int> &allArrays,
|
||||||
DataDirective &dataDirectives, std::map<std::string, std::vector<Messages>> &allMessages,
|
DataDirective &dataDirectives, std::map<std::string, std::vector<Messages>> &allMessages,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "types.h"
|
#include "../Utils/types.h"
|
||||||
|
|
||||||
namespace Distribution
|
namespace Distribution
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -30,9 +30,9 @@ using namespace std::chrono;
|
|||||||
#include "Arrays.h"
|
#include "Arrays.h"
|
||||||
#include "Array.h"
|
#include "Array.h"
|
||||||
#include "Distribution.h"
|
#include "Distribution.h"
|
||||||
#include "utils.h"
|
#include "../Utils/utils.h"
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "types.h"
|
#include "../Utils/types.h"
|
||||||
#include "../Distribution/Cycle.h"
|
#include "../Distribution/Cycle.h"
|
||||||
#include "../VisualizerCalls/get_information.h"
|
#include "../VisualizerCalls/get_information.h"
|
||||||
#include "../VisualizerCalls/SendMessage.h"
|
#include "../VisualizerCalls/SendMessage.h"
|
||||||
@@ -455,7 +455,15 @@ namespace Distribution
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (needPrint)
|
if (needPrint)
|
||||||
sendMessage_2lvl(4, k, (int)AllCycles.size());
|
{
|
||||||
|
#if _WIN32
|
||||||
|
wstring treeM = L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> " + std::to_wstring(k + 1) + L"/" + std::to_wstring(AllCycles.size());
|
||||||
|
#else
|
||||||
|
wstring treeM = L"conflict resolution, processing group " + std::to_wstring(k + 1) + L"/" + std::to_wstring(AllCycles.size());
|
||||||
|
#endif
|
||||||
|
sendMessage_2lvl(treeM);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
auto timeR = steady_clock::now();
|
auto timeR = steady_clock::now();
|
||||||
if (countConflicts != 0)
|
if (countConflicts != 0)
|
||||||
@@ -508,7 +516,7 @@ namespace Distribution
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (needPrint)
|
if (needPrint)
|
||||||
sendMessage_2lvl(2);
|
sendMessage_2lvl(L"");
|
||||||
|
|
||||||
return make_pair(allOnlySecondType, globalSum);
|
return make_pair(allOnlySecondType, globalSum);
|
||||||
}
|
}
|
||||||
@@ -564,7 +572,13 @@ namespace Distribution
|
|||||||
for (int z = 0; z < arraysV.size(); ++z)
|
for (int z = 0; z < arraysV.size(); ++z)
|
||||||
{
|
{
|
||||||
const DIST::Array *array = arraysV[z];
|
const DIST::Array *array = arraysV[z];
|
||||||
sendMessage_2lvl(5, z, (int)arrays.size());
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
wstring treeM = L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> " + std::to_wstring(z + 1) + L"/" + std::to_wstring(arrays.size());
|
||||||
|
#else
|
||||||
|
wstring treeM = L"conflict resolution, processing array " + std::to_wstring(z + 1) + L"/" + std::to_wstring(arrays.size());
|
||||||
|
#endif
|
||||||
|
sendMessage_2lvl(treeM);
|
||||||
|
|
||||||
vector<vType> verts;
|
vector<vType> verts;
|
||||||
|
|
||||||
@@ -591,7 +605,7 @@ namespace Distribution
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sendMessage_2lvl(2);
|
sendMessage_2lvl(L"");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -7,12 +7,12 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "types.h"
|
#include "../Utils/types.h"
|
||||||
#include "DvmhDirective.h"
|
#include "DvmhDirective.h"
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "../Sapfor.h"
|
#include "../Sapfor.h"
|
||||||
#include "graph_calls_func.h"
|
#include "../GraphCall/graph_calls_func.h"
|
||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
|
|
||||||
@@ -199,6 +199,15 @@ static set<string> fillUsedSymbols(SgStatement *loop)
|
|||||||
return usedS;
|
return usedS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static string correctSymbolModuleName(const string& origFull)
|
||||||
|
{
|
||||||
|
auto it = origFull.find("::");
|
||||||
|
if (it == string::npos)
|
||||||
|
return origFull;
|
||||||
|
else
|
||||||
|
return origFull.substr(it + 2);
|
||||||
|
}
|
||||||
|
|
||||||
static SgStatement* getModuleScope(const string& origFull, vector<SgStatement*>& moduleList, SgStatement *local)
|
static SgStatement* getModuleScope(const string& origFull, vector<SgStatement*>& moduleList, SgStatement *local)
|
||||||
{
|
{
|
||||||
auto it = origFull.find("::");
|
auto it = origFull.find("::");
|
||||||
@@ -346,7 +355,7 @@ static vector<SgExpression*>
|
|||||||
{
|
{
|
||||||
needToAdd = true;
|
needToAdd = true;
|
||||||
dim_found = true;
|
dim_found = true;
|
||||||
subs[i] = new SgVarRefExp(findSymbolOrCreate(file, currLoop->loopSymbol()));
|
subs[i] = new SgVarRefExp(findSymbolOrCreate(file, currLoop->loopSymbol));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -950,7 +959,7 @@ ParallelDirective::genDirective(File* file, const vector<pair<DIST::Array*, cons
|
|||||||
SgSymbol* redS;
|
SgSymbol* redS;
|
||||||
string clearName = correctSymbolModuleName(red);
|
string clearName = correctSymbolModuleName(red);
|
||||||
if (clearName != red)
|
if (clearName != red)
|
||||||
redS = getNameInLocation(parentFunc, red, getModuleScope(red, moduleList, parentFunc)->symbol()->identifier());
|
redS = getNameInLocation(parentFunc, clearName, getModuleScope(red, moduleList, parentFunc)->symbol()->identifier());
|
||||||
else
|
else
|
||||||
redS = findSymbolOrCreate(file, clearName, NULL, parentFunc);
|
redS = findSymbolOrCreate(file, clearName, NULL, parentFunc);
|
||||||
|
|
||||||
@@ -1008,12 +1017,12 @@ ParallelDirective::genDirective(File* file, const vector<pair<DIST::Array*, cons
|
|||||||
string clearName2 = correctSymbolModuleName(get<1>(list));
|
string clearName2 = correctSymbolModuleName(get<1>(list));
|
||||||
|
|
||||||
if (clearName1 != get<0>(list))
|
if (clearName1 != get<0>(list))
|
||||||
redS1 = getNameInLocation(parentFunc, get<0>(list), getModuleScope(get<0>(list), moduleList, parentFunc)->symbol()->identifier());
|
redS1 = getNameInLocation(parentFunc, clearName1, getModuleScope(get<0>(list), moduleList, parentFunc)->symbol()->identifier());
|
||||||
else
|
else
|
||||||
redS1 = findSymbolOrCreate(file, clearName1, NULL, parentFunc);
|
redS1 = findSymbolOrCreate(file, clearName1, NULL, parentFunc);
|
||||||
|
|
||||||
if (clearName2 != get<1>(list))
|
if (clearName2 != get<1>(list))
|
||||||
redS2 = getNameInLocation(parentFunc, get<1>(list), getModuleScope(get<1>(list), moduleList, parentFunc)->symbol()->identifier());
|
redS2 = getNameInLocation(parentFunc, clearName2, getModuleScope(get<1>(list), moduleList, parentFunc)->symbol()->identifier());
|
||||||
else
|
else
|
||||||
redS2 = findSymbolOrCreate(file, clearName2, NULL, parentFunc);
|
redS2 = findSymbolOrCreate(file, clearName2, NULL, parentFunc);
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
|
|
||||||
#include "Array.h"
|
#include "Array.h"
|
||||||
#include "DvmhDirectiveBase.h"
|
#include "DvmhDirectiveBase.h"
|
||||||
#include "AstWrapper.h"
|
#include "../Utils/AstWrapper.h"
|
||||||
#include "types.h"
|
#include "../Utils/types.h"
|
||||||
#include "utils.h"
|
#include "../Utils/utils.h"
|
||||||
|
|
||||||
extern int sharedMemoryParallelization;
|
extern int sharedMemoryParallelization;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -10,11 +10,9 @@
|
|||||||
#include "../Distribution/Array.h"
|
#include "../Distribution/Array.h"
|
||||||
#include "../Distribution/Arrays.h"
|
#include "../Distribution/Arrays.h"
|
||||||
#include "../Distribution/GraphCSR.h"
|
#include "../Distribution/GraphCSR.h"
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "utils.h"
|
#include "../Utils/utils.h"
|
||||||
#include "json.hpp"
|
#include "../GraphCall/graph_calls_func.h"
|
||||||
|
|
||||||
#include "graph_calls_func.h"
|
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::tuple;
|
using std::tuple;
|
||||||
@@ -29,8 +27,6 @@ using std::make_pair;
|
|||||||
using std::min;
|
using std::min;
|
||||||
using std::max;
|
using std::max;
|
||||||
|
|
||||||
using nlohmann::json;
|
|
||||||
|
|
||||||
template<typename setT>
|
template<typename setT>
|
||||||
static void uniteSets(const set<setT> &first, const set<setT> &second, set<setT> &result)
|
static void uniteSets(const set<setT> &first, const set<setT> &second, set<setT> &result)
|
||||||
{
|
{
|
||||||
@@ -736,34 +732,30 @@ string AlignRuleBase::GenRuleBase() const
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
json AlignRuleBase::toJson()
|
string AlignRuleBase::toString()
|
||||||
{
|
{
|
||||||
json retVal;
|
string retVal = "";
|
||||||
|
|
||||||
retVal["packedAlignArrayAddress"] = alignArray ? std::to_string((long long)alignArray) : std::to_string((long long)-1);
|
if (alignArray)
|
||||||
retVal["packedAlignWithAddress"] = alignWith ? std::to_string((long long)alignWith) : std::to_string((long long)-1);
|
retVal += "#" + std::to_string((long long)alignArray);
|
||||||
|
else
|
||||||
|
retVal += "#-1";
|
||||||
|
|
||||||
json alignRules = json::array();
|
if (alignWith)
|
||||||
for (auto& rule : alignRule)
|
retVal += "#" + std::to_string((long long)alignWith);
|
||||||
{
|
else
|
||||||
json pair;
|
retVal += "#-1";
|
||||||
pair["key"] = rule.first;
|
|
||||||
pair["value"] = rule.second;
|
|
||||||
alignRules.push_back(pair);
|
|
||||||
}
|
|
||||||
retVal["alignRule"] = alignRules;
|
|
||||||
|
|
||||||
json alignRuleWithJ = json::array();
|
retVal += "#" + std::to_string(alignRule.size());
|
||||||
for (auto& [dimNum, AB] : alignRuleWith)
|
for (int i = 0; i < alignRule.size(); ++i)
|
||||||
{
|
retVal += "#" + std::to_string(alignRule[i].first) + "#" + std::to_string(alignRule[i].second);
|
||||||
json tuple;
|
|
||||||
tuple["dimNum"] = dimNum;
|
retVal += "#" + std::to_string(alignRuleWith.size());
|
||||||
tuple["a"] = AB.first;
|
for (int i = 0; i < alignRuleWith.size(); ++i)
|
||||||
tuple["b"] = AB.second;
|
retVal += "#" + std::to_string(alignRuleWith[i].first)
|
||||||
|
+ "#" + std::to_string(alignRuleWith[i].second.first)
|
||||||
|
+ "#" + std::to_string(alignRuleWith[i].second.second);
|
||||||
|
|
||||||
alignRuleWithJ.push_back(tuple);
|
|
||||||
}
|
|
||||||
retVal["alignRuleWith"] = alignRuleWithJ;
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "json.hpp"
|
|
||||||
|
|
||||||
typedef enum lang : int { LANG_C, LANG_F } language;
|
typedef enum lang : int { LANG_C, LANG_F } language;
|
||||||
typedef enum dist : int { BLOCK, NONE } distType;
|
typedef enum dist : int { BLOCK, NONE } distType;
|
||||||
typedef std::pair<std::pair<int, int>, std::pair<int, int>> attrType;
|
typedef std::pair<std::pair<int, int>, std::pair<int, int>> attrType;
|
||||||
@@ -50,7 +48,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
std::string GenRuleBase() const;
|
std::string GenRuleBase() const;
|
||||||
nlohmann::json toJson();
|
std::string toString();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DIST::Array *alignArray;
|
DIST::Array *alignArray;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "types.h"
|
#include "../Utils/types.h"
|
||||||
|
|
||||||
SgExpression* createAndSetNext(const int side, const int variant, SgExpression *p);
|
SgExpression* createAndSetNext(const int side, const int variant, SgExpression *p);
|
||||||
std::vector<SgExpression*> genSubscripts(const std::vector<std::pair<int, int>> &shadowRenew, const std::vector<std::pair<int, int>> &shadowRenewShifts);
|
std::vector<SgExpression*> genSubscripts(const std::vector<std::pair<int, int>> &shadowRenew, const std::vector<std::pair<int, int>> &shadowRenewShifts);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -19,8 +19,8 @@ extern int passDone;
|
|||||||
#include "Cycle.h"
|
#include "Cycle.h"
|
||||||
#include "Arrays.h"
|
#include "Arrays.h"
|
||||||
#include "Array.h"
|
#include "Array.h"
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "utils.h"
|
#include "../Utils/utils.h"
|
||||||
#include "../VisualizerCalls/get_information.h"
|
#include "../VisualizerCalls/get_information.h"
|
||||||
#include "../VisualizerCalls/SendMessage.h"
|
#include "../VisualizerCalls/SendMessage.h"
|
||||||
|
|
||||||
@@ -830,13 +830,13 @@ namespace Distribution
|
|||||||
color[k] = WHITE;
|
color[k] = WHITE;
|
||||||
|
|
||||||
findFrom = currentV;
|
findFrom = currentV;
|
||||||
/*#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (needPrint)
|
if (needPrint)
|
||||||
{
|
{
|
||||||
wstring vertexM = std::to_wstring(k + 1) + L"/" + std::to_wstring(vertByTrees[t].size());
|
wstring vertexM = std::to_wstring(k + 1) + L"/" + std::to_wstring(vertByTrees[t].size());
|
||||||
sendMessage_2lvl(wstring(L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ") + wstring(treeM.begin(), treeM.end()) + L" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> " + wstring(vertexM.begin(), vertexM.end()));
|
sendMessage_2lvl(wstring(L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ") + wstring(treeM.begin(), treeM.end()) + L" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> " + wstring(vertexM.begin(), vertexM.end()));
|
||||||
}
|
}
|
||||||
#endif*/
|
#endif
|
||||||
__spf_print(PRINT_TIMES && needPrint, "v (tree %d) = %d (with neighb %d) ", t, i, neighbors[i + 1] - neighbors[i]);
|
__spf_print(PRINT_TIMES && needPrint, "v (tree %d) = %d (with neighb %d) ", t, i, neighbors[i + 1] - neighbors[i]);
|
||||||
activeV[activeCounter++] = currentV;
|
activeV[activeCounter++] = currentV;
|
||||||
FindLoop(cyclesTmp[t], currentV, currentV, numbers);
|
FindLoop(cyclesTmp[t], currentV, currentV, numbers);
|
||||||
@@ -847,8 +847,8 @@ namespace Distribution
|
|||||||
maxLoopDim = wasMaxLoopDim;
|
maxLoopDim = wasMaxLoopDim;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (needPrint)
|
if (needPrint)
|
||||||
sendMessage_2lvl(2);*/
|
sendMessage_2lvl(L"");
|
||||||
}
|
}
|
||||||
catch (int code)
|
catch (int code)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
#include "RationalNum.h"
|
#include "../Utils/RationalNum.h"
|
||||||
|
|
||||||
typedef enum links { RR_link, WR_link, WW_link } LinkType;
|
typedef enum links { RR_link, WR_link, WW_link } LinkType;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "graph_loops_func.h"
|
#include "../GraphLoop/graph_loops_func.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#include "DvmhRegionInserter.h"
|
#include "DvmhRegionInserter.h"
|
||||||
#include "DvmhRegions/RegionsMerger.h"
|
#include "DvmhRegions/RegionsMerger.h"
|
||||||
#include "../VerificationCode/verifications.h"
|
#include "../VerificationCode/verifications.h"
|
||||||
#include "../Transformations/FunctionPurifying/function_purifying.h"
|
#include "../Transformations/function_purifying.h"
|
||||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||||
#include "../DirectiveProcessing/directive_parser.h"
|
#include "../DirectiveProcessing/directive_parser.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "graph_calls_func.h"
|
#include "../GraphCall/graph_calls_func.h"
|
||||||
#include "graph_loops_func.h"
|
#include "../GraphLoop/graph_loops_func.h"
|
||||||
#include "expr_transform.h"
|
#include "../ExpressionTransform/expr_transform.h"
|
||||||
#include "../ParallelizationRegions/ParRegions.h"
|
#include "../ParallelizationRegions/ParRegions.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "ReadWriteAnalyzer.h"
|
#include "ReadWriteAnalyzer.h"
|
||||||
#include "DvmhRegion.h"
|
#include "DvmhRegion.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "graph_loops_func.h"
|
#include "../GraphLoop/graph_loops_func.h"
|
||||||
#include "graph_calls_func.h"
|
#include "../GraphCall/graph_calls_func.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "VarUsages.h"
|
#include "VarUsages.h"
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
enum class VAR_TYPE { VAR_ARR, VAR_DISTR_ARR, VAR_SCALAR, VAR_ANY, VAR_UNDEFINED };
|
enum class VAR_TYPE { VAR_ARR, VAR_DISTR_ARR, VAR_SCALAR, VAR_ANY, VAR_UNDEFINED };
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
#include "./createParallelRegions.h"
|
#include "./createParallelRegions.h"
|
||||||
|
|
||||||
#include "../CreateInterTree/CreateInterTree.h"
|
#include "../CreateInterTree/CreateInterTree.h"
|
||||||
#include "graph_calls.h"
|
#include "../GraphCall/graph_calls.h"
|
||||||
#include "./gcov_info.h"
|
#include "./gcov_info.h"
|
||||||
#include "./gCov_parser_func.h"
|
#include "./gCov_parser_func.h"
|
||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "utils.h"
|
#include "../Utils/utils.h"
|
||||||
|
|
||||||
#include "./gcov_info.h"
|
#include "./gcov_info.h"
|
||||||
#include "../CreateInterTree/CreateInterTree.h"
|
#include "../CreateInterTree/CreateInterTree.h"
|
||||||
#include "graph_calls.h"
|
#include "../GraphCall/graph_calls.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "gCov_parser_func.h"
|
#include "gCov_parser_func.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "gcov_info.h"
|
#include "gcov_info.h"
|
||||||
#include "../CreateInterTree/CreateInterTree.h"
|
#include "../CreateInterTree/CreateInterTree.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
|
|
||||||
#include "gcov_info.h"
|
#include "gcov_info.h"
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "utils.h"
|
#include "../Utils/utils.h"
|
||||||
|
|
||||||
//make 'class' - need friend for Gcov_info
|
//make 'class' - need friend for Gcov_info
|
||||||
struct Perform
|
struct Perform
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "acc_analyzer.h"
|
#include "acc_analyzer.h"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#if _WIN32 && NDEBUG && __SPF && __BOOST
|
#if _WIN32 && NDEBUG && __SPF && __BOOST
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
@@ -19,11 +19,11 @@ extern int passDone;
|
|||||||
|
|
||||||
#include "../ParallelizationRegions/ParRegions.h"
|
#include "../ParallelizationRegions/ParRegions.h"
|
||||||
#include "../ParallelizationRegions/ParRegions_func.h"
|
#include "../ParallelizationRegions/ParRegions_func.h"
|
||||||
#include "graph_loops.h"
|
#include "../GraphLoop/graph_loops.h"
|
||||||
#include "graph_calls.h"
|
#include "../GraphCall/graph_calls.h"
|
||||||
#include "graph_calls_func.h"
|
#include "../GraphCall/graph_calls_func.h"
|
||||||
#include "utils.h"
|
#include "../Utils/utils.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "../Distribution/Distribution.h"
|
#include "../Distribution/Distribution.h"
|
||||||
#include "../VisualizerCalls/get_information.h"
|
#include "../VisualizerCalls/get_information.h"
|
||||||
#include "expr_transform.h"
|
#include "expr_transform.h"
|
||||||
@@ -5,10 +5,10 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "../Distribution/Distribution.h"
|
#include "../Distribution/Distribution.h"
|
||||||
#include "graph_loops.h"
|
#include "../GraphLoop/graph_loops.h"
|
||||||
#include "../ParallelizationRegions/ParRegions.h"
|
#include "../ParallelizationRegions/ParRegions.h"
|
||||||
#include "graph_calls.h"
|
#include "../GraphCall/graph_calls.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
|
|
||||||
#include "acc_analyzer.h"
|
#include "acc_analyzer.h"
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -15,13 +15,13 @@
|
|||||||
#include "graph_calls_func.h"
|
#include "graph_calls_func.h"
|
||||||
|
|
||||||
#include "../CFGraph/CFGraph.h"
|
#include "../CFGraph/CFGraph.h"
|
||||||
#include "graph_loops_func.h"
|
#include "../GraphLoop/graph_loops_func.h"
|
||||||
#include "../DirectiveProcessing/directive_parser.h"
|
#include "../DirectiveProcessing/directive_parser.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "json.hpp"
|
#include "../Utils/json.hpp"
|
||||||
#include "../ParallelizationRegions/ParRegions_func.h"
|
#include "../ParallelizationRegions/ParRegions_func.h"
|
||||||
#include "../DynamicAnalysis/gCov_parser_func.h"
|
#include "../DynamicAnalysis/gCov_parser_func.h"
|
||||||
#include "expr_transform.h"
|
#include "../ExpressionTransform/expr_transform.h"
|
||||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||||
#include "../VerificationCode/verifications.h"
|
#include "../VerificationCode/verifications.h"
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "AstWrapper.h"
|
#include "../Utils/AstWrapper.h"
|
||||||
#include "utils.h"
|
#include "../Utils/utils.h"
|
||||||
#include "../DirectiveProcessing/shadow.h"
|
#include "../DirectiveProcessing/shadow.h"
|
||||||
#include "graph_loops.h"
|
#include "../GraphLoop/graph_loops.h"
|
||||||
|
|
||||||
static const char* paramNames[] =
|
static const char* paramNames[] =
|
||||||
{ "NONE_T", "ARRAY_T", "STRING_ARRAY_T", "STRING_T", "SCALAR_CHAR_T", "SCALAR_BOOL_T", "SCALAR_SHORT_T", "SCALAR_INT_T", "SCALAR_LONG_INT_T",
|
{ "NONE_T", "ARRAY_T", "STRING_ARRAY_T", "STRING_T", "SCALAR_CHAR_T", "SCALAR_BOOL_T", "SCALAR_SHORT_T", "SCALAR_INT_T", "SCALAR_LONG_INT_T",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -10,10 +10,10 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "graph_calls.h"
|
#include "graph_calls.h"
|
||||||
#include "../Distribution/Distribution.h"
|
#include "../Distribution/Distribution.h"
|
||||||
#include "utils.h"
|
#include "../Utils/utils.h"
|
||||||
#include "../ParallelizationRegions/ParRegions.h"
|
#include "../ParallelizationRegions/ParRegions.h"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "graph_calls.h"
|
#include "graph_calls.h"
|
||||||
#include "graph_loops.h"
|
#include "../GraphLoop/graph_loops.h"
|
||||||
#include "../ParallelizationRegions/ParRegions.h"
|
#include "../ParallelizationRegions/ParRegions.h"
|
||||||
#include "Utils/json.hpp"
|
#include "Utils/json.hpp"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -12,26 +12,26 @@
|
|||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "../Sapfor.h"
|
#include "../Sapfor.h"
|
||||||
#include "graph_calls_func.h"
|
#include "../GraphCall/graph_calls_func.h"
|
||||||
#include "../ParallelizationRegions/ParRegions_func.h"
|
#include "../ParallelizationRegions/ParRegions_func.h"
|
||||||
#include "expr_transform.h"
|
#include "../ExpressionTransform/expr_transform.h"
|
||||||
|
|
||||||
#include "../Distribution/GraphCSR.h"
|
#include "../Distribution/GraphCSR.h"
|
||||||
#include "../Distribution/Arrays.h"
|
#include "../Distribution/Arrays.h"
|
||||||
#include "../Distribution/Distribution.h"
|
#include "../Distribution/Distribution.h"
|
||||||
|
|
||||||
#include "graph_loops.h"
|
#include "graph_loops.h"
|
||||||
#include "utils.h"
|
#include "../Utils/utils.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
|
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "AstWrapper.h"
|
#include "../Utils/AstWrapper.h"
|
||||||
#include "json.hpp"
|
#include "../Utils/json.hpp"
|
||||||
|
|
||||||
#include "../DirectiveProcessing/directive_parser.h"
|
#include "../DirectiveProcessing/directive_parser.h"
|
||||||
#include "../DynamicAnalysis/gCov_parser_func.h"
|
#include "../DynamicAnalysis/gCov_parser_func.h"
|
||||||
|
|
||||||
#include "../Transformations/VectorAssignToLoop/array_assign_to_loop.h"
|
#include "../Transformations/array_assign_to_loop.h"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::map;
|
using std::map;
|
||||||
@@ -520,7 +520,7 @@ static void findArrayRef(SgExpression *exp, bool isWirte, set<DIST::Array*>& use
|
|||||||
{
|
{
|
||||||
if (exp)
|
if (exp)
|
||||||
{
|
{
|
||||||
if (isArrayRef(exp))
|
if (exp->variant() == ARRAY_REF)
|
||||||
{
|
{
|
||||||
DIST::Array *arrayRef = NULL;
|
DIST::Array *arrayRef = NULL;
|
||||||
SgSymbol *symbS = OriginalSymbol(exp->symbol());
|
SgSymbol *symbS = OriginalSymbol(exp->symbol());
|
||||||
@@ -699,12 +699,7 @@ void loopGraphAnalyzer(SgFile *file, vector<LoopGraph*> &loopGraph, const vector
|
|||||||
newLoop->hasPrints = hasThisIds(st, newLoop->linesOfIO, { WRITE_STAT, READ_STAT, OPEN_STAT, CLOSE_STAT, PRINT_STAT } ); // FORMAT_STAT
|
newLoop->hasPrints = hasThisIds(st, newLoop->linesOfIO, { WRITE_STAT, READ_STAT, OPEN_STAT, CLOSE_STAT, PRINT_STAT } ); // FORMAT_STAT
|
||||||
newLoop->hasStops = hasThisIds(st, newLoop->linesOfStop, { STOP_STAT, PAUSE_NODE });
|
newLoop->hasStops = hasThisIds(st, newLoop->linesOfStop, { STOP_STAT, PAUSE_NODE });
|
||||||
newLoop->hasDvmIntervals = hasThisIds(st, tmpLines, { DVM_INTERVAL_DIR, DVM_ENDINTERVAL_DIR, DVM_EXIT_INTERVAL_DIR });
|
newLoop->hasDvmIntervals = hasThisIds(st, tmpLines, { DVM_INTERVAL_DIR, DVM_ENDINTERVAL_DIR, DVM_EXIT_INTERVAL_DIR });
|
||||||
if (isSgForStmt(st))
|
newLoop->isFor = isSgForStmt(st) ? true : false;
|
||||||
newLoop->loopType = LoopType::FOR;
|
|
||||||
else if (isSgWhileStmt(st))
|
|
||||||
newLoop->loopType = LoopType::WHILE;
|
|
||||||
else
|
|
||||||
newLoop->loopType = LoopType::NONE;
|
|
||||||
newLoop->inCanonicalFrom = isSgForStmt(st) ? true : false;
|
newLoop->inCanonicalFrom = isSgForStmt(st) ? true : false;
|
||||||
newLoop->hasSubstringRefs = hasSubstringRef(st);
|
newLoop->hasSubstringRefs = hasSubstringRef(st);
|
||||||
|
|
||||||
@@ -782,7 +777,7 @@ void loopGraphAnalyzer(SgFile *file, vector<LoopGraph*> &loopGraph, const vector
|
|||||||
newLoop->startEndExpr = std::make_pair((Expression*)NULL, (Expression*)NULL);
|
newLoop->startEndExpr = std::make_pair((Expression*)NULL, (Expression*)NULL);
|
||||||
|
|
||||||
newLoop->loop = new Statement(st);
|
newLoop->loop = new Statement(st);
|
||||||
newLoop->loopSymbols.addMainVar(st->symbol() ? st->symbol()->identifier() : "unknown");
|
newLoop->loopSymbol = st->symbol() ? st->symbol()->identifier() : "unknown";
|
||||||
findArrayRefs(newLoop);
|
findArrayRefs(newLoop);
|
||||||
|
|
||||||
SgStatement *lexPrev = st->lexPrev();
|
SgStatement *lexPrev = st->lexPrev();
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "types.h"
|
#include "../Utils/types.h"
|
||||||
#include "../Distribution/DvmhDirective.h"
|
#include "../Distribution/DvmhDirective.h"
|
||||||
#include "../Distribution/Distribution.h"
|
#include "../Distribution/Distribution.h"
|
||||||
|
|
||||||
@@ -25,33 +25,6 @@ namespace DIST = Distribution;
|
|||||||
void getRealArrayRefs(DIST::Array* addTo, DIST::Array* curr, std::set<DIST::Array*>& realArrayRefs, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls);
|
void getRealArrayRefs(DIST::Array* addTo, DIST::Array* curr, std::set<DIST::Array*>& realArrayRefs, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls);
|
||||||
void getAllArrayRefs(DIST::Array* addTo, DIST::Array* curr, std::set<DIST::Array*>& realArrayRefs, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls);
|
void getAllArrayRefs(DIST::Array* addTo, DIST::Array* curr, std::set<DIST::Array*>& realArrayRefs, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls);
|
||||||
|
|
||||||
enum class LoopType { NONE, FOR, WHILE, IMPLICIT };
|
|
||||||
|
|
||||||
struct InductiveVariables
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
std::string mainVar;
|
|
||||||
std::set<std::string> allVars;
|
|
||||||
|
|
||||||
public:
|
|
||||||
InductiveVariables() { }
|
|
||||||
|
|
||||||
explicit InductiveVariables(const std::string& mainVar, const std::set<std::string>& allVars) : mainVar(mainVar), allVars(allVars) { };
|
|
||||||
|
|
||||||
std::string getMainVar() const { return mainVar; }
|
|
||||||
std::set<std::string> getAllVars() const { return allVars; }
|
|
||||||
|
|
||||||
void addVar(const std::string& var) { allVars.insert(var); }
|
|
||||||
void addMainVar(const std::string& var) { mainVar = var; allVars.insert(var); }
|
|
||||||
|
|
||||||
void replaceMainVar(const std::string& var)
|
|
||||||
{
|
|
||||||
allVars.erase(mainVar);
|
|
||||||
|
|
||||||
addMainVar(var);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct LoopGraph
|
struct LoopGraph
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -97,7 +70,7 @@ public:
|
|||||||
calculatedCountOfIters = 0;
|
calculatedCountOfIters = 0;
|
||||||
executionTimeInSec = -1.0;
|
executionTimeInSec = -1.0;
|
||||||
inDvmhRegion = 0;
|
inDvmhRegion = 0;
|
||||||
loopType = LoopType::NONE;
|
isFor = false;
|
||||||
inCanonicalFrom = false;
|
inCanonicalFrom = false;
|
||||||
hasAccessToSubArray = false;
|
hasAccessToSubArray = false;
|
||||||
hasSubstringRefs = false;
|
hasSubstringRefs = false;
|
||||||
@@ -140,24 +113,21 @@ public:
|
|||||||
{
|
{
|
||||||
return hasUnknownArrayDep || hasUnknownScalarDep || hasGoto || hasPrints || (hasConflicts.size() != 0) || hasStops || hasNonPureProcedures ||
|
return hasUnknownArrayDep || hasUnknownScalarDep || hasGoto || hasPrints || (hasConflicts.size() != 0) || hasStops || hasNonPureProcedures ||
|
||||||
hasUnknownArrayAssigns || hasNonRectangularBounds || hasIndirectAccess || hasWritesToNonDistribute || hasDifferentAlignRules || hasDvmIntervals ||
|
hasUnknownArrayAssigns || hasNonRectangularBounds || hasIndirectAccess || hasWritesToNonDistribute || hasDifferentAlignRules || hasDvmIntervals ||
|
||||||
!isFor() || lastprivateScalars.size() || hasAccessToSubArray || hasSubstringRefs;
|
!isFor || lastprivateScalars.size() || hasAccessToSubArray || hasSubstringRefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasLimitsToSplit() const
|
bool hasLimitsToSplit() const
|
||||||
{
|
{
|
||||||
return hasGoto || hasStops || !isFor() || hasPrints;
|
return hasGoto || hasStops || !isFor || hasPrints;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasLimitsToCombine() const
|
bool hasLimitsToCombine() const
|
||||||
{
|
{
|
||||||
return hasGoto || hasStops || !isFor() || hasPrints || linesOfCycle.size();
|
return hasGoto || hasStops || !isFor || hasPrints || linesOfCycle.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void addConflictMessages(std::vector<Messages> *messages)
|
void addConflictMessages(std::vector<Messages> *messages)
|
||||||
{
|
{
|
||||||
if (messages == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const int line = altLineNum > 0 ? altLineNum : lineNum;
|
const int line = altLineNum > 0 ? altLineNum : lineNum;
|
||||||
if (hasUnknownArrayDep)
|
if (hasUnknownArrayDep)
|
||||||
messages->push_back(Messages(NOTE, line, R113, L"unknown array dependency prevents parallelization of this loop", 3006));
|
messages->push_back(Messages(NOTE, line, R113, L"unknown array dependency prevents parallelization of this loop", 3006));
|
||||||
@@ -198,7 +168,7 @@ public:
|
|||||||
if (hasDvmIntervals)
|
if (hasDvmIntervals)
|
||||||
messages->push_back(Messages(NOTE, line, R145, L"DVM intervals prevent parallelization of this loop", 3006));
|
messages->push_back(Messages(NOTE, line, R145, L"DVM intervals prevent parallelization of this loop", 3006));
|
||||||
|
|
||||||
if (!isFor() || !inCanonicalFrom)
|
if (!isFor || !inCanonicalFrom)
|
||||||
messages->push_back(Messages(NOTE, line, R178, L"This type of loop is not supported by the system", 3006));
|
messages->push_back(Messages(NOTE, line, R178, L"This type of loop is not supported by the system", 3006));
|
||||||
|
|
||||||
if (lastprivateScalars.size())
|
if (lastprivateScalars.size())
|
||||||
@@ -423,14 +393,6 @@ public:
|
|||||||
|
|
||||||
void* getRealStat(const char* file) const;
|
void* getRealStat(const char* file) const;
|
||||||
|
|
||||||
bool isFor() const { return loopType == LoopType::FOR; }
|
|
||||||
|
|
||||||
bool isWhile() const { return loopType == LoopType::WHILE; }
|
|
||||||
|
|
||||||
bool isImplicit() const { return loopType == LoopType::IMPLICIT; }
|
|
||||||
|
|
||||||
std::string loopSymbol() const { return loopSymbols.getMainVar(); }
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int lineNum;
|
int lineNum;
|
||||||
int altLineNum;
|
int altLineNum;
|
||||||
@@ -445,7 +407,7 @@ public:
|
|||||||
int startVal, endVal, stepVal;
|
int startVal, endVal, stepVal;
|
||||||
std::tuple<Expression*, Expression*, Expression*> startEndStepVals;
|
std::tuple<Expression*, Expression*, Expression*> startEndStepVals;
|
||||||
|
|
||||||
InductiveVariables loopSymbols;
|
std::string loopSymbol;
|
||||||
std::pair<Expression*, Expression*> startEndExpr;
|
std::pair<Expression*, Expression*> startEndExpr;
|
||||||
|
|
||||||
bool hasGoto;
|
bool hasGoto;
|
||||||
@@ -486,7 +448,7 @@ public:
|
|||||||
|
|
||||||
bool hasSubstringRefs;
|
bool hasSubstringRefs;
|
||||||
|
|
||||||
LoopType loopType;
|
bool isFor;
|
||||||
|
|
||||||
bool inCanonicalFrom;
|
bool inCanonicalFrom;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -23,8 +23,8 @@ using std::make_pair;
|
|||||||
using std::get;
|
using std::get;
|
||||||
|
|
||||||
#include "graph_loops.h"
|
#include "graph_loops.h"
|
||||||
#include "graph_calls_func.h"
|
#include "../GraphCall/graph_calls_func.h"
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "../Distribution/Distribution.h"
|
#include "../Distribution/Distribution.h"
|
||||||
#include "../Distribution/CreateDistributionDirs.h"
|
#include "../Distribution/CreateDistributionDirs.h"
|
||||||
#include "../ParallelizationRegions/ParRegions.h"
|
#include "../ParallelizationRegions/ParRegions.h"
|
||||||
@@ -551,7 +551,7 @@ void addToDistributionGraph(const map<LoopGraph*, map<DIST::Array*, ArrayInfo*>>
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loopAccess.first->isFor())
|
if (!loopAccess.first->isFor)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
DIST::GraphCSR<int, double, attrType>& G = currReg->GetGraphToModify();
|
DIST::GraphCSR<int, double, attrType>& G = currReg->GetGraphToModify();
|
||||||
@@ -775,7 +775,7 @@ static void isAllOk(const vector<LoopGraph*> &loops, vector<Messages> &currMessa
|
|||||||
{
|
{
|
||||||
if (loops[i]->region)
|
if (loops[i]->region)
|
||||||
{
|
{
|
||||||
if (loops[i]->countOfIters == 0 && loops[i]->region && loops[i]->isFor())
|
if (loops[i]->countOfIters == 0 && loops[i]->region && loops[i]->isFor)
|
||||||
{
|
{
|
||||||
wstring bufE, bufR;
|
wstring bufE, bufR;
|
||||||
__spf_printToLongBuf(bufE, L" Can not calculate count of iterations for this loop, information about iterations in all loops in parallel regions '%s' will be ignored",
|
__spf_printToLongBuf(bufE, L" Can not calculate count of iterations for this loop, information about iterations in all loops in parallel regions '%s' will be ignored",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -8,13 +8,13 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "utils.h"
|
#include "../Utils/utils.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "graph_calls_func.h"
|
#include "../GraphCall/graph_calls_func.h"
|
||||||
#include "inliner.h"
|
#include "inliner.h"
|
||||||
#include "../VisualizerCalls/SendMessage.h"
|
#include "../VisualizerCalls/SendMessage.h"
|
||||||
#include "expr_transform.h"
|
#include "../ExpressionTransform/expr_transform.h"
|
||||||
|
|
||||||
using std::set;
|
using std::set;
|
||||||
using std::map;
|
using std::map;
|
||||||
@@ -1776,8 +1776,11 @@ static bool inliner(const string& fileName_in, const string& funcName, const int
|
|||||||
point.currCall = func->funcName;
|
point.currCall = func->funcName;
|
||||||
|
|
||||||
__spf_print(1, " INLINE %s - ", func->funcName.c_str());
|
__spf_print(1, " INLINE %s - ", func->funcName.c_str());
|
||||||
sendMessage_2lvl(6, func->funcName);
|
#ifdef _WIN32
|
||||||
|
sendMessage_2lvl(wstring(L"ïîäñòàíîâêà ôóíêöèè '") + wstring(func->funcName.begin(), func->funcName.end()) + L"'");
|
||||||
|
#else
|
||||||
|
sendMessage_2lvl(wstring(L"inlinig of function '") + wstring(func->funcName.begin(), func->funcName.end()) + L"'");
|
||||||
|
#endif
|
||||||
//1 level
|
//1 level
|
||||||
bool isInlined = run_inliner(funcMap, toInsert, SPF_messages, fileName, func, newSymbsToDeclare, point, commonBlocks);
|
bool isInlined = run_inliner(funcMap, toInsert, SPF_messages, fileName, func, newSymbsToDeclare, point, commonBlocks);
|
||||||
__spf_print(1, "%s\n", isInlined ? "done" : "fault");
|
__spf_print(1, "%s\n", isInlined ? "done" : "fault");
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
|
|
||||||
using std::set;
|
using std::set;
|
||||||
using std::pair;
|
using std::pair;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -20,8 +20,8 @@
|
|||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "loop_analyzer.h"
|
#include "loop_analyzer.h"
|
||||||
|
|
||||||
#include "utils.h"
|
#include "../Utils/utils.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "../ParallelizationRegions/ParRegions_func.h"
|
#include "../ParallelizationRegions/ParRegions_func.h"
|
||||||
#include "../SageAnalysisTool/depGraph.h"
|
#include "../SageAnalysisTool/depGraph.h"
|
||||||
#include "../SageAnalysisTool/OmegaForSage/include/lang-interf.h"
|
#include "../SageAnalysisTool/OmegaForSage/include/lang-interf.h"
|
||||||
|
|||||||
@@ -1,281 +0,0 @@
|
|||||||
#include <map>
|
|
||||||
#include <set>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
#include <stack>
|
|
||||||
|
|
||||||
#include "../CFGraph/IR.h"
|
|
||||||
#include "GraphCall/graph_calls.h"
|
|
||||||
#include "implicit_loops_analyzer.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace SAPFOR;
|
|
||||||
|
|
||||||
using std::map;
|
|
||||||
using std::set;
|
|
||||||
using std::vector;
|
|
||||||
using std::pair;
|
|
||||||
using std::string;
|
|
||||||
using std::cout;
|
|
||||||
using std::endl;
|
|
||||||
using std::make_pair;
|
|
||||||
using std::to_string;
|
|
||||||
|
|
||||||
enum VisitState { UNVISITED = 0, VISITING = 1, VISITED = 2 };
|
|
||||||
|
|
||||||
void dfs(SAPFOR::BasicBlock* block,
|
|
||||||
std::map<int, int>& visit,
|
|
||||||
std::vector<std::pair<SAPFOR::BasicBlock*, SAPFOR::BasicBlock*>>& startAndEnd,
|
|
||||||
SAPFOR::BasicBlock* prev)
|
|
||||||
{
|
|
||||||
if (!block)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int id = block->getNumber();
|
|
||||||
|
|
||||||
if (visit[id] == VISITING) {
|
|
||||||
startAndEnd.emplace_back(prev, block);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (visit[id] == VISITED)
|
|
||||||
return;
|
|
||||||
|
|
||||||
visit[id] = VISITING;
|
|
||||||
|
|
||||||
for (auto next : block->getNext())
|
|
||||||
dfs(next, visit, startAndEnd, block);
|
|
||||||
|
|
||||||
visit[id] = VISITED;
|
|
||||||
}
|
|
||||||
|
|
||||||
void getLoopBody(SAPFOR::BasicBlock* loopHeader, const std::set<SAPFOR::BasicBlock*>& loopExits, std::vector<SAPFOR::BasicBlock*>& loopBody)
|
|
||||||
{
|
|
||||||
std::set<SAPFOR::BasicBlock*> visited;
|
|
||||||
std::stack<SAPFOR::BasicBlock*> stack;
|
|
||||||
|
|
||||||
stack.push(loopHeader);
|
|
||||||
|
|
||||||
while (!stack.empty())
|
|
||||||
{
|
|
||||||
auto block = stack.top();
|
|
||||||
stack.pop();
|
|
||||||
|
|
||||||
if (visited.count(block))
|
|
||||||
continue;
|
|
||||||
visited.insert(block);
|
|
||||||
|
|
||||||
for (auto succ : block->getNext())
|
|
||||||
{
|
|
||||||
if (loopExits.count(succ))
|
|
||||||
continue;
|
|
||||||
if (!visited.count(succ))
|
|
||||||
stack.push(succ);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::set<SAPFOR::BasicBlock*> backReachable;
|
|
||||||
std::stack<SAPFOR::BasicBlock*> reverseStack;
|
|
||||||
reverseStack.push(loopHeader);
|
|
||||||
|
|
||||||
while (!reverseStack.empty())
|
|
||||||
{
|
|
||||||
auto block = reverseStack.top();
|
|
||||||
reverseStack.pop();
|
|
||||||
|
|
||||||
if (backReachable.count(block))
|
|
||||||
continue;
|
|
||||||
backReachable.insert(block);
|
|
||||||
|
|
||||||
for (auto pred : block->getPrev())
|
|
||||||
if (visited.count(pred) && !backReachable.count(pred))
|
|
||||||
reverseStack.push(pred);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto block : visited)
|
|
||||||
if (backReachable.count(block))
|
|
||||||
loopBody.push_back(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
SAPFOR::Instruction* findDef(const SAPFOR::Argument* arg,
|
|
||||||
const std::vector<SAPFOR::BasicBlock*>& blocks)
|
|
||||||
{
|
|
||||||
if (!arg)
|
|
||||||
return nullptr;
|
|
||||||
std::string argName = arg->getValue();
|
|
||||||
|
|
||||||
for (auto block : blocks) {
|
|
||||||
for (auto instrWrapper : block->getInstructions()) {
|
|
||||||
auto instr = instrWrapper->getInstruction();
|
|
||||||
if (!instr)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
auto res = instr->getResult();
|
|
||||||
if (!res)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (res->getValue() == argName)
|
|
||||||
return instr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
const SAPFOR::Argument* getBaseSource(const SAPFOR::Argument* arg, const std::vector<SAPFOR::BasicBlock*>& blocks)
|
|
||||||
{
|
|
||||||
while (arg && arg->getType() == CFG_ARG_TYPE::REG)
|
|
||||||
{
|
|
||||||
auto defInstr = findDef(arg, blocks);
|
|
||||||
if (!defInstr)
|
|
||||||
break;
|
|
||||||
auto defOp = defInstr->getOperation();
|
|
||||||
|
|
||||||
if (defOp == CFG_OP::ASSIGN)
|
|
||||||
arg = defInstr->getArg1();
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return arg;
|
|
||||||
}
|
|
||||||
|
|
||||||
void findInductiveVars(const std::vector<SAPFOR::BasicBlock*>& Loopblocks, const std::vector<SAPFOR::BasicBlock*>& blocks)
|
|
||||||
{
|
|
||||||
std::set<std::string> inductiveVars;
|
|
||||||
|
|
||||||
for (auto block : Loopblocks)
|
|
||||||
{
|
|
||||||
for (auto instrWrapper : block->getInstructions())
|
|
||||||
{
|
|
||||||
auto instr = instrWrapper->getInstruction();
|
|
||||||
if (!instr)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
auto res = instr->getResult();
|
|
||||||
if (!res || res->getType() != SAPFOR::CFG_ARG_TYPE::VAR)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
while (instr && instr->getOperation() == CFG_OP::ASSIGN)
|
|
||||||
instr = findDef(instr->getArg1(), blocks);
|
|
||||||
|
|
||||||
if (!instr || instr->getOperation() != CFG_OP::ADD && instr->getOperation() != CFG_OP::SUBT)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
auto arg1 = getBaseSource(instr->getArg1(), blocks);
|
|
||||||
auto arg2 = getBaseSource(instr->getArg2(), blocks);
|
|
||||||
|
|
||||||
bool ok = false;
|
|
||||||
if (res->getValue() == arg1->getValue() && arg2->getType() == CFG_ARG_TYPE::CONST)
|
|
||||||
ok = true;
|
|
||||||
else if (res->getValue() == arg2->getValue() && arg1->getType() == CFG_ARG_TYPE::CONST)
|
|
||||||
ok = true;
|
|
||||||
|
|
||||||
if (ok)
|
|
||||||
inductiveVars.insert(res->getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inductiveVars.empty())
|
|
||||||
std::cout << "No inductive variables found." << std::endl;
|
|
||||||
else
|
|
||||||
for (const auto& var : inductiveVars)
|
|
||||||
std::cout << "Inductive variable: " << var << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
Instruction* findInstructionAfterLoop(const std::vector<SAPFOR::BasicBlock*>& loopBody)
|
|
||||||
{
|
|
||||||
std::set<SAPFOR::BasicBlock*> loopSet(loopBody.begin(), loopBody.end());
|
|
||||||
|
|
||||||
for (auto block : loopBody)
|
|
||||||
{
|
|
||||||
for (auto succ : block->getNext())
|
|
||||||
{
|
|
||||||
if (!loopSet.count(succ))
|
|
||||||
{
|
|
||||||
auto instructions = succ->getInstructions();
|
|
||||||
if (instructions.empty())
|
|
||||||
std::cout << "Exit block has no instructions." << std::endl;
|
|
||||||
|
|
||||||
for (auto wrapper : instructions)
|
|
||||||
if (auto instr = wrapper->getInstruction())
|
|
||||||
return instr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void findImplicitLoops(const std::vector<SAPFOR::BasicBlock*>& irSSA, const std::vector<LoopGraph*> loopGraph)
|
|
||||||
{
|
|
||||||
map<int, int> visited;
|
|
||||||
for (auto i : irSSA)
|
|
||||||
visited[i->getNumber()] = UNVISITED;
|
|
||||||
|
|
||||||
vector<pair<SAPFOR::BasicBlock*, SAPFOR::BasicBlock*>> startAndEnd;
|
|
||||||
dfs(irSSA[0], visited, startAndEnd, NULL);
|
|
||||||
|
|
||||||
vector<LoopGraph*> loops;
|
|
||||||
|
|
||||||
for (auto& [tail, header] : startAndEnd)
|
|
||||||
{
|
|
||||||
set<SAPFOR::BasicBlock*> loopExits;
|
|
||||||
|
|
||||||
for (auto succ : tail->getNext())
|
|
||||||
if (succ != header)
|
|
||||||
loopExits.insert(succ);
|
|
||||||
|
|
||||||
vector<SAPFOR::BasicBlock*> loopBody;
|
|
||||||
getLoopBody(header, loopExits, loopBody);
|
|
||||||
|
|
||||||
findInductiveVars(loopBody, irSSA);
|
|
||||||
|
|
||||||
Instruction* instructionAfterLoop = findInstructionAfterLoop(loopBody);
|
|
||||||
|
|
||||||
if (instructionAfterLoop == NULL)
|
|
||||||
{
|
|
||||||
cout << "Warning: instruction after loop not found!" << endl;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto firstInstruction = header->getInstructions()[0]->getInstruction();
|
|
||||||
auto lastInstruction = tail->getInstructions().back()->getInstruction();
|
|
||||||
auto tmpLoop = new LoopGraph();
|
|
||||||
tmpLoop->lineNum = firstInstruction->getOperator()->lineNumber();
|
|
||||||
tmpLoop->lineNumAfterLoop = instructionAfterLoop->getOperator()->lineNumber();
|
|
||||||
|
|
||||||
|
|
||||||
if (firstInstruction->getOperator()->variant() == FOR_NODE)
|
|
||||||
{
|
|
||||||
SgForStmt* stmt = isSgForStmt(firstInstruction->getOperator());
|
|
||||||
|
|
||||||
cout << "for loop" << endl;
|
|
||||||
}
|
|
||||||
else if (firstInstruction->getOperator()->variant() == WHILE_NODE)
|
|
||||||
{
|
|
||||||
SgWhileStmt* stmt = isSgWhileStmt(firstInstruction->getOperator());
|
|
||||||
|
|
||||||
cout << (stmt->conditional() == NULL ? "infinit" : "") << "while loop" << endl;
|
|
||||||
}
|
|
||||||
else if (firstInstruction->getOperator()->variant() == DO_WHILE_NODE)
|
|
||||||
{
|
|
||||||
SgWhileStmt* stmt = isSgDoWhileStmt(firstInstruction->getOperator());
|
|
||||||
|
|
||||||
cout << "do while loop" << endl;
|
|
||||||
}
|
|
||||||
else if (firstInstruction->getOperator()->variant() == LOOP_NODE)
|
|
||||||
{
|
|
||||||
cout << "not known loop" << endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cout << "goto loop" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
cout << "loop start line " << tmpLoop->lineNum << endl;
|
|
||||||
cout << "after loop line " << tmpLoop->lineNumAfterLoop << endl << endl;
|
|
||||||
|
|
||||||
loops.push_back(tmpLoop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include "../CFGraph/CFGraph.h"
|
|
||||||
#include "../GraphCall/graph_calls.h"
|
|
||||||
|
|
||||||
void findImplicitLoops(const std::vector<SAPFOR::BasicBlock*>& fullIR_SSA, const std::vector<LoopGraph*> loopGraph);
|
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
|
||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#if _WIN32 && NDEBUG && __BOOST
|
#if _WIN32 && NDEBUG && __BOOST
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
@@ -30,25 +30,25 @@ extern int passDone;
|
|||||||
#include "../Distribution/Arrays.h"
|
#include "../Distribution/Arrays.h"
|
||||||
#include "../ParallelizationRegions/ParRegions.h"
|
#include "../ParallelizationRegions/ParRegions.h"
|
||||||
|
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "../DirectiveProcessing/directive_parser.h"
|
#include "../DirectiveProcessing/directive_parser.h"
|
||||||
#include "../DirectiveProcessing/directive_creator.h"
|
#include "../DirectiveProcessing/directive_creator.h"
|
||||||
|
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "AstWrapper.h"
|
#include "../Utils/AstWrapper.h"
|
||||||
|
|
||||||
#include "graph_calls_func.h"
|
#include "../GraphCall/graph_calls_func.h"
|
||||||
#include "graph_loops_func.h"
|
#include "../GraphLoop/graph_loops_func.h"
|
||||||
#include "../ParallelizationRegions/ParRegions_func.h"
|
#include "../ParallelizationRegions/ParRegions_func.h"
|
||||||
#include "../DynamicAnalysis/gCov_parser_func.h"
|
#include "../DynamicAnalysis/gCov_parser_func.h"
|
||||||
|
|
||||||
#include "expr_transform.h"
|
#include "../ExpressionTransform/expr_transform.h"
|
||||||
#include "../SageAnalysisTool/depInterfaceExt.h"
|
#include "../SageAnalysisTool/depInterfaceExt.h"
|
||||||
|
|
||||||
#include "../VisualizerCalls/get_information.h"
|
#include "../VisualizerCalls/get_information.h"
|
||||||
#include "../VisualizerCalls/SendMessage.h"
|
#include "../VisualizerCalls/SendMessage.h"
|
||||||
|
|
||||||
#include "../Transformations/LoopEndDoConverter/enddo_loop_converter.h"
|
#include "../Transformations/enddo_loop_converter.h"
|
||||||
|
|
||||||
#include "../DirectiveProcessing/remote_access.h"
|
#include "../DirectiveProcessing/remote_access.h"
|
||||||
#include "../DirectiveProcessing/directive_omp_parser.h"
|
#include "../DirectiveProcessing/directive_omp_parser.h"
|
||||||
@@ -1633,7 +1633,17 @@ void loopAnalyzer(SgFile *file, vector<ParallelRegion*> ®ions, map<tuple<int,
|
|||||||
createNeededException();
|
createNeededException();
|
||||||
|
|
||||||
string fName = file->functions(i)->symbol()->identifier();
|
string fName = file->functions(i)->symbol()->identifier();
|
||||||
sendMessage_2lvl(0, (file->functions(i)->variant() != MODULE_STMT), fName);
|
#if _WIN32
|
||||||
|
if (file->functions(i)->variant() != MODULE_STMT)
|
||||||
|
sendMessage_2lvl(wstring(L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '") + wstring(fName.begin(), fName.end()) + L"'");
|
||||||
|
else
|
||||||
|
sendMessage_2lvl(wstring(L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '") + wstring(fName.begin(), fName.end()) + L"'");
|
||||||
|
#else
|
||||||
|
if (file->functions(i)->variant() != MODULE_STMT)
|
||||||
|
sendMessage_2lvl(wstring(L"processing function '") + wstring(fName.begin(), fName.end()) + L"'");
|
||||||
|
else
|
||||||
|
sendMessage_2lvl(wstring(L"processing module '") + wstring(fName.begin(), fName.end()) + L"'");
|
||||||
|
#endif
|
||||||
|
|
||||||
set<SgSymbol*> delcsSymbViewed;
|
set<SgSymbol*> delcsSymbViewed;
|
||||||
set<SgStatement*> delcsStatViewed;
|
set<SgStatement*> delcsStatViewed;
|
||||||
@@ -1702,8 +1712,8 @@ void loopAnalyzer(SgFile *file, vector<ParallelRegion*> ®ions, map<tuple<int,
|
|||||||
|
|
||||||
const ParallelRegionLines* prevParLines = NULL;
|
const ParallelRegionLines* prevParLines = NULL;
|
||||||
double prevLinesWeight = 1.0;
|
double prevLinesWeight = 1.0;
|
||||||
double currentWeight = 1.0;
|
|
||||||
|
|
||||||
|
double currentWeight = 1.0;
|
||||||
while (st != lastNode)
|
while (st != lastNode)
|
||||||
{
|
{
|
||||||
createNeededException();
|
createNeededException();
|
||||||
@@ -2178,8 +2188,11 @@ void loopAnalyzer(SgFile *file, vector<ParallelRegion*> ®ions, map<tuple<int,
|
|||||||
if (!skipDeps)
|
if (!skipDeps)
|
||||||
{
|
{
|
||||||
string fName = file->functions(i)->symbol()->identifier();
|
string fName = file->functions(i)->symbol()->identifier();
|
||||||
sendMessage_2lvl(1, idx, (int)convertedLoopInfo.size());
|
#ifdef _WIN32
|
||||||
|
sendMessage_2lvl(wstring(L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> ") + std::to_wstring(idx) + L"/" + std::to_wstring(convertedLoopInfo.size()));
|
||||||
|
#else
|
||||||
|
sendMessage_2lvl(wstring(L"processing loop ") + std::to_wstring(idx) + L"/" + std::to_wstring(convertedLoopInfo.size()));
|
||||||
|
#endif
|
||||||
tryToFindDependencies(loop.first, allLoops, funcWasInit, file, regions, currMessages, collection, funcByName, defUseByPlace);
|
tryToFindDependencies(loop.first, allLoops, funcWasInit, file, regions, currMessages, collection, funcByName, defUseByPlace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2199,7 +2212,7 @@ void loopAnalyzer(SgFile *file, vector<ParallelRegion*> ®ions, map<tuple<int,
|
|||||||
LoopGraph *tmpLoop = new LoopGraph();
|
LoopGraph *tmpLoop = new LoopGraph();
|
||||||
|
|
||||||
tmpLoop->region = reg;
|
tmpLoop->region = reg;
|
||||||
tmpLoop->loopType = LoopType::FOR;
|
tmpLoop->isFor = true;
|
||||||
|
|
||||||
tmpLoops.push_back(tmpLoop);
|
tmpLoops.push_back(tmpLoop);
|
||||||
|
|
||||||
@@ -2327,7 +2340,7 @@ void loopAnalyzer(SgFile *file, vector<ParallelRegion*> ®ions, map<tuple<int,
|
|||||||
if (parallizeFreeLoops)
|
if (parallizeFreeLoops)
|
||||||
selectFreeLoopsForParallelization(loopsForFunction, funcName, (regime == DATA_DISTR), regions, messagesForFile);
|
selectFreeLoopsForParallelization(loopsForFunction, funcName, (regime == DATA_DISTR), regions, messagesForFile);
|
||||||
}
|
}
|
||||||
sendMessage_2lvl(2);
|
sendMessage_2lvl(L"");
|
||||||
}
|
}
|
||||||
else if (regime == COMP_DISTR)
|
else if (regime == COMP_DISTR)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include "graph_loops.h"
|
#include "../GraphLoop/graph_loops.h"
|
||||||
#include "graph_calls.h"
|
#include "../GraphCall/graph_calls.h"
|
||||||
#include "../ParallelizationRegions/ParRegions.h"
|
#include "../ParallelizationRegions/ParRegions.h"
|
||||||
#include "../SageAnalysisTool/depInterfaceExt.h"
|
#include "../SageAnalysisTool/depInterfaceExt.h"
|
||||||
#include "AstWrapper.h"
|
#include "../Utils/AstWrapper.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -10,12 +10,12 @@
|
|||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "ParRegions.h"
|
#include "ParRegions.h"
|
||||||
#include "utils.h"
|
#include "../Utils/utils.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "graph_calls_func.h"
|
#include "../GraphCall/graph_calls_func.h"
|
||||||
#include "graph_loops.h"
|
#include "../GraphLoop/graph_loops.h"
|
||||||
#include "../Distribution/Distribution.h"
|
#include "../Distribution/Distribution.h"
|
||||||
#include "expr_transform.h"
|
#include "../ExpressionTransform/expr_transform.h"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::string;
|
using std::string;
|
||||||
@@ -106,7 +106,7 @@ static void updateRegionInfo(SgStatement *st, map<string, pair<Statement*, State
|
|||||||
|
|
||||||
extendRegionInfo(st, startEnd, lines_);
|
extendRegionInfo(st, startEnd, lines_);
|
||||||
|
|
||||||
set<string> callsFromStatement;
|
set<string> calls_from_statement;
|
||||||
|
|
||||||
if (st->variant() == PROC_STAT)
|
if (st->variant() == PROC_STAT)
|
||||||
{
|
{
|
||||||
@@ -114,16 +114,16 @@ static void updateRegionInfo(SgStatement *st, map<string, pair<Statement*, State
|
|||||||
//check contains
|
//check contains
|
||||||
if (mapFuncs.find(containsPrefix + fullName) != mapFuncs.end())
|
if (mapFuncs.find(containsPrefix + fullName) != mapFuncs.end())
|
||||||
fullName = containsPrefix + fullName;
|
fullName = containsPrefix + fullName;
|
||||||
callsFromStatement.insert(fullName);
|
calls_from_statement.insert(fullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int z = 0; z < 3; ++z)
|
for (int z = 0; z < 3; ++z)
|
||||||
findFuncCalls(st->expr(z), callsFromStatement, containsPrefix, mapFuncs);
|
findFuncCalls(st->expr(z), calls_from_statement, containsPrefix, mapFuncs);
|
||||||
|
|
||||||
string filename = st->fileName();
|
string filename = st->fileName();
|
||||||
int line = st->lineNumber();
|
int line = st->lineNumber();
|
||||||
|
|
||||||
for (const auto &func_name : callsFromStatement)
|
for (const auto &func_name : calls_from_statement)
|
||||||
funcCallFromReg[func_name][filename].insert(line);
|
funcCallFromReg[func_name][filename].insert(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,6 +294,71 @@ static void checkForEmpty(SgStatement *start, SgStatement *end, vector<Messages>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool parseFortranDouble(const char* str, double &val)
|
||||||
|
{
|
||||||
|
int base_sign = 1, exp_sign = 1;
|
||||||
|
|
||||||
|
int integer_part = 0, power = 0;
|
||||||
|
double decimal_part = 0;
|
||||||
|
while (*str && *str != '.' && *str != 'd' && *str != 'D')
|
||||||
|
{
|
||||||
|
if (*str >= '0' && *str <= '9')
|
||||||
|
integer_part = integer_part * 10 + (*str - '0');
|
||||||
|
else if (*str == '-')
|
||||||
|
base_sign = -1;
|
||||||
|
else if (*str == '+')
|
||||||
|
base_sign = 1;
|
||||||
|
|
||||||
|
str++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*str == '.')
|
||||||
|
{
|
||||||
|
str++;
|
||||||
|
|
||||||
|
int base = 10;
|
||||||
|
while (*str >= '0' && *str <= '9')
|
||||||
|
{
|
||||||
|
decimal_part += double(*str - '0') / base;
|
||||||
|
str++;
|
||||||
|
base *= 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*str == 'd' || *str == 'D')
|
||||||
|
{
|
||||||
|
str++;
|
||||||
|
|
||||||
|
while (*str == '+' || *str == '-' || *str >= '0' && *str <= '9')
|
||||||
|
{
|
||||||
|
if (*str >= '0' && *str <= '9')
|
||||||
|
power = power * 10 + (*str - '0');
|
||||||
|
else if (*str == '-')
|
||||||
|
exp_sign = -1;
|
||||||
|
else if (*str == '+')
|
||||||
|
exp_sign = 1;
|
||||||
|
|
||||||
|
str++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double result = integer_part + decimal_part;
|
||||||
|
|
||||||
|
for(int i = 0; i < power; i++)
|
||||||
|
{
|
||||||
|
if (exp_sign > 0)
|
||||||
|
result *= 10;
|
||||||
|
else
|
||||||
|
result /= 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (base_sign < 0)
|
||||||
|
result = -result;
|
||||||
|
|
||||||
|
val = result;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void fillRegionLines(SgFile *file, vector<ParallelRegion*> ®ions, vector<Messages>& messagesForFile, vector<LoopGraph*> *loops, vector<FuncInfo*> *funcs)
|
void fillRegionLines(SgFile *file, vector<ParallelRegion*> ®ions, vector<Messages>& messagesForFile, vector<LoopGraph*> *loops, vector<FuncInfo*> *funcs)
|
||||||
{
|
{
|
||||||
map<string, FuncInfo*> mapFuncs;
|
map<string, FuncInfo*> mapFuncs;
|
||||||
@@ -388,6 +453,7 @@ void fillRegionLines(SgFile *file, vector<ParallelRegion*> ®ions, vector<Mess
|
|||||||
while (apply_fragment)
|
while (apply_fragment)
|
||||||
{
|
{
|
||||||
auto *curr = apply_fragment->lhs();
|
auto *curr = apply_fragment->lhs();
|
||||||
|
|
||||||
if (curr)
|
if (curr)
|
||||||
{
|
{
|
||||||
__spf_print(1, "%s %d\n", curr->unparse(), curr->variant());
|
__spf_print(1, "%s %d\n", curr->unparse(), curr->variant());
|
||||||
@@ -396,15 +462,18 @@ void fillRegionLines(SgFile *file, vector<ParallelRegion*> ®ions, vector<Mess
|
|||||||
{
|
{
|
||||||
if (curr->lhs() &&
|
if (curr->lhs() &&
|
||||||
isSgValueExp(curr->lhs()) &&
|
isSgValueExp(curr->lhs()) &&
|
||||||
isSgValueExp(curr->lhs())->doubleValue())
|
isSgValueExp(curr->lhs())->doubleValue() &&
|
||||||
|
parseFortranDouble(isSgValueExp(curr->lhs())->doubleValue(), fragmentWeight))
|
||||||
{
|
{
|
||||||
fragmentWeight = strtod(isSgValueExp(curr->lhs())->doubleValue(), NULL);
|
|
||||||
__spf_print(1, "->> %lf\n", fragmentWeight);
|
__spf_print(1, "->> %lf\n", fragmentWeight);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
__spf_print(1, "WEIGHT clause without double argument\n");
|
__spf_print(1, "WEIGHT clause without double argument\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
apply_fragment = apply_fragment->rhs();
|
apply_fragment = apply_fragment->rhs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,10 @@
|
|||||||
#include "../Distribution/DvmhDirective.h"
|
#include "../Distribution/DvmhDirective.h"
|
||||||
#include "../Distribution/GraphCSR.h"
|
#include "../Distribution/GraphCSR.h"
|
||||||
#include "../Distribution/Distribution.h"
|
#include "../Distribution/Distribution.h"
|
||||||
#include "AstWrapper.h"
|
#include "../Utils/AstWrapper.h"
|
||||||
|
|
||||||
#include "json.hpp"
|
|
||||||
|
|
||||||
#if __SPF
|
#if __SPF
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct ParallelRegionLines
|
struct ParallelRegionLines
|
||||||
@@ -255,42 +253,35 @@ public:
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json toJson()
|
std::string toString()
|
||||||
{
|
{
|
||||||
nlohmann::json retVal;
|
std::string retVal = "";
|
||||||
|
|
||||||
retVal["packedRegionId"] = std::to_string(regionId);
|
retVal += "#" + std::to_string(regionId);
|
||||||
retVal["originalName"] = originalName;
|
retVal += "#" + originalName;
|
||||||
|
retVal += "#" + std::to_string(lines.size());
|
||||||
|
|
||||||
nlohmann::json arrays = nlohmann::json::array();
|
for (auto it = lines.begin(); it != lines.end(); ++it)
|
||||||
for (auto& array : allArrays.GetArrays())
|
|
||||||
arrays.push_back(array->toJson());
|
|
||||||
retVal["packedArrays"] = arrays;
|
|
||||||
|
|
||||||
nlohmann::json linesInfo = nlohmann::json::array();
|
|
||||||
for (auto& [file, linesByFile] : lines)
|
|
||||||
{
|
{
|
||||||
nlohmann::json linesRegs;
|
retVal += "|" + it->first + "|";
|
||||||
nlohmann::json lines = nlohmann::json::array();
|
retVal += std::to_string(it->second.size());
|
||||||
|
for (int i = 0; i < it->second.size(); ++i)
|
||||||
for (auto& elem : linesByFile)
|
retVal += "#" + std::to_string(it->second[i].lines.first) + "#" + std::to_string(it->second[i].lines.second);
|
||||||
{
|
|
||||||
JSON pair;
|
|
||||||
pair["key"] = elem.lines.first;
|
|
||||||
pair["value"] = elem.lines.second;
|
|
||||||
lines.push_back(pair);
|
|
||||||
}
|
|
||||||
linesRegs["file"] = file;
|
|
||||||
linesRegs["lines"] = lines;
|
|
||||||
|
|
||||||
linesInfo.push_back(linesRegs);
|
|
||||||
}
|
}
|
||||||
retVal["regionsLines"] = linesInfo;
|
|
||||||
|
|
||||||
nlohmann::json alignRules = nlohmann::json::array();
|
const std::set<DIST::Array*> &arrays = allArrays.GetArrays();
|
||||||
for (auto& rule : dataDirectives.alignRules)
|
retVal += "#" + std::to_string(arrays.size());
|
||||||
alignRules.push_back(rule.toJson());
|
|
||||||
retVal["alignRules"] = alignRules;
|
//create map<array_address, DIST::Array_toString()>
|
||||||
|
for (auto it = arrays.begin(); it != arrays.end(); ++it)
|
||||||
|
{
|
||||||
|
retVal += "#" + std::to_string((long long)(*it));
|
||||||
|
retVal += "#" + (*it)->toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
retVal += "#" + std::to_string(dataDirectives.alignRules.size());
|
||||||
|
for (int i = 0; i < dataDirectives.alignRules.size(); ++i)
|
||||||
|
retVal += dataDirectives.alignRules[i].toString();
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ParRegions.h"
|
#include "ParRegions.h"
|
||||||
#include "graph_calls.h"
|
#include "../GraphCall/graph_calls.h"
|
||||||
#include "graph_loops.h"
|
#include "../GraphLoop/graph_loops.h"
|
||||||
|
|
||||||
void fillRegionLines(SgFile *file, std::vector<ParallelRegion*> ®ions, std::vector<Messages>& messagesForFile, std::vector<LoopGraph*> *loops = NULL, std::vector<FuncInfo*> *funcs = NULL);
|
void fillRegionLines(SgFile *file, std::vector<ParallelRegion*> ®ions, std::vector<Messages>& messagesForFile, std::vector<LoopGraph*> *loops = NULL, std::vector<FuncInfo*> *funcs = NULL);
|
||||||
void fillRegionLinesStep2(std::vector<ParallelRegion*> ®ions, const std::map<std::string, std::vector<FuncInfo*>> &allFuncInfo, std::map<std::string, std::vector<LoopGraph*>> *loopGraph = NULL);
|
void fillRegionLinesStep2(std::vector<ParallelRegion*> ®ions, const std::map<std::string, std::vector<FuncInfo*>> &allFuncInfo, std::map<std::string, std::vector<LoopGraph*>> *loopGraph = NULL);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ParRegions.h"
|
#include "ParRegions.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
|
|
||||||
bool expandExtractReg(const std::string &fileName, const int startLine, const int endLine, const std::vector<ParallelRegion*> ®ions, std::vector<Messages> &messagesForFile, const bool toDelete = false);
|
bool expandExtractReg(const std::string &fileName, const int startLine, const int endLine, const std::vector<ParallelRegion*> ®ions, std::vector<Messages> &messagesForFile, const bool toDelete = false);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -11,14 +11,14 @@
|
|||||||
#include "ParRegions_func.h"
|
#include "ParRegions_func.h"
|
||||||
#include "resolve_par_reg_conflicts.h"
|
#include "resolve_par_reg_conflicts.h"
|
||||||
|
|
||||||
#include "graph_calls_func.h"
|
#include "../GraphCall/graph_calls_func.h"
|
||||||
#include "graph_loops_func.h"
|
#include "../GraphLoop/graph_loops_func.h"
|
||||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||||
#include "../DirectiveProcessing/directive_creator.h"
|
#include "../DirectiveProcessing/directive_creator.h"
|
||||||
#include "../DirectiveProcessing/insert_directive.h"
|
#include "../DirectiveProcessing/insert_directive.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "expr_transform.h"
|
#include "../ExpressionTransform/expr_transform.h"
|
||||||
#include "../Transformations/FunctionPurifying/function_purifying.h"
|
#include "../Transformations/function_purifying.h"
|
||||||
|
|
||||||
using std::map;
|
using std::map;
|
||||||
using std::pair;
|
using std::pair;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ParRegions.h"
|
#include "ParRegions.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "graph_calls.h"
|
#include "../GraphCall/graph_calls.h"
|
||||||
|
|
||||||
void fillRegionIntervals(std::vector<ParallelRegion*> ®ions);
|
void fillRegionIntervals(std::vector<ParallelRegion*> ®ions);
|
||||||
void fillRegionArrays(std::vector<ParallelRegion*> ®ions, const std::map<std::string, std::vector<FuncInfo*>> &allFuncInfo, const std::map<std::string, CommonBlock*> &commonBlocks);
|
void fillRegionArrays(std::vector<ParallelRegion*> ®ions, const std::map<std::string, std::vector<FuncInfo*>> &allFuncInfo, const std::map<std::string, CommonBlock*> &commonBlocks);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -16,11 +16,11 @@
|
|||||||
#include "../DynamicAnalysis/gcov_info.h"
|
#include "../DynamicAnalysis/gcov_info.h"
|
||||||
#include "../DynamicAnalysis/gCov_parser_func.h"
|
#include "../DynamicAnalysis/gCov_parser_func.h"
|
||||||
#include "PredictScheme.h"
|
#include "PredictScheme.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "../DirectiveProcessing/directive_parser.h"
|
#include "../DirectiveProcessing/directive_parser.h"
|
||||||
#include "../Distribution/DvmhDirective.h"
|
#include "../Distribution/DvmhDirective.h"
|
||||||
#include "graph_loops_func.h"
|
#include "../GraphLoop/graph_loops_func.h"
|
||||||
#include "expr_transform.h"
|
#include "../ExpressionTransform/expr_transform.h"
|
||||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||||
#include "../CFGraph/CFGraph.h"
|
#include "../CFGraph/CFGraph.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "graph_calls.h"
|
#include "../GraphCall/graph_calls.h"
|
||||||
#include "json.hpp"
|
|
||||||
|
|
||||||
class ParallelStats
|
class ParallelStats
|
||||||
{
|
{
|
||||||
@@ -12,10 +11,10 @@ public:
|
|||||||
RemoteCount = ShadowCount = ReductionCount = AcrossCount = 0;
|
RemoteCount = ShadowCount = ReductionCount = AcrossCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RemoteCount = 0;
|
int RemoteCount;
|
||||||
int ShadowCount = 0;
|
int ShadowCount;
|
||||||
int ReductionCount = 0;
|
int ReductionCount;
|
||||||
int AcrossCount = 0;
|
int AcrossCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PredictorStats
|
class PredictorStats
|
||||||
@@ -28,32 +27,28 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
ParallelStats ParallelStat;
|
ParallelStats ParallelStat;
|
||||||
int ParallelCount = 0;
|
int ParallelCount;
|
||||||
int RemoteCount = 0;
|
int RemoteCount;
|
||||||
int RedistributeCount = 0;
|
int RedistributeCount;
|
||||||
int IntervalCount = 0;
|
int IntervalCount;
|
||||||
int TotalScoreComm = 0;
|
int TotalScoreComm;
|
||||||
int TotalScorePar = 0;
|
int TotalScorePar;
|
||||||
int TotalScoreDist = 0;
|
int TotalScoreDist;
|
||||||
|
|
||||||
nlohmann::json toJson()
|
std::string to_string()
|
||||||
{
|
{
|
||||||
nlohmann::json stat;
|
std::string res = "";
|
||||||
|
res += std::to_string(ParallelCount) + "|";
|
||||||
|
res += std::to_string(RemoteCount) + "|";
|
||||||
|
res += std::to_string(RedistributeCount) + "|";
|
||||||
|
res += std::to_string(IntervalCount) + "|";
|
||||||
|
|
||||||
stat["ParallelCount"] = ParallelCount;
|
res += std::to_string(ParallelStat.RemoteCount) + "|";
|
||||||
stat["RemoteCount"] = RemoteCount;
|
res += std::to_string(ParallelStat.ShadowCount) + "|";
|
||||||
stat["RedistributeCount"] = RedistributeCount;
|
res += std::to_string(ParallelStat.ReductionCount) + "|";
|
||||||
stat["IntervalCount"] = IntervalCount;
|
res += std::to_string(ParallelStat.AcrossCount);
|
||||||
|
|
||||||
stat["PS_RemoteCount"] = ParallelStat.RemoteCount;
|
return res;
|
||||||
stat["PS_ShadowCount"] = ParallelStat.ShadowCount;
|
|
||||||
stat["PS_ReductionCount"] = ParallelStat.ReductionCount;
|
|
||||||
stat["PS_AcrossCount"] = ParallelStat.AcrossCount;
|
|
||||||
|
|
||||||
//TODO: need to improve
|
|
||||||
// (summed.TotalScoreComm != 0 ? 1.0 / summed.TotalScoreComm : 0.0) + (double)summed.TotalScorePar * 1000 + (countOfDist == 0 ? -5000 : countOfDist);
|
|
||||||
stat["TotalScore"] = -1 * (ParallelStat.RemoteCount + ParallelStat.ShadowCount + ParallelStat.ReductionCount + ParallelStat.AcrossCount);
|
|
||||||
return stat;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#define _LEAK_
|
#define _LEAK_
|
||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include "graph_calls.h"
|
#include "../GraphCall/graph_calls.h"
|
||||||
#include "private_analyzer.h"
|
#include "private_analyzer.h"
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "../CFGraph/CFGraph.h"
|
#include "../CFGraph/CFGraph.h"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "graph_calls.h"
|
#include "../GraphCall/graph_calls.h"
|
||||||
|
|
||||||
extern void Private_Vars_Analyzer(SgStatement* start);
|
extern void Private_Vars_Analyzer(SgStatement* start);
|
||||||
void PrivateAnalyzer(SgFile *file, std::vector<FuncInfo*> &funcs);
|
void PrivateAnalyzer(SgFile *file, std::vector<FuncInfo*> &funcs);
|
||||||
|
|||||||
@@ -1,141 +0,0 @@
|
|||||||
#include <map>
|
|
||||||
#include <unordered_set>
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <vector>
|
|
||||||
#include <queue>
|
|
||||||
#include <numeric>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "private_arrays_search.h"
|
|
||||||
#include "range_structures.h"
|
|
||||||
#include "region.h"
|
|
||||||
#include "SgUtils.h"
|
|
||||||
#include "graph_loops.h"
|
|
||||||
#include "../CFGraph/CFGraph.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
void Collapse(Region* region)
|
|
||||||
{
|
|
||||||
if (region->getBasickBlocks().empty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (auto& [arrayName, arrayRanges] : region->getHeader()->array_out)
|
|
||||||
{
|
|
||||||
for (Region* byBlock : region->getBasickBlocks())
|
|
||||||
{
|
|
||||||
AccessingSet intersection = byBlock->array_def[arrayName].Intersect(arrayRanges);
|
|
||||||
region->array_def[arrayName] = region->array_def[arrayName].Union(intersection);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto& byBlock : region->getBasickBlocks())
|
|
||||||
{
|
|
||||||
for (auto& [arrayName, arrayRanges] : byBlock->array_use)
|
|
||||||
{
|
|
||||||
AccessingSet diff = byBlock->array_use[arrayName].Diff(byBlock->array_in[arrayName]);
|
|
||||||
region->array_use[arrayName] = region->array_use[arrayName].Union(diff);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ArrayAccessingIndexes useUnion;
|
|
||||||
for (auto& byBlock : region->getBasickBlocks())
|
|
||||||
for (auto& [arrayName, arrayRanges] : byBlock->array_use)
|
|
||||||
useUnion[arrayName] = useUnion[arrayName].Union(byBlock->array_use[arrayName]);
|
|
||||||
|
|
||||||
for (auto& [arrayName, arrayRanges] : useUnion)
|
|
||||||
region->array_priv[arrayName] = useUnion[arrayName].Diff(region->array_use[arrayName]);
|
|
||||||
|
|
||||||
for (Region* prevBlock : region->getHeader()->getPrevRegions())
|
|
||||||
prevBlock->replaceInNextRegions(region, region->getHeader());
|
|
||||||
|
|
||||||
for (Region* nextBlock : region->getHeader()->getNextRegions())
|
|
||||||
nextBlock->replaceInPrevRegions(region, region->getHeader());
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SolveDataFlowIteratively(Region* DFG)
|
|
||||||
{
|
|
||||||
unordered_set<Region*> worklist(DFG->getBasickBlocks());
|
|
||||||
do
|
|
||||||
{
|
|
||||||
Region* b = *worklist.begin();
|
|
||||||
ArrayAccessingIndexes newIn;
|
|
||||||
bool flagFirst = true;
|
|
||||||
for (Region* prevBlock : b->getPrevRegions())
|
|
||||||
{
|
|
||||||
if (flagFirst)
|
|
||||||
{
|
|
||||||
newIn = prevBlock->array_out;
|
|
||||||
flagFirst = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (prevBlock->array_out.empty())
|
|
||||||
{
|
|
||||||
newIn.clear();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (const auto& [arrayName, accessSet] : prevBlock->array_out)
|
|
||||||
{
|
|
||||||
if (newIn.find(arrayName) != newIn.end())
|
|
||||||
newIn[arrayName] = newIn[arrayName].Intersect(accessSet);
|
|
||||||
else
|
|
||||||
newIn[arrayName] = AccessingSet();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
b->array_in = move(newIn);
|
|
||||||
ArrayAccessingIndexes newOut;
|
|
||||||
if (b->array_def.empty())
|
|
||||||
newOut = b->array_in;
|
|
||||||
else if (b->array_in.empty())
|
|
||||||
newOut = b->array_def;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (auto& [arrayName, accessSet] : b->array_def)
|
|
||||||
{
|
|
||||||
if (newOut.find(arrayName) != newOut.end())
|
|
||||||
newOut[arrayName] = b->array_def[arrayName].Union(b->array_in[arrayName]);
|
|
||||||
else
|
|
||||||
newOut[arrayName] = accessSet;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* can not differ */
|
|
||||||
if (newOut != b->array_out)
|
|
||||||
b->array_out = newOut;
|
|
||||||
else
|
|
||||||
worklist.erase(b);
|
|
||||||
}
|
|
||||||
while (!worklist.empty());
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SolveDataFlow(Region* DFG)
|
|
||||||
{
|
|
||||||
if (!DFG)
|
|
||||||
return;
|
|
||||||
|
|
||||||
SolveDataFlowIteratively(DFG);
|
|
||||||
for (Region* subRegion : DFG->getSubRegions())
|
|
||||||
SolveDataFlow(subRegion);
|
|
||||||
Collapse(DFG);
|
|
||||||
}
|
|
||||||
|
|
||||||
map<LoopGraph*, ArrayAccessingIndexes> findPrivateArrays(map<string, vector<LoopGraph*>> &loopGraph, map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR)
|
|
||||||
{
|
|
||||||
map<LoopGraph*, ArrayAccessingIndexes> result;
|
|
||||||
for (const auto& [loopName, loops] : loopGraph)
|
|
||||||
{
|
|
||||||
for (const auto& loop : loops)
|
|
||||||
{
|
|
||||||
for (const auto& [funcInfo, blocks]: FullIR)
|
|
||||||
{
|
|
||||||
Region* loopRegion = new Region(loop, blocks);
|
|
||||||
SolveDataFlow(loopRegion);
|
|
||||||
result[loop] = loopRegion->array_priv;
|
|
||||||
delete(loopRegion);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <map>
|
|
||||||
#include <unordered_set>
|
|
||||||
|
|
||||||
#include "range_structures.h"
|
|
||||||
#include "region.h"
|
|
||||||
#include "graph_loops.h"
|
|
||||||
#include "../CFGraph/CFGraph.h"
|
|
||||||
|
|
||||||
void Collapse(Region* region);
|
|
||||||
std::map<LoopGraph*, ArrayAccessingIndexes> findPrivateArrays(std::map<std::string, std::vector<LoopGraph*>>& loopGraph, std::map<FuncInfo*, std::vector<SAPFOR::BasicBlock*>>& FullIR);
|
|
||||||
std::pair<SAPFOR::BasicBlock*, std::unordered_set<SAPFOR::BasicBlock*>> GetBasicBlocksForLoop(const LoopGraph* loop, const std::vector<SAPFOR::BasicBlock*> blocks);
|
|
||||||
@@ -1,293 +0,0 @@
|
|||||||
#include <vector>
|
|
||||||
#include <map>
|
|
||||||
#include <unordered_set>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "utils.h"
|
|
||||||
#include "range_structures.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
static vector<uint64_t> FindParticularSolution(const ArrayDimension& dim1, const ArrayDimension& dim2)
|
|
||||||
{
|
|
||||||
for (uint64_t i = 0; i < dim1.tripCount; i++)
|
|
||||||
{
|
|
||||||
uint64_t leftPart = dim1.start + i * dim1.step;
|
|
||||||
for (uint64_t j = 0; j < dim2.tripCount; j++)
|
|
||||||
{
|
|
||||||
uint64_t rightPart = dim2.start + j * dim2.step;
|
|
||||||
if (leftPart == rightPart)
|
|
||||||
return { i, j };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
/* dim1 /\ dim2 */
|
|
||||||
static ArrayDimension* DimensionIntersection(const ArrayDimension& dim1, const ArrayDimension& dim2)
|
|
||||||
{
|
|
||||||
vector<uint64_t> partSolution = FindParticularSolution(dim1, dim2);
|
|
||||||
if (partSolution.empty())
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
int64_t x0 = partSolution[0], y0 = partSolution[1];
|
|
||||||
/* x = x_0 + c * t */
|
|
||||||
/* y = y_0 + d * t */
|
|
||||||
int64_t c = dim2.step / gcd(dim1.step, dim2.step);
|
|
||||||
int64_t d = dim1.step / gcd(dim1.step, dim2.step);
|
|
||||||
int64_t tXMin, tXMax, tYMin, tYMax;
|
|
||||||
tXMin = -x0 / c;
|
|
||||||
tXMax = (dim1.tripCount - 1 - x0) / c;
|
|
||||||
tYMin = -y0 / d;
|
|
||||||
tYMax = (dim2.tripCount - 1 - y0) / d;
|
|
||||||
int64_t tMin = max(tXMin, tYMin);
|
|
||||||
uint64_t tMax = min(tXMax, tYMax);
|
|
||||||
if (tMin > tMax)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
uint64_t start3 = dim1.start + x0 * dim1.step;
|
|
||||||
uint64_t step3 = c * dim1.step;
|
|
||||||
ArrayDimension* result = new(ArrayDimension){ start3, step3, tMax + 1 };
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* dim1 / dim2 */
|
|
||||||
static vector<ArrayDimension> DimensionDifference(const ArrayDimension& dim1, const ArrayDimension& dim2)
|
|
||||||
{
|
|
||||||
ArrayDimension* intersection = DimensionIntersection(dim1, dim2);
|
|
||||||
if (!intersection)
|
|
||||||
return { dim1 };
|
|
||||||
|
|
||||||
vector<ArrayDimension> result;
|
|
||||||
/* add the part before intersection */
|
|
||||||
if (dim1.start < intersection->start)
|
|
||||||
result.push_back({ dim1.start, dim1.step, (intersection->start - dim1.start) / dim1.step });
|
|
||||||
|
|
||||||
/* add the parts between intersection steps */
|
|
||||||
uint64_t start = (intersection->start - dim1.start) / dim1.step;
|
|
||||||
uint64_t interValue = intersection->start;
|
|
||||||
for (int64_t i = start; dim1.start + i * dim1.step <= intersection->start + intersection->step * (intersection->tripCount - 1); i++)
|
|
||||||
{
|
|
||||||
uint64_t centerValue = dim1.start + i * dim1.step;
|
|
||||||
if (centerValue == interValue)
|
|
||||||
{
|
|
||||||
if (i - start > 1)
|
|
||||||
{
|
|
||||||
result.push_back({ dim1.start + (start + 1) * dim1.step, dim1.step, i - start - 1 });
|
|
||||||
start = i;
|
|
||||||
}
|
|
||||||
interValue += intersection->step;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* add the part after intersection */
|
|
||||||
if (intersection->start + intersection->step * (intersection->tripCount - 1) < dim1.start + dim1.step * (dim1.tripCount - 1))
|
|
||||||
{
|
|
||||||
/* first value after intersection */
|
|
||||||
uint64_t right_start = intersection->start + intersection->step * (intersection->tripCount - 1) + dim1.step;
|
|
||||||
uint64_t tripCount = (dim1.start + dim1.step * dim1.tripCount - right_start) / dim1.step;
|
|
||||||
result.push_back({ right_start, dim1.step, tripCount });
|
|
||||||
}
|
|
||||||
delete(intersection);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static vector<ArrayDimension> DimensionUnion(const ArrayDimension& dim1, const ArrayDimension& dim2)
|
|
||||||
{
|
|
||||||
vector<ArrayDimension> res;
|
|
||||||
ArrayDimension* inter = DimensionIntersection(dim1, dim2);
|
|
||||||
if (!inter)
|
|
||||||
return { dim1, dim2 };
|
|
||||||
|
|
||||||
res.push_back(*inter);
|
|
||||||
delete(inter);
|
|
||||||
|
|
||||||
vector<ArrayDimension> diff1, diff2;
|
|
||||||
diff1 = DimensionDifference(dim1, dim2);
|
|
||||||
diff2 = DimensionDifference(dim2, dim1);
|
|
||||||
res.insert(res.end(), diff1.begin(), diff1.end());
|
|
||||||
res.insert(res.end(), diff2.begin(), diff2.end());
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
static vector<ArrayDimension> ElementsIntersection(const vector<ArrayDimension>& firstElement, const vector<ArrayDimension>& secondElement)
|
|
||||||
{
|
|
||||||
if (firstElement.empty() || secondElement.empty())
|
|
||||||
return {};
|
|
||||||
|
|
||||||
size_t dimAmount = firstElement.size();
|
|
||||||
/* check if there is no intersecction */
|
|
||||||
for (size_t i = 0; i < dimAmount; i++)
|
|
||||||
if (FindParticularSolution(firstElement[i], secondElement[i]).empty())
|
|
||||||
return {};
|
|
||||||
|
|
||||||
vector<ArrayDimension> result(dimAmount);
|
|
||||||
for (size_t i = 0; i < dimAmount; i++)
|
|
||||||
{
|
|
||||||
ArrayDimension* resPtr = DimensionIntersection(firstElement[i], secondElement[i]);
|
|
||||||
if (resPtr)
|
|
||||||
result[i] = *resPtr;
|
|
||||||
else
|
|
||||||
return {};
|
|
||||||
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static vector<vector<ArrayDimension>> ElementsDifference(const vector<ArrayDimension>& firstElement,
|
|
||||||
const vector<ArrayDimension>& secondElement)
|
|
||||||
{
|
|
||||||
if (firstElement.empty() || secondElement.empty())
|
|
||||||
return {};
|
|
||||||
|
|
||||||
vector<ArrayDimension> intersection = ElementsIntersection(firstElement, secondElement);
|
|
||||||
vector<vector<ArrayDimension>> result;
|
|
||||||
if (intersection.empty())
|
|
||||||
return { firstElement };
|
|
||||||
|
|
||||||
for (int i = 0; i < firstElement.size(); i++)
|
|
||||||
{
|
|
||||||
auto dimDiff = DimensionDifference(firstElement[i], secondElement[i]);
|
|
||||||
if (!dimDiff.empty())
|
|
||||||
{
|
|
||||||
vector<ArrayDimension> firstCopy = firstElement;
|
|
||||||
for (const auto& range : dimDiff)
|
|
||||||
{
|
|
||||||
firstCopy[i] = range;
|
|
||||||
result.push_back(firstCopy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ElementsUnion(const vector<ArrayDimension>& firstElement, const vector<ArrayDimension>& secondElement,
|
|
||||||
vector<vector<ArrayDimension>>& lc, vector<vector<ArrayDimension>>& rc,
|
|
||||||
vector<ArrayDimension>& intersection)
|
|
||||||
{
|
|
||||||
/* lc(rc) is a set of ranges, which only exist in first(second) element*/
|
|
||||||
intersection = ElementsIntersection(firstElement, secondElement);
|
|
||||||
lc = ElementsDifference(firstElement, intersection);
|
|
||||||
rc = ElementsDifference(secondElement, intersection);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AccessingSet::FindUncovered(const vector<ArrayDimension>& element, vector<vector<ArrayDimension>>& result) const {
|
|
||||||
vector<vector<ArrayDimension>> newTails;
|
|
||||||
result.push_back(element);
|
|
||||||
for (const auto& currentElement : allElements)
|
|
||||||
{
|
|
||||||
for (const auto& tailLoc : result)
|
|
||||||
{
|
|
||||||
auto intersection = ElementsIntersection(tailLoc, currentElement);
|
|
||||||
auto diff = ElementsDifference(tailLoc, intersection);
|
|
||||||
if (!diff.empty()) {
|
|
||||||
newTails.insert(newTails.end(), diff.begin(), diff.end());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result = newTails;
|
|
||||||
newTails.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AccessingSet::ContainsElement(const vector<ArrayDimension>& element) const
|
|
||||||
{
|
|
||||||
vector<vector<ArrayDimension>> tails;
|
|
||||||
FindUncovered(element, tails);
|
|
||||||
return !tails.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AccessingSet::FindCoveredBy(const vector<ArrayDimension>& element, vector<vector<ArrayDimension>>& result) const
|
|
||||||
{
|
|
||||||
for (const auto& currentElement : allElements)
|
|
||||||
{
|
|
||||||
auto intersection = ElementsIntersection(element, currentElement);
|
|
||||||
if (!intersection.empty())
|
|
||||||
result.push_back(intersection);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vector<vector<ArrayDimension>> AccessingSet::GetElements() const { return allElements; }
|
|
||||||
|
|
||||||
void AccessingSet::Insert(const vector<ArrayDimension>& element)
|
|
||||||
{
|
|
||||||
vector<vector<ArrayDimension>> tails;
|
|
||||||
FindUncovered(element, tails);
|
|
||||||
allElements.insert(allElements.end(), tails.begin(), tails.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
AccessingSet AccessingSet::Union(const AccessingSet& source) {
|
|
||||||
AccessingSet result;
|
|
||||||
for (auto& element : source.GetElements())
|
|
||||||
result.Insert(element);
|
|
||||||
|
|
||||||
for (auto& element : allElements)
|
|
||||||
result.Insert(element);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
AccessingSet AccessingSet::Intersect(const AccessingSet& secondSet) const
|
|
||||||
{
|
|
||||||
vector<vector<ArrayDimension>> result;
|
|
||||||
if (secondSet.GetElements().empty() || this->allElements.empty())
|
|
||||||
return AccessingSet(result);
|
|
||||||
|
|
||||||
for (const auto& element : allElements)
|
|
||||||
{
|
|
||||||
if (secondSet.ContainsElement(element))
|
|
||||||
result.push_back(element);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vector<vector<ArrayDimension>> coveredBy;
|
|
||||||
secondSet.FindCoveredBy(element, coveredBy);
|
|
||||||
if (!coveredBy.empty())
|
|
||||||
result.insert(result.end(), coveredBy.begin(), coveredBy.end());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return AccessingSet(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
AccessingSet AccessingSet::Diff(const AccessingSet& secondSet) const
|
|
||||||
{
|
|
||||||
if (secondSet.GetElements().empty() || allElements.empty())
|
|
||||||
return *this;
|
|
||||||
|
|
||||||
AccessingSet intersection = this->Intersect(secondSet);
|
|
||||||
AccessingSet uncovered = *this;
|
|
||||||
vector<vector<ArrayDimension>> result;
|
|
||||||
for (const auto& element : intersection.GetElements())
|
|
||||||
{
|
|
||||||
vector<vector<ArrayDimension>> current_uncovered;
|
|
||||||
uncovered.FindUncovered(element, current_uncovered);
|
|
||||||
uncovered = AccessingSet(current_uncovered);
|
|
||||||
}
|
|
||||||
return uncovered;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator!=(const ArrayDimension& lhs, const ArrayDimension& rhs)
|
|
||||||
{
|
|
||||||
return !(lhs.start == rhs.start && lhs.step == rhs.step && lhs.tripCount == rhs.tripCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool operator!=(const AccessingSet& lhs, const AccessingSet& rhs)
|
|
||||||
{
|
|
||||||
for (size_t i = 0; i < lhs.allElements.size(); i++)
|
|
||||||
for (size_t j = 0; j < lhs.allElements[i].size(); j++)
|
|
||||||
if (lhs.allElements[i][j] != rhs.allElements[i][j])
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator!=(const ArrayAccessingIndexes& lhs, const ArrayAccessingIndexes& rhs)
|
|
||||||
{
|
|
||||||
if (lhs.size() != rhs.size())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
for (auto& [key, value] : lhs)
|
|
||||||
if (rhs.find(key) == rhs.end())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <map>
|
|
||||||
#include <unordered_set>
|
|
||||||
#include <string>
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
struct ArrayDimension
|
|
||||||
{
|
|
||||||
uint64_t start, step, tripCount;
|
|
||||||
};
|
|
||||||
|
|
||||||
class AccessingSet {
|
|
||||||
private:
|
|
||||||
std::vector<std::vector<ArrayDimension>> allElements;
|
|
||||||
|
|
||||||
public:
|
|
||||||
AccessingSet(std::vector<std::vector<ArrayDimension>> input) : allElements(input) {};
|
|
||||||
AccessingSet() {};
|
|
||||||
AccessingSet(const AccessingSet& a) { allElements = a.GetElements(); };
|
|
||||||
std::vector<std::vector<ArrayDimension>> GetElements() const;
|
|
||||||
void Insert(const std::vector<ArrayDimension>& element);
|
|
||||||
AccessingSet Union(const AccessingSet& source);
|
|
||||||
AccessingSet Intersect(const AccessingSet& secondSet) const;
|
|
||||||
AccessingSet Diff(const AccessingSet& secondSet) const;
|
|
||||||
bool ContainsElement(const std::vector<ArrayDimension>& element) const;
|
|
||||||
void FindCoveredBy(const std::vector<ArrayDimension>& element, std::vector<std::vector<ArrayDimension>>& result) const;
|
|
||||||
void FindUncovered(const std::vector<ArrayDimension>& element, std::vector<std::vector<ArrayDimension>>& result) const;
|
|
||||||
friend bool operator!=(const AccessingSet& lhs, const AccessingSet& rhs);
|
|
||||||
};
|
|
||||||
|
|
||||||
using ArrayAccessingIndexes = std::map<std::string, AccessingSet>;
|
|
||||||
|
|
||||||
bool operator!=(const ArrayDimension& lhs, const ArrayDimension& rhs);
|
|
||||||
bool operator!=(const AccessingSet& lhs, const AccessingSet& rhs);
|
|
||||||
bool operator!=(const ArrayAccessingIndexes& lhs, const ArrayAccessingIndexes& rhs);
|
|
||||||
@@ -1,251 +0,0 @@
|
|||||||
#include<vector>
|
|
||||||
#include<map>
|
|
||||||
#include<unordered_set>
|
|
||||||
#include<unordered_map>
|
|
||||||
#include<string>
|
|
||||||
#include <numeric>
|
|
||||||
|
|
||||||
#include "range_structures.h"
|
|
||||||
#include "region.h"
|
|
||||||
|
|
||||||
#include "SgUtils.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
static bool isParentStmt(SgStatement* stmt, SgStatement* parent)
|
|
||||||
{
|
|
||||||
for (; stmt; stmt = stmt->controlParent())
|
|
||||||
if (stmt == parent)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*returns head block and loop*/
|
|
||||||
pair<SAPFOR::BasicBlock*, unordered_set<SAPFOR::BasicBlock*>> GetBasicBlocksForLoop(const LoopGraph* loop, const vector<SAPFOR::BasicBlock*> blocks)
|
|
||||||
{
|
|
||||||
unordered_set<SAPFOR::BasicBlock*> block_loop;
|
|
||||||
SAPFOR::BasicBlock* head_block = nullptr;
|
|
||||||
auto loop_operator = loop->loop->GetOriginal();
|
|
||||||
for (const auto& block : blocks)
|
|
||||||
{
|
|
||||||
if (!block || (block->getInstructions().size() == 0))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
SgStatement* first = block->getInstructions().front()->getInstruction()->getOperator();
|
|
||||||
SgStatement* last = block->getInstructions().back()->getInstruction()->getOperator();
|
|
||||||
if (isParentStmt(first, loop_operator) && isParentStmt(last, loop_operator))
|
|
||||||
{
|
|
||||||
block_loop.insert(block);
|
|
||||||
|
|
||||||
if ((!head_block) && (first == loop_operator) && (last == loop_operator) &&
|
|
||||||
(block->getInstructions().size() == 2) &&
|
|
||||||
(block->getInstructions().back()->getInstruction()->getOperation() == SAPFOR::CFG_OP::JUMP_IF))
|
|
||||||
{
|
|
||||||
head_block = block;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return { head_block, block_loop };
|
|
||||||
}
|
|
||||||
|
|
||||||
static void BuildLoopIndex(map<string, LoopGraph*>& loopForIndex, LoopGraph* loop) {
|
|
||||||
string index = loop->loopSymbol();
|
|
||||||
loopForIndex[index] = loop;
|
|
||||||
|
|
||||||
for (const auto& childLoop : loop->children)
|
|
||||||
BuildLoopIndex(loopForIndex, childLoop);
|
|
||||||
}
|
|
||||||
|
|
||||||
static string FindIndexName(int pos, SAPFOR::BasicBlock* block, map<string, LoopGraph*>& loopForIndex) {
|
|
||||||
unordered_set<SAPFOR::Argument*> args = { block->getInstructions()[pos]->getInstruction()->getArg1() };
|
|
||||||
|
|
||||||
for (int i = pos - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
SAPFOR::Argument* res = block->getInstructions()[i]->getInstruction()->getResult();
|
|
||||||
if (res && args.find(res) != args.end())
|
|
||||||
{
|
|
||||||
SAPFOR::Argument* arg1 = block->getInstructions()[i]->getInstruction()->getArg1();
|
|
||||||
SAPFOR::Argument* arg2 = block->getInstructions()[i]->getInstruction()->getArg2();
|
|
||||||
if (arg1)
|
|
||||||
{
|
|
||||||
string name = arg1->getValue();
|
|
||||||
int idx = name.find('%');
|
|
||||||
if (idx != -1 && loopForIndex.find(name.substr(idx + 1)) != loopForIndex.end())
|
|
||||||
return name.substr(idx + 1);
|
|
||||||
else
|
|
||||||
args.insert(arg1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arg2)
|
|
||||||
{
|
|
||||||
string name = arg2->getValue();
|
|
||||||
int idx = name.find('%');
|
|
||||||
if (idx != -1 && loopForIndex.find(name.substr(idx + 1)) != loopForIndex.end())
|
|
||||||
return name.substr(idx + 1);
|
|
||||||
else
|
|
||||||
args.insert(arg2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
static int GetDefUseArray(SAPFOR::BasicBlock* block, LoopGraph* loop, ArrayAccessingIndexes& def, ArrayAccessingIndexes& use) {
|
|
||||||
auto instructions = block->getInstructions();
|
|
||||||
map<string, LoopGraph*> loopForIndex;
|
|
||||||
BuildLoopIndex(loopForIndex, loop);
|
|
||||||
for (int i = 0; i < instructions.size(); i++)
|
|
||||||
{
|
|
||||||
auto instruction = instructions[i];
|
|
||||||
if (!instruction->getInstruction()->getArg1())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
auto operation = instruction->getInstruction()->getOperation();
|
|
||||||
auto type = instruction->getInstruction()->getArg1()->getType();
|
|
||||||
if ((operation == SAPFOR::CFG_OP::STORE || operation == SAPFOR::CFG_OP::LOAD) && type == SAPFOR::CFG_ARG_TYPE::ARRAY)
|
|
||||||
{
|
|
||||||
vector<SAPFOR::Argument*> index_vars;
|
|
||||||
vector<int> refPos;
|
|
||||||
string array_name;
|
|
||||||
if (operation == SAPFOR::CFG_OP::STORE)
|
|
||||||
array_name = instruction->getInstruction()->getArg1()->getValue();
|
|
||||||
else
|
|
||||||
array_name = instruction->getInstruction()->getArg2()->getValue();
|
|
||||||
|
|
||||||
int j = i - 1;
|
|
||||||
while (j >= 0 && instructions[j]->getInstruction()->getOperation() == SAPFOR::CFG_OP::REF)
|
|
||||||
{
|
|
||||||
index_vars.push_back(instructions[j]->getInstruction()->getArg1());
|
|
||||||
refPos.push_back(j);
|
|
||||||
j--;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*to choose correct dimension*/
|
|
||||||
int n = index_vars.size();
|
|
||||||
vector<ArrayDimension> accessPoint(n);
|
|
||||||
|
|
||||||
auto* ref = isSgArrayRefExp(instruction->getInstruction()->getExpression());
|
|
||||||
vector<pair<int, int>> coefsForDims;
|
|
||||||
for (int i = 0; ref && i < ref->numberOfSubscripts(); ++i)
|
|
||||||
{
|
|
||||||
const vector<int*>& coefs = getAttributes<SgExpression*, int*>(ref->subscript(i), set<int>{ INT_VAL });
|
|
||||||
if (coefs.size() == 1)
|
|
||||||
{
|
|
||||||
const pair<int, int> coef(coefs[0][0], coefs[0][1]);
|
|
||||||
coefsForDims.push_back(coef);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(coefsForDims.empty())
|
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
|
||||||
|
|
||||||
while (!index_vars.empty())
|
|
||||||
{
|
|
||||||
auto var = index_vars.back();
|
|
||||||
int currentVarPos = refPos.back();
|
|
||||||
pair<int, int> currentCoefs = coefsForDims.back();
|
|
||||||
ArrayDimension current_dim;
|
|
||||||
if (var->getType() == SAPFOR::CFG_ARG_TYPE::CONST)
|
|
||||||
current_dim = { stoul(var->getValue()), 1, 1 };
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string name, full_name = var->getValue();
|
|
||||||
int pos = full_name.find('%');
|
|
||||||
LoopGraph* currentLoop;
|
|
||||||
if (pos != -1)
|
|
||||||
{
|
|
||||||
name = full_name.substr(pos + 1);
|
|
||||||
if (loopForIndex.find(name) != loopForIndex.end())
|
|
||||||
currentLoop = loopForIndex[name];
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
name = FindIndexName(currentVarPos, block, loopForIndex);
|
|
||||||
if (name == "")
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (loopForIndex.find(name) != loopForIndex.end())
|
|
||||||
currentLoop = loopForIndex[name];
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t start = currentLoop->startVal * currentCoefs.first + currentCoefs.second;
|
|
||||||
uint64_t step = currentCoefs.first;
|
|
||||||
current_dim = { start, step, (uint64_t)currentLoop->calculatedCountOfIters };
|
|
||||||
}
|
|
||||||
|
|
||||||
accessPoint[n - index_vars.size()] = current_dim;
|
|
||||||
index_vars.pop_back();
|
|
||||||
refPos.pop_back();
|
|
||||||
coefsForDims.pop_back();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (operation == SAPFOR::CFG_OP::STORE)
|
|
||||||
def[array_name].Insert(accessPoint);
|
|
||||||
else
|
|
||||||
use[array_name].Insert(accessPoint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SetConnections(unordered_map<SAPFOR::BasicBlock*, Region*>& bbToRegion, const unordered_set<SAPFOR::BasicBlock*>& blockSet)
|
|
||||||
{
|
|
||||||
for (SAPFOR::BasicBlock* block : blockSet)
|
|
||||||
{
|
|
||||||
for (SAPFOR::BasicBlock* nextBlock : block->getNext())
|
|
||||||
if (bbToRegion.find(nextBlock) != bbToRegion.end())
|
|
||||||
bbToRegion[block]->addNextRegion(bbToRegion[nextBlock]);
|
|
||||||
|
|
||||||
for (SAPFOR::BasicBlock* prevBlock : block->getPrev())
|
|
||||||
if (bbToRegion.find(prevBlock) != bbToRegion.end())
|
|
||||||
bbToRegion[block]->addPrevRegion(bbToRegion[prevBlock]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static Region* CreateSubRegion(LoopGraph* loop, const vector<SAPFOR::BasicBlock*>& Blocks, const unordered_map<SAPFOR::BasicBlock*, Region*>& bbToRegion)
|
|
||||||
{
|
|
||||||
Region* region = new Region;
|
|
||||||
auto [header, blockSet] = GetBasicBlocksForLoop(loop, Blocks);
|
|
||||||
if (bbToRegion.find(header) != bbToRegion.end())
|
|
||||||
region->setHeader(bbToRegion.at(header));
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (SAPFOR::BasicBlock* block : blockSet)
|
|
||||||
if (bbToRegion.find(block) != bbToRegion.end())
|
|
||||||
region->addBasickBlocks(bbToRegion.at(block));
|
|
||||||
|
|
||||||
for (LoopGraph* childLoop : loop->children)
|
|
||||||
region->addSubRegions(CreateSubRegion(childLoop, Blocks, bbToRegion));
|
|
||||||
|
|
||||||
return region;
|
|
||||||
}
|
|
||||||
|
|
||||||
Region::Region(LoopGraph* loop, const vector<SAPFOR::BasicBlock*>& Blocks)
|
|
||||||
{
|
|
||||||
auto [header, blockSet] = GetBasicBlocksForLoop(loop, Blocks);
|
|
||||||
unordered_map<SAPFOR::BasicBlock*, Region*> bbToRegion;
|
|
||||||
for (auto poiner : blockSet)
|
|
||||||
{
|
|
||||||
bbToRegion[poiner] = new Region(*poiner);
|
|
||||||
this->basickBlocks.insert(bbToRegion[poiner]);
|
|
||||||
GetDefUseArray(poiner, loop, bbToRegion[poiner]->array_def, bbToRegion[poiner]->array_use);
|
|
||||||
|
|
||||||
}
|
|
||||||
this->header = bbToRegion[header];
|
|
||||||
SetConnections(bbToRegion, blockSet);
|
|
||||||
//create subRegions
|
|
||||||
for (LoopGraph* childLoop : loop->children)
|
|
||||||
subRegions.insert(CreateSubRegion(childLoop, Blocks, bbToRegion));
|
|
||||||
}
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <map>
|
|
||||||
#include <unordered_set>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "graph_loops.h"
|
|
||||||
#include "../CFGraph/CFGraph.h"
|
|
||||||
|
|
||||||
class Region : public SAPFOR::BasicBlock {
|
|
||||||
public:
|
|
||||||
Region() { header = nullptr; }
|
|
||||||
|
|
||||||
Region(SAPFOR::BasicBlock block) : SAPFOR::BasicBlock::BasicBlock(block) { header = nullptr; }
|
|
||||||
|
|
||||||
Region(LoopGraph* loop, const std::vector<SAPFOR::BasicBlock*>& Blocks);
|
|
||||||
|
|
||||||
Region* getHeader() { return header; }
|
|
||||||
|
|
||||||
void setHeader(Region* region) { header = region; }
|
|
||||||
|
|
||||||
std::unordered_set<Region*>& getBasickBlocks() { return basickBlocks; }
|
|
||||||
|
|
||||||
void addBasickBlocks(Region* region) { basickBlocks.insert(region); }
|
|
||||||
|
|
||||||
const std::unordered_set<Region*>& getPrevRegions() { return prevRegions; }
|
|
||||||
|
|
||||||
std::unordered_set<Region*> getNextRegions() { return nextRegions; }
|
|
||||||
|
|
||||||
void addPrevRegion(Region* region) { prevRegions.insert(region); }
|
|
||||||
|
|
||||||
void addNextRegion(Region* region) { nextRegions.insert(region); }
|
|
||||||
|
|
||||||
void replaceInPrevRegions(Region* source, Region* destination)
|
|
||||||
{
|
|
||||||
prevRegions.erase(destination);
|
|
||||||
prevRegions.insert(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
void replaceInNextRegions(Region* source, Region* destination)
|
|
||||||
{
|
|
||||||
nextRegions.erase(destination);
|
|
||||||
nextRegions.insert(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unordered_set<Region*> getSubRegions() { return subRegions; }
|
|
||||||
|
|
||||||
void addSubRegions(Region* region) { subRegions.insert(region); }
|
|
||||||
|
|
||||||
ArrayAccessingIndexes array_def, array_use, array_out, array_in, array_priv;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::unordered_set<Region*> subRegions, basickBlocks;
|
|
||||||
/*next Region which is BB for current BB Region*/
|
|
||||||
std::unordered_set<Region*> nextRegions;
|
|
||||||
/*prev Regions which is BBs for current BB Region*/
|
|
||||||
std::unordered_set<Region*> prevRegions;
|
|
||||||
Region* header;
|
|
||||||
};
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -6,9 +6,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "utils.h"
|
#include "../Utils/utils.h"
|
||||||
|
|
||||||
#include "../VerificationCode/verifications.h"
|
#include "../VerificationCode/verifications.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -7,8 +7,8 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "FileInfo.h"
|
#include "FileInfo.h"
|
||||||
#include "utils.h"
|
#include "../Utils/utils.h"
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -22,8 +22,8 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "../VisualizerCalls/get_information.h"
|
#include "../VisualizerCalls/get_information.h"
|
||||||
#include "../VisualizerCalls/SendMessage.h"
|
#include "../VisualizerCalls/SendMessage.h"
|
||||||
|
|
||||||
@@ -34,7 +34,6 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
extern "C" int parse_file(int argc, char* argv[], char* proj_name);
|
extern "C" int parse_file(int argc, char* argv[], char* proj_name);
|
||||||
extern const char* VISUALIZER_DATA_PATH;
|
|
||||||
|
|
||||||
static void findModuleDeclInProject(const string& name, const vector<string>& files, map<string, string>& modDecls)
|
static void findModuleDeclInProject(const string& name, const vector<string>& files, map<string, string>& modDecls)
|
||||||
{
|
{
|
||||||
@@ -294,8 +293,11 @@ static vector<string> parseList(vector<FileInfo>& listOfProject,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMessage_2lvl(3, file);
|
#ifdef _WIN32
|
||||||
|
sendMessage_2lvl(L" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> '" + to_wstring(file) + L"'");
|
||||||
|
#else
|
||||||
|
sendMessage_2lvl(L" processing file '" + to_wstring(file) + L"'");
|
||||||
|
#endif
|
||||||
StdCapture::Init();
|
StdCapture::Init();
|
||||||
string errorMessage = "";
|
string errorMessage = "";
|
||||||
try
|
try
|
||||||
@@ -385,50 +387,7 @@ static string shiftLines(const string &in, const map<string, const FileInfo*> &m
|
|||||||
return newStr;
|
return newStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addMessage(const string& in, const map<string, const FileInfo*>& mapOfFiles,
|
static int dumpErrors(const vector<FileInfo>& listOfProject, const vector<string>& errors)
|
||||||
const FileInfo* currF, map<string, vector<Messages>>& messages, typeMessage type)
|
|
||||||
{
|
|
||||||
int byNum = 0;
|
|
||||||
|
|
||||||
auto it = in.find("on line ");
|
|
||||||
if (it != string::npos)
|
|
||||||
it += strlen("on line ");
|
|
||||||
|
|
||||||
int line = 0;
|
|
||||||
sscanf(in.c_str() + it, "%d", &line);
|
|
||||||
|
|
||||||
auto it1 = in.find("of", it + 1);
|
|
||||||
if (it1 == string::npos)
|
|
||||||
return;
|
|
||||||
it1 += 3;
|
|
||||||
|
|
||||||
string fileN = in.substr(it1, in.find(':', it1) - it1);
|
|
||||||
auto itF = mapOfFiles.find(fileN);
|
|
||||||
if (itF != mapOfFiles.end() && itF->second != currF)
|
|
||||||
{
|
|
||||||
byNum = itF->second->includesAdded;
|
|
||||||
if (byNum != 0)
|
|
||||||
{
|
|
||||||
if (line - byNum <= 0)
|
|
||||||
{
|
|
||||||
//return in;
|
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
line -= byNum;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const string newStr = in.substr(0, it) + std::to_string(line) + in.substr(in.find(' ', it + 1));
|
|
||||||
|
|
||||||
wstring messageE, messageR;
|
|
||||||
__spf_printToLongBuf(messageE, L"%s", to_wstring(newStr).c_str());
|
|
||||||
__spf_printToLongBuf(messageR, L"%s", to_wstring(newStr).c_str());
|
|
||||||
|
|
||||||
messages[fileN].push_back(Messages(type, line, messageR, messageE, 6000));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dumpErrors(const vector<FileInfo>& listOfProject, const vector<string>& errors, map<string, vector<Messages>>& messages)
|
|
||||||
{
|
{
|
||||||
int errorsCount = 0;
|
int errorsCount = 0;
|
||||||
map<string, const FileInfo*> mapOfFiles;
|
map<string, const FileInfo*> mapOfFiles;
|
||||||
@@ -441,46 +400,41 @@ static int dumpErrors(const vector<FileInfo>& listOfProject, const vector<string
|
|||||||
if (errors[z] == "")
|
if (errors[z] == "")
|
||||||
{
|
{
|
||||||
FILE* ferr = fopen(file.errPath.c_str(), "w");
|
FILE* ferr = fopen(file.errPath.c_str(), "w");
|
||||||
if (ferr)
|
if (!ferr)
|
||||||
fclose(ferr);
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
fclose(ferr);
|
||||||
++z;
|
++z;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FILE* ferr = fopen(file.errPath.c_str(), "w");
|
||||||
|
FILE* fout = fopen(file.outPath.c_str(), "w");
|
||||||
|
if (!ferr)
|
||||||
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
if (!fout)
|
||||||
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|
||||||
string errS = "", outS = "";
|
string errS = "", outS = "";
|
||||||
vector<string> splited;
|
vector<string> splited;
|
||||||
splitString(errors[z], '\n', splited);
|
splitString(errors[z], '\n', splited);
|
||||||
for (auto& elem : splited)
|
for (auto& elem : splited)
|
||||||
{
|
{
|
||||||
if (elem.find("Warning 308") != string::npos)
|
if (elem.find("Warning 308") != string::npos)
|
||||||
{
|
|
||||||
addMessage(elem, mapOfFiles, &file, messages, WARR);
|
|
||||||
outS += shiftLines(elem, mapOfFiles, &file) + "\n";
|
outS += shiftLines(elem, mapOfFiles, &file) + "\n";
|
||||||
}
|
|
||||||
else if (elem.find("Error") != string::npos)
|
else if (elem.find("Error") != string::npos)
|
||||||
{
|
{
|
||||||
addMessage(elem, mapOfFiles, &file, messages, ERROR);
|
|
||||||
errS += shiftLines(elem, mapOfFiles, &file) + "\n";
|
errS += shiftLines(elem, mapOfFiles, &file) + "\n";
|
||||||
errorsCount++;
|
errorsCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fprintf(fout, "%s", outS.c_str());
|
||||||
FILE* ferr = fopen(file.errPath.c_str(), "w");
|
fprintf(ferr, "%s", errS.c_str());
|
||||||
FILE* fout = fopen(file.outPath.c_str(), "w");
|
|
||||||
if (ferr)
|
|
||||||
{
|
|
||||||
fprintf(ferr, "%s", errS.c_str());
|
|
||||||
fclose(ferr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fout)
|
|
||||||
{
|
|
||||||
fprintf(fout, "%s", outS.c_str());
|
|
||||||
fclose(fout);
|
|
||||||
}
|
|
||||||
|
|
||||||
fflush(NULL);
|
fflush(NULL);
|
||||||
|
|
||||||
|
fclose(fout);
|
||||||
|
fclose(ferr);
|
||||||
++z;
|
++z;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -575,8 +529,11 @@ static void parseFiles(int& iters, vector<string>& errors, vector<FileInfo>& lis
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
sendMessage_1lvl(0, iters + 1);
|
#ifdef _WIN32
|
||||||
|
sendMessage_1lvl(L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> " + std::to_wstring((iters + 1)) + L" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||||
|
#else
|
||||||
|
sendMessage_1lvl(L"running " + std::to_wstring((iters + 1)) + L" iteration of syntax analisys");
|
||||||
|
#endif
|
||||||
errors = parseList(listOfProject, iters != 0, parseForInlining, mapModuleDeps, moduleDelc, modDirectOrder, isFromConsole);
|
errors = parseList(listOfProject, iters != 0, parseForInlining, mapModuleDeps, moduleDelc, modDirectOrder, isFromConsole);
|
||||||
changed = createMapOfUse(errors, listOfProject, mapModuleDeps);
|
changed = createMapOfUse(errors, listOfProject, mapModuleDeps);
|
||||||
if (iters != 0)
|
if (iters != 0)
|
||||||
@@ -695,7 +652,7 @@ static int parseFiles(vector<string>& errors, vector<FileInfo>& listOfProject, v
|
|||||||
return rethrow;
|
return rethrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int parseForInlining, map<string, vector<Messages>>& messages)
|
int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int parseForInlining)
|
||||||
{
|
{
|
||||||
FILE* list = fopen(proj, "r");
|
FILE* list = fopen(proj, "r");
|
||||||
if (!list)
|
if (!list)
|
||||||
@@ -709,7 +666,7 @@ int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int pars
|
|||||||
|
|
||||||
if (pathSplit.size() < 2)
|
if (pathSplit.size() < 2)
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
if (pathSplit[pathSplit.size() - 2] != VISUALIZER_DATA_PATH)
|
if (pathSplit[pathSplit.size() - 2] != "visualiser_data")
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
string fullPath = "";
|
string fullPath = "";
|
||||||
for (int z = 0; z < pathSplit.size() - 2; ++z)
|
for (int z = 0; z < pathSplit.size() - 2; ++z)
|
||||||
@@ -741,9 +698,9 @@ int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int pars
|
|||||||
else
|
else
|
||||||
fileNameFixed = (toAdd.substr(0, 2) == "./") ? toAdd.substr(2) : toAdd;
|
fileNameFixed = (toAdd.substr(0, 2) == "./") ? toAdd.substr(2) : toAdd;
|
||||||
|
|
||||||
const string optPath = fullPath + VISUALIZER_DATA_PATH + "/options/" + fileNameFixed + ".opt";
|
const string optPath = fullPath + "visualiser_data/options/" + fileNameFixed + ".opt";
|
||||||
const string errPath = fullPath + VISUALIZER_DATA_PATH + "/options/" + fileNameFixed + ".err";
|
const string errPath = fullPath + "visualiser_data/options/" + fileNameFixed + ".err";
|
||||||
const string outPath = fullPath + VISUALIZER_DATA_PATH + "/options/" + fileNameFixed + ".out";
|
const string outPath = fullPath + "visualiser_data/options/" + fileNameFixed + ".out";
|
||||||
|
|
||||||
const string fileText = readFileToStr(toAdd);
|
const string fileText = readFileToStr(toAdd);
|
||||||
|
|
||||||
@@ -766,7 +723,7 @@ int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int pars
|
|||||||
vector<string> errors;
|
vector<string> errors;
|
||||||
|
|
||||||
int rethrow = parseFiles(errors, listOfProject, filesCompilationOrder, parseForInlining);
|
int rethrow = parseFiles(errors, listOfProject, filesCompilationOrder, parseForInlining);
|
||||||
int errCount = dumpErrors(listOfProject, errors, messages);
|
int errCount = dumpErrors(listOfProject, errors);
|
||||||
|
|
||||||
if (rethrow != 0)
|
if (rethrow != 0)
|
||||||
throw rethrow;
|
throw rethrow;
|
||||||
@@ -775,8 +732,6 @@ int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int pars
|
|||||||
|
|
||||||
void parseFiles(int argc, char** argv)
|
void parseFiles(int argc, char** argv)
|
||||||
{
|
{
|
||||||
map<string, vector<Messages>> messages;
|
|
||||||
|
|
||||||
bool isInline = false;
|
bool isInline = false;
|
||||||
auto result = splitCommandLineForParse(argv, argc, isInline);
|
auto result = splitCommandLineForParse(argv, argc, isInline);
|
||||||
if (result.second.size() == 0)
|
if (result.second.size() == 0)
|
||||||
@@ -805,8 +760,6 @@ void parseFiles(int argc, char** argv)
|
|||||||
printf(" run parsing for inlining\n");
|
printf(" run parsing for inlining\n");
|
||||||
|
|
||||||
int rethrow = parseFiles(errors, listOfProject, filesCompilationOrder, isInline, true);
|
int rethrow = parseFiles(errors, listOfProject, filesCompilationOrder, isInline, true);
|
||||||
int errCount = dumpErrors(listOfProject, errors, messages);
|
|
||||||
|
|
||||||
if (rethrow == 0)
|
if (rethrow == 0)
|
||||||
{
|
{
|
||||||
for (auto& err : errors)
|
for (auto& err : errors)
|
||||||
@@ -836,7 +789,5 @@ void parseFiles(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
printf("Parsing was completed with errors, throw code %d, errors count %d\n", rethrow, code);
|
printf("Parsing was completed with errors, throw code %d, errors count %d\n", rethrow, code);
|
||||||
|
|
||||||
dumpMessages(false, messages, VISUALIZER_DATA_PATH);
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user