Compare commits
139 Commits
fae76c98cb
...
private_ar
| Author | SHA1 | Date | |
|---|---|---|---|
| 9ac15eec79 | |||
| 03f565f50b | |||
| 47e2b961e2 | |||
|
|
b95b336372 | ||
| f35d7cb4bd | |||
| 54615e34d4 | |||
| 8752f4a139 | |||
| 453105d273 | |||
| cad0a0b217 | |||
| 9c0fd40e7b | |||
| c7a31c8bbb | |||
|
|
9900929349 | ||
|
|
e1ba299159 | ||
|
|
8de18d1788 | ||
| 06aabdbee6 | |||
|
|
c6f290bb56 | ||
| 49d3b9b96e | |||
| 280beb13cc | |||
| 3bc9351641 | |||
| 16b2c6b42b | |||
| fe31df0ef2 | |||
|
|
4c8681bfe2 | ||
|
|
d330a6ee23 | ||
|
|
b439759e9b | ||
| b11973cb64 | |||
|
|
df9a9a30bb | ||
|
|
2cd02c295f | ||
|
|
278fc1ff9c | ||
|
|
80eac5b957 | ||
|
|
0c9eed4bb7 | ||
|
|
d3d6d0bec7 | ||
|
|
3095510826 | ||
|
|
85e2a60183 | ||
|
|
68bd21b7b0 | ||
|
|
177433a95b | ||
|
|
29ece9072e | ||
|
|
feafa43f32 | ||
|
|
b8f429256f | ||
|
|
2f53d6ae2e | ||
|
|
65237e4d63 | ||
|
|
7533739488 | ||
| c1d31b809b | |||
| 537f3eb6e9 | |||
| f5f99f6e8a | |||
|
|
fc47a1685c | ||
| 383d8df826 | |||
| ebc5a1cbc1 | |||
|
|
0eee799867 | ||
|
|
50dd54cec1 | ||
|
|
6a59bc0e09 | ||
|
|
9e777ceeab | ||
|
|
10636427ed | ||
|
|
a0704038db | ||
| 623f6c0d73 | |||
|
|
622159cba6 | ||
|
|
db26a2c332 | ||
|
|
8ad19cbfa5 | ||
|
|
1895a4b02a | ||
|
|
623898d913 | ||
|
|
a96a4bcaa6 | ||
|
|
a7764847c4 | ||
|
|
fca4f632e4 | ||
|
|
f53d514a47 | ||
| ae9cc2bf3b | |||
| c6a0c73287 | |||
|
|
db32a3e2b2 | ||
|
|
a0a401c42a | ||
| 8161609173 | |||
| a2e6269508 | |||
|
|
72a1c1d853 | ||
| 5c89299ad5 | |||
|
|
26e36bed46 | ||
|
|
8dcbd587ec | ||
|
|
f7a78f9626 | ||
| fbe22fca43 | |||
| bbb9823f1d | |||
| b454858647 | |||
|
|
ad99446b12 | ||
|
|
d3e8c481d2 | ||
| 4e16638c36 | |||
| 6742932862 | |||
| 8b2e59356a | |||
| f9d52c0c3e | |||
| 537d60222f | |||
| 4eb057731f | |||
| 402ae91c33 | |||
| ba632b29ce | |||
| 18edf55d15 | |||
| c347f56e47 | |||
|
|
8f55c13a0c | ||
| 11e9fab482 | |||
|
|
7ee9d839a1 | ||
|
|
78e9b63331 | ||
|
|
879094a6b7 | ||
|
|
6c16cc5432 | ||
|
|
b1eeac0b10 | ||
| 73d0b201f2 | |||
| 1973d095f5 | |||
|
|
f679666d01 | ||
| 0df1d3d5fe | |||
| 54eb1ecc95 | |||
| b7ebccf045 | |||
|
|
4bcf83f551 | ||
|
|
c548f4ab4c | ||
| 2338156a28 | |||
|
|
718b1738a1 | ||
|
|
0fe97ceb24 | ||
|
|
81725651b1 | ||
|
|
4614e166b4 | ||
|
|
bcecd5460b | ||
|
|
719e3723ae | ||
|
|
12d3c2c8e5 | ||
|
|
a719dea05f | ||
|
|
5f98eaf872 | ||
|
|
e3d77f51f1 | ||
| 738f2c5d12 | |||
|
|
29a8c30370 | ||
|
|
99f5febd58 | ||
|
|
0a4b795900 | ||
|
|
8efd632325 | ||
|
|
5a7d7269cd | ||
|
|
4b7c3d89b0 | ||
|
|
e7990bda0a | ||
|
|
a49f10cb5b | ||
| 636f2b0af1 | |||
|
|
640e34816f | ||
|
|
b88eccaad4 | ||
|
|
7b0cb828a7 | ||
|
|
06980ee344 | ||
|
|
cde49042ae | ||
|
|
dae0afef45 | ||
|
|
41b4649d83 | ||
|
|
b068a49b0b | ||
|
|
5acbd10a26 | ||
|
|
da6685df43 | ||
|
|
9c4993feeb | ||
|
|
7666a6c804 | ||
|
|
79302bf7b7 | ||
|
|
a7f199ad4c |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -74,6 +74,7 @@ Sapfor/Sapc++/Sapc++/x64/
|
|||||||
Sapfor/Sapc++/x64/
|
Sapfor/Sapc++/x64/
|
||||||
|
|
||||||
/build
|
/build
|
||||||
|
/cmake-build-debug
|
||||||
|
|
||||||
Sapfor/out/
|
Sapfor/out/
|
||||||
Sapfor/_bin/*
|
Sapfor/_bin/*
|
||||||
|
|||||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +1,6 @@
|
|||||||
[submodule "projects/dvm"]
|
[submodule "projects/dvm"]
|
||||||
path = projects/dvm
|
path = projects/dvm
|
||||||
url = https://dvmguest:dvmguest@dvm.keldysh.ru/dvm-system/dvm
|
url = https://dvmguest:dvmguest@dvm.keldysh.ru/dvm-system/dvm
|
||||||
|
[submodule "projects/libpredictor"]
|
||||||
|
path = projects/libpredictor
|
||||||
|
url = https://dvmguest:dvmguest@dvm.keldysh.ru/sapfor/dvm-perfm
|
||||||
|
|||||||
165
CMakeLists.txt
165
CMakeLists.txt
@@ -12,19 +12,30 @@ 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/)
|
||||||
set(sage_include_1 projects/dvm/fdvmh/include/sage/lib/)
|
set(sage_include_1 projects/dvm/fdvmh/include/sage/lib/)
|
||||||
set(sage_include_2 projects/dvm/fdvmh/include/sage/h/)
|
set(sage_include_2 projects/dvm/fdvmh/include/sage/h/)
|
||||||
set(libdb_sources projects/dvm/fdvmh/lib/sage/db/)
|
set(libdb_sources projects/dvm/fdvmh/lib/sage/db/)
|
||||||
set(sage_sources projects/dvm/fdvmh/lib/sage/sage/)
|
set(sage_sources projects/dvm/fdvmh/lib/sage/sage/)
|
||||||
set(sagepp_sources projects/dvm/fdvmh/lib/sage/sage++/)
|
set(sagepp_sources projects/dvm/fdvmh/lib/sage/sage++/)
|
||||||
set(parser_sources projects/dvm/fdvmh/tools/parser/)
|
set(parser_sources projects/dvm/fdvmh/tools/parser/)
|
||||||
set(pppa_sources projects/dvm/pppa/src/)
|
set(pppa_sources projects/dvm/pppa/src/)
|
||||||
set(zlib_sources projects/dvm/third-party/Zlib/)
|
set(zlib_sources projects/dvm/third-party/Zlib/)
|
||||||
|
set(libpred_sources projects/libpredictor/src/)
|
||||||
|
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})
|
||||||
@@ -33,6 +44,8 @@ include_directories(${sage_include_2})
|
|||||||
include_directories(${zlib_sources}/include)
|
include_directories(${zlib_sources}/include)
|
||||||
#PPPA includes
|
#PPPA includes
|
||||||
include_directories(${pppa_sources})
|
include_directories(${pppa_sources})
|
||||||
|
#Libpredictor includes
|
||||||
|
include_directories(${libpred_include})
|
||||||
|
|
||||||
set(PR_PARAM src/ProjectParameters/projectParameters.cpp
|
set(PR_PARAM src/ProjectParameters/projectParameters.cpp
|
||||||
src/ProjectParameters/projectParameters.h)
|
src/ProjectParameters/projectParameters.h)
|
||||||
@@ -54,7 +67,7 @@ set(VS_CALLS src/VisualizerCalls/get_information.cpp
|
|||||||
src/VisualizerCalls/SendMessage.h
|
src/VisualizerCalls/SendMessage.h
|
||||||
src/VisualizerCalls/BuildGraph.cpp
|
src/VisualizerCalls/BuildGraph.cpp
|
||||||
src/VisualizerCalls/BuildGraph.h)
|
src/VisualizerCalls/BuildGraph.h)
|
||||||
|
|
||||||
set(VERIF src/VerificationCode/CorrectVarDecl.cpp
|
set(VERIF src/VerificationCode/CorrectVarDecl.cpp
|
||||||
src/VerificationCode/IncludeChecker.cpp
|
src/VerificationCode/IncludeChecker.cpp
|
||||||
src/VerificationCode/StructureChecker.cpp
|
src/VerificationCode/StructureChecker.cpp
|
||||||
@@ -76,7 +89,8 @@ set(UTILS src/Utils/AstWrapper.h
|
|||||||
src/Utils/utils.h
|
src/Utils/utils.h
|
||||||
src/Utils/version.h
|
src/Utils/version.h
|
||||||
src/Utils/module_utils.h
|
src/Utils/module_utils.h
|
||||||
src/Utils/module_utils.cpp)
|
src/Utils/module_utils.cpp
|
||||||
|
src/Utils/json.hpp)
|
||||||
|
|
||||||
set(OMEGA src/SageAnalysisTool/OmegaForSage/add-assert.cpp
|
set(OMEGA src/SageAnalysisTool/OmegaForSage/add-assert.cpp
|
||||||
src/SageAnalysisTool/OmegaForSage/affine.cpp
|
src/SageAnalysisTool/OmegaForSage/affine.cpp
|
||||||
@@ -110,7 +124,11 @@ set(OMEGA src/SageAnalysisTool/OmegaForSage/add-assert.cpp
|
|||||||
set(PRIV src/PrivateAnalyzer/private_analyzer.cpp
|
set(PRIV src/PrivateAnalyzer/private_analyzer.cpp
|
||||||
src/PrivateAnalyzer/private_analyzer.h
|
src/PrivateAnalyzer/private_analyzer.h
|
||||||
src/PrivateAnalyzer/private_arrays_search.cpp
|
src/PrivateAnalyzer/private_arrays_search.cpp
|
||||||
src/PrivateAnalyzer/private_arrays_search.h)
|
src/PrivateAnalyzer/private_arrays_search.h
|
||||||
|
src/PrivateAnalyzer/range_structures.cpp
|
||||||
|
src/PrivateAnalyzer/range_structures.h
|
||||||
|
src/PrivateAnalyzer/region.cpp
|
||||||
|
src/PrivateAnalyzer/region.h)
|
||||||
|
|
||||||
set(FDVM ${fdvm_sources}/acc.cpp
|
set(FDVM ${fdvm_sources}/acc.cpp
|
||||||
${fdvm_sources}/acc_across.cpp
|
${fdvm_sources}/acc_across.cpp
|
||||||
@@ -145,40 +163,47 @@ 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/dead_code.cpp
|
set(TR_DEAD_CODE src/Transformations/DeadCodeRemoving/dead_code.cpp
|
||||||
src/Transformations/dead_code.h)
|
src/Transformations/DeadCodeRemoving/dead_code.h)
|
||||||
set(TR_CP src/Transformations/checkpoints.cpp
|
set(TR_CP src/Transformations/CheckPoints/checkpoints.cpp
|
||||||
src/Transformations/checkpoints.h)
|
src/Transformations/CheckPoints/checkpoints.h)
|
||||||
set(TR_VECTOR src/Transformations/array_assign_to_loop.cpp
|
set(TR_VECTOR src/Transformations/VectorAssignToLoop/array_assign_to_loop.cpp
|
||||||
src/Transformations/array_assign_to_loop.h)
|
src/Transformations/VectorAssignToLoop/array_assign_to_loop.h)
|
||||||
set(TR_ENDDO_LOOP src/Transformations/enddo_loop_converter.cpp
|
set(TR_ENDDO_LOOP src/Transformations/LoopEndDoConverter/enddo_loop_converter.cpp
|
||||||
src/Transformations/enddo_loop_converter.h)
|
src/Transformations/LoopEndDoConverter/enddo_loop_converter.h)
|
||||||
set(TR_LOOP_NEST src/Transformations/loop_transform.cpp
|
set(TR_LOOP_NEST src/Transformations/LoopNesting/loop_transform.cpp
|
||||||
src/Transformations/loop_transform.h)
|
src/Transformations/LoopNesting/loop_transform.h)
|
||||||
set(TR_LOOP_COMB src/Transformations/loops_combiner.cpp
|
set(TR_LOOP_COMB src/Transformations/LoopCombining/loops_combiner.cpp
|
||||||
src/Transformations/loops_combiner.h)
|
src/Transformations/LoopCombining/loops_combiner.h)
|
||||||
set(TR_LOOP_SPLIT src/Transformations/loops_splitter.cpp
|
set(TR_LOOP_SPLIT src/Transformations/LoopSplitting/loops_splitter.cpp
|
||||||
src/Transformations/loops_splitter.h)
|
src/Transformations/LoopSplitting/loops_splitter.h)
|
||||||
set(TR_LOOP_UNROLL src/Transformations/loops_unrolling.cpp
|
set(TR_LOOP_UNROLL src/Transformations/LoopUnrolling/loops_unrolling.cpp
|
||||||
src/Transformations/loops_unrolling.h)
|
src/Transformations/LoopUnrolling/loops_unrolling.h)
|
||||||
set(TR_PRIV_BR src/Transformations/private_arrays_resizing.cpp
|
set(TR_PRIV_BR src/Transformations/PrivateArrayResizing/private_arrays_resizing.cpp
|
||||||
src/Transformations/private_arrays_resizing.h)
|
src/Transformations/PrivateArrayResizing/private_arrays_resizing.h)
|
||||||
set(TR_PRIV_DEL src/Transformations/private_removing.cpp
|
set(TR_PRIV_DEL src/Transformations/PrivateArrayRemoving/private_removing.cpp
|
||||||
src/Transformations/private_removing.h)
|
src/Transformations/PrivateArrayRemoving/private_removing.h)
|
||||||
set(TR_SWAP_ARR_DIMS src/Transformations/swap_array_dims.cpp
|
set(TR_SWAP_ARR_DIMS src/Transformations/ArrayDimsSwapping/swap_array_dims.cpp
|
||||||
src/Transformations/swap_array_dims.h)
|
src/Transformations/ArrayDimsSwapping/swap_array_dims.h)
|
||||||
set(TR_FUNC_DUP src/Transformations/uniq_call_chain_dup.cpp
|
set(TR_FUNC_DUP src/Transformations/FunctionDuplication/uniq_call_chain_dup.cpp
|
||||||
src/Transformations/uniq_call_chain_dup.h)
|
src/Transformations/FunctionDuplication/uniq_call_chain_dup.h)
|
||||||
set(TR_FUNC_PURE src/Transformations/function_purifying.cpp
|
set(TR_FUNC_PURE src/Transformations/FunctionPurifying/function_purifying.cpp
|
||||||
src/Transformations/function_purifying.h)
|
src/Transformations/FunctionPurifying/function_purifying.h)
|
||||||
set(TR_GV src/Transformations/fix_common_blocks.cpp
|
set(TR_GV src/Transformations/GlobalVariables/fix_common_blocks.cpp
|
||||||
src/Transformations/fix_common_blocks.h)
|
src/Transformations/GlobalVariables/fix_common_blocks.h)
|
||||||
set(TR_CONV src/Transformations/convert_to_c.cpp
|
set(TR_CONV src/Transformations/ConvertToC/convert_to_c.cpp
|
||||||
src/Transformations/convert_to_c.h)
|
src/Transformations/ConvertToC/convert_to_c.h)
|
||||||
set(TR_IMPLICIT_NONE src/Transformations/set_implicit_none.cpp
|
set(TR_IMPLICIT_NONE src/Transformations/SetImplicitNone/set_implicit_none.cpp
|
||||||
src/Transformations/set_implicit_none.h)
|
src/Transformations/SetImplicitNone/set_implicit_none.h)
|
||||||
set(TR_REPLACE_ARRAYS_IN_IO src/Transformations/replace_dist_arrays_in_io.cpp
|
set(TR_REPLACE_ARRAYS_IN_IO src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.cpp
|
||||||
src/Transformations/replace_dist_arrays_in_io.h)
|
src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.h)
|
||||||
|
set(TR_EXPR_TRANSFORM src/Transformations/ExpressionSubstitution/control_flow_graph_part.cpp
|
||||||
|
src/Transformations/ExpressionSubstitution/expr_transform.cpp
|
||||||
|
src/Transformations/ExpressionSubstitution/expr_transform.h)
|
||||||
|
set(TR_INLINER src/Transformations/FunctionInlining/inliner.cpp
|
||||||
|
src/Transformations/FunctionInlining/inliner.h)
|
||||||
|
set(TR_RENAME_SYMBOLS src/Transformations/RenameSymbols/rename_symbols.cpp
|
||||||
|
src/Transformations/RenameSymbols/rename_symbols.h)
|
||||||
|
|
||||||
set(TRANSFORMS
|
set(TRANSFORMS
|
||||||
${TR_DEAD_CODE}
|
${TR_DEAD_CODE}
|
||||||
@@ -198,10 +223,15 @@ set(TRANSFORMS
|
|||||||
${TR_CONV}
|
${TR_CONV}
|
||||||
${TR_PRIV_DEL}
|
${TR_PRIV_DEL}
|
||||||
${TR_IMPLICIT_NONE}
|
${TR_IMPLICIT_NONE}
|
||||||
${TR_REPLACE_ARRAYS_IN_IO})
|
${TR_REPLACE_ARRAYS_IN_IO}
|
||||||
|
${TR_EXPR_TRANSFORM}
|
||||||
|
${TR_INLINER}
|
||||||
|
${TR_RENAME_SYMBOLS})
|
||||||
|
|
||||||
set(CFG src/CFGraph/IR.cpp
|
set(CFG src/CFGraph/IR.cpp
|
||||||
src/CFGraph/IR.h
|
src/CFGraph/IR.h
|
||||||
|
src/CFGraph/IR_domTree.cpp
|
||||||
|
src/CFGraph/IR_domTree.h
|
||||||
src/CFGraph/CFGraph.cpp
|
src/CFGraph/CFGraph.cpp
|
||||||
src/CFGraph/CFGraph.h
|
src/CFGraph/CFGraph.h
|
||||||
src/CFGraph/RD_subst.cpp
|
src/CFGraph/RD_subst.cpp
|
||||||
@@ -279,10 +309,6 @@ 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
|
||||||
@@ -294,18 +320,11 @@ 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
|
||||||
@@ -313,6 +332,15 @@ set(MAIN src/Sapfor.cpp
|
|||||||
|
|
||||||
set(PREDICTOR src/Predictor/PredictScheme.cpp
|
set(PREDICTOR src/Predictor/PredictScheme.cpp
|
||||||
src/Predictor/PredictScheme.h)
|
src/Predictor/PredictScheme.h)
|
||||||
|
|
||||||
|
set(LIBPREDICTOR ${libpred_sources}/cluster.cpp
|
||||||
|
${libpred_sources}/predictor.cpp
|
||||||
|
${libpred_sources}/transfer.cpp
|
||||||
|
${libpred_sources}/utils.cpp
|
||||||
|
${libpred_include}/libpredict/predictor.h
|
||||||
|
${libpred_include}/internal/cluster.h
|
||||||
|
${libpred_include}/internal/transfer.h
|
||||||
|
${libpred_include}/internal/utils.h)
|
||||||
|
|
||||||
set(PROJ_MAN src/ProjectManipulation/ParseFiles.cpp
|
set(PROJ_MAN src/ProjectManipulation/ParseFiles.cpp
|
||||||
src/ProjectManipulation/ParseFiles.h
|
src/ProjectManipulation/ParseFiles.h
|
||||||
@@ -386,12 +414,9 @@ 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}
|
||||||
@@ -402,6 +427,7 @@ set(SOURCE_EXE
|
|||||||
${VS_CALLS}
|
${VS_CALLS}
|
||||||
${MAIN}
|
${MAIN}
|
||||||
${PREDICTOR}
|
${PREDICTOR}
|
||||||
|
${LIBPREDICTOR}
|
||||||
${PARSER}
|
${PARSER}
|
||||||
${PPPA}
|
${PPPA}
|
||||||
${ZLIB}
|
${ZLIB}
|
||||||
@@ -414,7 +440,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 ${EXPR_TRANSFORM})
|
source_group (Transformations\\ExpressionSubstitution FILES ${TR_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})
|
||||||
@@ -422,13 +448,13 @@ source_group (Transformations\\LoopCombining FILES ${TR_LOOP_COMB})
|
|||||||
source_group (Transformations\\LoopSplitting FILES ${TR_LOOP_SPLIT})
|
source_group (Transformations\\LoopSplitting FILES ${TR_LOOP_SPLIT})
|
||||||
source_group (Transformations\\LoopUnrolling FILES ${TR_LOOP_UNROLL})
|
source_group (Transformations\\LoopUnrolling FILES ${TR_LOOP_UNROLL})
|
||||||
source_group (Transformations\\FunctionDuplication FILES ${TR_FUNC_DUP})
|
source_group (Transformations\\FunctionDuplication FILES ${TR_FUNC_DUP})
|
||||||
source_group (Transformations\\FunctionInlining FILES ${INLINER})
|
source_group (Transformations\\FunctionInlining FILES ${TR_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 ${RENAME_SYMBOLS})
|
source_group (Transformations\\RenameSymbols FILES ${TR_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})
|
||||||
@@ -456,11 +482,12 @@ source_group (VisualizerCalls FILES ${VS_CALLS})
|
|||||||
source_group (VisualizerCalls\\GraphLayout FILES ${GR_LAYOUT})
|
source_group (VisualizerCalls\\GraphLayout FILES ${GR_LAYOUT})
|
||||||
|
|
||||||
source_group (_SapforMain FILES ${MAIN})
|
source_group (_SapforMain FILES ${MAIN})
|
||||||
source_group (Predictor FILES ${PREDICTOR})
|
source_group (Predictor\\Analyzer FILES ${PREDICTOR})
|
||||||
|
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()
|
||||||
@@ -469,7 +496,9 @@ 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()
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(projects/Fdvm)
|
add_subdirectory(projects/Fdvm)
|
||||||
|
|||||||
Submodule projects/dvm updated: c00e381812...4d4041a081
1
projects/libpredictor
Submodule
1
projects/libpredictor
Submodule
Submodule projects/libpredictor added at d0772cdb57
@@ -1,5 +1,5 @@
|
|||||||
#define _LEAK_
|
#define _LEAK_
|
||||||
#include "../Utils/leak_detector.h"
|
#include "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 "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "../Utils/CommonBlock.h"
|
#include "CommonBlock.h"
|
||||||
#include "../GraphCall/graph_calls.h"
|
#include "graph_calls.h"
|
||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "IR.h"
|
#include "IR.h"
|
||||||
@@ -1149,9 +1149,22 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1226,4 +1239,49 @@ 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,6 +6,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "IR.h"
|
#include "IR.h"
|
||||||
|
#include "IR_domTree.h"
|
||||||
|
|
||||||
namespace SAPFOR
|
namespace SAPFOR
|
||||||
{
|
{
|
||||||
@@ -24,7 +25,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;
|
||||||
|
|
||||||
@@ -34,6 +35,7 @@ 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);
|
||||||
@@ -42,6 +44,7 @@ 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);
|
||||||
@@ -69,7 +72,11 @@ 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
|
||||||
*/
|
*/
|
||||||
@@ -105,13 +112,15 @@ 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 withCallFrom = true) :
|
bool withDVM = false, bool withSPF = false, bool withCallsInBlocks = false,
|
||||||
|
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)
|
withCallsInBlocks(withCallsInBlocks), withCallFrom(withCallFrom), withDominators(withDominators)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -146,4 +155,6 @@ 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 "../../Utils/SgUtils.h"
|
#include "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 "../../Utils/SgUtils.h"
|
#include "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 "../../Utils/SgUtils.h"
|
#include "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 "../../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "../CFGraph.h"
|
#include "../CFGraph.h"
|
||||||
#include "../IR.h"
|
#include "../IR.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
#include "../Utils/leak_detector.h"
|
#include "leak_detector.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "../Utils/CommonBlock.h"
|
#include "CommonBlock.h"
|
||||||
#include "../GraphCall/graph_calls.h"
|
#include "graph_calls.h"
|
||||||
#include "../ExpressionTransform/expr_transform.h"
|
#include "expr_transform.h"
|
||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "IR.h"
|
#include "IR.h"
|
||||||
@@ -395,7 +395,7 @@ static SAPFOR::Argument* processExpression(SgExpression* ex, vector<IR_Block*>&
|
|||||||
if (ex)
|
if (ex)
|
||||||
{
|
{
|
||||||
const int var = ex->variant();
|
const int var = ex->variant();
|
||||||
if ((var == VAR_REF || var == CONST_REF || var == LABEL_REF) && !ex->lhs() && !ex->rhs()) // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
if ((var == VAR_REF || var == CONST_REF || var == LABEL_REF) && !ex->lhs() && !ex->rhs()) // variable reference
|
||||||
{
|
{
|
||||||
if (var == CONST_REF)
|
if (var == CONST_REF)
|
||||||
{
|
{
|
||||||
@@ -450,7 +450,7 @@ static SAPFOR::Argument* processExpression(SgExpression* ex, vector<IR_Block*>&
|
|||||||
return arg1;
|
return arg1;
|
||||||
|
|
||||||
auto reg = isLeft ? NULL : createRegister();
|
auto reg = isLeft ? NULL : createRegister();
|
||||||
Instruction* instr = new Instruction(isLeft ? CFG_OP::STORE : CFG_OP::LOAD, arg1, createConstArg(numArgs), isLeft ? isLeft : reg);
|
Instruction* instr = new Instruction(isLeft ? CFG_OP::STORE : CFG_OP::LOAD, arg1, createConstArg(numArgs), isLeft ? isLeft : reg, NULL, ex);
|
||||||
blocks.push_back(new IR_Block(instr));
|
blocks.push_back(new IR_Block(instr));
|
||||||
return reg;
|
return reg;
|
||||||
}
|
}
|
||||||
@@ -485,7 +485,7 @@ static SAPFOR::Argument* processExpression(SgExpression* ex, vector<IR_Block*>&
|
|||||||
auto arg1 = arrayRef ? arrayRef : createArrayArg(ref, blocks, func, numArgs, commonVars);
|
auto arg1 = arrayRef ? arrayRef : createArrayArg(ref, blocks, func, numArgs, commonVars);
|
||||||
|
|
||||||
auto reg = isLeft ? NULL : createRegister();
|
auto reg = isLeft ? NULL : createRegister();
|
||||||
instr = new Instruction(isLeft ? CFG_OP::STORE : CFG_OP::LOAD, arg1, createConstArg(1), isLeft ? isLeft : reg);
|
instr = new Instruction(isLeft ? CFG_OP::STORE : CFG_OP::LOAD, arg1, createConstArg(1), isLeft ? isLeft : reg, NULL, ex);
|
||||||
blocks.push_back(new IR_Block(instr));
|
blocks.push_back(new IR_Block(instr));
|
||||||
return reg;
|
return reg;
|
||||||
}
|
}
|
||||||
@@ -602,7 +602,7 @@ static SAPFOR::Argument* processExpression(SgExpression* ex, vector<IR_Block*>&
|
|||||||
{
|
{
|
||||||
if (returnReg == NULL)
|
if (returnReg == NULL)
|
||||||
{
|
{
|
||||||
Instruction* instr = new Instruction(CFG_OP::LOAD, arg, NULL, reg);
|
Instruction* instr = new Instruction(CFG_OP::LOAD, arg, NULL, reg, NULL, ex);
|
||||||
blocks.push_back(new IR_Block(instr));
|
blocks.push_back(new IR_Block(instr));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1572,7 +1572,7 @@ vector<IR_Block*> buildIR(SgStatement* function, const FuncInfo* func, const vec
|
|||||||
else
|
else
|
||||||
findReturn(0, blocks.size(), blocks, blocks.back()->getNumber());
|
findReturn(0, blocks.size(), blocks, blocks.back()->getNumber());
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> GOTO <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// adding links by GOTO and jumps
|
||||||
for (int z = 0; z < blocks.size(); ++z)
|
for (int z = 0; z < blocks.size(); ++z)
|
||||||
{
|
{
|
||||||
auto op = blocks[z]->getInstruction()->getOperation();
|
auto op = blocks[z]->getInstruction()->getOperation();
|
||||||
@@ -1592,7 +1592,7 @@ vector<IR_Block*> buildIR(SgStatement* function, const FuncInfo* func, const vec
|
|||||||
|
|
||||||
blocks[z]->setJump(it->second);
|
blocks[z]->setJump(it->second);
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// replacing the label with the instruction number
|
||||||
arg->setValue(to_string(it->second->getNumber()));
|
arg->setValue(to_string(it->second->getNumber()));
|
||||||
arg->setType(CFG_ARG_TYPE::INSTR);
|
arg->setType(CFG_ARG_TYPE::INSTR);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "CFGraph.h"
|
#include "CFGraph.h"
|
||||||
#include "../Utils/CommonBlock.h"
|
#include "CommonBlock.h"
|
||||||
|
|
||||||
namespace SAPFOR
|
namespace SAPFOR
|
||||||
{
|
{
|
||||||
|
|||||||
102
src/CFGraph/IR_domTree.cpp
Normal file
102
src/CFGraph/IR_domTree.cpp
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
#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);
|
||||||
|
}
|
||||||
|
}
|
||||||
35
src/CFGraph/IR_domTree.h
Normal file
35
src/CFGraph/IR_domTree.h
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#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 "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "../Utils/CommonBlock.h"
|
#include "CommonBlock.h"
|
||||||
#include "../GraphCall/graph_calls.h"
|
#include "graph_calls.h"
|
||||||
#include "../ExpressionTransform/expr_transform.h"
|
#include "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 "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "../Utils/CommonBlock.h"
|
#include "CommonBlock.h"
|
||||||
#include "../GraphCall/graph_calls.h"
|
#include "graph_calls.h"
|
||||||
|
|
||||||
#include "CFGraph.h"
|
#include "CFGraph.h"
|
||||||
#include "IR.h"
|
#include "IR.h"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "CFGraph.h"
|
#include "CFGraph.h"
|
||||||
|
|
||||||
namespace LIVE_VARIABLES
|
namespace LIVE_VARIABLES
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "../Utils/errors.h"
|
#include "errors.h"
|
||||||
#include "private_variables_analysis.h"
|
#include "private_variables_analysis.h"
|
||||||
#include "../GraphLoop/graph_loops.h"
|
#include "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 "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "../GraphLoop/graph_loops.h"
|
#include "graph_loops.h"
|
||||||
#include "CFGraph.h"
|
#include "CFGraph.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "CreateInterTree.h"
|
#include "CreateInterTree.h"
|
||||||
#include "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "../Utils/utils.h"
|
#include "utils.h"
|
||||||
#include "../GraphCall/graph_calls_func.h"
|
#include "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 "../GraphLoop/graph_loops_func.h"
|
#include "graph_loops_func.h"
|
||||||
|
|
||||||
struct SpfInterval
|
struct SpfInterval
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../Utils/leak_detector.h"
|
#include "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 "../GraphLoop/graph_loops.h"
|
#include "graph_loops.h"
|
||||||
#include "directive_analyzer.h"
|
#include "directive_analyzer.h"
|
||||||
#include "../Utils/utils.h"
|
#include "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 "../GraphLoop/graph_loops.h"
|
#include "graph_loops.h"
|
||||||
|
|
||||||
void UniteNestedDirectives(std::vector<LoopGraph*> &loopGraph);
|
void UniteNestedDirectives(std::vector<LoopGraph*> &loopGraph);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../Utils/leak_detector.h"
|
#include "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 "../Utils/errors.h"
|
#include "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 "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "../Sapfor.h"
|
#include "../Sapfor.h"
|
||||||
#include "../GraphLoop/graph_loops_func.h"
|
#include "graph_loops_func.h"
|
||||||
#include "../Transformations/loop_transform.h"
|
#include "LoopNesting/loop_transform.h"
|
||||||
#include "../ExpressionTransform/expr_transform.h"
|
#include "expr_transform.h"
|
||||||
#include "../GraphCall/graph_calls_func.h"
|
#include "graph_calls_func.h"
|
||||||
|
|
||||||
#include "../Utils/AstWrapper.h"
|
#include "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 "../Utils/errors.h"
|
#include "errors.h"
|
||||||
#include "../GraphLoop/graph_loops.h"
|
#include "graph_loops.h"
|
||||||
#include "../Utils/types.h"
|
#include "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 "../Utils/leak_detector.h"
|
#include "leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -10,9 +10,9 @@
|
|||||||
|
|
||||||
#include "../ParallelizationRegions/ParRegions.h"
|
#include "../ParallelizationRegions/ParRegions.h"
|
||||||
#include "../Distribution/Arrays.h"
|
#include "../Distribution/Arrays.h"
|
||||||
#include "../Transformations/loop_transform.h"
|
#include "LoopNesting/loop_transform.h"
|
||||||
|
|
||||||
#include "../Utils/errors.h"
|
#include "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->isFor) // TODO: need to add all inductive variables!
|
if (tmpL->isWhile()) // TODO: need to add all inductive variables!
|
||||||
{
|
{
|
||||||
SgWhileStmt* dow = isSgWhileStmt(tmpL->loop->GetOriginal());
|
SgWhileStmt* dow = isSgWhileStmt(tmpL->loop->GetOriginal());
|
||||||
if (dow->conditional())
|
if (dow->conditional())
|
||||||
@@ -1124,7 +1124,7 @@ static bool tryToResolveUnmatchedDims(const map<DIST::Array*, vector<bool>> &dim
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
deprecateToMatch.insert(tmpL->loopSymbol);
|
deprecateToMatch.insert(tmpL->loopSymbol());
|
||||||
tmpL = tmpL->parent;
|
tmpL = tmpL->parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1601,7 +1601,7 @@ static bool matchParallelAndDist(const pair<DIST::Array*, const DistrVariant*>&
|
|||||||
parallelOn = NULL;
|
parallelOn = NULL;
|
||||||
for (auto& refOn : realRefs)
|
for (auto& refOn : realRefs)
|
||||||
{
|
{
|
||||||
linkWithTempl = parallelOn->GetLinksWithTemplate(regionId);
|
linkWithTempl = refOn->GetLinksWithTemplate(regionId);
|
||||||
int z = 0;
|
int z = 0;
|
||||||
for (int k = 0; k < linkWithTempl.size(); ++k)
|
for (int k = 0; k < linkWithTempl.size(); ++k)
|
||||||
if (linkWithTempl[k] != -1)
|
if (linkWithTempl[k] != -1)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../Utils/leak_detector.h"
|
#include "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 "../Utils/SgUtils.h"
|
#include "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 "../Utils/errors.h"
|
#include "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 "../Utils/leak_detector.h"
|
#include "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 "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||||
#include "../Utils/AstWrapper.h"
|
#include "AstWrapper.h"
|
||||||
#include "../Utils/errors.h"
|
#include "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 "../Utils/AstWrapper.h"
|
#include "AstWrapper.h"
|
||||||
#include "../GraphLoop/graph_loops.h"
|
#include "graph_loops.h"
|
||||||
#include "../Distribution/DvmhDirective.h"
|
#include "../Distribution/DvmhDirective.h"
|
||||||
|
|
||||||
struct DvmDirective
|
struct DvmDirective
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../Utils/leak_detector.h"
|
#include "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 "../GraphLoop/graph_loops_func.h"
|
#include "graph_loops_func.h"
|
||||||
#include "../GraphCall/graph_calls_func.h"
|
#include "graph_calls_func.h"
|
||||||
|
|
||||||
#include "../Utils/errors.h"
|
#include "errors.h"
|
||||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||||
#include "directive_parser.h"
|
#include "directive_parser.h"
|
||||||
#include "../Utils/SgUtils.h"
|
#include "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 "../Utils/leak_detector.h"
|
#include "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 "../Utils/types.h"
|
#include "types.h"
|
||||||
#include "../Utils/errors.h"
|
#include "errors.h"
|
||||||
#include "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "../Distribution/Arrays.h"
|
#include "../Distribution/Arrays.h"
|
||||||
#include "../GraphCall/graph_calls.h"
|
#include "graph_calls.h"
|
||||||
#include "../GraphCall/graph_calls_func.h"
|
#include "graph_calls_func.h"
|
||||||
#include "../GraphLoop/graph_loops_func.h"
|
#include "graph_loops_func.h"
|
||||||
#include "remote_access.h"
|
#include "remote_access.h"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../Utils/leak_detector.h"
|
#include "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 "../GraphCall/graph_calls.h"
|
#include "graph_calls.h"
|
||||||
#include "../GraphLoop/graph_loops.h"
|
#include "graph_loops.h"
|
||||||
#include "../ParallelizationRegions/ParRegions.h"
|
#include "../ParallelizationRegions/ParRegions.h"
|
||||||
#include "remote_access.h"
|
#include "remote_access.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
#include "../Utils/leak_detector.h"
|
#include "leak_detector.h"
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../Utils/errors.h"
|
#include "errors.h"
|
||||||
#include "../Utils/utils.h"
|
#include "utils.h"
|
||||||
#include "../GraphLoop/graph_loops_func.h"
|
#include "graph_loops_func.h"
|
||||||
#include "../GraphCall/graph_calls.h"
|
#include "graph_calls.h"
|
||||||
#include "../GraphCall/graph_calls_func.h"
|
#include "graph_calls_func.h"
|
||||||
#include "directive_parser.h"
|
#include "directive_parser.h"
|
||||||
#include "../Distribution/DvmhDirective_func.h"
|
#include "../Distribution/DvmhDirective_func.h"
|
||||||
#include "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "../ExpressionTransform/expr_transform.h"
|
#include "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 "../Utils/leak_detector.h"
|
#include "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 "../GraphLoop/graph_loops.h"
|
#include "graph_loops.h"
|
||||||
#include "../GraphCall/graph_calls_func.h"
|
#include "graph_calls_func.h"
|
||||||
#include "../SageAnalysisTool/depInterfaceExt.h"
|
#include "../SageAnalysisTool/depInterfaceExt.h"
|
||||||
#include "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "../Utils/errors.h"
|
#include "errors.h"
|
||||||
#include "directive_parser.h"
|
#include "directive_parser.h"
|
||||||
#include "../ExpressionTransform/expr_transform.h"
|
#include "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 "../Utils/errors.h"
|
#include "errors.h"
|
||||||
#include "../Utils/utils.h"
|
#include "utils.h"
|
||||||
#include "../GraphCall/graph_calls.h"
|
#include "graph_calls.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,9 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include "DvmhDirectiveBase.h"
|
#include "DvmhDirectiveBase.h"
|
||||||
#include "../Utils/utils.h"
|
#include "utils.h"
|
||||||
#include "../Utils/errors.h"
|
#include "errors.h"
|
||||||
|
#include "json.hpp"
|
||||||
|
|
||||||
class Symbol;
|
class Symbol;
|
||||||
class Expression;
|
class Expression;
|
||||||
@@ -20,6 +21,7 @@ struct FuncInfo;
|
|||||||
#define MAP std::map
|
#define MAP std::map
|
||||||
#define SET std::set
|
#define SET std::set
|
||||||
#define TO_STR std::to_string
|
#define TO_STR std::to_string
|
||||||
|
#define JSON nlohmann::json
|
||||||
|
|
||||||
#if __SPF
|
#if __SPF
|
||||||
extern int sharedMemoryParallelization;
|
extern int sharedMemoryParallelization;
|
||||||
@@ -104,7 +106,7 @@ namespace Distribution
|
|||||||
MAP<STRING, SET<int>> usagePlaces;
|
MAP<STRING, SET<int>> usagePlaces;
|
||||||
|
|
||||||
VECTOR<bool> mappedDims;
|
VECTOR<bool> mappedDims;
|
||||||
VECTOR<bool> depracateToDistribute;
|
VECTOR<bool> deprecateToDistribute;
|
||||||
|
|
||||||
bool ompThreadPrivate;
|
bool ompThreadPrivate;
|
||||||
bool privateInLoop;
|
bool privateInLoop;
|
||||||
@@ -169,7 +171,7 @@ namespace Distribution
|
|||||||
sizes.resize(dimSize);
|
sizes.resize(dimSize);
|
||||||
sizesExpr.resize(dimSize);
|
sizesExpr.resize(dimSize);
|
||||||
mappedDims.resize(dimSize);
|
mappedDims.resize(dimSize);
|
||||||
depracateToDistribute.resize(dimSize);
|
deprecateToDistribute.resize(dimSize);
|
||||||
|
|
||||||
for (int z = 0; z < dimSize; ++z)
|
for (int z = 0; z < dimSize; ++z)
|
||||||
{
|
{
|
||||||
@@ -177,7 +179,7 @@ namespace Distribution
|
|||||||
PAIR<int, int> initVal = std::make_pair(0, 0);
|
PAIR<int, int> initVal = std::make_pair(0, 0);
|
||||||
sizesExpr[z] = std::make_pair(std::make_pair((Expression*)NULL, initVal), std::make_pair((Expression*)NULL, initVal));
|
sizesExpr[z] = std::make_pair(std::make_pair((Expression*)NULL, initVal), std::make_pair((Expression*)NULL, initVal));
|
||||||
mappedDims[z] = false;
|
mappedDims[z] = false;
|
||||||
depracateToDistribute[z] = false;
|
deprecateToDistribute[z] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GenUniqKey();
|
GenUniqKey();
|
||||||
@@ -212,7 +214,7 @@ namespace Distribution
|
|||||||
uniqKey = copy.uniqKey;
|
uniqKey = copy.uniqKey;
|
||||||
containsInRegions = copy.containsInRegions;
|
containsInRegions = copy.containsInRegions;
|
||||||
mappedDims = copy.mappedDims;
|
mappedDims = copy.mappedDims;
|
||||||
depracateToDistribute = copy.depracateToDistribute;
|
deprecateToDistribute = copy.deprecateToDistribute;
|
||||||
ompThreadPrivate = copy.ompThreadPrivate;
|
ompThreadPrivate = copy.ompThreadPrivate;
|
||||||
privateInLoop = copy.privateInLoop;
|
privateInLoop = copy.privateInLoop;
|
||||||
inEquivalence = copy.inEquivalence;
|
inEquivalence = copy.inEquivalence;
|
||||||
@@ -224,7 +226,7 @@ namespace Distribution
|
|||||||
int countToRem = 0;
|
int countToRem = 0;
|
||||||
for (int z = 0; z < dimSize; ++z)
|
for (int z = 0; z < dimSize; ++z)
|
||||||
{
|
{
|
||||||
if (!mappedDims[z] || depracateToDistribute[z])
|
if (!mappedDims[z] || deprecateToDistribute[z])
|
||||||
{
|
{
|
||||||
needToRemove = true;
|
needToRemove = true;
|
||||||
countToRem++;
|
countToRem++;
|
||||||
@@ -244,19 +246,19 @@ namespace Distribution
|
|||||||
|
|
||||||
for (int z = 0; z < dimSize; ++z)
|
for (int z = 0; z < dimSize; ++z)
|
||||||
{
|
{
|
||||||
if (mappedDims[z] && !depracateToDistribute[z])
|
if (mappedDims[z] && !deprecateToDistribute[z])
|
||||||
{
|
{
|
||||||
newSizes.push_back(sizes[z]);
|
newSizes.push_back(sizes[z]);
|
||||||
newSizesExpr.push_back(sizesExpr[z]);
|
newSizesExpr.push_back(sizesExpr[z]);
|
||||||
newMappedDims.push_back(mappedDims[z]);
|
newMappedDims.push_back(mappedDims[z]);
|
||||||
newDepr.push_back(depracateToDistribute[z]);
|
newDepr.push_back(deprecateToDistribute[z]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sizes = newSizes;
|
sizes = newSizes;
|
||||||
sizesExpr = newSizesExpr;
|
sizesExpr = newSizesExpr;
|
||||||
mappedDims = newMappedDims;
|
mappedDims = newMappedDims;
|
||||||
depracateToDistribute = newDepr;
|
deprecateToDistribute = newDepr;
|
||||||
dimSize = (int)sizes.size();
|
dimSize = (int)sizes.size();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -424,48 +426,64 @@ namespace Distribution
|
|||||||
|
|
||||||
void ClearShadowSpecs() { allShadowSpecs.clear(); }
|
void ClearShadowSpecs() { allShadowSpecs.clear(); }
|
||||||
|
|
||||||
STRING toString()
|
JSON toJson()
|
||||||
{
|
{
|
||||||
STRING retVal = "";
|
JSON retVal;
|
||||||
retVal += TO_STR(id);
|
|
||||||
retVal += "#" + name;
|
|
||||||
retVal += "#" + shortName;
|
|
||||||
retVal += "#" + TO_STR(dimSize);
|
|
||||||
retVal += "#" + TO_STR(typeSize);
|
|
||||||
retVal += "#" + TO_STR(isNonDistribute);
|
|
||||||
|
|
||||||
retVal += "#" + TO_STR(locationPos.first);
|
|
||||||
retVal += "#" + locationPos.second;
|
|
||||||
|
|
||||||
retVal += "#" + TO_STR(sizes.size());
|
retVal["id"] = (int64_t)id;
|
||||||
for (int i = 0; i < sizes.size(); ++i)
|
retVal["name"] = name;
|
||||||
retVal += "#" + TO_STR(sizes[i].first) + "#" + TO_STR(sizes[i].second);
|
retVal["shortName"] = shortName;
|
||||||
|
retVal["packedAddress"] = std::to_string((long long)this);
|
||||||
|
|
||||||
retVal += "#" + TO_STR(depracateToDistribute.size());
|
retVal["dimSize"] = dimSize;
|
||||||
for (int i = 0; i < depracateToDistribute.size(); ++i)
|
retVal["typeSize"] = typeSize;
|
||||||
retVal += "#" + TO_STR((int)depracateToDistribute[i]);
|
retVal["state"] = (int)isNonDistribute;
|
||||||
|
retVal["location"] = (int)locationPos.first;
|
||||||
|
retVal["locName"] = locationPos.second;
|
||||||
|
|
||||||
retVal += "#" + TO_STR(mappedDims.size());
|
retVal["isTemplFlag"] = (int)isTemplFlag;
|
||||||
|
retVal["isLoopArrayFlag"] = (int)isLoopArrayFlag;
|
||||||
|
|
||||||
|
JSON deprToDist = nlohmann::json::array();
|
||||||
|
for (int i = 0; i < deprecateToDistribute.size(); ++i)
|
||||||
|
deprToDist.push_back((int)deprecateToDistribute[i]);
|
||||||
|
retVal["deprecateToDist"] = deprToDist;
|
||||||
|
|
||||||
|
JSON mappedDimsJ = nlohmann::json::array();
|
||||||
for (int i = 0; i < mappedDims.size(); ++i)
|
for (int i = 0; i < mappedDims.size(); ++i)
|
||||||
retVal += "#" + TO_STR((int)mappedDims[i]);
|
mappedDimsJ.push_back((int)mappedDims[i]);
|
||||||
|
retVal["mappedDims"] = mappedDimsJ;
|
||||||
|
|
||||||
retVal += "#" + TO_STR(templateInfo.size());
|
JSON sizesJ = nlohmann::json::array();
|
||||||
for (auto it = templateInfo.begin(); it != templateInfo.end(); ++it)
|
for (int i = 0; i < sizes.size(); ++i)
|
||||||
retVal += "#" + TO_STR(it->first) + it->second->toString();
|
{
|
||||||
|
JSON pair;
|
||||||
retVal += "#" + TO_STR((int)isTemplFlag);
|
pair["key"] = sizes[i].first;
|
||||||
retVal += "|" + TO_STR((int)isLoopArrayFlag);
|
pair["value"] = sizes[i].second;
|
||||||
retVal += "|" + TO_STR(declPlaces.size());
|
sizesJ.push_back(pair);
|
||||||
|
}
|
||||||
|
retVal["sizes"] = sizesJ;
|
||||||
|
|
||||||
for (auto &place : declPlaces)
|
JSON regions = nlohmann::json::array();
|
||||||
retVal += "|" + place.first + "|" + TO_STR(place.second);
|
for (auto& reg : containsInRegions)
|
||||||
|
regions.push_back(reg);
|
||||||
|
retVal["regions"] = regions;
|
||||||
|
|
||||||
|
|
||||||
|
JSON declPlacesJ = nlohmann::json::array();
|
||||||
|
for (auto& place : declPlaces)
|
||||||
|
{
|
||||||
|
JSON elem;
|
||||||
|
elem["file"] = place.first;
|
||||||
|
elem["line"] = place.second;
|
||||||
|
|
||||||
|
declPlacesJ.push_back(elem);
|
||||||
|
}
|
||||||
|
retVal["declPlaces"] = declPlacesJ;
|
||||||
|
|
||||||
retVal += "|" + TO_STR(containsInRegions.size());
|
|
||||||
for (auto ® : containsInRegions)
|
|
||||||
retVal += "|" + reg;
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array* GetTemplateArray(const uint64_t regionId, bool withCheck = true)
|
Array* GetTemplateArray(const uint64_t regionId, bool withCheck = true)
|
||||||
{
|
{
|
||||||
TemplateLink *currLink = getTemlateInfo(regionId, withCheck);
|
TemplateLink *currLink = getTemlateInfo(regionId, withCheck);
|
||||||
@@ -587,13 +605,13 @@ namespace Distribution
|
|||||||
{
|
{
|
||||||
if (dim >= dimSize)
|
if (dim >= dimSize)
|
||||||
return;
|
return;
|
||||||
depracateToDistribute[dim] = value;
|
deprecateToDistribute[dim] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeprecateAllDims()
|
void DeprecateAllDims()
|
||||||
{
|
{
|
||||||
for (int dim = 0; dim < dimSize; ++dim)
|
for (int dim = 0; dim < dimSize; ++dim)
|
||||||
depracateToDistribute[dim] = true;
|
deprecateToDistribute[dim] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsDimDepracated(const int dim) const
|
bool IsDimDepracated(const int dim) const
|
||||||
@@ -603,9 +621,9 @@ namespace Distribution
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (templateDimsOrder.size() == 0)
|
if (templateDimsOrder.size() == 0)
|
||||||
return depracateToDistribute[dim];
|
return deprecateToDistribute[dim];
|
||||||
else
|
else
|
||||||
return depracateToDistribute[templateDimsOrder[dim]];
|
return deprecateToDistribute[templateDimsOrder[dim]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -613,11 +631,11 @@ namespace Distribution
|
|||||||
{
|
{
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
for (int z = 0; z < dimSize; ++z)
|
for (int z = 0; z < dimSize; ++z)
|
||||||
ret = ret && depracateToDistribute[z];
|
ret = ret && deprecateToDistribute[z];
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
const VECTOR<bool>& GetDeprecetedDims() const { return depracateToDistribute; }
|
const VECTOR<bool>& GetDeprecetedDims() const { return deprecateToDistribute; }
|
||||||
|
|
||||||
int GetTypeSize() const { return typeSize; }
|
int GetTypeSize() const { return typeSize; }
|
||||||
|
|
||||||
@@ -809,4 +827,4 @@ namespace Distribution
|
|||||||
#undef PAIR
|
#undef PAIR
|
||||||
#undef MAP
|
#undef MAP
|
||||||
#undef SET
|
#undef SET
|
||||||
#undef TO_STR
|
#undef TO_STR
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#include "Array.h"
|
#include "Array.h"
|
||||||
#include "../Utils/errors.h"
|
#include "errors.h"
|
||||||
#include "../Utils/utils.h"
|
#include "utils.h"
|
||||||
#include "../GraphCall/graph_calls.h"
|
#include "graph_calls.h"
|
||||||
#include "../Utils/SgUtils.h"
|
#include "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,13 +241,15 @@ 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 (privates.find(symb->identifier()) != privates.end() || isarrayInModule)
|
else if (deprecatedByIO.find(symb->identifier()) != deprecatedByIO.end())
|
||||||
|
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)
|
||||||
@@ -274,8 +276,6 @@ 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 "../Utils/leak_detector.h"
|
#include "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 "../Utils/errors.h"
|
#include "errors.h"
|
||||||
#include "../Utils/utils.h"
|
#include "utils.h"
|
||||||
#include "../GraphLoop/graph_loops.h"
|
#include "graph_loops.h"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::set;
|
using std::set;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../GraphLoop/graph_loops.h"
|
#include "graph_loops.h"
|
||||||
#include "../Utils/errors.h"
|
#include "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 "../Utils/leak_detector.h"
|
#include "leak_detector.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "../Utils/types.h"
|
#include "types.h"
|
||||||
|
|
||||||
namespace Distribution
|
namespace Distribution
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../Utils/leak_detector.h"
|
#include "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/utils.h"
|
#include "utils.h"
|
||||||
#include "../Utils/errors.h"
|
#include "errors.h"
|
||||||
#include "../Utils/types.h"
|
#include "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,15 +455,7 @@ 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)
|
||||||
@@ -516,7 +508,7 @@ namespace Distribution
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (needPrint)
|
if (needPrint)
|
||||||
sendMessage_2lvl(L"");
|
sendMessage_2lvl(2);
|
||||||
|
|
||||||
return make_pair(allOnlySecondType, globalSum);
|
return make_pair(allOnlySecondType, globalSum);
|
||||||
}
|
}
|
||||||
@@ -572,13 +564,7 @@ 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;
|
||||||
|
|
||||||
@@ -605,7 +591,7 @@ namespace Distribution
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sendMessage_2lvl(L"");
|
sendMessage_2lvl(2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../Utils/leak_detector.h"
|
#include "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 "../Utils/types.h"
|
#include "types.h"
|
||||||
#include "DvmhDirective.h"
|
#include "DvmhDirective.h"
|
||||||
#include "../Utils/errors.h"
|
#include "errors.h"
|
||||||
#include "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "../Sapfor.h"
|
#include "../Sapfor.h"
|
||||||
#include "../GraphCall/graph_calls_func.h"
|
#include "graph_calls_func.h"
|
||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
|
|
||||||
@@ -199,15 +199,6 @@ static set<string> fillUsedSymbols(SgStatement *loop)
|
|||||||
return usedS;
|
return usedS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static string correctSymbolModuleName(const string& origFull)
|
|
||||||
{
|
|
||||||
auto it = origFull.find("::");
|
|
||||||
if (it == string::npos)
|
|
||||||
return origFull;
|
|
||||||
else
|
|
||||||
return origFull.substr(it + 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static SgStatement* getModuleScope(const string& origFull, vector<SgStatement*>& moduleList, SgStatement *local)
|
static SgStatement* getModuleScope(const string& origFull, vector<SgStatement*>& moduleList, SgStatement *local)
|
||||||
{
|
{
|
||||||
auto it = origFull.find("::");
|
auto it = origFull.find("::");
|
||||||
@@ -355,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -959,7 +950,7 @@ ParallelDirective::genDirective(File* file, const vector<pair<DIST::Array*, cons
|
|||||||
SgSymbol* redS;
|
SgSymbol* redS;
|
||||||
string clearName = correctSymbolModuleName(red);
|
string clearName = correctSymbolModuleName(red);
|
||||||
if (clearName != red)
|
if (clearName != red)
|
||||||
redS = getNameInLocation(parentFunc, clearName, getModuleScope(red, moduleList, parentFunc)->symbol()->identifier());
|
redS = getNameInLocation(parentFunc, red, getModuleScope(red, moduleList, parentFunc)->symbol()->identifier());
|
||||||
else
|
else
|
||||||
redS = findSymbolOrCreate(file, clearName, NULL, parentFunc);
|
redS = findSymbolOrCreate(file, clearName, NULL, parentFunc);
|
||||||
|
|
||||||
@@ -1017,12 +1008,12 @@ ParallelDirective::genDirective(File* file, const vector<pair<DIST::Array*, cons
|
|||||||
string clearName2 = correctSymbolModuleName(get<1>(list));
|
string clearName2 = correctSymbolModuleName(get<1>(list));
|
||||||
|
|
||||||
if (clearName1 != get<0>(list))
|
if (clearName1 != get<0>(list))
|
||||||
redS1 = getNameInLocation(parentFunc, clearName1, getModuleScope(get<0>(list), moduleList, parentFunc)->symbol()->identifier());
|
redS1 = getNameInLocation(parentFunc, get<0>(list), getModuleScope(get<0>(list), moduleList, parentFunc)->symbol()->identifier());
|
||||||
else
|
else
|
||||||
redS1 = findSymbolOrCreate(file, clearName1, NULL, parentFunc);
|
redS1 = findSymbolOrCreate(file, clearName1, NULL, parentFunc);
|
||||||
|
|
||||||
if (clearName2 != get<1>(list))
|
if (clearName2 != get<1>(list))
|
||||||
redS2 = getNameInLocation(parentFunc, clearName2, getModuleScope(get<1>(list), moduleList, parentFunc)->symbol()->identifier());
|
redS2 = getNameInLocation(parentFunc, get<1>(list), getModuleScope(get<1>(list), moduleList, parentFunc)->symbol()->identifier());
|
||||||
else
|
else
|
||||||
redS2 = findSymbolOrCreate(file, clearName2, NULL, parentFunc);
|
redS2 = findSymbolOrCreate(file, clearName2, NULL, parentFunc);
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
|
|
||||||
#include "Array.h"
|
#include "Array.h"
|
||||||
#include "DvmhDirectiveBase.h"
|
#include "DvmhDirectiveBase.h"
|
||||||
#include "../Utils/AstWrapper.h"
|
#include "AstWrapper.h"
|
||||||
#include "../Utils/types.h"
|
#include "types.h"
|
||||||
#include "../Utils/utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
extern int sharedMemoryParallelization;
|
extern int sharedMemoryParallelization;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../Utils/leak_detector.h"
|
#include "leak_detector.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -10,9 +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 "../Utils/errors.h"
|
#include "errors.h"
|
||||||
#include "../Utils/utils.h"
|
#include "utils.h"
|
||||||
#include "../GraphCall/graph_calls_func.h"
|
#include "json.hpp"
|
||||||
|
|
||||||
|
#include "graph_calls_func.h"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::tuple;
|
using std::tuple;
|
||||||
@@ -27,6 +29,8 @@ using std::make_pair;
|
|||||||
using std::min;
|
using std::min;
|
||||||
using std::max;
|
using std::max;
|
||||||
|
|
||||||
|
using nlohmann::json;
|
||||||
|
|
||||||
template<typename setT>
|
template<typename setT>
|
||||||
static void uniteSets(const set<setT> &first, const set<setT> &second, set<setT> &result)
|
static void uniteSets(const set<setT> &first, const set<setT> &second, set<setT> &result)
|
||||||
{
|
{
|
||||||
@@ -732,30 +736,34 @@ string AlignRuleBase::GenRuleBase() const
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
string AlignRuleBase::toString()
|
json AlignRuleBase::toJson()
|
||||||
{
|
{
|
||||||
string retVal = "";
|
json retVal;
|
||||||
|
|
||||||
if (alignArray)
|
retVal["packedAlignArrayAddress"] = alignArray ? std::to_string((long long)alignArray) : std::to_string((long long)-1);
|
||||||
retVal += "#" + std::to_string((long long)alignArray);
|
retVal["packedAlignWithAddress"] = alignWith ? std::to_string((long long)alignWith) : std::to_string((long long)-1);
|
||||||
else
|
|
||||||
retVal += "#-1";
|
|
||||||
|
|
||||||
if (alignWith)
|
json alignRules = json::array();
|
||||||
retVal += "#" + std::to_string((long long)alignWith);
|
for (auto& rule : alignRule)
|
||||||
else
|
{
|
||||||
retVal += "#-1";
|
json pair;
|
||||||
|
pair["key"] = rule.first;
|
||||||
|
pair["value"] = rule.second;
|
||||||
|
alignRules.push_back(pair);
|
||||||
|
}
|
||||||
|
retVal["alignRule"] = alignRules;
|
||||||
|
|
||||||
retVal += "#" + std::to_string(alignRule.size());
|
json alignRuleWithJ = json::array();
|
||||||
for (int i = 0; i < alignRule.size(); ++i)
|
for (auto& [dimNum, AB] : alignRuleWith)
|
||||||
retVal += "#" + std::to_string(alignRule[i].first) + "#" + std::to_string(alignRule[i].second);
|
{
|
||||||
|
json tuple;
|
||||||
retVal += "#" + std::to_string(alignRuleWith.size());
|
tuple["dimNum"] = dimNum;
|
||||||
for (int i = 0; i < alignRuleWith.size(); ++i)
|
tuple["a"] = AB.first;
|
||||||
retVal += "#" + std::to_string(alignRuleWith[i].first)
|
tuple["b"] = AB.second;
|
||||||
+ "#" + std::to_string(alignRuleWith[i].second.first)
|
|
||||||
+ "#" + std::to_string(alignRuleWith[i].second.second);
|
|
||||||
|
|
||||||
|
alignRuleWithJ.push_back(tuple);
|
||||||
|
}
|
||||||
|
retVal["alignRuleWith"] = alignRuleWithJ;
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "json.hpp"
|
||||||
|
|
||||||
typedef enum lang : int { LANG_C, LANG_F } language;
|
typedef enum lang : int { LANG_C, LANG_F } language;
|
||||||
typedef enum dist : int { BLOCK, NONE } distType;
|
typedef enum dist : int { BLOCK, NONE } distType;
|
||||||
typedef std::pair<std::pair<int, int>, std::pair<int, int>> attrType;
|
typedef std::pair<std::pair<int, int>, std::pair<int, int>> attrType;
|
||||||
@@ -48,7 +50,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
std::string GenRuleBase() const;
|
std::string GenRuleBase() const;
|
||||||
std::string toString();
|
nlohmann::json toJson();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DIST::Array *alignArray;
|
DIST::Array *alignArray;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "../Utils/types.h"
|
#include "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 "../Utils/leak_detector.h"
|
#include "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 "../Utils/errors.h"
|
#include "errors.h"
|
||||||
#include "../Utils/utils.h"
|
#include "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"<22><><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"<22><><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(L"");
|
sendMessage_2lvl(2);*/
|
||||||
}
|
}
|
||||||
catch (int code)
|
catch (int code)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
#include "../Utils/RationalNum.h"
|
#include "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 "../GraphLoop/graph_loops_func.h"
|
#include "graph_loops_func.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|||||||
@@ -11,13 +11,12 @@
|
|||||||
#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;
|
||||||
|
|
||||||
|
|
||||||
#define DVMH_REG_RD 0
|
#define DVMH_REG_RD 0
|
||||||
#define DVMH_REG_WT 1
|
#define DVMH_REG_WT 1
|
||||||
|
|
||||||
@@ -795,152 +794,6 @@ 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());
|
|
||||||
|
|
||||||
//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)
|
|
||||||
{
|
|
||||||
SgStatement* next = st->lexNext();
|
|
||||||
st->extractStmt();
|
|
||||||
st = next;
|
|
||||||
}
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
SgStatement* next = st->lexNext();
|
|
||||||
toExtract.push_back(st);
|
|
||||||
st = next;
|
|
||||||
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();
|
||||||
@@ -1171,7 +1024,7 @@ static bool isPure(SgStatement* func)
|
|||||||
|
|
||||||
void DvmhRegionInserter::createInterfaceBlockForOutCall(FuncInfo* func, FuncInfo* callFrom)
|
void DvmhRegionInserter::createInterfaceBlockForOutCall(FuncInfo* func, FuncInfo* callFrom)
|
||||||
{
|
{
|
||||||
insertInterface(func->funcPointer, getInterfaceBlock(callFrom->funcPointer->GetOriginal(), callFrom->funcParams), callFrom->funcName);
|
insertInterface(func->funcPointer, callFrom);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DvmhRegionInserter::createInterfaceBlockForParallelFunctions(bool onlyRoutine)
|
void DvmhRegionInserter::createInterfaceBlockForParallelFunctions(bool onlyRoutine)
|
||||||
@@ -1428,21 +1281,15 @@ static set<DIST::Array*>
|
|||||||
|
|
||||||
for (auto& realArray : realRef)
|
for (auto& realArray : realRef)
|
||||||
{
|
{
|
||||||
if (added.count(realArray) != 0 || !realArray->IsNotDistribute())
|
if (added.count(realArray) != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!realArray->IsNotDistribute())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
SgStatement* declStat = NULL;
|
SgStatement* declStat = NULL;
|
||||||
|
|
||||||
if (realArray->GetLocation().first != DIST::l_COMMON)
|
if (realArray->GetLocation().first == DIST::l_COMMON)
|
||||||
{
|
|
||||||
if (std::count(usedAll.begin(), usedAll.end(), realArray) == 0)
|
|
||||||
{
|
|
||||||
auto declInfo = *realArray->GetDeclInfo().begin();
|
|
||||||
declStat = SgStatement::getStatementByFileAndLine(declInfo.first, declInfo.second);
|
|
||||||
checkNull(declStat, convertFileName(__FILE__).c_str(), __LINE__);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
commonArrays.insert(realArray);
|
commonArrays.insert(realArray);
|
||||||
auto decls = realArray->GetDeclInfo();
|
auto decls = realArray->GetDeclInfo();
|
||||||
@@ -1450,7 +1297,10 @@ 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)
|
||||||
@@ -1462,7 +1312,7 @@ static set<DIST::Array*>
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
declStat = getFuncStat(declStat);
|
declStat = getFuncStat(declStat, { BLOCK_DATA });
|
||||||
if (declStat != main)
|
if (declStat != main)
|
||||||
{
|
{
|
||||||
declStat = NULL;
|
declStat = NULL;
|
||||||
@@ -1471,6 +1321,19 @@ static set<DIST::Array*>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (realArray->GetLocation().first == DIST::l_MODULE)
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (std::count(usedAll.begin(), usedAll.end(), realArray) == 0)
|
||||||
|
{
|
||||||
|
auto declInfo = *realArray->GetDeclInfo().begin();
|
||||||
|
declStat = SgStatement::getStatementByFileAndLine(declInfo.first, declInfo.second);
|
||||||
|
checkNull(declStat, convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (declStat)
|
if (declStat)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../GraphCall/graph_calls_func.h"
|
#include "graph_calls_func.h"
|
||||||
#include "../GraphLoop/graph_loops_func.h"
|
#include "graph_loops_func.h"
|
||||||
#include "../ExpressionTransform/expr_transform.h"
|
#include "expr_transform.h"
|
||||||
#include "../ParallelizationRegions/ParRegions.h"
|
#include "../ParallelizationRegions/ParRegions.h"
|
||||||
#include "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "ReadWriteAnalyzer.h"
|
#include "ReadWriteAnalyzer.h"
|
||||||
#include "DvmhRegion.h"
|
#include "DvmhRegion.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../GraphLoop/graph_loops_func.h"
|
#include "graph_loops_func.h"
|
||||||
#include "../GraphCall/graph_calls_func.h"
|
#include "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 "../Utils/SgUtils.h"
|
#include "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 "../Utils/SgUtils.h"
|
#include "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 "../GraphCall/graph_calls.h"
|
#include "graph_calls.h"
|
||||||
#include "./gcov_info.h"
|
#include "./gcov_info.h"
|
||||||
#include "./gCov_parser_func.h"
|
#include "./gCov_parser_func.h"
|
||||||
#include "../Utils/leak_detector.h"
|
#include "leak_detector.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../Utils/utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include "./gcov_info.h"
|
#include "./gcov_info.h"
|
||||||
#include "../CreateInterTree/CreateInterTree.h"
|
#include "../CreateInterTree/CreateInterTree.h"
|
||||||
#include "../GraphCall/graph_calls.h"
|
#include "graph_calls.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../Utils/leak_detector.h"
|
#include "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 "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "../Utils/errors.h"
|
#include "errors.h"
|
||||||
#include "gcov_info.h"
|
#include "gcov_info.h"
|
||||||
#include "../CreateInterTree/CreateInterTree.h"
|
#include "../CreateInterTree/CreateInterTree.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#include "../Utils/leak_detector.h"
|
#include "leak_detector.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "../Utils/errors.h"
|
#include "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/utils.h"
|
#include "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 "../Utils/leak_detector.h"
|
#include "leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -14,13 +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 "../GraphLoop/graph_loops_func.h"
|
#include "graph_loops_func.h"
|
||||||
#include "../DirectiveProcessing/directive_parser.h"
|
#include "../DirectiveProcessing/directive_parser.h"
|
||||||
#include "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
|
#include "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 "../ExpressionTransform/expr_transform.h"
|
#include "expr_transform.h"
|
||||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||||
#include "../VerificationCode/verifications.h"
|
#include "../VerificationCode/verifications.h"
|
||||||
|
|
||||||
@@ -37,6 +38,8 @@ using std::cout;
|
|||||||
using std::endl;
|
using std::endl;
|
||||||
using std::stack;
|
using std::stack;
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
|
|
||||||
//TODO: improve parameter checking
|
//TODO: improve parameter checking
|
||||||
@@ -776,6 +779,20 @@ 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)
|
||||||
@@ -795,8 +812,13 @@ 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 (isSgExecutableStatement(st) == NULL || st->lineNumber() <= 0)
|
if (st->lineNumber() <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (activeOps.size() && activeOps.find(st) == activeOps.end())
|
if (activeOps.size() && activeOps.find(st) == activeOps.end())
|
||||||
@@ -2592,4 +2614,71 @@ void setInlineAttributeToCalls(const map<string, FuncInfo*>& allFunctions,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static json convertToJson(const FuncInfo* currFunc) {
|
||||||
|
json func;
|
||||||
|
|
||||||
|
if (currFunc)
|
||||||
|
{
|
||||||
|
func["funcName"] = currFunc->funcName;
|
||||||
|
func["line"] = currFunc->linesNum.first;
|
||||||
|
func["lineEnd"] = currFunc->linesNum.second;
|
||||||
|
func["isMain"] = (int)currFunc->isMain;
|
||||||
|
func["needToInline"] = (int)currFunc->needToInline;
|
||||||
|
func["doNotInline"] = (int)currFunc->doNotInline;
|
||||||
|
func["doNotAnalyze"] = (int)currFunc->doNotAnalyze;
|
||||||
|
|
||||||
|
json func_pars = json::array();
|
||||||
|
|
||||||
|
for (int z = 0; z < currFunc->funcParams.countOfPars; ++z)
|
||||||
|
{
|
||||||
|
json par;
|
||||||
|
par["inoutType"] = currFunc->funcParams.inout_types[z];
|
||||||
|
par["identificator"] = currFunc->funcParams.identificators[z];
|
||||||
|
par["parameterT"] = string(paramNames[currFunc->funcParams.parametersT[z]]);
|
||||||
|
|
||||||
|
func_pars.push_back(par);
|
||||||
|
}
|
||||||
|
|
||||||
|
func["params"] = func_pars;
|
||||||
|
|
||||||
|
json calls_from = json::array();
|
||||||
|
for (const auto& call_from : currFunc->callsFromDetailed)
|
||||||
|
{
|
||||||
|
json call;
|
||||||
|
call["line"] = call_from.detailCallsFrom.second;
|
||||||
|
call["funcName"] = call_from.detailCallsFrom.first;
|
||||||
|
|
||||||
|
calls_from.push_back(call);
|
||||||
|
}
|
||||||
|
func["callsFrom"] = calls_from;
|
||||||
|
}
|
||||||
|
return func;
|
||||||
|
}
|
||||||
|
|
||||||
|
json convertToJson(const map<string, vector<FuncInfo*>>& funcsByFileMap) {
|
||||||
|
json loopsByFile = json::array();
|
||||||
|
|
||||||
|
for (auto& byFile : funcsByFileMap)
|
||||||
|
{
|
||||||
|
json func;
|
||||||
|
const string& file = byFile.first;
|
||||||
|
|
||||||
|
json func_array = json::array();
|
||||||
|
for (auto& func : byFile.second)
|
||||||
|
{
|
||||||
|
auto conv = convertToJson(func);
|
||||||
|
if (!conv.empty())
|
||||||
|
func_array.push_back(conv);
|
||||||
|
}
|
||||||
|
|
||||||
|
func["file"] = file;
|
||||||
|
func["functions"] = func_array;
|
||||||
|
|
||||||
|
loopsByFile.push_back(func);
|
||||||
|
}
|
||||||
|
|
||||||
|
json allFuncs;
|
||||||
|
allFuncs["allFunctions"] = loopsByFile;
|
||||||
|
return allFuncs;
|
||||||
|
}
|
||||||
#undef DEBUG
|
#undef DEBUG
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "../Utils/AstWrapper.h"
|
#include "AstWrapper.h"
|
||||||
#include "../Utils/utils.h"
|
#include "utils.h"
|
||||||
#include "../DirectiveProcessing/shadow.h"
|
#include "../DirectiveProcessing/shadow.h"
|
||||||
#include "../GraphLoop/graph_loops.h"
|
#include "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 "../Utils/leak_detector.h"
|
#include "leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -10,10 +10,10 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "../Utils/errors.h"
|
#include "errors.h"
|
||||||
#include "graph_calls.h"
|
#include "graph_calls.h"
|
||||||
#include "../Distribution/Distribution.h"
|
#include "../Distribution/Distribution.h"
|
||||||
#include "../Utils/utils.h"
|
#include "utils.h"
|
||||||
#include "../ParallelizationRegions/ParRegions.h"
|
#include "../ParallelizationRegions/ParRegions.h"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
@@ -378,33 +378,6 @@ FuncInfo* isUserFunctionInProject(const string &func)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
string convertToString(const FuncInfo *currFunc)
|
|
||||||
{
|
|
||||||
string result = "";
|
|
||||||
if (currFunc)
|
|
||||||
{
|
|
||||||
result += "|" + currFunc->funcName + "|" + to_string(currFunc->linesNum.first) +
|
|
||||||
"#" + to_string(currFunc->linesNum.second) +
|
|
||||||
"#" + to_string(currFunc->callsFromDetailed.size()) +
|
|
||||||
"#" + to_string(currFunc->needToInline) + "#" + to_string(currFunc->doNotInline) +
|
|
||||||
"#" + to_string(currFunc->doNotAnalyze) + "#" + to_string((int)currFunc->isMain);
|
|
||||||
|
|
||||||
result += "#" + to_string(currFunc->funcParams.countOfPars);
|
|
||||||
if (currFunc->funcParams.countOfPars)
|
|
||||||
{
|
|
||||||
for (int z = 0; z < currFunc->funcParams.countOfPars; ++z)
|
|
||||||
{
|
|
||||||
result += "#" + currFunc->funcParams.identificators[z] + "#" + to_string(currFunc->funcParams.inout_types[z]);
|
|
||||||
result += "#" + string(paramNames[currFunc->funcParams.parametersT[z]]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < currFunc->callsFromDetailed.size(); ++i)
|
|
||||||
result += "|" + currFunc->callsFromDetailed[i].detailCallsFrom.first + "|" + to_string(currFunc->callsFromDetailed[i].detailCallsFrom.second);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find dead functions and fill callTo / callFrom information
|
// Find dead functions and fill callTo / callFrom information
|
||||||
void findDeadFunctionsAndFillCalls(map<string, vector<FuncInfo*>> &allFuncInfo, map<string, vector<Messages>> &allMessages, bool noPrint)
|
void findDeadFunctionsAndFillCalls(map<string, vector<FuncInfo*>> &allFuncInfo, map<string, vector<Messages>> &allMessages, bool noPrint)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,8 +5,9 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "graph_calls.h"
|
#include "graph_calls.h"
|
||||||
#include "../GraphLoop/graph_loops.h"
|
#include "graph_loops.h"
|
||||||
#include "../ParallelizationRegions/ParRegions.h"
|
#include "../ParallelizationRegions/ParRegions.h"
|
||||||
|
#include "Utils/json.hpp"
|
||||||
|
|
||||||
namespace Distribution
|
namespace Distribution
|
||||||
{
|
{
|
||||||
@@ -23,7 +24,6 @@ int CreateCallGraphViz(const char *fileName, const std::map<std::string, std::ve
|
|||||||
int CreateFuncInfo(const char *fileName, const std::map<std::string, std::vector<FuncInfo*>> &funcByFile);
|
int CreateFuncInfo(const char *fileName, const std::map<std::string, std::vector<FuncInfo*>> &funcByFile);
|
||||||
std::string removeString(const std::string &toRemove, const std::string &inStr);
|
std::string removeString(const std::string &toRemove, const std::string &inStr);
|
||||||
FuncInfo* isUserFunctionInProject(const std::string &func);
|
FuncInfo* isUserFunctionInProject(const std::string &func);
|
||||||
std::string convertToString(const FuncInfo *currFunc);
|
|
||||||
void findDeadFunctionsAndFillCalls(std::map<std::string, std::vector<FuncInfo*>> &allFuncInfo, std::map<std::string, std::vector<Messages>> &allMessages, bool noPrint = false);
|
void findDeadFunctionsAndFillCalls(std::map<std::string, std::vector<FuncInfo*>> &allFuncInfo, std::map<std::string, std::vector<Messages>> &allMessages, bool noPrint = false);
|
||||||
void createLinksBetweenFormalAndActualParams(std::map<std::string, std::vector<FuncInfo*>> &allFuncInfo, std::map<DIST::Array*, std::set<DIST::Array*>> &arrayLinksByFuncCalls,
|
void createLinksBetweenFormalAndActualParams(std::map<std::string, std::vector<FuncInfo*>> &allFuncInfo, std::map<DIST::Array*, std::set<DIST::Array*>> &arrayLinksByFuncCalls,
|
||||||
const std::map<std::tuple<int, std::string, std::string>, std::pair<DIST::Array*, DIST::ArrayAccessInfo*>> &declaredArrays,
|
const std::map<std::tuple<int, std::string, std::string>, std::pair<DIST::Array*, DIST::ArrayAccessInfo*>> &declaredArrays,
|
||||||
@@ -53,5 +53,6 @@ void findContainsFunctions(SgStatement *st, std::vector<SgStatement*> &found, co
|
|||||||
void correctNameIfContains(SgStatement* call, SgExpression* exCall, std::string& name, const std::vector<SgStatement*>& containsFunctions, const std::string& prefix);
|
void correctNameIfContains(SgStatement* call, SgExpression* exCall, std::string& name, const std::vector<SgStatement*>& containsFunctions, const std::string& prefix);
|
||||||
int countPerfectLoopNest(SgStatement* st);
|
int countPerfectLoopNest(SgStatement* st);
|
||||||
void setInlineAttributeToCalls(const std::map<std::string, FuncInfo*>& allFunctions, const std::map<std::string, std::set<std::pair<std::string, int>>>& inDataChains, const std::map<std::string, std::vector<SgStatement*>>& hiddenData);
|
void setInlineAttributeToCalls(const std::map<std::string, FuncInfo*>& allFunctions, const std::map<std::string, std::set<std::pair<std::string, int>>>& inDataChains, const std::map<std::string, std::vector<SgStatement*>>& hiddenData);
|
||||||
|
nlohmann::json convertToJson(const std::map<std::string, std::vector<FuncInfo*>>& funcsByFile);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../Utils/leak_detector.h"
|
#include "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 "../GraphCall/graph_calls_func.h"
|
#include "graph_calls_func.h"
|
||||||
#include "../ParallelizationRegions/ParRegions_func.h"
|
#include "../ParallelizationRegions/ParRegions_func.h"
|
||||||
#include "../ExpressionTransform/expr_transform.h"
|
#include "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/utils.h"
|
#include "utils.h"
|
||||||
#include "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
|
|
||||||
#include "../Utils/errors.h"
|
#include "errors.h"
|
||||||
#include "../Utils/AstWrapper.h"
|
#include "AstWrapper.h"
|
||||||
|
#include "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 "../GraphCall/graph_calls_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;
|
||||||
@@ -40,6 +40,8 @@ using std::string;
|
|||||||
using std::wstring;
|
using std::wstring;
|
||||||
using std::pair;
|
using std::pair;
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
static inline void insertLabels(SgExpression *lb, map<int, vector<int>> &gotoLabels, const int line)
|
static inline void insertLabels(SgExpression *lb, map<int, vector<int>> &gotoLabels, const int line)
|
||||||
{
|
{
|
||||||
@@ -518,7 +520,7 @@ static void findArrayRef(SgExpression *exp, bool isWirte, set<DIST::Array*>& use
|
|||||||
{
|
{
|
||||||
if (exp)
|
if (exp)
|
||||||
{
|
{
|
||||||
if (exp->variant() == ARRAY_REF)
|
if (isArrayRef(exp))
|
||||||
{
|
{
|
||||||
DIST::Array *arrayRef = NULL;
|
DIST::Array *arrayRef = NULL;
|
||||||
SgSymbol *symbS = OriginalSymbol(exp->symbol());
|
SgSymbol *symbS = OriginalSymbol(exp->symbol());
|
||||||
@@ -697,7 +699,12 @@ 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 });
|
||||||
newLoop->isFor = isSgForStmt(st) ? true : false;
|
if (isSgForStmt(st))
|
||||||
|
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);
|
||||||
|
|
||||||
@@ -775,7 +782,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->loopSymbol = st->symbol() ? st->symbol()->identifier() : "unknown";
|
newLoop->loopSymbols.addMainVar(st->symbol() ? st->symbol()->identifier() : "unknown");
|
||||||
findArrayRefs(newLoop);
|
findArrayRefs(newLoop);
|
||||||
|
|
||||||
SgStatement *lexPrev = st->lexPrev();
|
SgStatement *lexPrev = st->lexPrev();
|
||||||
@@ -918,7 +925,7 @@ void* LoopGraph::getRealStat(const char* file) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern int PASSES_DONE[EMPTY_PASS];
|
extern int PASSES_DONE[EMPTY_PASS];
|
||||||
static void printToBuffer(const LoopGraph *currLoop, const int childSize, char buf[512])
|
static int getLoopState(const LoopGraph* currLoop)
|
||||||
{
|
{
|
||||||
int loopState = 0; // 0 - unknown, 1 - good, 2 - bad
|
int loopState = 0; // 0 - unknown, 1 - good, 2 - bad
|
||||||
if (PASSES_DONE[CREATE_TEMPLATE_LINKS] ||
|
if (PASSES_DONE[CREATE_TEMPLATE_LINKS] ||
|
||||||
@@ -934,49 +941,92 @@ static void printToBuffer(const LoopGraph *currLoop, const int childSize, char b
|
|||||||
if (currLoop->hasLimitsToParallel())
|
if (currLoop->hasLimitsToParallel())
|
||||||
loopState = 2;
|
loopState = 2;
|
||||||
}
|
}
|
||||||
sprintf(buf, "#%d#%d#%d#%d#%d#%d#%d#%d",
|
|
||||||
currLoop->lineNum, currLoop->lineNumAfterLoop, currLoop->perfectLoop, currLoop->hasGoto, currLoop->hasPrints, childSize, loopState,
|
return loopState;
|
||||||
currLoop->hasNonRectangularBounds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int calculateNormalChildSize(const LoopGraph *currLoop)
|
static json convertToJson(const LoopGraph* currLoop)
|
||||||
{
|
{
|
||||||
int count = 0;
|
json loop;
|
||||||
for (auto &elem : currLoop->children)
|
|
||||||
count += (elem->lineNum > 0) ? 1 : 0;
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
void convertToString(const LoopGraph *currLoop, string &result)
|
|
||||||
{
|
|
||||||
if (currLoop && currLoop->lineNum > 0)
|
if (currLoop && currLoop->lineNum > 0)
|
||||||
{
|
{
|
||||||
char buf[512];
|
loop["file"] = currLoop->fileName;
|
||||||
result += "#" + std::to_string(currLoop->calls.size());
|
loop["line"] = currLoop->lineNum;
|
||||||
for (int i = 0; i < currLoop->calls.size(); ++i)
|
loop["lineNumAfterLoop"] = currLoop->lineNumAfterLoop;
|
||||||
result += "#" + currLoop->calls[i].first + "#" + std::to_string(currLoop->calls[i].second);
|
loop["perfectLoop"] = currLoop->perfectLoop;
|
||||||
printToBuffer(currLoop, calculateNormalChildSize(currLoop), buf);
|
loop["loopState"] = getLoopState(currLoop);
|
||||||
result += string(buf);
|
loop["hasNonRectangularBounds"] = (int)currLoop->hasNonRectangularBounds;
|
||||||
|
|
||||||
result += "#" + std::to_string(currLoop->linesOfExternalGoTo.size());
|
json calls = json::array();
|
||||||
for (int i = 0; i < currLoop->linesOfExternalGoTo.size(); ++i)
|
for (auto& [func, line] : currLoop->calls)
|
||||||
result += "#" + std::to_string(currLoop->linesOfExternalGoTo[i]);
|
{
|
||||||
|
json call;
|
||||||
|
call["line"] = line;
|
||||||
|
call["funcName"] = func;
|
||||||
|
|
||||||
result += "#" + std::to_string(currLoop->linesOfInternalGoTo.size());
|
calls.push_back(call);
|
||||||
for (int i = 0; i < currLoop->linesOfInternalGoTo.size(); ++i)
|
}
|
||||||
result += "#" + std::to_string(currLoop->linesOfInternalGoTo[i]);
|
loop["funcCalls"] = calls;
|
||||||
|
|
||||||
result += "#" + std::to_string(currLoop->linesOfIO.size());
|
json e_gotos = json::array();
|
||||||
for (auto& i : currLoop->linesOfIO)
|
for (auto& line : currLoop->linesOfExternalGoTo)
|
||||||
result += "#" + std::to_string(i);
|
e_gotos.push_back(line);
|
||||||
|
loop["extGotos"] = e_gotos;
|
||||||
|
|
||||||
result += "#" + std::to_string(currLoop->linesOfStop.size());
|
json i_gotos = json::array();
|
||||||
for (auto& i : currLoop->linesOfStop)
|
for (auto& line : currLoop->linesOfInternalGoTo)
|
||||||
result += "#" + std::to_string(i);
|
i_gotos.push_back(line);
|
||||||
|
loop["intGotos"] = i_gotos;
|
||||||
|
|
||||||
for (int i = 0; i < (int)currLoop->children.size(); ++i)
|
json ios = json::array();
|
||||||
convertToString(currLoop->children[i], result);
|
for (auto& line : currLoop->linesOfIO)
|
||||||
|
ios.push_back(line);
|
||||||
|
loop["ios"] = ios;
|
||||||
|
|
||||||
|
json stops = json::array();
|
||||||
|
for (auto& line : currLoop->linesOfStop)
|
||||||
|
stops.push_back(line);
|
||||||
|
loop["stops"] = stops;
|
||||||
|
|
||||||
|
json children = json::array();
|
||||||
|
for (const auto& ch : currLoop->children)
|
||||||
|
{
|
||||||
|
auto conv = convertToJson(ch);
|
||||||
|
if (!conv.empty())
|
||||||
|
children.push_back(conv);
|
||||||
|
}
|
||||||
|
loop["children"] = children;
|
||||||
}
|
}
|
||||||
|
return loop;
|
||||||
|
}
|
||||||
|
|
||||||
|
json convertToJson(const map<string, vector<LoopGraph*>>& loopsByFileMap)
|
||||||
|
{
|
||||||
|
json loopsByFile = json::array();
|
||||||
|
|
||||||
|
for (auto& byFile : loopsByFileMap)
|
||||||
|
{
|
||||||
|
json loop;
|
||||||
|
const string& file = byFile.first;
|
||||||
|
|
||||||
|
json loops_array = json::array();
|
||||||
|
for (auto& loop : byFile.second)
|
||||||
|
{
|
||||||
|
auto conv = convertToJson(loop);
|
||||||
|
if (!conv.empty())
|
||||||
|
loops_array.push_back(conv);
|
||||||
|
}
|
||||||
|
|
||||||
|
loop["file"] = file;
|
||||||
|
loop["loops"] = loops_array;
|
||||||
|
|
||||||
|
loopsByFile.push_back(loop);
|
||||||
|
}
|
||||||
|
|
||||||
|
json allLoops;
|
||||||
|
allLoops["allLoops"] = loopsByFile;
|
||||||
|
return allLoops;
|
||||||
}
|
}
|
||||||
|
|
||||||
void createMapLoopGraph(const vector<LoopGraph*> &loops, map<int, LoopGraph*> &mapGraph)
|
void createMapLoopGraph(const vector<LoopGraph*> &loops, map<int, LoopGraph*> &mapGraph)
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "../Utils/errors.h"
|
#include "errors.h"
|
||||||
#include "../Utils/types.h"
|
#include "types.h"
|
||||||
#include "../Distribution/DvmhDirective.h"
|
#include "../Distribution/DvmhDirective.h"
|
||||||
#include "../Distribution/Distribution.h"
|
#include "../Distribution/Distribution.h"
|
||||||
|
|
||||||
@@ -25,6 +25,33 @@ 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:
|
||||||
@@ -70,7 +97,7 @@ public:
|
|||||||
calculatedCountOfIters = 0;
|
calculatedCountOfIters = 0;
|
||||||
executionTimeInSec = -1.0;
|
executionTimeInSec = -1.0;
|
||||||
inDvmhRegion = 0;
|
inDvmhRegion = 0;
|
||||||
isFor = false;
|
loopType = LoopType::NONE;
|
||||||
inCanonicalFrom = false;
|
inCanonicalFrom = false;
|
||||||
hasAccessToSubArray = false;
|
hasAccessToSubArray = false;
|
||||||
hasSubstringRefs = false;
|
hasSubstringRefs = false;
|
||||||
@@ -113,21 +140,24 @@ 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));
|
||||||
@@ -168,7 +198,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())
|
||||||
@@ -393,6 +423,14 @@ 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;
|
||||||
@@ -407,7 +445,7 @@ public:
|
|||||||
int startVal, endVal, stepVal;
|
int startVal, endVal, stepVal;
|
||||||
std::tuple<Expression*, Expression*, Expression*> startEndStepVals;
|
std::tuple<Expression*, Expression*, Expression*> startEndStepVals;
|
||||||
|
|
||||||
std::string loopSymbol;
|
InductiveVariables loopSymbols;
|
||||||
std::pair<Expression*, Expression*> startEndExpr;
|
std::pair<Expression*, Expression*> startEndExpr;
|
||||||
|
|
||||||
bool hasGoto;
|
bool hasGoto;
|
||||||
@@ -448,7 +486,7 @@ public:
|
|||||||
|
|
||||||
bool hasSubstringRefs;
|
bool hasSubstringRefs;
|
||||||
|
|
||||||
bool isFor;
|
LoopType loopType;
|
||||||
|
|
||||||
bool inCanonicalFrom;
|
bool inCanonicalFrom;
|
||||||
|
|
||||||
@@ -497,7 +535,6 @@ void processLoopInformationForFunction(std::map<LoopGraph*, std::map<DIST::Array
|
|||||||
void addToDistributionGraph(const std::map<LoopGraph*, std::map<DIST::Array*, ArrayInfo*>>& loopInfo, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls);
|
void addToDistributionGraph(const std::map<LoopGraph*, std::map<DIST::Array*, ArrayInfo*>>& loopInfo, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls);
|
||||||
void selectFreeLoopsForParallelization(const std::vector<LoopGraph*>& loops, const std::string& funcName, bool isDistribute, const std::vector<ParallelRegion*>& regions, std::vector<Messages>& messagesForFile);
|
void selectFreeLoopsForParallelization(const std::vector<LoopGraph*>& loops, const std::string& funcName, bool isDistribute, const std::vector<ParallelRegion*>& regions, std::vector<Messages>& messagesForFile);
|
||||||
|
|
||||||
void convertToString(const LoopGraph* currLoop, std::string& result);
|
|
||||||
int printLoopGraph(const char* fileName, const std::map<std::string, std::vector<LoopGraph*>>& loopGraph, bool withRegs = false);
|
int printLoopGraph(const char* fileName, const std::map<std::string, std::vector<LoopGraph*>>& loopGraph, bool withRegs = false);
|
||||||
void checkCountOfIter(std::map<std::string, std::vector<LoopGraph*>>& loopGraph, const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo, std::map<std::string, std::vector<Messages>>& SPF_messages);
|
void checkCountOfIter(std::map<std::string, std::vector<LoopGraph*>>& loopGraph, const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo, std::map<std::string, std::vector<Messages>>& SPF_messages);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../Utils/leak_detector.h"
|
#include "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 "../GraphCall/graph_calls_func.h"
|
#include "graph_calls_func.h"
|
||||||
#include "../Utils/errors.h"
|
#include "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",
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <string>
|
||||||
#include "graph_loops.h"
|
#include "graph_loops.h"
|
||||||
#include "../Distribution/DvmhDirective.h"
|
#include "../Distribution/DvmhDirective.h"
|
||||||
|
#include "Utils/json.hpp"
|
||||||
|
|
||||||
struct SpfInterval;
|
struct SpfInterval;
|
||||||
|
|
||||||
@@ -17,4 +19,6 @@ bool checkRegionEntries(SgStatement *begin, SgStatement *end, const std::map<std
|
|||||||
bool recSymbolFind(SgExpression *ex, const std::string &symb, const int var);
|
bool recSymbolFind(SgExpression *ex, const std::string &symb, const int var);
|
||||||
void completeFillOfArrayUsageBetweenProc(const std::map<std::string, std::vector<LoopGraph*>>& loopGraph, const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo);
|
void completeFillOfArrayUsageBetweenProc(const std::map<std::string, std::vector<LoopGraph*>>& loopGraph, const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo);
|
||||||
bool detectMpiCalls(SgProject* proj, std::map<std::string, std::vector<Messages>>& SPF_messages);
|
bool detectMpiCalls(SgProject* proj, std::map<std::string, std::vector<Messages>>& SPF_messages);
|
||||||
int calculateLoopIters(SgExpression* start, SgExpression* end, SgExpression* step, std::tuple<int, int, int>& result);
|
int calculateLoopIters(SgExpression* start, SgExpression* end, SgExpression* step, std::tuple<int, int, int>& result);
|
||||||
|
|
||||||
|
nlohmann::json convertToJson(const std::map<std::string, std::vector<LoopGraph*>>& loopsByFile);
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../Utils/leak_detector.h"
|
#include "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 "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "../Utils/errors.h"
|
#include "errors.h"
|
||||||
|
|
||||||
using std::set;
|
using std::set;
|
||||||
using std::pair;
|
using std::pair;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../Utils/leak_detector.h"
|
#include "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/utils.h"
|
#include "utils.h"
|
||||||
#include "../Utils/SgUtils.h"
|
#include "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 "../Utils/leak_detector.h"
|
#include "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 "../Utils/errors.h"
|
#include "errors.h"
|
||||||
#include "../DirectiveProcessing/directive_parser.h"
|
#include "../DirectiveProcessing/directive_parser.h"
|
||||||
#include "../DirectiveProcessing/directive_creator.h"
|
#include "../DirectiveProcessing/directive_creator.h"
|
||||||
|
|
||||||
#include "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "../Utils/AstWrapper.h"
|
#include "AstWrapper.h"
|
||||||
|
|
||||||
#include "../GraphCall/graph_calls_func.h"
|
#include "graph_calls_func.h"
|
||||||
#include "../GraphLoop/graph_loops_func.h"
|
#include "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 "../ExpressionTransform/expr_transform.h"
|
#include "expr_transform.h"
|
||||||
#include "../SageAnalysisTool/depInterfaceExt.h"
|
#include "../SageAnalysisTool/depInterfaceExt.h"
|
||||||
|
|
||||||
#include "../VisualizerCalls/get_information.h"
|
#include "../VisualizerCalls/get_information.h"
|
||||||
#include "../VisualizerCalls/SendMessage.h"
|
#include "../VisualizerCalls/SendMessage.h"
|
||||||
|
|
||||||
#include "../Transformations/enddo_loop_converter.h"
|
#include "LoopEndDoConverter/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,17 +1633,7 @@ 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();
|
||||||
#if _WIN32
|
sendMessage_2lvl(0, (file->functions(i)->variant() != MODULE_STMT), fName);
|
||||||
if (file->functions(i)->variant() != MODULE_STMT)
|
|
||||||
sendMessage_2lvl(wstring(L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '") + wstring(fName.begin(), fName.end()) + L"'");
|
|
||||||
else
|
|
||||||
sendMessage_2lvl(wstring(L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '") + wstring(fName.begin(), fName.end()) + L"'");
|
|
||||||
#else
|
|
||||||
if (file->functions(i)->variant() != MODULE_STMT)
|
|
||||||
sendMessage_2lvl(wstring(L"processing function '") + wstring(fName.begin(), fName.end()) + L"'");
|
|
||||||
else
|
|
||||||
sendMessage_2lvl(wstring(L"processing module '") + wstring(fName.begin(), fName.end()) + L"'");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
set<SgSymbol*> delcsSymbViewed;
|
set<SgSymbol*> delcsSymbViewed;
|
||||||
set<SgStatement*> delcsStatViewed;
|
set<SgStatement*> delcsStatViewed;
|
||||||
@@ -1710,7 +1700,10 @@ void loopAnalyzer(SgFile *file, vector<ParallelRegion*> ®ions, map<tuple<int,
|
|||||||
map<string, pair<SgSymbol*, SgStatement*>> notMappedDistributedArrays;
|
map<string, pair<SgSymbol*, SgStatement*>> notMappedDistributedArrays;
|
||||||
set<string> mappedDistrbutedArrays;
|
set<string> mappedDistrbutedArrays;
|
||||||
|
|
||||||
|
const ParallelRegionLines* prevParLines = NULL;
|
||||||
|
double prevLinesWeight = 1.0;
|
||||||
double currentWeight = 1.0;
|
double currentWeight = 1.0;
|
||||||
|
|
||||||
while (st != lastNode)
|
while (st != lastNode)
|
||||||
{
|
{
|
||||||
createNeededException();
|
createNeededException();
|
||||||
@@ -1733,13 +1726,31 @@ void loopAnalyzer(SgFile *file, vector<ParallelRegion*> ®ions, map<tuple<int,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const int currentLine = st->lineNumber() < -1 ? st->localLineNumber() : st->lineNumber();
|
const int currentLine = st->lineNumber() < -1 ? st->localLineNumber() : st->lineNumber();
|
||||||
ParallelRegion *currReg = getRegionByLine(regions, st->fileName(), currentLine);
|
auto regAndLines = getRegionAndLinesByLine(regions, st->fileName(), currentLine);
|
||||||
|
|
||||||
|
auto *currReg = regAndLines.first;
|
||||||
|
auto *parLines = regAndLines.second;
|
||||||
if (currReg == NULL)
|
if (currReg == NULL)
|
||||||
{
|
{
|
||||||
st = st->lexNext();
|
st = st->lexNext();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parLines != prevParLines)
|
||||||
|
{
|
||||||
|
prevParLines = parLines;
|
||||||
|
auto newParLinesWeight = parLines ? parLines->weight : 1.0;
|
||||||
|
|
||||||
|
if (prevParLines)
|
||||||
|
currentWeight /= prevLinesWeight;
|
||||||
|
|
||||||
|
if (parLines)
|
||||||
|
currentWeight *= newParLinesWeight;
|
||||||
|
|
||||||
|
prevLinesWeight = newParLinesWeight;
|
||||||
|
prevParLines = parLines;
|
||||||
|
}
|
||||||
|
|
||||||
if (isSgExecutableStatement(st) == NULL)
|
if (isSgExecutableStatement(st) == NULL)
|
||||||
delcsStatViewed.insert(st);
|
delcsStatViewed.insert(st);
|
||||||
else if (!sharedMemoryParallelization &&
|
else if (!sharedMemoryParallelization &&
|
||||||
@@ -2167,11 +2178,8 @@ 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();
|
||||||
#ifdef _WIN32
|
sendMessage_2lvl(1, idx, (int)convertedLoopInfo.size());
|
||||||
sendMessage_2lvl(wstring(L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> ") + std::to_wstring(idx) + L"/" + std::to_wstring(convertedLoopInfo.size()));
|
|
||||||
#else
|
|
||||||
sendMessage_2lvl(wstring(L"processing loop ") + std::to_wstring(idx) + L"/" + std::to_wstring(convertedLoopInfo.size()));
|
|
||||||
#endif
|
|
||||||
tryToFindDependencies(loop.first, allLoops, funcWasInit, file, regions, currMessages, collection, funcByName, defUseByPlace);
|
tryToFindDependencies(loop.first, allLoops, funcWasInit, file, regions, currMessages, collection, funcByName, defUseByPlace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2191,7 +2199,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->isFor = true;
|
tmpLoop->loopType = LoopType::FOR;
|
||||||
|
|
||||||
tmpLoops.push_back(tmpLoop);
|
tmpLoops.push_back(tmpLoop);
|
||||||
|
|
||||||
@@ -2319,7 +2327,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(L"");
|
sendMessage_2lvl(2);
|
||||||
}
|
}
|
||||||
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 "../GraphLoop/graph_loops.h"
|
#include "graph_loops.h"
|
||||||
#include "../GraphCall/graph_calls.h"
|
#include "graph_calls.h"
|
||||||
#include "../ParallelizationRegions/ParRegions.h"
|
#include "../ParallelizationRegions/ParRegions.h"
|
||||||
#include "../SageAnalysisTool/depInterfaceExt.h"
|
#include "../SageAnalysisTool/depInterfaceExt.h"
|
||||||
#include "../Utils/AstWrapper.h"
|
#include "AstWrapper.h"
|
||||||
#include "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../Utils/leak_detector.h"
|
#include "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/utils.h"
|
#include "utils.h"
|
||||||
#include "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "../GraphCall/graph_calls_func.h"
|
#include "graph_calls_func.h"
|
||||||
#include "../GraphLoop/graph_loops.h"
|
#include "graph_loops.h"
|
||||||
#include "../Distribution/Distribution.h"
|
#include "../Distribution/Distribution.h"
|
||||||
#include "../ExpressionTransform/expr_transform.h"
|
#include "expr_transform.h"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::string;
|
using std::string;
|
||||||
@@ -93,8 +93,10 @@ static inline SgStatement* getParentStat(SgStatement *st)
|
|||||||
return iterator;
|
return iterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void updateRegionInfo(SgStatement *st, map<string, pair<Statement*, Statement*>> &startEnd, map<string, pair<int, int>> &lines_,
|
static void updateRegionInfo(SgStatement *st, map<string, pair<Statement*, Statement*>> &startEnd,
|
||||||
set<string> &funcCallFromReg, const map<string, FuncInfo*> &mapFuncs)
|
map<string, pair<int, int>> &lines_,
|
||||||
|
map<string, map<string, set<int>>> &funcCallFromReg,
|
||||||
|
const map<string, FuncInfo*> &mapFuncs)
|
||||||
{
|
{
|
||||||
string containsPrefix = "";
|
string containsPrefix = "";
|
||||||
SgStatement *st_ps = getParentStat(st);
|
SgStatement *st_ps = getParentStat(st);
|
||||||
@@ -103,17 +105,26 @@ static void updateRegionInfo(SgStatement *st, map<string, pair<Statement*, State
|
|||||||
containsPrefix = st_ps->symbol()->identifier() + string(".");
|
containsPrefix = st_ps->symbol()->identifier() + string(".");
|
||||||
|
|
||||||
extendRegionInfo(st, startEnd, lines_);
|
extendRegionInfo(st, startEnd, lines_);
|
||||||
|
|
||||||
|
set<string> callsFromStatement;
|
||||||
|
|
||||||
if (st->variant() == PROC_STAT)
|
if (st->variant() == PROC_STAT)
|
||||||
{
|
{
|
||||||
string fullName = st->symbol()->identifier();
|
string fullName = st->symbol()->identifier();
|
||||||
//check contains
|
//check contains
|
||||||
if (mapFuncs.find(containsPrefix + fullName) != mapFuncs.end())
|
if (mapFuncs.find(containsPrefix + fullName) != mapFuncs.end())
|
||||||
fullName = containsPrefix + fullName;
|
fullName = containsPrefix + fullName;
|
||||||
funcCallFromReg.insert(fullName);
|
callsFromStatement.insert(fullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int z = 0; z < 3; ++z)
|
for (int z = 0; z < 3; ++z)
|
||||||
findFuncCalls(st->expr(z), funcCallFromReg, containsPrefix, mapFuncs);
|
findFuncCalls(st->expr(z), callsFromStatement, containsPrefix, mapFuncs);
|
||||||
|
|
||||||
|
string filename = st->fileName();
|
||||||
|
int line = st->lineNumber();
|
||||||
|
|
||||||
|
for (const auto &func_name : callsFromStatement)
|
||||||
|
funcCallFromReg[func_name][filename].insert(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fillArrayNamesInReg(set<string> &usedArrayInRegion, SgExpression *exp)
|
static void fillArrayNamesInReg(set<string> &usedArrayInRegion, SgExpression *exp)
|
||||||
@@ -318,8 +329,9 @@ void fillRegionLines(SgFile *file, vector<ParallelRegion*> ®ions, vector<Mess
|
|||||||
string regionName = "";
|
string regionName = "";
|
||||||
map<string, pair<Statement*, Statement*>> startEnd;
|
map<string, pair<Statement*, Statement*>> startEnd;
|
||||||
map<string, pair<int, int>> lines_;
|
map<string, pair<int, int>> lines_;
|
||||||
set<string> funcCallFromReg;
|
map<string, map<string, set<int>>> funcCallFromReg;
|
||||||
bool regionStarted = false;
|
bool regionStarted = false;
|
||||||
|
double fragmentWeight = 1.0;
|
||||||
|
|
||||||
vector<SgStatement*> toDel;
|
vector<SgStatement*> toDel;
|
||||||
for (int i = 0; i < funcNum; ++i)
|
for (int i = 0; i < funcNum; ++i)
|
||||||
@@ -368,6 +380,33 @@ void fillRegionLines(SgFile *file, vector<ParallelRegion*> ®ions, vector<Mess
|
|||||||
itFunc->second->callRegions.insert(0);
|
itFunc->second->callRegions.insert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// parse SPF_APPLY_FRAGMENT clause
|
||||||
|
auto *apply_fragment = data->expr(1);
|
||||||
|
fragmentWeight = 1.0;
|
||||||
|
|
||||||
|
while (apply_fragment)
|
||||||
|
{
|
||||||
|
auto *curr = apply_fragment->lhs();
|
||||||
|
if (curr)
|
||||||
|
{
|
||||||
|
__spf_print(1, "%s %d\n", curr->unparse(), curr->variant());
|
||||||
|
|
||||||
|
if (curr->variant() == SPF_WEIGHT_OP)
|
||||||
|
{
|
||||||
|
if (curr->lhs() &&
|
||||||
|
isSgValueExp(curr->lhs()) &&
|
||||||
|
isSgValueExp(curr->lhs())->doubleValue())
|
||||||
|
{
|
||||||
|
fragmentWeight = strtod(isSgValueExp(curr->lhs())->doubleValue(), NULL);
|
||||||
|
__spf_print(1, "->> %lf\n", fragmentWeight);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
__spf_print(1, "WEIGHT clause without double argument\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
apply_fragment = apply_fragment->rhs();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (next && next->variant() == SPF_END_PARALLEL_REG_DIR)
|
if (next && next->variant() == SPF_END_PARALLEL_REG_DIR)
|
||||||
@@ -400,10 +439,12 @@ void fillRegionLines(SgFile *file, vector<ParallelRegion*> ®ions, vector<Mess
|
|||||||
|
|
||||||
extendRegionInfo(st, startEnd, lines_, true);
|
extendRegionInfo(st, startEnd, lines_, true);
|
||||||
for (auto itRegInfo = startEnd.begin(); itRegInfo != startEnd.end(); ++itRegInfo)
|
for (auto itRegInfo = startEnd.begin(); itRegInfo != startEnd.end(); ++itRegInfo)
|
||||||
currReg->AddLines(lines_[itRegInfo->first], itRegInfo->first, &itRegInfo->second);
|
currReg->AddLines(lines_[itRegInfo->first], itRegInfo->first, &itRegInfo->second, fragmentWeight);
|
||||||
|
|
||||||
for (auto &func : funcCallFromReg)
|
for (auto &by_func : funcCallFromReg)
|
||||||
currReg->AddFuncCalls(func);
|
for (auto &by_file : by_func.second)
|
||||||
|
for(auto &by_line : by_file.second)
|
||||||
|
currReg->AddFuncCalls(by_func.first, by_file.first, by_line);
|
||||||
|
|
||||||
filterUserDirectives(currReg, usedArrayInRegion, userDvmRedistrDirs, userDvmRealignDirs, userDvmShadowDirs);
|
filterUserDirectives(currReg, usedArrayInRegion, userDvmRedistrDirs, userDvmRealignDirs, userDvmShadowDirs);
|
||||||
currReg->AddUserDirectives(userDvmRealignDirs, DVM_REALIGN_DIR);
|
currReg->AddUserDirectives(userDvmRealignDirs, DVM_REALIGN_DIR);
|
||||||
@@ -496,34 +537,48 @@ void fillRegionLinesStep2(vector<ParallelRegion*> ®ions, const map<string, ve
|
|||||||
{
|
{
|
||||||
if (regions[i]->GetName() != "DEFAULT")
|
if (regions[i]->GetName() != "DEFAULT")
|
||||||
for (auto &func : regions[i]->GetFuncCalls())
|
for (auto &func : regions[i]->GetFuncCalls())
|
||||||
setExplicitFlag(func, funcMap);
|
setExplicitFlag(func.first, funcMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < regions.size(); ++i)
|
for (int i = 0; i < regions.size(); ++i)
|
||||||
{
|
{
|
||||||
if (regions[i]->GetName() != "DEFAULT")
|
if (regions[i]->GetName() != "DEFAULT")
|
||||||
{
|
{
|
||||||
set<string> uniqFuncCalls;
|
map<string, double> uniqFuncCalls;
|
||||||
for (auto &elem : regions[i]->GetFuncCalls())
|
map<string, map<string, set<int>>> callPlaces;
|
||||||
uniqFuncCalls.insert(elem);
|
|
||||||
|
for (auto &elem : regions[i]->GetFuncCalls())
|
||||||
|
{
|
||||||
|
double max_weight = 0;
|
||||||
|
for (auto* fragment : elem.second)
|
||||||
|
if (fragment->weight > max_weight)
|
||||||
|
max_weight = fragment->weight;
|
||||||
|
|
||||||
|
uniqFuncCalls[elem.first] = max_weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wasChanged = true;
|
||||||
|
auto funcsBefore = uniqFuncCalls;
|
||||||
|
|
||||||
bool wasChanged = 1;
|
|
||||||
while (wasChanged)
|
while (wasChanged)
|
||||||
{
|
{
|
||||||
wasChanged = 0;
|
wasChanged = false;
|
||||||
|
auto updated = uniqFuncCalls;
|
||||||
|
|
||||||
for (auto &uniqF : uniqFuncCalls)
|
for (auto &uniqF : uniqFuncCalls)
|
||||||
{
|
{
|
||||||
auto func = funcMap.find(uniqF);
|
auto func = funcMap.find(uniqF.first);
|
||||||
if (func != funcMap.end())
|
if (func != funcMap.end())
|
||||||
{
|
{
|
||||||
for (auto &calls : func->second->callsFrom)
|
for (auto &call : func->second->callsFromDetailed)
|
||||||
{
|
{
|
||||||
auto it = uniqFuncCalls.find(calls);
|
auto it = updated.find(call.detailCallsFrom.first);
|
||||||
if (it == uniqFuncCalls.end())
|
if (it == updated.end())
|
||||||
{
|
updated.insert({call.detailCallsFrom.first, uniqF.second});
|
||||||
uniqFuncCalls.insert(it, calls);
|
else
|
||||||
wasChanged = 1;
|
it->second = std::max(it->second, uniqF.second);
|
||||||
}
|
|
||||||
|
callPlaces[call.detailCallsFrom.first][func->second->fileName].insert(call.detailCallsFrom.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -532,21 +587,27 @@ void fillRegionLinesStep2(vector<ParallelRegion*> ®ions, const map<string, ve
|
|||||||
string toPrint = "";
|
string toPrint = "";
|
||||||
for (auto &elem : uniqFuncCalls)
|
for (auto &elem : uniqFuncCalls)
|
||||||
{
|
{
|
||||||
auto it = funcMap.find(elem);
|
auto it = funcMap.find(elem.first);
|
||||||
if (it != funcMap.end())
|
if (it != funcMap.end())
|
||||||
{
|
{
|
||||||
regions[i]->AddLines(it->second->linesNum, it->second->fileName);
|
regions[i]->AddLines(it->second->linesNum, it->second->fileName, NULL, elem.second);
|
||||||
regions[i]->AddFuncCallsToAllCalls(it->second);
|
|
||||||
|
|
||||||
if (it->second->inRegion == 0)
|
if (it->second->inRegion == 0)
|
||||||
it->second->inRegion = 2;
|
it->second->inRegion = 2;
|
||||||
|
|
||||||
it->second->callRegions.insert(i);
|
it->second->callRegions.insert(i);
|
||||||
|
|
||||||
toPrint += elem + " ";
|
toPrint += elem.first + " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto &elem : callPlaces)
|
||||||
|
{
|
||||||
|
for (const auto &byFile : elem.second)
|
||||||
|
for (auto byLine : byFile.second)
|
||||||
|
regions[i]->AddFuncCalls(elem.first, byFile.first, byLine);
|
||||||
|
}
|
||||||
|
|
||||||
if (toPrint != "")
|
if (toPrint != "")
|
||||||
__spf_print(1, "[%s]: funcs: %s\n", regions[i]->GetName().c_str(), toPrint.c_str());
|
__spf_print(1, "[%s]: funcs: %s\n", regions[i]->GetName().c_str(), toPrint.c_str());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,15 +9,17 @@
|
|||||||
#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 "../Utils/AstWrapper.h"
|
#include "AstWrapper.h"
|
||||||
|
|
||||||
|
#include "json.hpp"
|
||||||
|
|
||||||
#if __SPF
|
#if __SPF
|
||||||
#include "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct ParallelRegionLines
|
struct ParallelRegionLines
|
||||||
{
|
{
|
||||||
ParallelRegionLines()
|
ParallelRegionLines(double weight = 1.0) : weight(weight)
|
||||||
{
|
{
|
||||||
lines = std::make_pair(-1, -1);
|
lines = std::make_pair(-1, -1);
|
||||||
stats = std::make_pair<Statement*, Statement*>(NULL, NULL);
|
stats = std::make_pair<Statement*, Statement*>(NULL, NULL);
|
||||||
@@ -25,14 +27,15 @@ struct ParallelRegionLines
|
|||||||
intervalAfter = std::make_pair<Statement*, Statement*>(NULL, NULL);
|
intervalAfter = std::make_pair<Statement*, Statement*>(NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ParallelRegionLines(const std::pair<int, int> &lines) : lines(lines)
|
ParallelRegionLines(const std::pair<int, int> &lines, double weight = 1.0) : lines(lines), weight(weight)
|
||||||
{
|
{
|
||||||
stats = std::make_pair<Statement*, Statement*>(NULL, NULL);
|
stats = std::make_pair<Statement*, Statement*>(NULL, NULL);
|
||||||
intervalBefore = std::make_pair<Statement*, Statement*>(NULL, NULL);
|
intervalBefore = std::make_pair<Statement*, Statement*>(NULL, NULL);
|
||||||
intervalAfter = std::make_pair<Statement*, Statement*>(NULL, NULL);
|
intervalAfter = std::make_pair<Statement*, Statement*>(NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ParallelRegionLines(const std::pair<int, int> &lines, const std::pair<Statement*, Statement*> stats) : lines(lines), stats(stats)
|
ParallelRegionLines(const std::pair<int, int> &lines, const std::pair<Statement*, Statement*> stats, double weight = 1.0)
|
||||||
|
: lines(lines), stats(stats), weight(weight)
|
||||||
{
|
{
|
||||||
intervalBefore = std::make_pair<Statement*, Statement*>(NULL, NULL);
|
intervalBefore = std::make_pair<Statement*, Statement*>(NULL, NULL);
|
||||||
intervalAfter = std::make_pair<Statement*, Statement*>(NULL, NULL);
|
intervalAfter = std::make_pair<Statement*, Statement*>(NULL, NULL);
|
||||||
@@ -60,6 +63,8 @@ struct ParallelRegionLines
|
|||||||
// <start, end> interval
|
// <start, end> interval
|
||||||
std::pair<Statement*, Statement*> intervalBefore;
|
std::pair<Statement*, Statement*> intervalBefore;
|
||||||
std::pair<Statement*, Statement*> intervalAfter;
|
std::pair<Statement*, Statement*> intervalAfter;
|
||||||
|
|
||||||
|
double weight; // weight of the fragment among all fragments of this region
|
||||||
};
|
};
|
||||||
|
|
||||||
#if __SPF
|
#if __SPF
|
||||||
@@ -114,7 +119,7 @@ public:
|
|||||||
currentVariant = copy.currentVariant;
|
currentVariant = copy.currentVariant;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AddLines(const std::pair<int, int> &linesToAdd, const std::string &file, const std::pair<Statement*, Statement*> *startEnd = NULL)
|
int AddLines(const std::pair<int, int> &linesToAdd, const std::string &file, const std::pair<Statement*, Statement*> *startEnd = NULL, double weight = 1.0)
|
||||||
{
|
{
|
||||||
if (linesToAdd.first > linesToAdd.second)
|
if (linesToAdd.first > linesToAdd.second)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -124,17 +129,29 @@ public:
|
|||||||
it = lines.insert(it, make_pair(file, std::vector<ParallelRegionLines>()));
|
it = lines.insert(it, make_pair(file, std::vector<ParallelRegionLines>()));
|
||||||
|
|
||||||
if (startEnd)
|
if (startEnd)
|
||||||
it->second.push_back(ParallelRegionLines(linesToAdd, *startEnd));
|
it->second.push_back(ParallelRegionLines(linesToAdd, *startEnd, weight));
|
||||||
else
|
else
|
||||||
it->second.push_back(ParallelRegionLines(linesToAdd));
|
it->second.push_back(ParallelRegionLines(linesToAdd, weight));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddFuncCalls(const std::string &func) { functionsCall.insert(func); }
|
void AddFuncCalls(const std::string &func, const std::string &file, const int line)
|
||||||
|
{
|
||||||
|
auto *found_lines = GetLinesByLine(file, line);
|
||||||
|
|
||||||
|
if (found_lines)
|
||||||
|
functionsCall[func].insert(found_lines);
|
||||||
|
}
|
||||||
|
|
||||||
#if __SPF
|
#if __SPF
|
||||||
void AddFuncCallsToAllCalls(FuncInfo *func) { allFunctionsCall.insert(func); }
|
void AddFuncCallsToAllCalls(FuncInfo *func, const std::string &file, const int line)
|
||||||
|
{
|
||||||
|
auto *found_lines = GetLinesByLine(file, line);
|
||||||
|
|
||||||
|
if (found_lines)
|
||||||
|
allFunctionsCall[func].insert(found_lines);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint64_t GetId() const { return regionId; }
|
uint64_t GetId() const { return regionId; }
|
||||||
@@ -174,10 +191,10 @@ public:
|
|||||||
const DataDirective& GetDataDir() const { return dataDirectives; }
|
const DataDirective& GetDataDir() const { return dataDirectives; }
|
||||||
DataDirective& GetDataDirToModify() { return dataDirectives; }
|
DataDirective& GetDataDirToModify() { return dataDirectives; }
|
||||||
|
|
||||||
const std::set<std::string>& GetFuncCalls() const { return functionsCall; }
|
const std::map<std::string, std::set<const ParallelRegionLines*>>& GetFuncCalls() const { return functionsCall; }
|
||||||
|
|
||||||
#if __SPF
|
#if __SPF
|
||||||
const std::set<FuncInfo*>& GetAllFuncCalls() const { return allFunctionsCall; }
|
const std::map<FuncInfo*, std::set<const ParallelRegionLines*>>& GetAllFuncCalls() const { return allFunctionsCall; }
|
||||||
const std::map<FuncInfo*, std::map<DIST::Array*, std::vector<ParallelRegionLines>>>& GetUsedLocalArrays() const { return usedLocalArrays; }
|
const std::map<FuncInfo*, std::map<DIST::Array*, std::vector<ParallelRegionLines>>>& GetUsedLocalArrays() const { return usedLocalArrays; }
|
||||||
const std::map<FuncInfo*, std::map<DIST::Array*, std::vector<ParallelRegionLines>>>& GetUsedCommonArrays() const { return usedCommonArrays; }
|
const std::map<FuncInfo*, std::map<DIST::Array*, std::vector<ParallelRegionLines>>>& GetUsedCommonArrays() const { return usedCommonArrays; }
|
||||||
|
|
||||||
@@ -216,7 +233,7 @@ public:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool HasThisLine(const int line, const std::string &file) const
|
bool HasThisLine(const int line, const std::string &file, const ParallelRegionLines** found = nullptr) const
|
||||||
{
|
{
|
||||||
bool retVal = false;
|
bool retVal = false;
|
||||||
auto it = lines.find(file);
|
auto it = lines.find(file);
|
||||||
@@ -227,6 +244,9 @@ public:
|
|||||||
if (it->second[i].lines.first <= line && it->second[i].lines.second >= line)
|
if (it->second[i].lines.first <= line && it->second[i].lines.second >= line)
|
||||||
{
|
{
|
||||||
retVal = true;
|
retVal = true;
|
||||||
|
if (found)
|
||||||
|
*found = &(it->second[i]);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -235,35 +255,42 @@ public:
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string toString()
|
nlohmann::json toJson()
|
||||||
{
|
{
|
||||||
std::string retVal = "";
|
nlohmann::json retVal;
|
||||||
|
|
||||||
retVal += "#" + std::to_string(regionId);
|
retVal["packedRegionId"] = std::to_string(regionId);
|
||||||
retVal += "#" + originalName;
|
retVal["originalName"] = originalName;
|
||||||
retVal += "#" + std::to_string(lines.size());
|
|
||||||
|
|
||||||
for (auto it = lines.begin(); it != lines.end(); ++it)
|
nlohmann::json arrays = nlohmann::json::array();
|
||||||
|
for (auto& array : allArrays.GetArrays())
|
||||||
|
arrays.push_back(array->toJson());
|
||||||
|
retVal["packedArrays"] = arrays;
|
||||||
|
|
||||||
|
nlohmann::json linesInfo = nlohmann::json::array();
|
||||||
|
for (auto& [file, linesByFile] : lines)
|
||||||
{
|
{
|
||||||
retVal += "|" + it->first + "|";
|
nlohmann::json linesRegs;
|
||||||
retVal += std::to_string(it->second.size());
|
nlohmann::json lines = nlohmann::json::array();
|
||||||
for (int i = 0; i < it->second.size(); ++i)
|
|
||||||
retVal += "#" + std::to_string(it->second[i].lines.first) + "#" + std::to_string(it->second[i].lines.second);
|
for (auto& elem : linesByFile)
|
||||||
|
{
|
||||||
|
JSON pair;
|
||||||
|
pair["key"] = elem.lines.first;
|
||||||
|
pair["value"] = elem.lines.second;
|
||||||
|
lines.push_back(pair);
|
||||||
|
}
|
||||||
|
linesRegs["file"] = file;
|
||||||
|
linesRegs["lines"] = lines;
|
||||||
|
|
||||||
|
linesInfo.push_back(linesRegs);
|
||||||
}
|
}
|
||||||
|
retVal["regionsLines"] = linesInfo;
|
||||||
|
|
||||||
const std::set<DIST::Array*> &arrays = allArrays.GetArrays();
|
nlohmann::json alignRules = nlohmann::json::array();
|
||||||
retVal += "#" + std::to_string(arrays.size());
|
for (auto& rule : dataDirectives.alignRules)
|
||||||
|
alignRules.push_back(rule.toJson());
|
||||||
//create map<array_address, DIST::Array_toString()>
|
retVal["alignRules"] = alignRules;
|
||||||
for (auto it = arrays.begin(); it != arrays.end(); ++it)
|
|
||||||
{
|
|
||||||
retVal += "#" + std::to_string((long long)(*it));
|
|
||||||
retVal += "#" + (*it)->toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
retVal += "#" + std::to_string(dataDirectives.alignRules.size());
|
|
||||||
for (int i = 0; i < dataDirectives.alignRules.size(); ++i)
|
|
||||||
retVal += dataDirectives.alignRules[i].toString();
|
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
@@ -283,7 +310,7 @@ public:
|
|||||||
fprintf(fileOut, " originalName '%s'\n", originalName.c_str());
|
fprintf(fileOut, " originalName '%s'\n", originalName.c_str());
|
||||||
fprintf(fileOut, " functions call from %d:\n", (int)functionsCall.size());
|
fprintf(fileOut, " functions call from %d:\n", (int)functionsCall.size());
|
||||||
for (auto &func : functionsCall)
|
for (auto &func : functionsCall)
|
||||||
fprintf(fileOut, " '%s'\n", func.c_str());
|
fprintf(fileOut, " '%s'\n", func.first.c_str());
|
||||||
fprintf(fileOut, " total lines %d:\n", (int)lines.size());
|
fprintf(fileOut, " total lines %d:\n", (int)lines.size());
|
||||||
for (auto &line : lines)
|
for (auto &line : lines)
|
||||||
{
|
{
|
||||||
@@ -353,11 +380,11 @@ private:
|
|||||||
std::string originalName;
|
std::string originalName;
|
||||||
// file -> lines info
|
// file -> lines info
|
||||||
std::map<std::string, std::vector<ParallelRegionLines>> lines;
|
std::map<std::string, std::vector<ParallelRegionLines>> lines;
|
||||||
std::set<std::string> functionsCall;
|
std::map<std::string, std::set<const ParallelRegionLines*>> functionsCall; // func name -> fragments with calls
|
||||||
|
|
||||||
#if __SPF
|
#if __SPF
|
||||||
// for RESOLVE_PAR_REGIONS
|
// for RESOLVE_PAR_REGIONS
|
||||||
std::set<FuncInfo*> allFunctionsCall;
|
std::map<FuncInfo*, std::set<const ParallelRegionLines*>> allFunctionsCall; // function -> fragments with calls
|
||||||
std::map<FuncInfo*, std::map<DIST::Array*, std::vector<ParallelRegionLines>>> usedLocalArrays; // func -> array -> lines
|
std::map<FuncInfo*, std::map<DIST::Array*, std::vector<ParallelRegionLines>>> usedLocalArrays; // func -> array -> lines
|
||||||
std::map<FuncInfo*, std::map<DIST::Array*, std::vector<ParallelRegionLines>>> usedCommonArrays; // func -> array -> lines
|
std::map<FuncInfo*, std::map<DIST::Array*, std::vector<ParallelRegionLines>>> usedCommonArrays; // func -> array -> lines
|
||||||
//
|
//
|
||||||
@@ -399,4 +426,5 @@ private:
|
|||||||
ParallelRegion* getRegionById(const std::vector<ParallelRegion*>& regions, const uint64_t regionId);
|
ParallelRegion* getRegionById(const std::vector<ParallelRegion*>& regions, const uint64_t regionId);
|
||||||
ParallelRegion* getRegionByName(const std::vector<ParallelRegion*>& regions, const std::string& regionName);
|
ParallelRegion* getRegionByName(const std::vector<ParallelRegion*>& regions, const std::string& regionName);
|
||||||
ParallelRegion* getRegionByLine(const std::vector<ParallelRegion*>& regions, const std::string& file, const int line);
|
ParallelRegion* getRegionByLine(const std::vector<ParallelRegion*>& regions, const std::string& file, const int line);
|
||||||
|
std::pair<ParallelRegion*, const ParallelRegionLines*> getRegionAndLinesByLine(const std::vector<ParallelRegion*>& regions, const std::string& file, const int line);
|
||||||
std::set<ParallelRegion*> getAllRegionsByLine(const std::vector<ParallelRegion*>& regions, const std::string& file, const int line);
|
std::set<ParallelRegion*> getAllRegionsByLine(const std::vector<ParallelRegion*>& regions, const std::string& file, const int line);
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ParRegions.h"
|
#include "ParRegions.h"
|
||||||
#include "../GraphCall/graph_calls.h"
|
#include "graph_calls.h"
|
||||||
#include "../GraphLoop/graph_loops.h"
|
#include "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 "../Utils/leak_detector.h"
|
#include "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 "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "../Utils/errors.h"
|
#include "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 "../Utils/leak_detector.h"
|
#include "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 "../GraphCall/graph_calls_func.h"
|
#include "graph_calls_func.h"
|
||||||
#include "../GraphLoop/graph_loops_func.h"
|
#include "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 "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "../ExpressionTransform/expr_transform.h"
|
#include "expr_transform.h"
|
||||||
#include "../Transformations/function_purifying.h"
|
#include "FunctionPurifying/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 "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "../Utils/errors.h"
|
#include "errors.h"
|
||||||
#include "../GraphCall/graph_calls.h"
|
#include "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 "../Utils/leak_detector.h"
|
#include "leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -14,15 +14,15 @@
|
|||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "../DynamicAnalysis/gcov_info.h"
|
#include "../DynamicAnalysis/gcov_info.h"
|
||||||
|
#include "../DynamicAnalysis/gCov_parser_func.h"
|
||||||
#include "PredictScheme.h"
|
#include "PredictScheme.h"
|
||||||
#include "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "../DirectiveProcessing/directive_parser.h"
|
#include "../DirectiveProcessing/directive_parser.h"
|
||||||
#include "../Distribution/DvmhDirective.h"
|
#include "../Distribution/DvmhDirective.h"
|
||||||
#include "../GraphLoop/graph_loops_func.h"
|
#include "graph_loops_func.h"
|
||||||
#include "../ExpressionTransform/expr_transform.h"
|
#include "expr_transform.h"
|
||||||
#include "../DirectiveProcessing/directive_parser.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"
|
||||||
|
|
||||||
@@ -208,27 +208,31 @@ void calculateStatsForPredictor(const map<string, vector<FuncInfo*>>& allFuncInf
|
|||||||
uint64_t paralle_exec = 0;
|
uint64_t paralle_exec = 0;
|
||||||
uint64_t lines_count = 0;
|
uint64_t lines_count = 0;
|
||||||
|
|
||||||
if (st->variant() == DVM_PARALLEL_ON_DIR)
|
if (st->variant() == DVM_PARALLEL_ON_DIR)
|
||||||
{
|
{
|
||||||
auto loop = st->lexNext();
|
auto loop = st->lexNext();
|
||||||
checkNull(loop, convertFileName(__FILE__).c_str(), __LINE__);
|
checkNull(loop, convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
if (loop->variant() != FOR_NODE)
|
if (loop->variant() != FOR_NODE)
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|
||||||
calculateForParallelLoop(loop, gcov, paralle_exec, lines_count);
|
if (__gcov_doesThisLineExecuted(byFile.first, loop->lineNumber()))
|
||||||
st = loop->lastNodeOfStmt();
|
{
|
||||||
|
calculateForParallelLoop(loop, gcov, paralle_exec, lines_count);
|
||||||
|
st = loop->lastNodeOfStmt();
|
||||||
|
|
||||||
parallel_exec_count += paralle_exec;
|
parallel_exec_count += paralle_exec;
|
||||||
count_of_parallel_lines += lines_count;
|
count_of_parallel_lines += lines_count;
|
||||||
|
|
||||||
__spf_print(1, " PAR LOOP [%d %s] total exec %llu, total exec lines %llu, avg %.16e\n",
|
__spf_print(1, " PAR LOOP [%d %s] total exec %llu, total exec lines %llu, avg %.16e\n",
|
||||||
loop->lineNumber(), byFile.first.c_str(), paralle_exec, lines_count, paralle_exec / (double)lines_count);
|
loop->lineNumber(), byFile.first.c_str(), paralle_exec, lines_count, paralle_exec / (double)lines_count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto st = stat->lexNext(); st != stat->lastNodeOfStmt(); st = st->lexNext())
|
for (auto st = stat->lexNext(); st != stat->lastNodeOfStmt(); st = st->lexNext())
|
||||||
{
|
{
|
||||||
if (!isSgExecutableStatement(st) || isDVM_stat(st) || isSPF_stat(st))
|
if (!isSgExecutableStatement(st) || isDVM_stat(st) || isSPF_stat(st) ||
|
||||||
|
!__gcov_doesThisLineExecuted(byFile.first, st->lineNumber()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int line = st->lineNumber();
|
int line = st->lineNumber();
|
||||||
@@ -428,6 +432,7 @@ static void parallelDir(const map<DIST::Array*, int>& byPos, SgExpression* spec,
|
|||||||
parallel["loops_count"] = loopSymbs.size();
|
parallel["loops_count"] = loopSymbs.size();
|
||||||
|
|
||||||
SgStatement* loop = isSgForStmt(st->lexNext());
|
SgStatement* loop = isSgForStmt(st->lexNext());
|
||||||
|
|
||||||
if (loop == NULL)
|
if (loop == NULL)
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
SgStatement* lastNode = loop->lastNodeOfStmt();
|
SgStatement* lastNode = loop->lastNodeOfStmt();
|
||||||
@@ -444,11 +449,13 @@ static void parallelDir(const map<DIST::Array*, int>& byPos, SgExpression* spec,
|
|||||||
loop = loop->lexNext();
|
loop = loop->lexNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int z = execs.size() - 1; z > 0; --z)
|
for (int z = execs.size() - 1; z > 0; --z)
|
||||||
execs[z] /= execs[z - 1];
|
if (execs[z - 1] != 0)
|
||||||
|
execs[z] /= execs[z - 1];
|
||||||
|
|
||||||
auto& info = getInfo(before, gcov);
|
auto& info = getInfo(before, gcov);
|
||||||
execs[0] /= info.getExecutedCount();
|
if (info.getExecutedCount() && loopSymbs.size() > 1)
|
||||||
|
execs[0] /= info.getExecutedCount();
|
||||||
|
|
||||||
parallel["iterations_count"] = execs;
|
parallel["iterations_count"] = execs;
|
||||||
|
|
||||||
@@ -501,8 +508,6 @@ static void parallelDir(const map<DIST::Array*, int>& byPos, SgExpression* spec,
|
|||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|
||||||
auto cfg = buildCFGforCurrentFunc(func, SAPFOR::CFG_Settings(true, false, false, true, false, false, true), commonBlocks, allFuncInfo);
|
auto cfg = buildCFGforCurrentFunc(func, SAPFOR::CFG_Settings(true, false, false, true, false, false, true), commonBlocks, allFuncInfo);
|
||||||
if (cfg.size() != 1)
|
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
|
||||||
//TODO IP analysis
|
//TODO IP analysis
|
||||||
|
|
||||||
unsigned countOfAccess = 0;
|
unsigned countOfAccess = 0;
|
||||||
@@ -589,6 +594,9 @@ void parseDvmDirForPredictor(const map<tuple<int, string, string>, pair<DIST::Ar
|
|||||||
|
|
||||||
for (auto st = stat->lexNext(); st != stat->lastNodeOfStmt(); st = st->lexNext())
|
for (auto st = stat->lexNext(); st != stat->lastNodeOfStmt(); st = st->lexNext())
|
||||||
{
|
{
|
||||||
|
if (!__gcov_doesThisLineExecuted(byFile.first, st->lineNumber()))
|
||||||
|
continue;
|
||||||
|
|
||||||
SgExpression* list;
|
SgExpression* list;
|
||||||
SgExpression* dup;
|
SgExpression* dup;
|
||||||
auto line = 0;
|
auto line = 0;
|
||||||
@@ -596,7 +604,10 @@ void parseDvmDirForPredictor(const map<tuple<int, string, string>, pair<DIST::Ar
|
|||||||
switch (st->variant())
|
switch (st->variant())
|
||||||
{
|
{
|
||||||
case DVM_PARALLEL_ON_DIR:
|
case DVM_PARALLEL_ON_DIR:
|
||||||
parallelDir(byPos, st->expr(2), st->expr(0)->symbol(), st->expr(0)->lhs(), st, st->expr(1), gcov, directives, commonBlocks, allFuncInfo);
|
parallelDir(byPos, st->expr(2),
|
||||||
|
st->expr(0) ? st->expr(0)->symbol() : NULL,
|
||||||
|
st->expr(0) ? st->expr(0)->lhs() : NULL,
|
||||||
|
st, st->expr(1), gcov, directives, commonBlocks, allFuncInfo);
|
||||||
break;
|
break;
|
||||||
case DVM_VAR_DECL: // TODO
|
case DVM_VAR_DECL: // TODO
|
||||||
{
|
{
|
||||||
@@ -615,7 +626,8 @@ void parseDvmDirForPredictor(const map<tuple<int, string, string>, pair<DIST::Ar
|
|||||||
list = st->expr(0);
|
list = st->expr(0);
|
||||||
while (list)
|
while (list)
|
||||||
{
|
{
|
||||||
directives["align"].push_back(parseAlign(byPos, list->lhs()->symbol(), type->rhs()->symbol(), type->lhs(), type->rhs()->lhs(), st->lineNumber()));
|
if (type->lhs()) // if ALIGN A(...) with B(...)
|
||||||
|
directives["align"].push_back(parseAlign(byPos, list->lhs()->symbol(), type->rhs()->symbol(), type->lhs(), type->rhs()->lhs(), st->lineNumber()));
|
||||||
list = list->rhs();
|
list = list->rhs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -627,6 +639,9 @@ void parseDvmDirForPredictor(const map<tuple<int, string, string>, pair<DIST::Ar
|
|||||||
case DVM_ALIGN_DIR:
|
case DVM_ALIGN_DIR:
|
||||||
directives["align"].push_back(parseAlign(byPos, st->expr(0)->lhs()->symbol(), st->expr(2)->symbol(), st->expr(1), st->expr(2)->lhs(), st->lineNumber()));
|
directives["align"].push_back(parseAlign(byPos, st->expr(0)->lhs()->symbol(), st->expr(2)->symbol(), st->expr(1), st->expr(2)->lhs(), st->lineNumber()));
|
||||||
break;
|
break;
|
||||||
|
case DVM_REALIGN_DIR:
|
||||||
|
directives["realign"].push_back(parseAlign(byPos, st->expr(0)->lhs()->symbol(), st->expr(2)->symbol(), st->expr(1), st->expr(2)->lhs(), st->lineNumber()));
|
||||||
|
break;
|
||||||
case DVM_SHADOW_DIR:
|
case DVM_SHADOW_DIR:
|
||||||
//dirs << "1;" << "SHADOW;" << st->expr(0)->unparse() << "(" << st->expr(1)->unparse() << ");\n";
|
//dirs << "1;" << "SHADOW;" << st->expr(0)->unparse() << "(" << st->expr(1)->unparse() << ");\n";
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "../GraphCall/graph_calls.h"
|
#include "graph_calls.h"
|
||||||
|
#include "json.hpp"
|
||||||
|
|
||||||
class ParallelStats
|
class ParallelStats
|
||||||
{
|
{
|
||||||
@@ -11,10 +12,10 @@ public:
|
|||||||
RemoteCount = ShadowCount = ReductionCount = AcrossCount = 0;
|
RemoteCount = ShadowCount = ReductionCount = AcrossCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RemoteCount;
|
int RemoteCount = 0;
|
||||||
int ShadowCount;
|
int ShadowCount = 0;
|
||||||
int ReductionCount;
|
int ReductionCount = 0;
|
||||||
int AcrossCount;
|
int AcrossCount = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PredictorStats
|
class PredictorStats
|
||||||
@@ -27,28 +28,32 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
ParallelStats ParallelStat;
|
ParallelStats ParallelStat;
|
||||||
int ParallelCount;
|
int ParallelCount = 0;
|
||||||
int RemoteCount;
|
int RemoteCount = 0;
|
||||||
int RedistributeCount;
|
int RedistributeCount = 0;
|
||||||
int IntervalCount;
|
int IntervalCount = 0;
|
||||||
int TotalScoreComm;
|
int TotalScoreComm = 0;
|
||||||
int TotalScorePar;
|
int TotalScorePar = 0;
|
||||||
int TotalScoreDist;
|
int TotalScoreDist = 0;
|
||||||
|
|
||||||
std::string to_string()
|
nlohmann::json toJson()
|
||||||
{
|
{
|
||||||
std::string res = "";
|
nlohmann::json stat;
|
||||||
res += std::to_string(ParallelCount) + "|";
|
|
||||||
res += std::to_string(RemoteCount) + "|";
|
|
||||||
res += std::to_string(RedistributeCount) + "|";
|
|
||||||
res += std::to_string(IntervalCount) + "|";
|
|
||||||
|
|
||||||
res += std::to_string(ParallelStat.RemoteCount) + "|";
|
stat["ParallelCount"] = ParallelCount;
|
||||||
res += std::to_string(ParallelStat.ShadowCount) + "|";
|
stat["RemoteCount"] = RemoteCount;
|
||||||
res += std::to_string(ParallelStat.ReductionCount) + "|";
|
stat["RedistributeCount"] = RedistributeCount;
|
||||||
res += std::to_string(ParallelStat.AcrossCount);
|
stat["IntervalCount"] = IntervalCount;
|
||||||
|
|
||||||
return res;
|
stat["PS_RemoteCount"] = ParallelStat.RemoteCount;
|
||||||
|
stat["PS_ShadowCount"] = ParallelStat.ShadowCount;
|
||||||
|
stat["PS_ReductionCount"] = ParallelStat.ReductionCount;
|
||||||
|
stat["PS_AcrossCount"] = ParallelStat.AcrossCount;
|
||||||
|
|
||||||
|
//TODO: need to improve
|
||||||
|
// (summed.TotalScoreComm != 0 ? 1.0 / summed.TotalScoreComm : 0.0) + (double)summed.TotalScorePar * 1000 + (countOfDist == 0 ? -5000 : countOfDist);
|
||||||
|
stat["TotalScore"] = -1 * (ParallelStat.RemoteCount + ParallelStat.ShadowCount + ParallelStat.ReductionCount + ParallelStat.AcrossCount);
|
||||||
|
return stat;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#define _LEAK_
|
#define _LEAK_
|
||||||
#include "../Utils/leak_detector.h"
|
#include "leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@@ -9,10 +9,10 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include "../GraphCall/graph_calls.h"
|
#include "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 "../GraphCall/graph_calls.h"
|
#include "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);
|
||||||
|
|||||||
@@ -7,584 +7,149 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "private_arrays_search.h"
|
#include "private_arrays_search.h"
|
||||||
#include "../Utils/SgUtils.h"
|
#include "range_structures.h"
|
||||||
#include "../GraphLoop/graph_loops.h"
|
#include "region.h"
|
||||||
#include "../CFGraph/CFGraph.h"
|
#include "SgUtils.h"
|
||||||
|
#include "graph_loops.h"
|
||||||
|
#include "CFGraph/CFGraph.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void print_info(LoopGraph* loop)
|
static void Collapse(Region* region)
|
||||||
{
|
{
|
||||||
cout << "loopSymbol: " << loop->loopSymbol << endl;
|
if (region->getBasickBlocks().empty())
|
||||||
for (const auto& ops : loop->writeOpsForLoop)
|
return;
|
||||||
|
|
||||||
|
for (auto& [arrayName, arrayRanges] : region->getHeader()->array_out)
|
||||||
{
|
{
|
||||||
cout << "Array name: " << ops.first->GetShortName() << endl;
|
for (Region* byBlock : region->getBasickBlocks())
|
||||||
for (const auto i : ops.second)
|
|
||||||
{
|
|
||||||
i.printInfo();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!loop->children.empty())
|
|
||||||
{
|
|
||||||
for (const auto child : loop->children)
|
|
||||||
{
|
|
||||||
print_info(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool isParentStmt(SgStatement* stmt, SgStatement* parent)
|
|
||||||
{
|
|
||||||
for (; stmt; stmt = stmt->controlParent())
|
|
||||||
if (stmt == parent)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*returns head block and loop*/
|
|
||||||
static pair<SAPFOR::BasicBlock*, unordered_set<SAPFOR::BasicBlock*>> GetBasicBlocksForLoop(LoopGraph* loop, vector<SAPFOR::BasicBlock*> blocks)
|
|
||||||
{
|
|
||||||
unordered_set<SAPFOR::BasicBlock*> block_loop;
|
|
||||||
SAPFOR::BasicBlock* head_block = nullptr;
|
|
||||||
auto loop_operator = loop->loop->GetOriginal();
|
|
||||||
for (const auto& block : blocks)
|
|
||||||
{
|
|
||||||
if (!block || (block->getInstructions().size() == 0))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
SgStatement* first = block->getInstructions().front()->getInstruction()->getOperator();
|
|
||||||
SgStatement* last = block->getInstructions().back()->getInstruction()->getOperator();
|
|
||||||
if (isParentStmt(first, loop_operator) && isParentStmt(last, loop_operator))
|
|
||||||
{
|
|
||||||
block_loop.insert(block);
|
|
||||||
|
|
||||||
if ((!head_block) && (first == loop_operator) && (last == loop_operator) &&
|
|
||||||
(block->getInstructions().size() == 2) &&
|
|
||||||
(block->getInstructions().back()->getInstruction()->getOperation() == SAPFOR::CFG_OP::JUMP_IF))
|
|
||||||
{
|
|
||||||
head_block = block;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return { head_block, block_loop };
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void BuildLoopIndex(map<string, LoopGraph*>& loopForIndex, LoopGraph* loop) {
|
|
||||||
string index = loop->loopSymbol;
|
|
||||||
loopForIndex[index] = loop;
|
|
||||||
for (const auto& childLoop : loop->children) {
|
|
||||||
BuildLoopIndex(loopForIndex, childLoop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static string FindIndexName(int pos, SAPFOR::BasicBlock* block, map<string, LoopGraph*>& loopForIndex) {
|
|
||||||
unordered_set<SAPFOR::Argument*> args = {block->getInstructions()[pos]->getInstruction()->getArg1()};
|
|
||||||
|
|
||||||
for (int i = pos-1; i >= 0; i--) {
|
|
||||||
SAPFOR::Argument* res = block->getInstructions()[i]->getInstruction()->getResult();
|
|
||||||
if (res && args.find(res) != args.end()) {
|
|
||||||
SAPFOR::Argument* arg1 = block->getInstructions()[i]->getInstruction()->getArg1();
|
|
||||||
SAPFOR::Argument* arg2 = block->getInstructions()[i]->getInstruction()->getArg2();
|
|
||||||
if (arg1) {
|
|
||||||
string name = arg1->getValue();
|
|
||||||
int idx = name.find('%');
|
|
||||||
if (idx != -1 && loopForIndex.find(name.substr(idx + 1)) != loopForIndex.end())
|
|
||||||
return name.substr(idx + 1);
|
|
||||||
else {
|
|
||||||
args.insert(arg1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (arg2) {
|
|
||||||
string name = arg2->getValue();
|
|
||||||
int idx = name.find('%');
|
|
||||||
if (idx != -1 && loopForIndex.find(name.substr(idx + 1)) != loopForIndex.end())
|
|
||||||
return name.substr(idx + 1);
|
|
||||||
else {
|
|
||||||
args.insert(arg2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
static int GetDefUseArray(SAPFOR::BasicBlock* block, LoopGraph* loop, ArrayAccessingIndexes& def, ArrayAccessingIndexes& use) {
|
|
||||||
auto instructions = block->getInstructions();
|
|
||||||
map<string, LoopGraph*> loopForIndex;
|
|
||||||
BuildLoopIndex(loopForIndex, loop);
|
|
||||||
for(int i = 0; i < instructions.size(); i++)
|
|
||||||
{
|
|
||||||
auto instruction = instructions[i];
|
|
||||||
if(!instruction->getInstruction()->getArg1()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
auto operation = instruction->getInstruction()->getOperation();
|
|
||||||
auto type = instruction->getInstruction()->getArg1()->getType();
|
|
||||||
if ((operation == SAPFOR::CFG_OP::STORE || operation == SAPFOR::CFG_OP::LOAD) && type == SAPFOR::CFG_ARG_TYPE::ARRAY)
|
|
||||||
{
|
|
||||||
vector<SAPFOR::Argument*> index_vars;
|
|
||||||
vector<int> refPos;
|
|
||||||
string array_name;
|
|
||||||
if (operation == SAPFOR::CFG_OP::STORE)
|
|
||||||
{
|
|
||||||
array_name = instruction->getInstruction()->getArg1()->getValue();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
array_name = instruction->getInstruction()->getArg2()->getValue();
|
|
||||||
}
|
|
||||||
int j = i - 1;
|
|
||||||
while (j >= 0 && instructions[j]->getInstruction()->getOperation() == SAPFOR::CFG_OP::REF)
|
|
||||||
{
|
|
||||||
index_vars.push_back(instructions[j]->getInstruction()->getArg1());
|
|
||||||
refPos.push_back(j);
|
|
||||||
j--;
|
|
||||||
}
|
|
||||||
/*to choose correct dimension*/
|
|
||||||
int n = index_vars.size();
|
|
||||||
vector<ArrayDimension> accessPoint(n);
|
|
||||||
/*if (operation == SAPFOR::CFG_OP::STORE)
|
|
||||||
{
|
|
||||||
if (def[array_name].empty())
|
|
||||||
{
|
|
||||||
def[array_name].resize(n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (use[array_name].empty())
|
|
||||||
{
|
|
||||||
use[array_name].resize(n);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
SgArrayRefExp* ref = (SgArrayRefExp*)instruction->getInstruction()->getExpression();
|
|
||||||
vector<pair<int, int>> coefsForDims;
|
|
||||||
for (int i = 0; i < ref->numberOfSubscripts(); ++i)
|
|
||||||
{
|
|
||||||
const vector<int*>& coefs = getAttributes<SgExpression*, int*>(ref->subscript(i), set<int>{ INT_VAL });
|
|
||||||
if (coefs.size() == 1)
|
|
||||||
{
|
|
||||||
const pair<int, int> coef(coefs[0][0], coefs[0][1]);
|
|
||||||
coefsForDims.push_back(coef);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!index_vars.empty())
|
|
||||||
{
|
|
||||||
auto var = index_vars.back();
|
|
||||||
int currentVarPos = refPos.back();
|
|
||||||
pair currentCoefs = coefsForDims.back();
|
|
||||||
ArrayDimension current_dim;
|
|
||||||
if (var->getType() == SAPFOR::CFG_ARG_TYPE::CONST) {
|
|
||||||
current_dim = { stoul(var->getValue()), 1, 1 };
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string name, full_name = var->getValue();
|
|
||||||
int pos = full_name.find('%');
|
|
||||||
LoopGraph* currentLoop;
|
|
||||||
if (pos != -1) {
|
|
||||||
name = full_name.substr(pos+1);
|
|
||||||
if (loopForIndex.find(name) != loopForIndex.end()) {
|
|
||||||
currentLoop = loopForIndex[name];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
name = FindIndexName(currentVarPos, block, loopForIndex);
|
|
||||||
if (name == "") {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (loopForIndex.find(name) != loopForIndex.end()) {
|
|
||||||
currentLoop = loopForIndex[name];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
uint64_t start = currentLoop->startVal * currentCoefs.first + currentCoefs.second;
|
|
||||||
uint64_t step = currentCoefs.first;
|
|
||||||
current_dim = { start, step, (uint64_t)currentLoop->calculatedCountOfIters };
|
|
||||||
}
|
|
||||||
/*if (operation == SAPFOR::CFG_OP::STORE)
|
|
||||||
{
|
|
||||||
def[array_name][n - index_vars.size()].push_back(current_dim);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
use[array_name][n - index_vars.size()].push_back(current_dim);
|
|
||||||
}*/
|
|
||||||
accessPoint[n - index_vars.size()] = current_dim;
|
|
||||||
index_vars.pop_back();
|
|
||||||
refPos.pop_back();
|
|
||||||
coefsForDims.pop_back();
|
|
||||||
}
|
|
||||||
if (operation == SAPFOR::CFG_OP::STORE)
|
|
||||||
{
|
|
||||||
def[array_name].Insert(accessPoint);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
use[array_name].Insert(accessPoint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static vector<uint64_t> FindParticularSolution(const ArrayDimension& dim1, const ArrayDimension& dim2)
|
|
||||||
{
|
|
||||||
for (uint64_t i = 0; i < dim1.tripCount; i++)
|
|
||||||
{
|
|
||||||
uint64_t leftPart = dim1.start + i * dim1.step;
|
|
||||||
for (uint64_t j = 0; j < dim2.tripCount; j++)
|
|
||||||
{
|
|
||||||
uint64_t rightPart = dim2.start + j * dim2.step;
|
|
||||||
if (leftPart == rightPart)
|
|
||||||
{
|
|
||||||
return {i, j};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
/* dim1 /\ dim2 */
|
|
||||||
static ArrayDimension* DimensionIntersection(const ArrayDimension& dim1, const ArrayDimension& dim2)
|
|
||||||
{
|
|
||||||
vector<uint64_t> partSolution = FindParticularSolution(dim1, dim2);
|
|
||||||
if (partSolution.empty())
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
int64_t x0 = partSolution[0], y0 = partSolution[1];
|
|
||||||
/* x = x_0 + c * t */
|
|
||||||
/* y = y_0 + d * t */
|
|
||||||
int64_t c = dim2.step / gcd(dim1.step, dim2.step);
|
|
||||||
int64_t d = dim1.step / gcd(dim1.step, dim2.step);
|
|
||||||
int64_t tXMin, tXMax, tYMin, tYMax;
|
|
||||||
tXMin = -x0 / c;
|
|
||||||
tXMax = (dim1.tripCount - 1 - x0) / c;
|
|
||||||
tYMin = -y0 / d;
|
|
||||||
tYMax = (dim2.tripCount - 1 - y0) / d;
|
|
||||||
int64_t tMin = max(tXMin, tYMin);
|
|
||||||
uint64_t tMax = min(tXMax, tYMax);
|
|
||||||
if (tMin > tMax)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
uint64_t start3 = dim1.start + x0 * dim1.step;
|
|
||||||
uint64_t step3 = c * dim1.step;
|
|
||||||
ArrayDimension* result = new(ArrayDimension){ start3, step3, tMax + 1 };
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* dim1 / dim2 */
|
|
||||||
static vector<ArrayDimension> DimensionDifference(const ArrayDimension& dim1, const ArrayDimension& dim2)
|
|
||||||
{
|
|
||||||
ArrayDimension* intersection = DimensionIntersection(dim1, dim2);
|
|
||||||
if (!intersection)
|
|
||||||
{
|
|
||||||
return {dim1};
|
|
||||||
}
|
|
||||||
vector<ArrayDimension> result;
|
|
||||||
/* add the part before intersection */
|
|
||||||
if (dim1.start < intersection->start)
|
|
||||||
{
|
|
||||||
result.push_back({ dim1.start, dim1.step, (intersection->start - dim1.start) / dim1.step });
|
|
||||||
}
|
|
||||||
/* add the parts between intersection steps */
|
|
||||||
uint64_t start = (intersection->start - dim1.start) / dim1.step;
|
|
||||||
uint64_t interValue = intersection->start;
|
|
||||||
for (int64_t i = start; dim1.start + i * dim1.step <= intersection->start + intersection->step * (intersection->tripCount - 1); i++)
|
|
||||||
{
|
|
||||||
uint64_t centerValue = dim1.start + i * dim1.step;
|
|
||||||
if (centerValue == interValue)
|
|
||||||
{
|
|
||||||
if (i - start > 1)
|
|
||||||
{
|
|
||||||
result.push_back({ dim1.start + (start + 1) * dim1.step, dim1.step, i - start - 1 });
|
|
||||||
start = i;
|
|
||||||
}
|
|
||||||
interValue += intersection->step;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* add the part after intersection */
|
|
||||||
if (intersection->start + intersection->step * (intersection->tripCount - 1) < dim1.start + dim1.step * (dim1.tripCount - 1))
|
|
||||||
{
|
|
||||||
/* first value after intersection */
|
|
||||||
uint64_t right_start = intersection->start + intersection->step * (intersection->tripCount - 1) + dim1.step;
|
|
||||||
uint64_t tripCount = (dim1.start + dim1.step * dim1.tripCount - right_start) / dim1.step;
|
|
||||||
result.push_back({right_start, dim1.step, tripCount});
|
|
||||||
}
|
|
||||||
delete(intersection);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static vector<ArrayDimension> DimensionUnion(const ArrayDimension& dim1, const ArrayDimension& dim2)
|
|
||||||
{
|
|
||||||
vector<ArrayDimension> res;
|
|
||||||
ArrayDimension* inter = DimensionIntersection(dim1, dim2);
|
|
||||||
if(!inter)
|
|
||||||
{
|
|
||||||
return { dim1, dim2 };
|
|
||||||
}
|
|
||||||
res.push_back(*inter);
|
|
||||||
delete(inter);
|
|
||||||
vector<ArrayDimension> diff1, diff2;
|
|
||||||
diff1 = DimensionDifference(dim1, dim2);
|
|
||||||
diff2 = DimensionDifference(dim2, dim1);
|
|
||||||
res.insert(res.end(), diff1.begin(), diff1.end());
|
|
||||||
res.insert(res.end(), diff2.begin(), diff2.end());
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
static vector<ArrayDimension> ElementsIntersection(const vector<ArrayDimension>& firstElement, const vector<ArrayDimension>& secondElement)
|
|
||||||
{
|
|
||||||
if(firstElement.empty() || secondElement.empty()) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
size_t dimAmount = firstElement.size();
|
|
||||||
/* check if there is no intersecction */
|
|
||||||
for(size_t i = 0; i < dimAmount; i++)
|
|
||||||
{
|
|
||||||
if(FindParticularSolution(firstElement[i], secondElement[i]).empty()){
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
vector<ArrayDimension> result(dimAmount);
|
|
||||||
for(size_t i = 0; i < dimAmount; i++)
|
|
||||||
{
|
|
||||||
ArrayDimension* resPtr = DimensionIntersection(firstElement[i], secondElement[i]);
|
|
||||||
if(resPtr)
|
|
||||||
{
|
|
||||||
result[i] = *resPtr;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static vector<vector<ArrayDimension>> ElementsDifference(const vector<ArrayDimension>& firstElement,
|
|
||||||
const vector<ArrayDimension>& secondElement)
|
|
||||||
{
|
|
||||||
if(firstElement.empty() || secondElement.empty()) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
vector<ArrayDimension> intersection = ElementsIntersection(firstElement, secondElement);
|
|
||||||
vector<vector<ArrayDimension>> result;
|
|
||||||
if(intersection.empty())
|
|
||||||
{
|
|
||||||
return {firstElement};
|
|
||||||
}
|
|
||||||
for(int i = 0; i < firstElement.size(); i++)
|
|
||||||
{
|
|
||||||
auto dimDiff = DimensionDifference(firstElement[i], secondElement[i]);
|
|
||||||
if(!dimDiff.empty())
|
|
||||||
{
|
|
||||||
vector<ArrayDimension> firstCopy = firstElement;
|
|
||||||
for(const auto range: dimDiff)
|
|
||||||
{
|
|
||||||
firstCopy[i] = range;
|
|
||||||
result.push_back(firstCopy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ElementsUnion(const vector<ArrayDimension>& firstElement, const vector<ArrayDimension>& secondElement,
|
|
||||||
vector<vector<ArrayDimension>>& lc, vector<vector<ArrayDimension>>& rc,
|
|
||||||
vector<ArrayDimension>& intersection)
|
|
||||||
{
|
|
||||||
/* lc(rc) is a set of ranges, which only exist in first(second) element*/
|
|
||||||
intersection = ElementsIntersection(firstElement, secondElement);
|
|
||||||
lc = ElementsDifference(firstElement, intersection);
|
|
||||||
rc = ElementsDifference(secondElement, intersection);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AccessingSet::FindUncovered(const vector<ArrayDimension>& element, vector<vector<ArrayDimension>>& result) const{
|
|
||||||
vector<vector<ArrayDimension>> newTails;
|
|
||||||
result.push_back(element);
|
|
||||||
for(const auto& currentElement: allElements)
|
|
||||||
{
|
|
||||||
for(const auto& tailLoc: result)
|
|
||||||
{
|
|
||||||
auto intersection = ElementsIntersection(tailLoc, currentElement);
|
|
||||||
auto diff = ElementsDifference(tailLoc, intersection);
|
|
||||||
if(!diff.empty()) {
|
|
||||||
newTails.insert(newTails.end(), diff.begin(), diff.end());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result = move(newTails);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AccessingSet::ContainsElement(const vector<ArrayDimension>& element) const
|
|
||||||
{
|
|
||||||
vector<vector<ArrayDimension>> tails;
|
|
||||||
FindUncovered(element, tails);
|
|
||||||
return !tails.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AccessingSet::FindCoveredBy(const vector<ArrayDimension>& element, vector<vector<ArrayDimension>>& result) const
|
|
||||||
{
|
|
||||||
for(const auto& currentElement: allElements)
|
|
||||||
{
|
|
||||||
auto intersection = ElementsIntersection(element, currentElement);
|
|
||||||
if(!intersection.empty()) {
|
|
||||||
result.push_back(intersection);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vector<vector<ArrayDimension>> AccessingSet::GetElements() const
|
|
||||||
{
|
|
||||||
return allElements;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AccessingSet::Insert(const vector<ArrayDimension>& element)
|
|
||||||
{
|
|
||||||
vector<vector<ArrayDimension>> tails;
|
|
||||||
FindUncovered(element, tails);
|
|
||||||
allElements.insert(allElements.end(), tails.begin(), tails.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
void AccessingSet::Union(const AccessingSet& source) {
|
|
||||||
for(auto& element: source.GetElements()) {
|
|
||||||
Insert(element);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AccessingSet AccessingSet::Intersect(const AccessingSet& secondSet) const
|
|
||||||
{
|
|
||||||
vector<vector<ArrayDimension>> result;
|
|
||||||
for(const auto& element: allElements)
|
|
||||||
{
|
|
||||||
if(secondSet.ContainsElement(element))
|
|
||||||
{
|
|
||||||
result.push_back(element);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vector<vector<ArrayDimension>> coveredBy;
|
|
||||||
secondSet.FindCoveredBy(element, coveredBy);
|
|
||||||
if(!coveredBy.empty())
|
|
||||||
{
|
|
||||||
result.insert(result.end(), coveredBy.begin(), coveredBy.end());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return AccessingSet(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
AccessingSet AccessingSet::Diff(const AccessingSet& secondSet) const
|
|
||||||
{
|
|
||||||
AccessingSet intersection = this->Intersect(secondSet);
|
|
||||||
AccessingSet uncovered = *this;
|
|
||||||
vector<vector<ArrayDimension>> result;
|
|
||||||
for (const auto& element : intersection.GetElements())
|
|
||||||
{
|
|
||||||
vector<vector<ArrayDimension>> current_uncovered;
|
|
||||||
uncovered.FindUncovered(element, current_uncovered);
|
|
||||||
uncovered = AccessingSet(current_uncovered);
|
|
||||||
}
|
|
||||||
return uncovered;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Collapse(Region* region)
|
|
||||||
{
|
|
||||||
Region* newBlock = new Region();
|
|
||||||
for (auto& [arrayName, arrayRanges] : region->GetHeader()->array_out)
|
|
||||||
{
|
|
||||||
for (Region* byBlock : region->GetBasickBlocks())
|
|
||||||
{
|
{
|
||||||
AccessingSet intersection = byBlock->array_def[arrayName].Intersect(arrayRanges);
|
AccessingSet intersection = byBlock->array_def[arrayName].Intersect(arrayRanges);
|
||||||
newBlock->array_def[arrayName].Union(intersection);
|
region->array_def[arrayName] = region->array_def[arrayName].Union(intersection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& byBlock : region->GetBasickBlocks()) {
|
for (auto& byBlock : region->getBasickBlocks())
|
||||||
|
{
|
||||||
for (auto& [arrayName, arrayRanges] : byBlock->array_use)
|
for (auto& [arrayName, arrayRanges] : byBlock->array_use)
|
||||||
{
|
{
|
||||||
AccessingSet diff = byBlock->array_use[arrayName].Diff(byBlock->array_in[arrayName]);
|
AccessingSet diff = byBlock->array_use[arrayName].Diff(byBlock->array_in[arrayName]);
|
||||||
newBlock->array_use[arrayName].Union(diff);
|
region->array_use[arrayName] = region->array_use[arrayName].Union(diff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Region* prevRegion : region->getPrevRegions()) {
|
ArrayAccessingIndexes useUnion;
|
||||||
prevRegion->setNextRegion(newBlock);
|
for (auto& byBlock : region->getBasickBlocks())
|
||||||
}
|
for (auto& [arrayName, arrayRanges] : byBlock->array_use)
|
||||||
region->getNextRegion()->setPrevRegion(newBlock);
|
useUnion[arrayName] = useUnion[arrayName].Union(byBlock->array_use[arrayName]);
|
||||||
|
|
||||||
|
for (auto& [arrayName, arrayRanges] : useUnion)
|
||||||
|
region->array_priv[arrayName] = useUnion[arrayName].Diff(region->array_use[arrayName]);
|
||||||
|
|
||||||
|
for (Region* prevBlock : region->getHeader()->getPrevRegions())
|
||||||
|
prevBlock->replaceInNextRegions(region, region->getHeader());
|
||||||
|
|
||||||
|
for (Region* nextBlock : region->getHeader()->getNextRegions())
|
||||||
|
nextBlock->replaceInPrevRegions(region, region->getHeader());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindPrivateArrays(map<string, vector<LoopGraph*>> &loopGraph, map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR)
|
static void SolveDataFlowIteratively(Region* DFG)
|
||||||
{
|
|
||||||
for (const auto& curr_graph_pair: loopGraph)
|
|
||||||
{
|
|
||||||
for (const auto& curr_loop : curr_graph_pair.second)
|
|
||||||
{
|
|
||||||
auto block_loop = GetBasicBlocksForLoop(curr_loop, (*FullIR.begin()).second);
|
|
||||||
for (const auto& bb : block_loop.second) {
|
|
||||||
ArrayAccessingIndexes def, use;
|
|
||||||
//GetDefUseArray(bb, curr_loop, def, use);
|
|
||||||
}
|
|
||||||
ArrayAccessingIndexes loopDimensionsInfo;
|
|
||||||
//GetDimensionInfo(curr_loop, loopDimensionsInfo, 0);
|
|
||||||
//print_info(curr_loop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void GetDimensionInfo(LoopGraph* loop, map<DIST::Array*, vector<vector<ArrayDimension>>>& loopDimensionsInfo, int level)
|
|
||||||
{
|
{
|
||||||
cout << "line_num: " << loop->lineNum << endl;
|
unordered_set<Region*> worklist(DFG->getBasickBlocks());
|
||||||
for (const auto& writeOpPairs : loop->writeOpsForLoop)
|
do
|
||||||
{
|
{
|
||||||
vector<vector<ArrayDimension>> arrayDimensions(writeOpPairs.first->GetDimSize());
|
Region* b = *worklist.begin();
|
||||||
loopDimensionsInfo[writeOpPairs.first] = arrayDimensions;
|
ArrayAccessingIndexes newIn;
|
||||||
for (const auto& writeOp : writeOpPairs.second)
|
bool flagFirst = true;
|
||||||
|
for (Region* prevBlock : b->getPrevRegions())
|
||||||
{
|
{
|
||||||
for (const auto& coeficient_pair : writeOp.coefficients)
|
if (flagFirst)
|
||||||
{
|
{
|
||||||
uint64_t start, step, tripCount;
|
newIn = prevBlock->array_out;
|
||||||
start = loop->startVal * coeficient_pair.first.first + coeficient_pair.first.second;
|
flagFirst = false;
|
||||||
step = loop->stepVal * coeficient_pair.first.first;
|
}
|
||||||
tripCount = (loop->endVal - coeficient_pair.first.second) / step;
|
else
|
||||||
if (start <= loop->endVal)
|
{
|
||||||
|
if (prevBlock->array_out.empty())
|
||||||
{
|
{
|
||||||
loopDimensionsInfo[writeOpPairs.first][level].push_back({start, step, tripCount});
|
newIn.clear();
|
||||||
cout << "level: " << level << endl;
|
continue;
|
||||||
cout << "start: " << start << endl;
|
}
|
||||||
cout << "step: " << step << endl;
|
for (const auto& [arrayName, accessSet] : prevBlock->array_out)
|
||||||
cout << "trip_count: " << tripCount << endl;
|
{
|
||||||
cout << endl;
|
if (newIn.find(arrayName) != newIn.end())
|
||||||
|
newIn[arrayName] = newIn[arrayName].Intersect(accessSet);
|
||||||
|
else
|
||||||
|
newIn[arrayName] = AccessingSet();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
b->array_in = move(newIn);
|
||||||
|
ArrayAccessingIndexes newOut;
|
||||||
|
if (b->array_def.empty())
|
||||||
|
newOut = b->array_in;
|
||||||
|
else if (b->array_in.empty())
|
||||||
|
newOut = b->array_def;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (auto& [arrayName, accessSet] : b->array_def)
|
||||||
|
{
|
||||||
|
if (newOut.find(arrayName) != newOut.end())
|
||||||
|
newOut[arrayName] = b->array_def[arrayName].Union(b->array_in[arrayName]);
|
||||||
|
else
|
||||||
|
newOut[arrayName] = accessSet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* can not differ */
|
||||||
|
if (newOut != b->array_out)
|
||||||
|
b->array_out = newOut;
|
||||||
|
else
|
||||||
|
worklist.erase(b);
|
||||||
|
}
|
||||||
|
while (!worklist.empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SolveDataFlow(Region* DFG)
|
||||||
|
{
|
||||||
|
if (!DFG)
|
||||||
|
return;
|
||||||
|
|
||||||
|
SolveDataFlowIteratively(DFG);
|
||||||
|
for (Region* subRegion : DFG->getSubRegions())
|
||||||
|
SolveDataFlow(subRegion);
|
||||||
|
Collapse(DFG);
|
||||||
|
}
|
||||||
|
|
||||||
|
map<LoopGraph*, ArrayAccessingIndexes> FindPrivateArrays(map<string, vector<LoopGraph*>> &loopGraph, map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR)
|
||||||
|
{
|
||||||
|
map<LoopGraph*, ArrayAccessingIndexes> result;
|
||||||
|
for (const auto& [fileName, loops] : loopGraph)
|
||||||
|
{
|
||||||
|
SgFile::switchToFile(fileName);
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
if (funcInfo->fileName == fileName && funcInfo->funcPointer->GetOriginal() == search_func)
|
||||||
|
{
|
||||||
|
Region* loopRegion = new Region(loop, blocks);
|
||||||
|
if (loopRegion->getBasickBlocks().size() <= 1)
|
||||||
|
{
|
||||||
|
delete(loopRegion);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
SolveDataFlow(loopRegion);
|
||||||
|
result[loop] = loopRegion->array_priv;
|
||||||
|
delete(loopRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cout << "line_num_after: " << loop->lineNumAfterLoop << endl;
|
return result;
|
||||||
if (!loop->children.empty())
|
|
||||||
{
|
|
||||||
for (const auto& childLoop : loop->children)
|
|
||||||
{
|
|
||||||
GetDimensionInfo(childLoop, loopDimensionsInfo, level+1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,84 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../GraphLoop/graph_loops.h"
|
#include <vector>
|
||||||
#include "../CFGraph/CFGraph.h"
|
#include <map>
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
using std::vector;
|
#include "range_structures.h"
|
||||||
using std::map;
|
#include "graph_loops.h"
|
||||||
using std::string;
|
#include "CFGraph/CFGraph.h"
|
||||||
using std::set;
|
|
||||||
|
|
||||||
struct ArrayDimension
|
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);
|
||||||
uint64_t start, step, tripCount;
|
|
||||||
};
|
|
||||||
|
|
||||||
class AccessingSet {
|
|
||||||
private:
|
|
||||||
vector<vector<ArrayDimension>> allElements;
|
|
||||||
|
|
||||||
public:
|
|
||||||
AccessingSet(vector<vector<ArrayDimension>> input) : allElements(input) {};
|
|
||||||
AccessingSet() {};
|
|
||||||
vector<vector<ArrayDimension>> GetElements() const;
|
|
||||||
void Insert(const vector<ArrayDimension>& element);
|
|
||||||
void Union(const AccessingSet& source);
|
|
||||||
AccessingSet Intersect(const AccessingSet& secondSet) const;
|
|
||||||
AccessingSet Diff(const AccessingSet& secondSet) const;
|
|
||||||
bool ContainsElement(const vector<ArrayDimension>& element) const;
|
|
||||||
void FindCoveredBy(const vector<ArrayDimension>& element, vector<vector<ArrayDimension>>& result) const;
|
|
||||||
void FindUncovered(const vector<ArrayDimension>& element, vector<vector<ArrayDimension>>& result) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
using ArrayAccessingIndexes = map<string, AccessingSet>;
|
|
||||||
|
|
||||||
class Region: public SAPFOR::BasicBlock {
|
|
||||||
public:
|
|
||||||
Region()
|
|
||||||
{
|
|
||||||
header = nullptr;
|
|
||||||
nextRegion = nullptr;
|
|
||||||
}
|
|
||||||
Region(SAPFOR::BasicBlock block) : SAPFOR::BasicBlock::BasicBlock(block)
|
|
||||||
{
|
|
||||||
header = nullptr;
|
|
||||||
nextRegion = nullptr;
|
|
||||||
};
|
|
||||||
//Region(LoopGraph* loop);
|
|
||||||
Region* GetHeader()
|
|
||||||
{
|
|
||||||
return header;
|
|
||||||
}
|
|
||||||
set<Region*> GetBasickBlocks()
|
|
||||||
{
|
|
||||||
return basickBlocks;
|
|
||||||
}
|
|
||||||
vector<Region*> getPrevRegions()
|
|
||||||
{
|
|
||||||
return prevRegions;
|
|
||||||
}
|
|
||||||
Region* getNextRegion()
|
|
||||||
{
|
|
||||||
return nextRegion;
|
|
||||||
}
|
|
||||||
void setPrevRegion(Region* region)
|
|
||||||
{
|
|
||||||
prevRegions.push_back(region);
|
|
||||||
}
|
|
||||||
void setNextRegion(Region* region)
|
|
||||||
{
|
|
||||||
nextRegion = region;
|
|
||||||
}
|
|
||||||
ArrayAccessingIndexes array_def, array_use, array_out, array_in;
|
|
||||||
|
|
||||||
private:
|
|
||||||
set<Region*> subRegions, basickBlocks;
|
|
||||||
Region* header;
|
|
||||||
Region* nextRegion;
|
|
||||||
vector<Region*> prevRegions;
|
|
||||||
};
|
|
||||||
|
|
||||||
void Collapse(Region* region);
|
|
||||||
void FindPrivateArrays(map<string, vector<LoopGraph*>>& loopGraph, map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR);
|
|
||||||
void GetDimensionInfo(LoopGraph* loop, map<DIST::Array*, vector<vector<ArrayDimension>>>& loopDimensionsInfo, int level);
|
|
||||||
set<SAPFOR::BasicBlock> GetBasicBlocksForLoop(LoopGraph* loop, vector<SAPFOR::BasicBlock>);
|
|
||||||
|
|||||||
293
src/PrivateAnalyzer/range_structures.cpp
Normal file
293
src/PrivateAnalyzer/range_structures.cpp
Normal file
@@ -0,0 +1,293 @@
|
|||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
#include <unordered_set>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
#include "range_structures.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
static vector<uint64_t> FindParticularSolution(const ArrayDimension& dim1, const ArrayDimension& dim2)
|
||||||
|
{
|
||||||
|
for (uint64_t i = 0; i < dim1.tripCount; i++)
|
||||||
|
{
|
||||||
|
uint64_t leftPart = dim1.start + i * dim1.step;
|
||||||
|
for (uint64_t j = 0; j < dim2.tripCount; j++)
|
||||||
|
{
|
||||||
|
uint64_t rightPart = dim2.start + j * dim2.step;
|
||||||
|
if (leftPart == rightPart)
|
||||||
|
return { i, j };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* dim1 /\ dim2 */
|
||||||
|
static ArrayDimension* DimensionIntersection(const ArrayDimension& dim1, const ArrayDimension& dim2)
|
||||||
|
{
|
||||||
|
vector<uint64_t> partSolution = FindParticularSolution(dim1, dim2);
|
||||||
|
if (partSolution.empty())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
int64_t x0 = partSolution[0], y0 = partSolution[1];
|
||||||
|
/* x = x_0 + c * t */
|
||||||
|
/* y = y_0 + d * t */
|
||||||
|
int64_t c = dim2.step / gcd(dim1.step, dim2.step);
|
||||||
|
int64_t d = dim1.step / gcd(dim1.step, dim2.step);
|
||||||
|
int64_t tXMin, tXMax, tYMin, tYMax;
|
||||||
|
tXMin = -x0 / c;
|
||||||
|
tXMax = (dim1.tripCount - 1 - x0) / c;
|
||||||
|
tYMin = -y0 / d;
|
||||||
|
tYMax = (dim2.tripCount - 1 - y0) / d;
|
||||||
|
int64_t tMin = max(tXMin, tYMin);
|
||||||
|
uint64_t tMax = min(tXMax, tYMax);
|
||||||
|
if (tMin > tMax)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
uint64_t start3 = dim1.start + x0 * dim1.step;
|
||||||
|
uint64_t step3 = c * dim1.step;
|
||||||
|
ArrayDimension* result = new(ArrayDimension){ start3, step3, tMax + 1 };
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* dim1 / dim2 */
|
||||||
|
static vector<ArrayDimension> DimensionDifference(const ArrayDimension& dim1, const ArrayDimension& dim2)
|
||||||
|
{
|
||||||
|
ArrayDimension* intersection = DimensionIntersection(dim1, dim2);
|
||||||
|
if (!intersection)
|
||||||
|
return { dim1 };
|
||||||
|
|
||||||
|
vector<ArrayDimension> result;
|
||||||
|
/* add the part before intersection */
|
||||||
|
if (dim1.start < intersection->start)
|
||||||
|
result.push_back({ dim1.start, dim1.step, (intersection->start - dim1.start) / dim1.step });
|
||||||
|
|
||||||
|
/* add the parts between intersection steps */
|
||||||
|
uint64_t start = (intersection->start - dim1.start) / dim1.step;
|
||||||
|
uint64_t interValue = intersection->start;
|
||||||
|
for (int64_t i = start; dim1.start + i * dim1.step <= intersection->start + intersection->step * (intersection->tripCount - 1); i++)
|
||||||
|
{
|
||||||
|
uint64_t centerValue = dim1.start + i * dim1.step;
|
||||||
|
if (centerValue == interValue)
|
||||||
|
{
|
||||||
|
if (i - start > 1)
|
||||||
|
{
|
||||||
|
result.push_back({ dim1.start + (start + 1) * dim1.step, dim1.step, i - start - 1 });
|
||||||
|
start = i;
|
||||||
|
}
|
||||||
|
interValue += intersection->step;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* add the part after intersection */
|
||||||
|
if (intersection->start + intersection->step * (intersection->tripCount - 1) < dim1.start + dim1.step * (dim1.tripCount - 1))
|
||||||
|
{
|
||||||
|
/* first value after intersection */
|
||||||
|
uint64_t right_start = intersection->start + intersection->step * (intersection->tripCount - 1) + dim1.step;
|
||||||
|
uint64_t tripCount = (dim1.start + dim1.step * dim1.tripCount - right_start) / dim1.step;
|
||||||
|
result.push_back({ right_start, dim1.step, tripCount });
|
||||||
|
}
|
||||||
|
delete(intersection);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static vector<ArrayDimension> DimensionUnion(const ArrayDimension& dim1, const ArrayDimension& dim2)
|
||||||
|
{
|
||||||
|
vector<ArrayDimension> res;
|
||||||
|
ArrayDimension* inter = DimensionIntersection(dim1, dim2);
|
||||||
|
if (!inter)
|
||||||
|
return { dim1, dim2 };
|
||||||
|
|
||||||
|
res.push_back(*inter);
|
||||||
|
delete(inter);
|
||||||
|
|
||||||
|
vector<ArrayDimension> diff1, diff2;
|
||||||
|
diff1 = DimensionDifference(dim1, dim2);
|
||||||
|
diff2 = DimensionDifference(dim2, dim1);
|
||||||
|
res.insert(res.end(), diff1.begin(), diff1.end());
|
||||||
|
res.insert(res.end(), diff2.begin(), diff2.end());
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
static vector<ArrayDimension> ElementsIntersection(const vector<ArrayDimension>& firstElement, const vector<ArrayDimension>& secondElement)
|
||||||
|
{
|
||||||
|
if (firstElement.empty() || secondElement.empty())
|
||||||
|
return {};
|
||||||
|
|
||||||
|
size_t dimAmount = firstElement.size();
|
||||||
|
/* check if there is no intersecction */
|
||||||
|
for (size_t i = 0; i < dimAmount; i++)
|
||||||
|
if (FindParticularSolution(firstElement[i], secondElement[i]).empty())
|
||||||
|
return {};
|
||||||
|
|
||||||
|
vector<ArrayDimension> result(dimAmount);
|
||||||
|
for (size_t i = 0; i < dimAmount; i++)
|
||||||
|
{
|
||||||
|
ArrayDimension* resPtr = DimensionIntersection(firstElement[i], secondElement[i]);
|
||||||
|
if (resPtr)
|
||||||
|
result[i] = *resPtr;
|
||||||
|
else
|
||||||
|
return {};
|
||||||
|
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static vector<vector<ArrayDimension>> ElementsDifference(const vector<ArrayDimension>& firstElement,
|
||||||
|
const vector<ArrayDimension>& secondElement)
|
||||||
|
{
|
||||||
|
if (firstElement.empty() || secondElement.empty())
|
||||||
|
return {};
|
||||||
|
|
||||||
|
vector<ArrayDimension> intersection = ElementsIntersection(firstElement, secondElement);
|
||||||
|
vector<vector<ArrayDimension>> result;
|
||||||
|
if (intersection.empty())
|
||||||
|
return { firstElement };
|
||||||
|
|
||||||
|
for (int i = 0; i < firstElement.size(); i++)
|
||||||
|
{
|
||||||
|
auto dimDiff = DimensionDifference(firstElement[i], secondElement[i]);
|
||||||
|
if (!dimDiff.empty())
|
||||||
|
{
|
||||||
|
vector<ArrayDimension> firstCopy = firstElement;
|
||||||
|
for (const auto& range : dimDiff)
|
||||||
|
{
|
||||||
|
firstCopy[i] = range;
|
||||||
|
result.push_back(firstCopy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ElementsUnion(const vector<ArrayDimension>& firstElement, const vector<ArrayDimension>& secondElement,
|
||||||
|
vector<vector<ArrayDimension>>& lc, vector<vector<ArrayDimension>>& rc,
|
||||||
|
vector<ArrayDimension>& intersection)
|
||||||
|
{
|
||||||
|
/* lc(rc) is a set of ranges, which only exist in first(second) element*/
|
||||||
|
intersection = ElementsIntersection(firstElement, secondElement);
|
||||||
|
lc = ElementsDifference(firstElement, intersection);
|
||||||
|
rc = ElementsDifference(secondElement, intersection);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AccessingSet::FindUncovered(const vector<ArrayDimension>& element, vector<vector<ArrayDimension>>& result) const {
|
||||||
|
vector<vector<ArrayDimension>> newTails;
|
||||||
|
result.push_back(element);
|
||||||
|
for (const auto& currentElement : allElements)
|
||||||
|
{
|
||||||
|
for (const auto& tailLoc : result)
|
||||||
|
{
|
||||||
|
auto intersection = ElementsIntersection(tailLoc, currentElement);
|
||||||
|
auto diff = ElementsDifference(tailLoc, intersection);
|
||||||
|
if (!diff.empty()) {
|
||||||
|
newTails.insert(newTails.end(), diff.begin(), diff.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result = newTails;
|
||||||
|
newTails.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AccessingSet::ContainsElement(const vector<ArrayDimension>& element) const
|
||||||
|
{
|
||||||
|
vector<vector<ArrayDimension>> tails;
|
||||||
|
FindUncovered(element, tails);
|
||||||
|
return !tails.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AccessingSet::FindCoveredBy(const vector<ArrayDimension>& element, vector<vector<ArrayDimension>>& result) const
|
||||||
|
{
|
||||||
|
for (const auto& currentElement : allElements)
|
||||||
|
{
|
||||||
|
auto intersection = ElementsIntersection(element, currentElement);
|
||||||
|
if (!intersection.empty())
|
||||||
|
result.push_back(intersection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<vector<ArrayDimension>> AccessingSet::GetElements() const { return allElements; }
|
||||||
|
|
||||||
|
void AccessingSet::Insert(const vector<ArrayDimension>& element)
|
||||||
|
{
|
||||||
|
vector<vector<ArrayDimension>> tails;
|
||||||
|
FindUncovered(element, tails);
|
||||||
|
allElements.insert(allElements.end(), tails.begin(), tails.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
AccessingSet AccessingSet::Union(const AccessingSet& source) {
|
||||||
|
AccessingSet result;
|
||||||
|
for (auto& element : source.GetElements())
|
||||||
|
result.Insert(element);
|
||||||
|
|
||||||
|
for (auto& element : allElements)
|
||||||
|
result.Insert(element);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
AccessingSet AccessingSet::Intersect(const AccessingSet& secondSet) const
|
||||||
|
{
|
||||||
|
vector<vector<ArrayDimension>> result;
|
||||||
|
if (secondSet.GetElements().empty() || this->allElements.empty())
|
||||||
|
return AccessingSet(result);
|
||||||
|
|
||||||
|
for (const auto& element : allElements)
|
||||||
|
{
|
||||||
|
if (secondSet.ContainsElement(element))
|
||||||
|
result.push_back(element);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vector<vector<ArrayDimension>> coveredBy;
|
||||||
|
secondSet.FindCoveredBy(element, coveredBy);
|
||||||
|
if (!coveredBy.empty())
|
||||||
|
result.insert(result.end(), coveredBy.begin(), coveredBy.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return AccessingSet(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
AccessingSet AccessingSet::Diff(const AccessingSet& secondSet) const
|
||||||
|
{
|
||||||
|
if (secondSet.GetElements().empty() || allElements.empty())
|
||||||
|
return *this;
|
||||||
|
|
||||||
|
AccessingSet intersection = this->Intersect(secondSet);
|
||||||
|
AccessingSet uncovered = *this;
|
||||||
|
vector<vector<ArrayDimension>> result;
|
||||||
|
for (const auto& element : intersection.GetElements())
|
||||||
|
{
|
||||||
|
vector<vector<ArrayDimension>> current_uncovered;
|
||||||
|
uncovered.FindUncovered(element, current_uncovered);
|
||||||
|
uncovered = AccessingSet(current_uncovered);
|
||||||
|
}
|
||||||
|
return uncovered;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const ArrayDimension& lhs, const ArrayDimension& rhs)
|
||||||
|
{
|
||||||
|
return !(lhs.start == rhs.start && lhs.step == rhs.step && lhs.tripCount == rhs.tripCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool operator!=(const AccessingSet& lhs, const AccessingSet& rhs)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < lhs.allElements.size(); i++)
|
||||||
|
for (size_t j = 0; j < lhs.allElements[i].size(); j++)
|
||||||
|
if (lhs.allElements[i][j] != rhs.allElements[i][j])
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const ArrayAccessingIndexes& lhs, const ArrayAccessingIndexes& rhs)
|
||||||
|
{
|
||||||
|
if (lhs.size() != rhs.size())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
for (auto& [key, value] : lhs)
|
||||||
|
if (rhs.find(key) == rhs.end())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
37
src/PrivateAnalyzer/range_structures.h
Normal file
37
src/PrivateAnalyzer/range_structures.h
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
#include <unordered_set>
|
||||||
|
#include <string>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
struct ArrayDimension
|
||||||
|
{
|
||||||
|
uint64_t start, step, tripCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
class AccessingSet {
|
||||||
|
private:
|
||||||
|
std::vector<std::vector<ArrayDimension>> allElements;
|
||||||
|
|
||||||
|
public:
|
||||||
|
AccessingSet(std::vector<std::vector<ArrayDimension>> input) : allElements(input) {};
|
||||||
|
AccessingSet() {};
|
||||||
|
AccessingSet(const AccessingSet& a) { allElements = a.GetElements(); };
|
||||||
|
std::vector<std::vector<ArrayDimension>> GetElements() const;
|
||||||
|
void Insert(const std::vector<ArrayDimension>& element);
|
||||||
|
AccessingSet Union(const AccessingSet& source);
|
||||||
|
AccessingSet Intersect(const AccessingSet& secondSet) const;
|
||||||
|
AccessingSet Diff(const AccessingSet& secondSet) const;
|
||||||
|
bool ContainsElement(const std::vector<ArrayDimension>& element) const;
|
||||||
|
void FindCoveredBy(const std::vector<ArrayDimension>& element, std::vector<std::vector<ArrayDimension>>& result) const;
|
||||||
|
void FindUncovered(const std::vector<ArrayDimension>& element, std::vector<std::vector<ArrayDimension>>& result) const;
|
||||||
|
friend bool operator!=(const AccessingSet& lhs, const AccessingSet& rhs);
|
||||||
|
};
|
||||||
|
|
||||||
|
using ArrayAccessingIndexes = std::map<std::string, AccessingSet>;
|
||||||
|
|
||||||
|
bool operator!=(const ArrayDimension& lhs, const ArrayDimension& rhs);
|
||||||
|
bool operator!=(const AccessingSet& lhs, const AccessingSet& rhs);
|
||||||
|
bool operator!=(const ArrayAccessingIndexes& lhs, const ArrayAccessingIndexes& rhs);
|
||||||
251
src/PrivateAnalyzer/region.cpp
Normal file
251
src/PrivateAnalyzer/region.cpp
Normal file
@@ -0,0 +1,251 @@
|
|||||||
|
#include<vector>
|
||||||
|
#include<map>
|
||||||
|
#include<unordered_set>
|
||||||
|
#include<unordered_map>
|
||||||
|
#include<string>
|
||||||
|
#include <numeric>
|
||||||
|
|
||||||
|
#include "range_structures.h"
|
||||||
|
#include "region.h"
|
||||||
|
|
||||||
|
#include "SgUtils.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
static bool isParentStmt(SgStatement* stmt, SgStatement* parent)
|
||||||
|
{
|
||||||
|
for (; stmt; stmt = stmt->controlParent())
|
||||||
|
if (stmt == parent)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*returns head block and loop*/
|
||||||
|
pair<SAPFOR::BasicBlock*, unordered_set<SAPFOR::BasicBlock*>> GetBasicBlocksForLoop(const LoopGraph* loop, const vector<SAPFOR::BasicBlock*> blocks)
|
||||||
|
{
|
||||||
|
unordered_set<SAPFOR::BasicBlock*> block_loop;
|
||||||
|
SAPFOR::BasicBlock* head_block = nullptr;
|
||||||
|
auto loop_operator = loop->loop->GetOriginal();
|
||||||
|
for (const auto& block : blocks)
|
||||||
|
{
|
||||||
|
if (!block || (block->getInstructions().size() == 0))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
SgStatement* first = block->getInstructions().front()->getInstruction()->getOperator();
|
||||||
|
SgStatement* last = block->getInstructions().back()->getInstruction()->getOperator();
|
||||||
|
if (isParentStmt(first, loop_operator) && isParentStmt(last, loop_operator))
|
||||||
|
{
|
||||||
|
block_loop.insert(block);
|
||||||
|
|
||||||
|
if ((!head_block) && (first == loop_operator) && (last == loop_operator) &&
|
||||||
|
(block->getInstructions().size() == 2) &&
|
||||||
|
(block->getInstructions().back()->getInstruction()->getOperation() == SAPFOR::CFG_OP::JUMP_IF))
|
||||||
|
{
|
||||||
|
head_block = block;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { head_block, block_loop };
|
||||||
|
}
|
||||||
|
|
||||||
|
static void BuildLoopIndex(map<string, LoopGraph*>& loopForIndex, LoopGraph* loop) {
|
||||||
|
string index = loop->loopSymbol();
|
||||||
|
loopForIndex[index] = loop;
|
||||||
|
|
||||||
|
for (const auto& childLoop : loop->children)
|
||||||
|
BuildLoopIndex(loopForIndex, childLoop);
|
||||||
|
}
|
||||||
|
|
||||||
|
static string FindIndexName(int pos, SAPFOR::BasicBlock* block, map<string, LoopGraph*>& loopForIndex) {
|
||||||
|
unordered_set<SAPFOR::Argument*> args = { block->getInstructions()[pos]->getInstruction()->getArg1() };
|
||||||
|
|
||||||
|
for (int i = pos - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
SAPFOR::Argument* res = block->getInstructions()[i]->getInstruction()->getResult();
|
||||||
|
if (res && args.find(res) != args.end())
|
||||||
|
{
|
||||||
|
SAPFOR::Argument* arg1 = block->getInstructions()[i]->getInstruction()->getArg1();
|
||||||
|
SAPFOR::Argument* arg2 = block->getInstructions()[i]->getInstruction()->getArg2();
|
||||||
|
if (arg1)
|
||||||
|
{
|
||||||
|
string name = arg1->getValue();
|
||||||
|
int idx = name.find('%');
|
||||||
|
if (idx != -1 && loopForIndex.find(name.substr(idx + 1)) != loopForIndex.end())
|
||||||
|
return name.substr(idx + 1);
|
||||||
|
else
|
||||||
|
args.insert(arg1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arg2)
|
||||||
|
{
|
||||||
|
string name = arg2->getValue();
|
||||||
|
int idx = name.find('%');
|
||||||
|
if (idx != -1 && loopForIndex.find(name.substr(idx + 1)) != loopForIndex.end())
|
||||||
|
return name.substr(idx + 1);
|
||||||
|
else
|
||||||
|
args.insert(arg2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
static int GetDefUseArray(SAPFOR::BasicBlock* block, LoopGraph* loop, ArrayAccessingIndexes& def, ArrayAccessingIndexes& use) {
|
||||||
|
auto instructions = block->getInstructions();
|
||||||
|
map<string, LoopGraph*> loopForIndex;
|
||||||
|
BuildLoopIndex(loopForIndex, loop);
|
||||||
|
for (int i = 0; i < instructions.size(); i++)
|
||||||
|
{
|
||||||
|
auto instruction = instructions[i];
|
||||||
|
if (!instruction->getInstruction()->getArg1())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
auto operation = instruction->getInstruction()->getOperation();
|
||||||
|
auto type = instruction->getInstruction()->getArg1()->getType();
|
||||||
|
if ((operation == SAPFOR::CFG_OP::STORE || operation == SAPFOR::CFG_OP::LOAD) && type == SAPFOR::CFG_ARG_TYPE::ARRAY)
|
||||||
|
{
|
||||||
|
vector<SAPFOR::Argument*> index_vars;
|
||||||
|
vector<int> refPos;
|
||||||
|
string array_name;
|
||||||
|
if (operation == SAPFOR::CFG_OP::STORE)
|
||||||
|
array_name = instruction->getInstruction()->getArg1()->getValue();
|
||||||
|
else
|
||||||
|
array_name = instruction->getInstruction()->getArg2()->getValue();
|
||||||
|
|
||||||
|
int j = i - 1;
|
||||||
|
while (j >= 0 && instructions[j]->getInstruction()->getOperation() == SAPFOR::CFG_OP::REF)
|
||||||
|
{
|
||||||
|
index_vars.push_back(instructions[j]->getInstruction()->getArg1());
|
||||||
|
refPos.push_back(j);
|
||||||
|
j--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*to choose correct dimension*/
|
||||||
|
int n = index_vars.size();
|
||||||
|
vector<ArrayDimension> accessPoint(n);
|
||||||
|
|
||||||
|
auto* ref = isSgArrayRefExp(instruction->getInstruction()->getExpression());
|
||||||
|
vector<pair<int, int>> coefsForDims;
|
||||||
|
for (int i = 0; ref && i < ref->numberOfSubscripts(); ++i)
|
||||||
|
{
|
||||||
|
const vector<int*>& coefs = getAttributes<SgExpression*, int*>(ref->subscript(i), set<int>{ INT_VAL });
|
||||||
|
if (coefs.size() == 1)
|
||||||
|
{
|
||||||
|
const pair<int, int> coef(coefs[0][0], coefs[0][1]);
|
||||||
|
coefsForDims.push_back(coef);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(coefsForDims.empty())
|
||||||
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|
||||||
|
while (!index_vars.empty())
|
||||||
|
{
|
||||||
|
auto var = index_vars.back();
|
||||||
|
int currentVarPos = refPos.back();
|
||||||
|
pair<int, int> currentCoefs = coefsForDims.back();
|
||||||
|
ArrayDimension current_dim;
|
||||||
|
if (var->getType() == SAPFOR::CFG_ARG_TYPE::CONST)
|
||||||
|
current_dim = { stoul(var->getValue()), 1, 1 };
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string name, full_name = var->getValue();
|
||||||
|
int pos = full_name.find('%');
|
||||||
|
LoopGraph* currentLoop;
|
||||||
|
if (pos != -1)
|
||||||
|
{
|
||||||
|
name = full_name.substr(pos + 1);
|
||||||
|
if (loopForIndex.find(name) != loopForIndex.end())
|
||||||
|
currentLoop = loopForIndex[name];
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
name = FindIndexName(currentVarPos, block, loopForIndex);
|
||||||
|
if (name == "")
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (loopForIndex.find(name) != loopForIndex.end())
|
||||||
|
currentLoop = loopForIndex[name];
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t start = currentLoop->startVal * currentCoefs.first + currentCoefs.second;
|
||||||
|
uint64_t step = currentCoefs.first;
|
||||||
|
current_dim = { start, step, (uint64_t)currentLoop->calculatedCountOfIters };
|
||||||
|
}
|
||||||
|
|
||||||
|
accessPoint[n - index_vars.size()] = current_dim;
|
||||||
|
index_vars.pop_back();
|
||||||
|
refPos.pop_back();
|
||||||
|
coefsForDims.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operation == SAPFOR::CFG_OP::STORE)
|
||||||
|
def[array_name].Insert(accessPoint);
|
||||||
|
else
|
||||||
|
use[array_name].Insert(accessPoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SetConnections(unordered_map<SAPFOR::BasicBlock*, Region*>& bbToRegion, const unordered_set<SAPFOR::BasicBlock*>& blockSet)
|
||||||
|
{
|
||||||
|
for (SAPFOR::BasicBlock* block : blockSet)
|
||||||
|
{
|
||||||
|
for (SAPFOR::BasicBlock* nextBlock : block->getNext())
|
||||||
|
if (bbToRegion.find(nextBlock) != bbToRegion.end())
|
||||||
|
bbToRegion[block]->addNextRegion(bbToRegion[nextBlock]);
|
||||||
|
|
||||||
|
for (SAPFOR::BasicBlock* prevBlock : block->getPrev())
|
||||||
|
if (bbToRegion.find(prevBlock) != bbToRegion.end())
|
||||||
|
bbToRegion[block]->addPrevRegion(bbToRegion[prevBlock]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static Region* CreateSubRegion(LoopGraph* loop, const vector<SAPFOR::BasicBlock*>& Blocks, const unordered_map<SAPFOR::BasicBlock*, Region*>& bbToRegion)
|
||||||
|
{
|
||||||
|
Region* region = new Region;
|
||||||
|
auto [header, blockSet] = GetBasicBlocksForLoop(loop, Blocks);
|
||||||
|
if (bbToRegion.find(header) != bbToRegion.end())
|
||||||
|
region->setHeader(bbToRegion.at(header));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (SAPFOR::BasicBlock* block : blockSet)
|
||||||
|
if (bbToRegion.find(block) != bbToRegion.end())
|
||||||
|
region->addBasickBlocks(bbToRegion.at(block));
|
||||||
|
|
||||||
|
for (LoopGraph* childLoop : loop->children)
|
||||||
|
region->addSubRegions(CreateSubRegion(childLoop, Blocks, bbToRegion));
|
||||||
|
|
||||||
|
return region;
|
||||||
|
}
|
||||||
|
|
||||||
|
Region::Region(LoopGraph* loop, const vector<SAPFOR::BasicBlock*>& Blocks)
|
||||||
|
{
|
||||||
|
auto [header, blockSet] = GetBasicBlocksForLoop(loop, Blocks);
|
||||||
|
unordered_map<SAPFOR::BasicBlock*, Region*> bbToRegion;
|
||||||
|
for (auto poiner : blockSet)
|
||||||
|
{
|
||||||
|
bbToRegion[poiner] = new Region(*poiner);
|
||||||
|
this->basickBlocks.insert(bbToRegion[poiner]);
|
||||||
|
GetDefUseArray(poiner, loop, bbToRegion[poiner]->array_def, bbToRegion[poiner]->array_use);
|
||||||
|
|
||||||
|
}
|
||||||
|
this->header = bbToRegion[header];
|
||||||
|
SetConnections(bbToRegion, blockSet);
|
||||||
|
//create subRegions
|
||||||
|
for (LoopGraph* childLoop : loop->children)
|
||||||
|
subRegions.insert(CreateSubRegion(childLoop, Blocks, bbToRegion));
|
||||||
|
}
|
||||||
60
src/PrivateAnalyzer/region.h
Normal file
60
src/PrivateAnalyzer/region.h
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
#include <unordered_set>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "graph_loops.h"
|
||||||
|
#include "CFGraph/CFGraph.h"
|
||||||
|
|
||||||
|
class Region : public SAPFOR::BasicBlock {
|
||||||
|
public:
|
||||||
|
Region() { header = nullptr; }
|
||||||
|
|
||||||
|
Region(SAPFOR::BasicBlock block) : SAPFOR::BasicBlock::BasicBlock(block) { header = nullptr; }
|
||||||
|
|
||||||
|
Region(LoopGraph* loop, const std::vector<SAPFOR::BasicBlock*>& Blocks);
|
||||||
|
|
||||||
|
Region* getHeader() { return header; }
|
||||||
|
|
||||||
|
void setHeader(Region* region) { header = region; }
|
||||||
|
|
||||||
|
std::unordered_set<Region*>& getBasickBlocks() { return basickBlocks; }
|
||||||
|
|
||||||
|
void addBasickBlocks(Region* region) { basickBlocks.insert(region); }
|
||||||
|
|
||||||
|
const std::unordered_set<Region*>& getPrevRegions() { return prevRegions; }
|
||||||
|
|
||||||
|
std::unordered_set<Region*> getNextRegions() { return nextRegions; }
|
||||||
|
|
||||||
|
void addPrevRegion(Region* region) { prevRegions.insert(region); }
|
||||||
|
|
||||||
|
void addNextRegion(Region* region) { nextRegions.insert(region); }
|
||||||
|
|
||||||
|
void replaceInPrevRegions(Region* source, Region* destination)
|
||||||
|
{
|
||||||
|
prevRegions.erase(destination);
|
||||||
|
prevRegions.insert(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
void replaceInNextRegions(Region* source, Region* destination)
|
||||||
|
{
|
||||||
|
nextRegions.erase(destination);
|
||||||
|
nextRegions.insert(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unordered_set<Region*> getSubRegions() { return subRegions; }
|
||||||
|
|
||||||
|
void addSubRegions(Region* region) { subRegions.insert(region); }
|
||||||
|
|
||||||
|
ArrayAccessingIndexes array_def, array_use, array_out, array_in, array_priv;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unordered_set<Region*> subRegions, basickBlocks;
|
||||||
|
/*next Region which is BB for current BB Region*/
|
||||||
|
std::unordered_set<Region*> nextRegions;
|
||||||
|
/*prev Regions which is BBs for current BB Region*/
|
||||||
|
std::unordered_set<Region*> prevRegions;
|
||||||
|
Region* header;
|
||||||
|
};
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../Utils/leak_detector.h"
|
#include "leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -6,9 +6,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../Utils/errors.h"
|
#include "errors.h"
|
||||||
#include "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "../Utils/utils.h"
|
#include "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);
|
UnparseTo_CufAndCu_Files(file, fout_cuf, fout_C_cu, fout_info, fout_name);
|
||||||
|
|
||||||
const string fileN = file->filename();
|
const string fileN = file->filename();
|
||||||
set<SgStatement*> toRemove;
|
set<SgStatement*> toRemove;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../Utils/leak_detector.h"
|
#include "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/utils.h"
|
#include "utils.h"
|
||||||
#include "../Utils/errors.h"
|
#include "errors.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../Utils/leak_detector.h"
|
#include "leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -22,8 +22,8 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
|
||||||
#include "../Utils/errors.h"
|
#include "errors.h"
|
||||||
#include "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
#include "../VisualizerCalls/get_information.h"
|
#include "../VisualizerCalls/get_information.h"
|
||||||
#include "../VisualizerCalls/SendMessage.h"
|
#include "../VisualizerCalls/SendMessage.h"
|
||||||
|
|
||||||
@@ -34,6 +34,7 @@
|
|||||||
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)
|
||||||
{
|
{
|
||||||
@@ -293,11 +294,8 @@ static vector<string> parseList(vector<FileInfo>& listOfProject,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
sendMessage_2lvl(3, file);
|
||||||
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
|
||||||
@@ -387,7 +385,50 @@ static string shiftLines(const string &in, const map<string, const FileInfo*> &m
|
|||||||
return newStr;
|
return newStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dumpErrors(const vector<FileInfo>& listOfProject, const vector<string>& errors)
|
static void addMessage(const string& in, const map<string, const FileInfo*>& mapOfFiles,
|
||||||
|
const FileInfo* currF, map<string, vector<Messages>>& messages, typeMessage type)
|
||||||
|
{
|
||||||
|
int byNum = 0;
|
||||||
|
|
||||||
|
auto it = in.find("on line ");
|
||||||
|
if (it != string::npos)
|
||||||
|
it += strlen("on line ");
|
||||||
|
|
||||||
|
int line = 0;
|
||||||
|
sscanf(in.c_str() + it, "%d", &line);
|
||||||
|
|
||||||
|
auto it1 = in.find("of", it + 1);
|
||||||
|
if (it1 == string::npos)
|
||||||
|
return;
|
||||||
|
it1 += 3;
|
||||||
|
|
||||||
|
string fileN = in.substr(it1, in.find(':', it1) - it1);
|
||||||
|
auto itF = mapOfFiles.find(fileN);
|
||||||
|
if (itF != mapOfFiles.end() && itF->second != currF)
|
||||||
|
{
|
||||||
|
byNum = itF->second->includesAdded;
|
||||||
|
if (byNum != 0)
|
||||||
|
{
|
||||||
|
if (line - byNum <= 0)
|
||||||
|
{
|
||||||
|
//return in;
|
||||||
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
line -= byNum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const string newStr = in.substr(0, it) + std::to_string(line) + in.substr(in.find(' ', it + 1));
|
||||||
|
|
||||||
|
wstring messageE, messageR;
|
||||||
|
__spf_printToLongBuf(messageE, L"%s", to_wstring(newStr).c_str());
|
||||||
|
__spf_printToLongBuf(messageR, L"%s", to_wstring(newStr).c_str());
|
||||||
|
|
||||||
|
messages[fileN].push_back(Messages(type, line, messageR, messageE, 6000));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dumpErrors(const vector<FileInfo>& listOfProject, const vector<string>& errors, map<string, vector<Messages>>& messages)
|
||||||
{
|
{
|
||||||
int errorsCount = 0;
|
int errorsCount = 0;
|
||||||
map<string, const FileInfo*> mapOfFiles;
|
map<string, const FileInfo*> mapOfFiles;
|
||||||
@@ -400,41 +441,46 @@ 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)
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
fclose(ferr);
|
||||||
fclose(ferr);
|
|
||||||
++z;
|
++z;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE* ferr = fopen(file.errPath.c_str(), "w");
|
|
||||||
FILE* fout = fopen(file.outPath.c_str(), "w");
|
|
||||||
if (!ferr)
|
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
|
||||||
if (!fout)
|
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
|
||||||
|
|
||||||
string errS = "", outS = "";
|
string errS = "", outS = "";
|
||||||
vector<string> splited;
|
vector<string> splited;
|
||||||
splitString(errors[z], '\n', splited);
|
splitString(errors[z], '\n', splited);
|
||||||
for (auto& elem : splited)
|
for (auto& elem : splited)
|
||||||
{
|
{
|
||||||
if (elem.find("Warning 308") != string::npos)
|
if (elem.find("Warning 308") != string::npos)
|
||||||
|
{
|
||||||
|
addMessage(elem, mapOfFiles, &file, messages, WARR);
|
||||||
outS += shiftLines(elem, mapOfFiles, &file) + "\n";
|
outS += shiftLines(elem, mapOfFiles, &file) + "\n";
|
||||||
|
}
|
||||||
else if (elem.find("Error") != string::npos)
|
else if (elem.find("Error") != string::npos)
|
||||||
{
|
{
|
||||||
|
addMessage(elem, mapOfFiles, &file, messages, ERROR);
|
||||||
errS += shiftLines(elem, mapOfFiles, &file) + "\n";
|
errS += shiftLines(elem, mapOfFiles, &file) + "\n";
|
||||||
errorsCount++;
|
errorsCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fout, "%s", outS.c_str());
|
|
||||||
fprintf(ferr, "%s", errS.c_str());
|
FILE* ferr = fopen(file.errPath.c_str(), "w");
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -529,11 +575,8 @@ static void parseFiles(int& iters, vector<string>& errors, vector<FileInfo>& lis
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
sendMessage_1lvl(0, iters + 1);
|
||||||
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)
|
||||||
@@ -652,7 +695,7 @@ static int parseFiles(vector<string>& errors, vector<FileInfo>& listOfProject, v
|
|||||||
return rethrow;
|
return rethrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int parseForInlining)
|
int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int parseForInlining, map<string, vector<Messages>>& messages)
|
||||||
{
|
{
|
||||||
FILE* list = fopen(proj, "r");
|
FILE* list = fopen(proj, "r");
|
||||||
if (!list)
|
if (!list)
|
||||||
@@ -666,7 +709,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] != "visualiser_data")
|
if (pathSplit[pathSplit.size() - 2] != VISUALIZER_DATA_PATH)
|
||||||
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)
|
||||||
@@ -698,9 +741,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 + "visualiser_data/options/" + fileNameFixed + ".opt";
|
const string optPath = fullPath + VISUALIZER_DATA_PATH + "/options/" + fileNameFixed + ".opt";
|
||||||
const string errPath = fullPath + "visualiser_data/options/" + fileNameFixed + ".err";
|
const string errPath = fullPath + VISUALIZER_DATA_PATH + "/options/" + fileNameFixed + ".err";
|
||||||
const string outPath = fullPath + "visualiser_data/options/" + fileNameFixed + ".out";
|
const string outPath = fullPath + VISUALIZER_DATA_PATH + "/options/" + fileNameFixed + ".out";
|
||||||
|
|
||||||
const string fileText = readFileToStr(toAdd);
|
const string fileText = readFileToStr(toAdd);
|
||||||
|
|
||||||
@@ -723,7 +766,7 @@ int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int pars
|
|||||||
vector<string> errors;
|
vector<string> errors;
|
||||||
|
|
||||||
int rethrow = parseFiles(errors, listOfProject, filesCompilationOrder, parseForInlining);
|
int rethrow = parseFiles(errors, listOfProject, filesCompilationOrder, parseForInlining);
|
||||||
int errCount = dumpErrors(listOfProject, errors);
|
int errCount = dumpErrors(listOfProject, errors, messages);
|
||||||
|
|
||||||
if (rethrow != 0)
|
if (rethrow != 0)
|
||||||
throw rethrow;
|
throw rethrow;
|
||||||
@@ -732,6 +775,8 @@ int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int pars
|
|||||||
|
|
||||||
void parseFiles(int argc, char** argv)
|
void parseFiles(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
map<string, vector<Messages>> messages;
|
||||||
|
|
||||||
bool isInline = false;
|
bool isInline = false;
|
||||||
auto result = splitCommandLineForParse(argv, argc, isInline);
|
auto result = splitCommandLineForParse(argv, argc, isInline);
|
||||||
if (result.second.size() == 0)
|
if (result.second.size() == 0)
|
||||||
@@ -760,6 +805,8 @@ 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)
|
||||||
@@ -789,5 +836,7 @@ 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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,5 +3,5 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
int parseFiles(const char* proj, std::vector<std::string>& filesCompilationOrder, int parseForInlining);
|
int parseFiles(const char* proj, std::vector<std::string>& filesCompilationOrder, int parseForInlining, std::map<std::string, std::vector<Messages>>& messages);
|
||||||
void parseFiles(int argc, char** argv);
|
void parseFiles(int argc, char** argv);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../Utils/leak_detector.h"
|
#include "leak_detector.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -6,8 +6,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../Utils/errors.h"
|
#include "errors.h"
|
||||||
#include "../Utils/SgUtils.h"
|
#include "SgUtils.h"
|
||||||
|
|
||||||
#include "StdCapture.h"
|
#include "StdCapture.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,33 +1,443 @@
|
|||||||
#include "../Utils/leak_detector.h"
|
#include "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 "../Utils/SgUtils.h"
|
#include "errors.h"
|
||||||
#include "../GraphCall/graph_calls.h"
|
#include "SgUtils.h"
|
||||||
#include "../GraphCall/graph_calls_func.h"
|
#include "graph_calls.h"
|
||||||
|
#include "graph_calls_func.h"
|
||||||
|
|
||||||
#include "projectParameters.h"
|
#include "projectParameters.h"
|
||||||
|
|
||||||
using namespace std;
|
using std::set;
|
||||||
|
using std::map;
|
||||||
|
using std::string;
|
||||||
|
using std::vector;
|
||||||
|
using std::tuple;
|
||||||
|
using std::pair;
|
||||||
|
using std::make_tuple;
|
||||||
|
using std::find_if;
|
||||||
|
|
||||||
map< pair<string, int>, set<string>>
|
static map<FuncInfo*, vector<SAPFOR::Instruction*>> call_sites;
|
||||||
findParameters(const map<string, vector<DefUseList>> &defUseByFunctions,
|
|
||||||
const map<string, CommonBlock*> &commonBlocks,
|
enum class MODE
|
||||||
const map<string, vector<FuncInfo*>> &allFuncInfo)
|
|
||||||
{
|
{
|
||||||
map< pair<string, int>, set<string>> foundParameters;
|
BEFORE,
|
||||||
|
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,3 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
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 <map>
|
||||||
|
#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,9 +4,9 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "../GraphCall/graph_calls.h"
|
#include "graph_calls.h"
|
||||||
#include "../Utils/errors.h"
|
#include "errors.h"
|
||||||
#include "../Utils/utils.h"
|
#include "utils.h"
|
||||||
#include "sage++user.h"
|
#include "sage++user.h"
|
||||||
#include "definesValues.h"
|
#include "definesValues.h"
|
||||||
#include "set.h"
|
#include "set.h"
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user