Compare commits
11 Commits
private_ar
...
ca5174f447
| Author | SHA1 | Date | |
|---|---|---|---|
| ca5174f447 | |||
|
|
18b2666c0e | ||
|
|
edc19e4e9b | ||
|
|
6a50d83b33 | ||
|
|
caf4d8da0d | ||
|
|
adbd9c64e8 | ||
|
|
703f21405d | ||
|
|
9fe2f0fe25 | ||
|
|
2edc10f7dc | ||
|
|
7f131d577e | ||
|
|
3ab6eb50f5 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -78,3 +78,4 @@ Sapfor/Sapc++/x64/
|
|||||||
|
|
||||||
Sapfor/out/
|
Sapfor/out/
|
||||||
Sapfor/_bin/*
|
Sapfor/_bin/*
|
||||||
|
_bin/*
|
||||||
|
|||||||
119
CMakeLists.txt
119
CMakeLists.txt
@@ -12,7 +12,6 @@ add_definitions("-D SYS5")
|
|||||||
add_definitions("-D YYDEBUG")
|
add_definitions("-D YYDEBUG")
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_C_STANDARD 17)
|
|
||||||
|
|
||||||
set(fdvm_include projects/dvm/fdvmh/include/fdvmh/)
|
set(fdvm_include projects/dvm/fdvmh/include/fdvmh/)
|
||||||
set(fdvm_sources projects/dvm/fdvmh/tools/fdvmh/)
|
set(fdvm_sources projects/dvm/fdvmh/tools/fdvmh/)
|
||||||
@@ -28,14 +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)
|
|
||||||
include_directories(src/Transformations)
|
|
||||||
|
|
||||||
#Sage lib includes
|
#Sage lib includes
|
||||||
include_directories(${fdvm_include})
|
include_directories(${fdvm_include})
|
||||||
include_directories(${sage_include_1})
|
include_directories(${sage_include_1})
|
||||||
@@ -163,47 +154,42 @@ 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
|
SET(TR_SWAP_OPERATORS src/Transformations/SwapOperators/swap_operators.cpp
|
||||||
src/Transformations/ExpressionSubstitution/expr_transform.cpp
|
src/Transformations/SwapOperators/swap_operators.h)
|
||||||
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}
|
||||||
@@ -224,14 +210,10 @@ set(TRANSFORMS
|
|||||||
${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_SWAP_OPERATORS})
|
||||||
${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
|
||||||
@@ -309,6 +291,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
|
||||||
@@ -320,11 +306,18 @@ 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)
|
||||||
|
|
||||||
|
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
|
||||||
src/SapforData.h
|
src/SapforData.h
|
||||||
@@ -414,9 +407,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 +436,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,17 +444,18 @@ 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})
|
||||||
source_group (Transformations\\ReplaceArraysInIO FILES ${TR_REPLACE_ARRAYS_IN_IO})
|
source_group (Transformations\\ReplaceArraysInIO FILES ${TR_REPLACE_ARRAYS_IN_IO})
|
||||||
|
source_group (Transformations\\SwapOperators FILES ${TR_SWAP_OPERATORS})
|
||||||
|
|
||||||
|
|
||||||
source_group (CreateIntervals FILES ${CREATE_INTER_T})
|
source_group (CreateIntervals FILES ${CREATE_INTER_T})
|
||||||
@@ -487,7 +484,7 @@ source_group (Predictor\\Library FILES ${LIBPREDICTOR})
|
|||||||
source_group (Parser FILES ${PARSER})
|
source_group (Parser FILES ${PARSER})
|
||||||
source_group (PPPA\\PPPA FILES ${PPPA})
|
source_group (PPPA\\PPPA FILES ${PPPA})
|
||||||
source_group (PPPA\\ZLib FILES ${ZLIB})
|
source_group (PPPA\\ZLib FILES ${ZLIB})
|
||||||
|
|
||||||
if (MSVC_IDE)
|
if (MSVC_IDE)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /Zc:__cplusplus")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /Zc:__cplusplus")
|
||||||
else()
|
else()
|
||||||
@@ -496,9 +493,7 @@ else()
|
|||||||
else()
|
else()
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||||
endif()
|
endif()
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(projects/Fdvm)
|
add_subdirectory(projects/Fdvm)
|
||||||
|
|||||||
Submodule projects/dvm updated: 4d4041a081...3a567d7582
@@ -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"
|
||||||
@@ -1149,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1239,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,7 +6,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "IR.h"
|
#include "IR.h"
|
||||||
#include "IR_domTree.h"
|
|
||||||
|
|
||||||
namespace SAPFOR
|
namespace SAPFOR
|
||||||
{
|
{
|
||||||
@@ -25,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;
|
||||||
|
|
||||||
@@ -35,7 +34,6 @@ 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);
|
||||||
@@ -44,7 +42,6 @@ namespace SAPFOR
|
|||||||
void addInstruction(IR_Block* item);
|
void addInstruction(IR_Block* item);
|
||||||
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);
|
||||||
@@ -72,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
|
||||||
*/
|
*/
|
||||||
@@ -112,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)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -155,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"
|
||||||
|
|||||||
@@ -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
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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 "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 "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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,21 +1,21 @@
|
|||||||
#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"
|
||||||
|
|
||||||
#include "shadow.h"
|
#include "shadow.h"
|
||||||
#include "dvm.h"
|
#include "dvm.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,9 @@
|
|||||||
#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"
|
#include "../Utils/json.hpp"
|
||||||
|
|
||||||
class Symbol;
|
class Symbol;
|
||||||
class Expression;
|
class Expression;
|
||||||
|
|||||||
@@ -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"
|
||||||
@@ -241,15 +241,13 @@ static void findArrayRefs (SgExpression* ex, SgStatement* st, string fName, int
|
|||||||
itNew->second.first->SetRegionPlace(reg);
|
itNew->second.first->SetRegionPlace(reg);
|
||||||
|
|
||||||
const auto oldVal = itNew->second.first->GetDistributeFlagVal();
|
const auto oldVal = itNew->second.first->GetDistributeFlagVal();
|
||||||
bool isArrayInModule = (itNew->second.first->GetLocation().first == DIST::l_MODULE);
|
bool isarrayInModule = (itNew->second.first->GetLocation().first == DIST::l_MODULE);
|
||||||
|
|
||||||
if (oldVal == DIST::DISTR || oldVal == DIST::NO_DISTR)
|
if (oldVal == DIST::DISTR || oldVal == DIST::NO_DISTR)
|
||||||
{
|
{
|
||||||
if (itNew->second.first->IsOmpThreadPrivate())
|
if (itNew->second.first->IsOmpThreadPrivate())
|
||||||
itNew->second.first->SetDistributeFlag(DIST::SPF_PRIV);
|
itNew->second.first->SetDistributeFlag(DIST::SPF_PRIV);
|
||||||
else if (deprecatedByIO.find(symb->identifier()) != deprecatedByIO.end())
|
else if (privates.find(symb->identifier()) != privates.end() || isarrayInModule)
|
||||||
itNew->second.first->SetDistributeFlag(DIST::IO_PRIV);
|
|
||||||
else if (isArrayInModule || privates.find(symb->identifier()) != privates.end())
|
|
||||||
{
|
{
|
||||||
//check in module
|
//check in module
|
||||||
if (itNew->second.first->GetLocation().first == DIST::l_MODULE)
|
if (itNew->second.first->GetLocation().first == DIST::l_MODULE)
|
||||||
@@ -276,6 +274,8 @@ static void findArrayRefs (SgExpression* ex, SgStatement* st, string fName, int
|
|||||||
else
|
else
|
||||||
itNew->second.first->SetDistributeFlag(DIST::SPF_PRIV);
|
itNew->second.first->SetDistributeFlag(DIST::SPF_PRIV);
|
||||||
}
|
}
|
||||||
|
else if (deprecatedByIO.find(symb->identifier()) != deprecatedByIO.end())
|
||||||
|
itNew->second.first->SetDistributeFlag(DIST::IO_PRIV);
|
||||||
else if (isSgConstantSymb(symb) || inDataStat)
|
else if (isSgConstantSymb(symb) || inDataStat)
|
||||||
itNew->second.first->SetDistributeFlag(DIST::SPF_PRIV);
|
itNew->second.first->SetDistributeFlag(DIST::SPF_PRIV);
|
||||||
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>
|
||||||
@@ -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"
|
||||||
|
|
||||||
@@ -346,7 +346,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,11 @@
|
|||||||
#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 "../Utils/json.hpp"
|
||||||
|
|
||||||
#include "graph_calls_func.h"
|
#include "../GraphCall/graph_calls_func.h"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::tuple;
|
using std::tuple;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "json.hpp"
|
#include "../Utils/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;
|
||||||
|
|||||||
@@ -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,9 +11,9 @@
|
|||||||
#include "DvmhRegionInserter.h"
|
#include "DvmhRegionInserter.h"
|
||||||
#include "DvmhRegions/RegionsMerger.h"
|
#include "DvmhRegions/RegionsMerger.h"
|
||||||
#include "../VerificationCode/verifications.h"
|
#include "../VerificationCode/verifications.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"
|
||||||
#include "FunctionPurifying/function_purifying.h"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -794,6 +794,154 @@ ArraySet DvmhRegionInserter::get_used_arrs_for_block(SgStatement* st, int usage_
|
|||||||
return usages;
|
return usages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool filterFromList(SgStatement* st, const set<string>& idents, bool exclude = false)
|
||||||
|
{
|
||||||
|
bool empty = false;
|
||||||
|
SgExpression* list = st->expr(0);
|
||||||
|
vector<SgExpression*> newList;
|
||||||
|
|
||||||
|
int total = 0;
|
||||||
|
while (list)
|
||||||
|
{
|
||||||
|
if (exclude)
|
||||||
|
{
|
||||||
|
if (idents.find(list->lhs()->symbol()->identifier()) == idents.end())
|
||||||
|
newList.push_back(list->lhs());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (idents.find(list->lhs()->symbol()->identifier()) != idents.end())
|
||||||
|
newList.push_back(list->lhs());
|
||||||
|
}
|
||||||
|
total++;
|
||||||
|
list = list->rhs();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newList.size() == 0)
|
||||||
|
empty = true;
|
||||||
|
else if (total != newList.size())
|
||||||
|
st->setExpression(0, makeExprList(newList));
|
||||||
|
|
||||||
|
return empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
static string getInterfaceBlock(SgStatement* func, const FuncParam& pars)
|
||||||
|
{
|
||||||
|
string oldFile = current_file->filename();
|
||||||
|
if (!func->switchToFile())
|
||||||
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|
||||||
|
auto copy = duplicateProcedure(func, NULL, false, false, false, true);
|
||||||
|
const set<string> idents(pars.identificators.begin(), pars.identificators.end());
|
||||||
|
|
||||||
|
bool need = (func->symbol()->identifier() == string("bl182"));
|
||||||
|
|
||||||
|
//remove all exec
|
||||||
|
SgStatement* st = copy->lexNext();
|
||||||
|
SgStatement* last = copy->lastNodeOfStmt();
|
||||||
|
vector<SgStatement*> toExtract;
|
||||||
|
|
||||||
|
while (st != last)
|
||||||
|
{
|
||||||
|
if (isDVM_stat(st) || isSPF_stat(st))
|
||||||
|
{
|
||||||
|
if (st->variant() != ACC_ROUTINE_DIR)
|
||||||
|
{
|
||||||
|
toExtract.push_back(st);
|
||||||
|
st = st->lexNext();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
st = st->lexNext();
|
||||||
|
}
|
||||||
|
else if (isSgExecutableStatement(st))
|
||||||
|
{
|
||||||
|
SgStatement* next = st->lastNodeOfStmt();
|
||||||
|
if (next != last)
|
||||||
|
next = next->lexNext();
|
||||||
|
toExtract.push_back(st);
|
||||||
|
st = next;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
st = st->lexNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
//remove unused declarations
|
||||||
|
st = copy->lexNext();
|
||||||
|
while (st != last)
|
||||||
|
{
|
||||||
|
const int var = st->variant();
|
||||||
|
|
||||||
|
if (var == VAR_DECL
|
||||||
|
|| var == VAR_DECL_90
|
||||||
|
|| var == DIM_STAT
|
||||||
|
|| var == INTENT_STMT
|
||||||
|
|| var == EXTERN_STAT)
|
||||||
|
{
|
||||||
|
bool empty = filterFromList(st, idents);
|
||||||
|
if (empty)
|
||||||
|
{
|
||||||
|
toExtract.push_back(st);
|
||||||
|
st = st->lexNext();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!isDVM_stat(st) && !isSPF_stat(st))
|
||||||
|
toExtract.push_back(st);
|
||||||
|
|
||||||
|
if (st->variant() == CONTAINS_STMT)
|
||||||
|
break;
|
||||||
|
st = st->lexNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& elem : toExtract)
|
||||||
|
elem->extractStmt();
|
||||||
|
|
||||||
|
string retVal = copy->unparse();
|
||||||
|
|
||||||
|
if (SgFile::switchToFile(oldFile) == -1)
|
||||||
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void insertInterface(SgStatement* func, const string& iface, const string& fName)
|
||||||
|
{
|
||||||
|
string oldFile = current_file->filename();
|
||||||
|
if (!func->switchToFile())
|
||||||
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|
||||||
|
SgStatement* st = func->lexNext();
|
||||||
|
SgStatement* last = func->lastNodeOfStmt();
|
||||||
|
while (st != last)
|
||||||
|
{
|
||||||
|
if (st->variant() == VAR_DECL || st->variant() == VAR_DECL_90)
|
||||||
|
{
|
||||||
|
bool empty = filterFromList(st, { fName }, true);
|
||||||
|
if (empty)
|
||||||
|
{
|
||||||
|
SgStatement* next = st->lexNext();
|
||||||
|
st->extractStmt();
|
||||||
|
st = next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSgExecutableStatement(st))
|
||||||
|
break;
|
||||||
|
st = st->lexNext();
|
||||||
|
}
|
||||||
|
SgStatement* ifaceBlock = new SgStatement(INTERFACE_STMT);
|
||||||
|
addControlEndToStmt(ifaceBlock->thebif);
|
||||||
|
|
||||||
|
ifaceBlock->setlineNumber(getNextNegativeLineNumber()); // st->lineNumber()
|
||||||
|
ifaceBlock->setFileName(st->fileName());
|
||||||
|
st->insertStmtBefore(*ifaceBlock, *st->controlParent());
|
||||||
|
ifaceBlock->lastNodeOfStmt()->addComment(iface.c_str());
|
||||||
|
|
||||||
|
if (SgFile::switchToFile(oldFile) == -1)
|
||||||
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
}
|
||||||
|
|
||||||
static LoopGraph* getParallelLoop(LoopGraph* loop)
|
static LoopGraph* getParallelLoop(LoopGraph* loop)
|
||||||
{
|
{
|
||||||
auto prev_st = loop->loop->lexPrev();
|
auto prev_st = loop->loop->lexPrev();
|
||||||
@@ -1024,7 +1172,7 @@ static bool isPure(SgStatement* func)
|
|||||||
|
|
||||||
void DvmhRegionInserter::createInterfaceBlockForOutCall(FuncInfo* func, FuncInfo* callFrom)
|
void DvmhRegionInserter::createInterfaceBlockForOutCall(FuncInfo* func, FuncInfo* callFrom)
|
||||||
{
|
{
|
||||||
insertInterface(func->funcPointer, callFrom);
|
insertInterface(func->funcPointer, getInterfaceBlock(callFrom->funcPointer->GetOriginal(), callFrom->funcParams), callFrom->funcName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DvmhRegionInserter::createInterfaceBlockForParallelFunctions(bool onlyRoutine)
|
void DvmhRegionInserter::createInterfaceBlockForParallelFunctions(bool onlyRoutine)
|
||||||
@@ -1297,10 +1445,7 @@ static set<DIST::Array*>
|
|||||||
{
|
{
|
||||||
declStat = SgStatement::getStatementByFileAndLine(decl.first, decl.second);
|
declStat = SgStatement::getStatementByFileAndLine(decl.first, decl.second);
|
||||||
if (declStat == NULL) // check in inlcudes
|
if (declStat == NULL) // check in inlcudes
|
||||||
{
|
{
|
||||||
if (!main->switchToFile())
|
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
|
||||||
|
|
||||||
for (auto st = main; st != main->lastNodeOfStmt() && !declStat; st = st->lexNext())
|
for (auto st = main; st != main->lastNodeOfStmt() && !declStat; st = st->lexNext())
|
||||||
{
|
{
|
||||||
if (st->fileName() == decl.first && st->lineNumber() == decl.second)
|
if (st->fileName() == decl.first && st->lineNumber() == decl.second)
|
||||||
@@ -1312,7 +1457,7 @@ static set<DIST::Array*>
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
declStat = getFuncStat(declStat, { BLOCK_DATA });
|
declStat = getFuncStat(declStat);
|
||||||
if (declStat != main)
|
if (declStat != main)
|
||||||
{
|
{
|
||||||
declStat = NULL;
|
declStat = NULL;
|
||||||
|
|||||||
@@ -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"
|
||||||
@@ -440,18 +440,15 @@ bool replaceConstantRec(SgExpression *&exp)
|
|||||||
if (exp->variant() == CONST_REF)
|
if (exp->variant() == CONST_REF)
|
||||||
{
|
{
|
||||||
SgExpression *ret = ReplaceParameter_(exp);
|
SgExpression *ret = ReplaceParameter_(exp);
|
||||||
|
|
||||||
int sign = 1;
|
int sign = 1;
|
||||||
SgExpression* toCalc = ret;
|
SgExpression* toCalc = ret;
|
||||||
if (toCalc->variant() == UNARY_ADD_OP)
|
if (ret->variant() == UNARY_ADD_OP)
|
||||||
toCalc = toCalc->lhs();
|
toCalc = ret->lhs();
|
||||||
|
if (ret->variant() == MINUS_OP)
|
||||||
if (toCalc->variant() == MINUS_OP)
|
|
||||||
{
|
{
|
||||||
toCalc = toCalc->lhs();
|
toCalc = ret->lhs();
|
||||||
sign = -1;
|
sign = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toCalc->isInteger())
|
if (toCalc->isInteger())
|
||||||
{
|
{
|
||||||
exp = new SgValueExp(sign * toCalc->valueInteger());
|
exp = new SgValueExp(sign * toCalc->valueInteger());
|
||||||
@@ -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>
|
||||||
@@ -14,14 +14,14 @@
|
|||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#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"
|
||||||
|
|
||||||
@@ -779,20 +779,6 @@ static void checkSpecList(SgExpression *spec, FuncInfo* currF, const map<string,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void checkInTypeDescription(SgExpression *ex, FuncInfo* currF, const map<string, int>& parNames)
|
|
||||||
{
|
|
||||||
if (ex)
|
|
||||||
{
|
|
||||||
if (ex->variant() == ARRAY_REF)
|
|
||||||
fillIn(currF, ex->lhs(), parNames, false);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
checkInTypeDescription(ex->lhs(), currF, parNames);
|
|
||||||
checkInTypeDescription(ex->rhs(), currF, parNames);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void fillInOut(FuncInfo *currF, SgStatement *start, SgStatement *last, const set<SgStatement*>& activeOps)
|
static void fillInOut(FuncInfo *currF, SgStatement *start, SgStatement *last, const set<SgStatement*>& activeOps)
|
||||||
{
|
{
|
||||||
if (currF->funcParams.countOfPars == 0)
|
if (currF->funcParams.countOfPars == 0)
|
||||||
@@ -812,13 +798,8 @@ static void fillInOut(FuncInfo *currF, SgStatement *start, SgStatement *last, co
|
|||||||
|
|
||||||
if (st->variant() == ENTRY_STAT)
|
if (st->variant() == ENTRY_STAT)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (isSgExecutableStatement(st) == NULL) {
|
|
||||||
checkInTypeDescription(st->expr(0), currF, parNames);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (st->lineNumber() <= 0)
|
if (isSgExecutableStatement(st) == NULL || st->lineNumber() <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (activeOps.size() && activeOps.find(st) == activeOps.end())
|
if (activeOps.size() && activeOps.find(st) == activeOps.end())
|
||||||
|
|||||||
@@ -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 "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"
|
||||||
|
|||||||
@@ -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 "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"обработка функции '") + wstring(fName.begin(), fName.end()) + L"'");
|
||||||
|
else
|
||||||
|
sendMessage_2lvl(wstring(L"обработка модуля '") + 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;
|
||||||
@@ -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"обработка цикла ") + 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;
|
||||||
|
|||||||
@@ -9,12 +9,12 @@
|
|||||||
#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"
|
#include "../Utils/json.hpp"
|
||||||
|
|
||||||
#if __SPF
|
#if __SPF
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct ParallelRegionLines
|
struct ParallelRegionLines
|
||||||
|
|||||||
@@ -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 "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,13 +16,13 @@
|
|||||||
#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"
|
||||||
|
|
||||||
#include "json.hpp"
|
#include "json.hpp"
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#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"
|
#include "../Utils/json.hpp"
|
||||||
|
|
||||||
class ParallelStats
|
class ParallelStats
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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,10 +9,10 @@
|
|||||||
#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"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -9,13 +9,13 @@
|
|||||||
#include "private_arrays_search.h"
|
#include "private_arrays_search.h"
|
||||||
#include "range_structures.h"
|
#include "range_structures.h"
|
||||||
#include "region.h"
|
#include "region.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "graph_loops.h"
|
#include "../GraphLoop/graph_loops.h"
|
||||||
#include "CFGraph/CFGraph.h"
|
#include "../CFGraph/CFGraph.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
static void Collapse(Region* region)
|
void Collapse(Region* region)
|
||||||
{
|
{
|
||||||
if (region->getBasickBlocks().empty())
|
if (region->getBasickBlocks().empty())
|
||||||
return;
|
return;
|
||||||
@@ -124,30 +124,16 @@ static void SolveDataFlow(Region* DFG)
|
|||||||
map<LoopGraph*, ArrayAccessingIndexes> FindPrivateArrays(map<string, vector<LoopGraph*>> &loopGraph, map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR)
|
map<LoopGraph*, ArrayAccessingIndexes> FindPrivateArrays(map<string, vector<LoopGraph*>> &loopGraph, map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR)
|
||||||
{
|
{
|
||||||
map<LoopGraph*, ArrayAccessingIndexes> result;
|
map<LoopGraph*, ArrayAccessingIndexes> result;
|
||||||
for (const auto& [fileName, loops] : loopGraph)
|
for (const auto& [loopName, loops] : loopGraph)
|
||||||
{
|
{
|
||||||
SgFile::switchToFile(fileName);
|
|
||||||
for (const auto& loop : loops)
|
for (const auto& loop : loops)
|
||||||
{
|
{
|
||||||
SgStatement* search_func = loop->loop->GetOriginal();
|
|
||||||
|
|
||||||
while (search_func && (!isSgProgHedrStmt(search_func)))
|
|
||||||
search_func = search_func->controlParent();
|
|
||||||
|
|
||||||
for (const auto& [funcInfo, blocks]: FullIR)
|
for (const auto& [funcInfo, blocks]: FullIR)
|
||||||
{
|
{
|
||||||
if (funcInfo->fileName == fileName && funcInfo->funcPointer->GetOriginal() == search_func)
|
Region* loopRegion = new Region(loop, blocks);
|
||||||
{
|
SolveDataFlow(loopRegion);
|
||||||
Region* loopRegion = new Region(loop, blocks);
|
result[loop] = loopRegion->array_priv;
|
||||||
if (loopRegion->getBasickBlocks().size() <= 1)
|
delete(loopRegion);
|
||||||
{
|
|
||||||
delete(loopRegion);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
SolveDataFlow(loopRegion);
|
|
||||||
result[loop] = loopRegion->array_priv;
|
|
||||||
delete(loopRegion);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,10 @@
|
|||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
#include "range_structures.h"
|
#include "range_structures.h"
|
||||||
#include "graph_loops.h"
|
#include "region.h"
|
||||||
#include "CFGraph/CFGraph.h"
|
#include "../GraphLoop/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::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);
|
std::pair<SAPFOR::BasicBlock*, std::unordered_set<SAPFOR::BasicBlock*>> GetBasicBlocksForLoop(const LoopGraph* loop, const std::vector<SAPFOR::BasicBlock*> blocks);
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <numeric>
|
||||||
|
|
||||||
#include "utils.h"
|
|
||||||
#include "range_structures.h"
|
#include "range_structures.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include "range_structures.h"
|
#include "range_structures.h"
|
||||||
#include "region.h"
|
#include "region.h"
|
||||||
|
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ pair<SAPFOR::BasicBlock*, unordered_set<SAPFOR::BasicBlock*>> GetBasicBlocksForL
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void BuildLoopIndex(map<string, LoopGraph*>& loopForIndex, LoopGraph* loop) {
|
static void BuildLoopIndex(map<string, LoopGraph*>& loopForIndex, LoopGraph* loop) {
|
||||||
string index = loop->loopSymbol();
|
string index = loop->loopSymbol;
|
||||||
loopForIndex[index] = loop;
|
loopForIndex[index] = loop;
|
||||||
|
|
||||||
for (const auto& childLoop : loop->children)
|
for (const auto& childLoop : loop->children)
|
||||||
@@ -146,7 +146,7 @@ static int GetDefUseArray(SAPFOR::BasicBlock* block, LoopGraph* loop, ArrayAcces
|
|||||||
{
|
{
|
||||||
auto var = index_vars.back();
|
auto var = index_vars.back();
|
||||||
int currentVarPos = refPos.back();
|
int currentVarPos = refPos.back();
|
||||||
pair<int, int> currentCoefs = coefsForDims.back();
|
pair currentCoefs = coefsForDims.back();
|
||||||
ArrayDimension current_dim;
|
ArrayDimension current_dim;
|
||||||
if (var->getType() == SAPFOR::CFG_ARG_TYPE::CONST)
|
if (var->getType() == SAPFOR::CFG_ARG_TYPE::CONST)
|
||||||
current_dim = { stoul(var->getValue()), 1, 1 };
|
current_dim = { stoul(var->getValue()), 1, 1 };
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "graph_loops.h"
|
#include "../GraphLoop/graph_loops.h"
|
||||||
#include "CFGraph/CFGraph.h"
|
#include "../CFGraph/CFGraph.h"
|
||||||
|
|
||||||
class Region : public SAPFOR::BasicBlock {
|
class Region : public SAPFOR::BasicBlock {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|
||||||
@@ -403,7 +403,7 @@ static int convertFile(int argc, char* argv[], const set<string>& filesInProj, c
|
|||||||
fprintf(stderr, "<<<<< Unparsing %s >>>>>\n", fout_name);
|
fprintf(stderr, "<<<<< Unparsing %s >>>>>\n", fout_name);
|
||||||
|
|
||||||
if (mod_gpu) /*ACC*/
|
if (mod_gpu) /*ACC*/
|
||||||
UnparseTo_CufAndCu_Files(file, fout_cuf, fout_C_cu, fout_info, fout_name);
|
UnparseTo_CufAndCu_Files(file, fout_cuf, fout_C_cu, fout_info);
|
||||||
|
|
||||||
const string fileN = file->filename();
|
const string fileN = file->filename();
|
||||||
set<SgStatement*> toRemove;
|
set<SgStatement*> toRemove;
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -441,12 +443,20 @@ 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);
|
||||||
@@ -465,22 +475,13 @@ static int dumpErrors(const vector<FileInfo>& listOfProject, const vector<string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 +576,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)
|
||||||
@@ -709,7 +713,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 +745,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);
|
||||||
|
|
||||||
@@ -805,8 +809,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 +838,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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -6,8 +6,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
|
|
||||||
#include "StdCapture.h"
|
#include "StdCapture.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,443 +1,33 @@
|
|||||||
#include "leak_detector.h"
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <cstring>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
#include "CFGraph/CFGraph.h"
|
|
||||||
#include "CFGraph/IR.h"
|
|
||||||
#include "Distribution/Array.h"
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
|
#include "../Utils/errors.h"
|
||||||
#include "errors.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "SgUtils.h"
|
#include "../GraphCall/graph_calls.h"
|
||||||
#include "graph_calls.h"
|
#include "../GraphCall/graph_calls_func.h"
|
||||||
#include "graph_calls_func.h"
|
|
||||||
|
|
||||||
#include "projectParameters.h"
|
#include "projectParameters.h"
|
||||||
|
|
||||||
using std::set;
|
using namespace std;
|
||||||
using std::map;
|
|
||||||
using std::string;
|
|
||||||
using std::vector;
|
|
||||||
using std::tuple;
|
|
||||||
using std::pair;
|
|
||||||
using std::make_tuple;
|
|
||||||
using std::find_if;
|
|
||||||
|
|
||||||
static map<FuncInfo*, vector<SAPFOR::Instruction*>> call_sites;
|
map< pair<string, int>, set<string>>
|
||||||
|
findParameters(const map<string, vector<DefUseList>> &defUseByFunctions,
|
||||||
enum class MODE
|
const map<string, CommonBlock*> &commonBlocks,
|
||||||
|
const map<string, vector<FuncInfo*>> &allFuncInfo)
|
||||||
{
|
{
|
||||||
BEFORE,
|
map< pair<string, int>, set<string>> foundParameters;
|
||||||
AFTER
|
|
||||||
};
|
|
||||||
|
return foundParameters;
|
||||||
template<typename Iterator>
|
}
|
||||||
static void extract_vars_from_reg(set<SAPFOR::Argument*>& worklist, SAPFOR::Argument* reg, Iterator instr, Iterator first_instr);
|
|
||||||
|
|
||||||
static tuple<FuncInfo*, SAPFOR::Instruction*, SAPFOR::BasicBlock*>
|
|
||||||
stmtToIR(const map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& CFGraph, SgStatement* stmt)
|
|
||||||
{
|
|
||||||
SgStatement* cur = stmt;
|
|
||||||
cur->switchToFile();
|
|
||||||
while (cur->variant() != PROC_HEDR && cur->variant() != PROG_HEDR && cur->variant() != FUNC_HEDR)
|
|
||||||
cur = cur->controlParent();
|
|
||||||
|
|
||||||
string funcName = ((SgProcHedrStmt*)cur)->nameWithContains();
|
|
||||||
|
|
||||||
int stmtID = stmt->id();
|
|
||||||
for (const auto& [func, bblocks] : CFGraph)
|
|
||||||
{
|
|
||||||
if (func->funcName != funcName)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
for (auto basicBlock : bblocks)
|
|
||||||
for (auto ins : basicBlock->getInstructions())
|
|
||||||
if (stmtID == ins->getInstruction()->getOperator()->id())
|
|
||||||
return make_tuple(func, ins->getInstruction(), basicBlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
|
||||||
return { NULL, NULL, NULL };
|
|
||||||
}
|
|
||||||
|
|
||||||
static tuple<FuncInfo*, SAPFOR::Instruction*, SAPFOR::BasicBlock*>
|
|
||||||
IRByNumber(const map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& CFGraph, int num)
|
|
||||||
{
|
|
||||||
if (num < 0)
|
|
||||||
return { NULL, NULL, NULL };
|
|
||||||
|
|
||||||
for (const auto& [func, bblocks] : CFGraph)
|
|
||||||
for (auto byBB : bblocks)
|
|
||||||
if (byBB->getInstructions().front()->getNumber() <= num && byBB->getInstructions().back()->getNumber() >= num)
|
|
||||||
return make_tuple(func, getInstructionByNumber(byBB->getInstructions(), num), byBB);
|
|
||||||
|
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
|
||||||
return { NULL, NULL, NULL };
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Iterator>
|
|
||||||
static void processArgument(set<SAPFOR::Argument*>& worklist,
|
|
||||||
SAPFOR::Argument* arg,
|
|
||||||
Iterator instr, Iterator first_instr)
|
|
||||||
{
|
|
||||||
if (arg == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (arg->getType() == SAPFOR::CFG_ARG_TYPE::REG)
|
|
||||||
extract_vars_from_reg(worklist, arg, instr, first_instr);
|
|
||||||
else if (arg->getType() == SAPFOR::CFG_ARG_TYPE::VAR)
|
|
||||||
worklist.insert(arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Iterator>
|
|
||||||
static void extract_vars_from_reg(set<SAPFOR::Argument*>& worklist,
|
|
||||||
SAPFOR::Argument* reg,
|
|
||||||
Iterator instr, Iterator first_instr)
|
|
||||||
{
|
|
||||||
for (; instr >= first_instr; instr--)
|
|
||||||
{
|
|
||||||
if ((*instr)->getInstruction()->getResult() == reg)
|
|
||||||
{
|
|
||||||
processArgument(worklist, (*instr)->getInstruction()->getArg1(), instr, first_instr);
|
|
||||||
processArgument(worklist, (*instr)->getInstruction()->getArg2(), instr, first_instr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lookup_for_vars(set<tuple<SgStatement*, string, MODE>>& where_to_add,
|
|
||||||
set<SAPFOR::Argument*>& worklist,
|
|
||||||
SAPFOR::Instruction* instr,
|
|
||||||
SAPFOR::BasicBlock* bblock,
|
|
||||||
FuncInfo* cur_func,
|
|
||||||
const map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& fullIR)
|
|
||||||
{
|
|
||||||
while (bblock)
|
|
||||||
{
|
|
||||||
auto first_instr = bblock->getInstructions().begin();
|
|
||||||
auto cur_instr = find_if(first_instr, bblock->getInstructions().end(), [instr](SAPFOR::IR_Block* i) {
|
|
||||||
return i->getInstruction() == instr;
|
|
||||||
});
|
|
||||||
|
|
||||||
for (; cur_instr >= bblock->getInstructions().begin(); --cur_instr)
|
|
||||||
{
|
|
||||||
auto instr = (*cur_instr)->getInstruction();
|
|
||||||
auto result_arg = instr->getResult();
|
|
||||||
auto arg1 = instr->getArg1();
|
|
||||||
auto arg2 = instr->getArg2();
|
|
||||||
|
|
||||||
if (worklist.count(result_arg))
|
|
||||||
{
|
|
||||||
worklist.erase(result_arg);
|
|
||||||
processArgument(worklist, arg1, cur_instr, first_instr);
|
|
||||||
processArgument(worklist, arg2, cur_instr, first_instr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (instr->getOperation() == SAPFOR::CFG_OP::PARAM && worklist.count(arg1))
|
|
||||||
{
|
|
||||||
// skip to F_CALL
|
|
||||||
auto f_call_instr = cur_instr;
|
|
||||||
while ((*f_call_instr)->getInstruction()->getOperation() != SAPFOR::CFG_OP::F_CALL)
|
|
||||||
f_call_instr++;
|
|
||||||
|
|
||||||
if ((*f_call_instr)->getInstruction()->getArg1()->getValue() == "_READ")
|
|
||||||
{
|
|
||||||
auto stmt_before = (*f_call_instr)->getInstruction()->getOperator();
|
|
||||||
auto filename = stmt_before->fileName();
|
|
||||||
auto line = stmt_before->lineNumber();
|
|
||||||
auto var_name = arg1->getValue().substr(arg1->getValue().find('%') + 1);
|
|
||||||
__spf_print(1, "Please specify value of variable %s on line %d of file %s\n", arg1->getValue().c_str(), line, filename);
|
|
||||||
auto toAdd = make_tuple(stmt_before, var_name, MODE::AFTER);
|
|
||||||
where_to_add.insert(toAdd);
|
|
||||||
worklist.erase(arg1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto& RD = bblock->getRD_In();
|
|
||||||
map<SAPFOR::BasicBlock*, SAPFOR::Instruction*> group_by_block;
|
|
||||||
|
|
||||||
set<SAPFOR::Argument*> to_erase;
|
|
||||||
for (auto& arg : worklist)
|
|
||||||
{
|
|
||||||
if (RD.count(arg))
|
|
||||||
{
|
|
||||||
if (RD.at(arg).size() == 1 && *RD.at(arg).begin() == SAPFOR::CFG_VAL::UNINIT)
|
|
||||||
__spf_print(1, "variable %s has no definition\n", arg->getValue().c_str());
|
|
||||||
else if (RD.at(arg).size() > 1)
|
|
||||||
{
|
|
||||||
auto stmt_after = (*first_instr)->getInstruction()->getOperator();
|
|
||||||
auto filename = stmt_after->fileName();
|
|
||||||
auto line = stmt_after->lineNumber();
|
|
||||||
auto var_name = arg->getValue().substr(arg->getValue().find('%') + 1);
|
|
||||||
__spf_print(1, "variable %s has multiple reaching definitions, further analysis is impossible\n", arg->getValue().c_str());
|
|
||||||
__spf_print(1, "Please specify value of variable %s on line %d of file %s\n", arg->getValue().c_str(), line, filename);
|
|
||||||
auto toAdd = make_tuple(stmt_after, var_name, MODE::BEFORE);
|
|
||||||
where_to_add.insert(toAdd);
|
|
||||||
to_erase.insert(arg);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto instr_num = *RD.at(arg).begin();
|
|
||||||
auto [func, instr, bblock] = IRByNumber(fullIR, instr_num);
|
|
||||||
if (cur_func == func && (group_by_block[bblock] == NULL || group_by_block[bblock]->getNumber() < instr_num))
|
|
||||||
group_by_block[bblock] = instr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (const auto& arg : to_erase)
|
|
||||||
worklist.erase(arg);
|
|
||||||
|
|
||||||
while (bblock && group_by_block.find(bblock) == group_by_block.end())
|
|
||||||
bblock = bblock->getDom();
|
|
||||||
|
|
||||||
if (bblock)
|
|
||||||
instr = group_by_block[bblock];
|
|
||||||
}
|
|
||||||
|
|
||||||
// other variables are from global scope
|
|
||||||
const auto& RD = fullIR.at(cur_func).front()->getRD_In();
|
|
||||||
for (auto& arg : worklist)
|
|
||||||
{
|
|
||||||
if (arg->isMemGlobal())
|
|
||||||
{
|
|
||||||
set<int> found_rd;
|
|
||||||
if (RD.count(arg))
|
|
||||||
found_rd = RD.at(arg);
|
|
||||||
|
|
||||||
if (found_rd.size() == 0)
|
|
||||||
{
|
|
||||||
auto call_instr = call_sites[cur_func].size() ? call_sites[cur_func].front() : NULL;
|
|
||||||
while (call_instr && found_rd.size() == 0)
|
|
||||||
{
|
|
||||||
auto [call_func, _, call_bblock] = IRByNumber(fullIR, call_instr->getNumber());
|
|
||||||
if (call_bblock->getRD_Out().count(arg))
|
|
||||||
found_rd = call_bblock->getRD_Out().at(arg);
|
|
||||||
|
|
||||||
|
|
||||||
call_instr = call_sites[call_func].size() ? call_sites[call_func].front() : NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (found_rd.size() == 1 && *found_rd.begin() == SAPFOR::CFG_VAL::UNINIT)
|
|
||||||
__spf_print(1, "variable %s has no definition\n", arg->getValue().c_str());
|
|
||||||
else if (found_rd.size() > 1)
|
|
||||||
{
|
|
||||||
auto first_instr = fullIR.at(cur_func).front()->getInstructions().begin();
|
|
||||||
auto stmt_after = (*first_instr)->getInstruction()->getOperator();
|
|
||||||
auto filename = stmt_after->fileName();
|
|
||||||
auto line = stmt_after->lineNumber();
|
|
||||||
auto var_name = arg->getValue().substr(arg->getValue().find('%') + 1);
|
|
||||||
__spf_print(1, "variable %s has multiple reaching definitions, further analysis is impossible\n", arg->getValue().c_str());
|
|
||||||
__spf_print(1, "Please specify value of variable %s on line %d of file %s\n", arg->getValue().c_str(), line, filename);
|
|
||||||
auto toAdd = make_tuple(stmt_after, var_name, MODE::BEFORE);
|
|
||||||
where_to_add.insert(toAdd);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto instr_num = *found_rd.begin();
|
|
||||||
auto [func, instr, bblock] = IRByNumber(fullIR, instr_num);
|
|
||||||
set<SAPFOR::Argument*> new_worklist = { arg };
|
|
||||||
|
|
||||||
lookup_for_vars(where_to_add, new_worklist, instr, bblock, func, fullIR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (const auto& call_instr : call_sites[cur_func])
|
|
||||||
{
|
|
||||||
set<SAPFOR::Argument*> new_worklist;
|
|
||||||
auto params_num = cur_func->funcParams.countOfPars;
|
|
||||||
|
|
||||||
auto [call_func, _, call_bblock] = IRByNumber(fullIR, call_instr->getNumber());
|
|
||||||
auto first_instr = call_bblock->getInstructions().begin();
|
|
||||||
auto cur_instr = find_if(first_instr, call_bblock->getInstructions().end(), [call_instr](SAPFOR::IR_Block* i) {
|
|
||||||
return i->getInstruction() == call_instr;
|
|
||||||
});
|
|
||||||
|
|
||||||
for (auto& arg : worklist)
|
|
||||||
{
|
|
||||||
if (arg->getMemType() == SAPFOR::CFG_MEM_TYPE::FUNC_PARAM_)
|
|
||||||
{
|
|
||||||
auto param_num = stoi(arg->getValue().substr(arg->getValue().find('%', arg->getValue().find('%') + 1) + 1));
|
|
||||||
auto param_instr = (cur_instr - (params_num - param_num));
|
|
||||||
auto param_arg = (*param_instr)->getInstruction()->getArg1();
|
|
||||||
processArgument(new_worklist, param_arg, param_instr, first_instr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lookup_for_vars(where_to_add, new_worklist, call_instr, call_bblock, call_func, fullIR);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_single_allocate(set<tuple<SgStatement*, string, MODE>>& where_to_add,
|
|
||||||
SgStatement* alloc_statement,
|
|
||||||
const map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& fullIR)
|
|
||||||
{
|
|
||||||
auto [func, instr, bblock] = stmtToIR(fullIR, alloc_statement);
|
|
||||||
|
|
||||||
auto first_instr = bblock->getInstructions().begin();
|
|
||||||
auto cur_instr = find_if(first_instr, bblock->getInstructions().end(), [instr](SAPFOR::IR_Block* i) {
|
|
||||||
return i->getInstruction() == instr;
|
|
||||||
});
|
|
||||||
auto alloc_instr = cur_instr;
|
|
||||||
|
|
||||||
// skip to F_CALL _ALLOC n
|
|
||||||
while ((*alloc_instr)->getInstruction()->getOperation() != SAPFOR::CFG_OP::F_CALL ||
|
|
||||||
(*alloc_instr)->getInstruction()->getArg1()->getValue() != "_ALLOC")
|
|
||||||
alloc_instr++;
|
|
||||||
|
|
||||||
auto arrays_num = stoi((*alloc_instr)->getInstruction()->getArg2()->getValue());
|
|
||||||
|
|
||||||
set<SAPFOR::Argument*> worklist;
|
|
||||||
for (int i = 0; i < arrays_num; i++)
|
|
||||||
{
|
|
||||||
auto param_instr = --alloc_instr;
|
|
||||||
auto param_reg = (*param_instr)->getInstruction()->getArg1();
|
|
||||||
|
|
||||||
while ((*param_instr)->getInstruction()->getOperation() != SAPFOR::CFG_OP::LOAD ||
|
|
||||||
(*param_instr)->getInstruction()->getResult() != param_reg)
|
|
||||||
param_instr--;
|
|
||||||
|
|
||||||
|
|
||||||
auto dimensions_num = stoi((*param_instr)->getInstruction()->getArg2()->getValue());
|
|
||||||
|
|
||||||
for (int j = 0; j < dimensions_num; j++)
|
|
||||||
{
|
|
||||||
auto ref_instr = --param_instr;
|
|
||||||
if ((*ref_instr)->getInstruction()->getOperation() == SAPFOR::CFG_OP::RANGE)
|
|
||||||
{
|
|
||||||
vector<SAPFOR::Argument*> range_args = { (*ref_instr)->getInstruction()->getArg1(),
|
|
||||||
(*ref_instr)->getInstruction()->getArg2(),
|
|
||||||
(*ref_instr)->getInstruction()->getResult() };
|
|
||||||
for (auto& arg : range_args)
|
|
||||||
processArgument(worklist, arg, ref_instr, first_instr);
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto arg = (*ref_instr)->getInstruction()->getArg1();
|
|
||||||
processArgument(worklist, arg, ref_instr, first_instr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lookup_for_vars(where_to_add, worklist, instr, bblock, func, fullIR);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void handle_single_loop(set<tuple<SgStatement*, string, MODE>>& where_to_add,
|
|
||||||
SgStatement* loop_stmt,
|
|
||||||
const map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& fullIR)
|
|
||||||
{
|
|
||||||
auto [func, instr, bblock] = stmtToIR(fullIR, loop_stmt);
|
|
||||||
auto cur_instr = bblock->getInstructions().end() - 1;
|
|
||||||
|
|
||||||
set<SAPFOR::Argument*> worklist;
|
|
||||||
extract_vars_from_reg(worklist, (*cur_instr)->getInstruction()->getResult(), cur_instr, bblock->getInstructions().begin());
|
|
||||||
|
|
||||||
lookup_for_vars(where_to_add, worklist, (*cur_instr)->getInstruction(), bblock, func, fullIR);
|
|
||||||
}
|
|
||||||
|
|
||||||
void findParameters(ResultSet& foundParameters,
|
|
||||||
map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& fullIR,
|
|
||||||
const map<tuple<int, string, string>, pair<DIST::Array*, DIST::ArrayAccessInfo*>>& declaredArrays)
|
|
||||||
{
|
|
||||||
set<tuple<SgStatement*, string, MODE>> where_to_add;
|
|
||||||
|
|
||||||
map<string, FuncInfo*> name_to_func;
|
|
||||||
for (const auto& [func, _] : fullIR)
|
|
||||||
name_to_func[func->funcName] = func;
|
|
||||||
|
|
||||||
for (auto& [func, bblocks] : fullIR)
|
|
||||||
{
|
|
||||||
for (const auto& block : bblocks)
|
|
||||||
{
|
|
||||||
for (const auto& ir_block : block->getInstructions())
|
|
||||||
{
|
|
||||||
auto instr = ir_block->getInstruction();
|
|
||||||
if (instr->getOperation() == SAPFOR::CFG_OP::F_CALL)
|
|
||||||
{
|
|
||||||
auto func_name = instr->getArg1()->getValue();
|
|
||||||
auto func_info = name_to_func.find(func_name);
|
|
||||||
|
|
||||||
if (func_info != name_to_func.end())
|
|
||||||
call_sites[func_info->second].push_back(instr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
set<SgStatement*> alloc_statements;
|
|
||||||
for (const auto& [func, bblocks] : fullIR)
|
|
||||||
{
|
|
||||||
for (const auto& block : bblocks)
|
|
||||||
{
|
|
||||||
for (auto instr = block->getInstructions().begin(); instr != block->getInstructions().end(); ++instr)
|
|
||||||
{
|
|
||||||
auto op = (*instr)->getInstruction()->getOperator();
|
|
||||||
if (op && op->variant() == ALLOCATE_STMT)
|
|
||||||
alloc_statements.insert(op);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
set<SgStatement*> for_statements;
|
|
||||||
// Find all FOR statements in the program
|
|
||||||
for (const auto& [func, bblocks] : fullIR)
|
|
||||||
{
|
|
||||||
for (const auto& block : bblocks)
|
|
||||||
{
|
|
||||||
for (auto instr = block->getInstructions().begin(); instr != block->getInstructions().end(); ++instr)
|
|
||||||
{
|
|
||||||
auto op = (*instr)->getInstruction()->getOperator();
|
|
||||||
if (op && op->variant() == FOR_NODE)
|
|
||||||
for_statements.insert(op);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto& alloc_statement : alloc_statements)
|
|
||||||
handle_single_allocate(where_to_add, alloc_statement, fullIR);
|
|
||||||
|
|
||||||
for (const auto& stmt : for_statements)
|
|
||||||
handle_single_loop(where_to_add, stmt, fullIR);
|
|
||||||
|
|
||||||
for (const auto& [stmt_before, var_name, mode] : where_to_add)
|
|
||||||
{
|
|
||||||
stmt_before->switchToFile();
|
|
||||||
|
|
||||||
SgVariableSymb* var_symb = new SgVariableSymb(var_name.c_str());
|
|
||||||
SgVarRefExp* var = new SgVarRefExp(var_symb);
|
|
||||||
SgExprListExp* ex = new SgExprListExp();
|
|
||||||
auto assgn_op = new SgExpression(ASSGN_OP, var, NULL);
|
|
||||||
ex->setLhs(assgn_op);
|
|
||||||
|
|
||||||
SgExpression* parameter_op = new SgExpression(SPF_PARAMETER_OP, ex);
|
|
||||||
auto dir_list = new SgExprListExp();
|
|
||||||
dir_list->setLhs(parameter_op);
|
|
||||||
SgStatement* toAdd = new SgStatement(SPF_ANALYSIS_DIR, NULL, NULL, dir_list, NULL, NULL);
|
|
||||||
|
|
||||||
toAdd->setlineNumber(stmt_before->lineNumber());
|
|
||||||
toAdd->setLocalLineNumber(stmt_before->lineNumber());
|
|
||||||
toAdd->setFileId(stmt_before->getFileId());
|
|
||||||
toAdd->setProject(stmt_before->getProject());
|
|
||||||
|
|
||||||
//NOTE: only for debbuging, results will be transferred to the visualizer
|
|
||||||
/*if (mode == MODE::AFTER)
|
|
||||||
stmt_before->insertStmtAfter(*toAdd, *stmt_before->controlParent());
|
|
||||||
else
|
|
||||||
stmt_before->insertStmtBefore(*toAdd, *stmt_before->controlParent());*/
|
|
||||||
|
|
||||||
foundParameters.insert(make_tuple(stmt_before->fileName(), stmt_before->lineNumber(), var_name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <map>
|
std::map< std::pair<std::string, int>, std::set<std::string>> findParameters(const std::map<std::string, std::vector<DefUseList>> &defUseByFunctions, const std::map<std::string, CommonBlock*> &commonBlocks, const std::map<std::string, std::vector<FuncInfo*>> &allFuncInfo);
|
||||||
#include <string>
|
|
||||||
#include <set>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "../GraphCall/graph_calls.h"
|
|
||||||
|
|
||||||
using ResultSet = std::set<std::tuple<std::string, int, std::string>>;
|
|
||||||
|
|
||||||
void findParameters(ResultSet& foundParameters,
|
|
||||||
std::map<FuncInfo*, std::vector<SAPFOR::BasicBlock*>>& fullIR,
|
|
||||||
const std::map<std::tuple<int, std::string, std::string>, std::pair<DIST::Array*, DIST::ArrayAccessInfo*>>& declaredArrays);
|
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Utils/SgUtils.h"
|
#include "Utils/SgUtils.h"
|
||||||
#include "rename_symbols.h"
|
#include "RenameSymbols/rename_symbols.h"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::map;
|
using std::map;
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user