Compare commits
85 Commits
ae9cc2bf3b
...
libpredict
| Author | SHA1 | Date | |
|---|---|---|---|
| 9d0fee77c7 | |||
| 6fceaaf704 | |||
| f623eaeb5b | |||
| c26cc261c4 | |||
| d1a9113072 | |||
| 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 | ||
|
|
db32a3e2b2 | ||
|
|
a0a401c42a | ||
| 8161609173 | |||
| a2e6269508 | |||
|
|
72a1c1d853 | ||
| 5c89299ad5 | |||
|
|
26e36bed46 | ||
|
|
8dcbd587ec | ||
|
|
f7a78f9626 | ||
| fbe22fca43 | |||
| bbb9823f1d | |||
| c347f56e47 | |||
| 11e9fab482 | |||
| 73d0b201f2 | |||
| 1973d095f5 | |||
|
|
f679666d01 | ||
| 0df1d3d5fe | |||
| 54eb1ecc95 | |||
| b7ebccf045 |
125
CMakeLists.txt
125
CMakeLists.txt
@@ -12,6 +12,7 @@ add_definitions("-D SYS5")
|
||||
add_definitions("-D YYDEBUG")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_C_STANDARD 17)
|
||||
|
||||
set(fdvm_include projects/dvm/fdvmh/include/fdvmh/)
|
||||
set(fdvm_sources projects/dvm/fdvmh/tools/fdvmh/)
|
||||
@@ -27,6 +28,14 @@ set(libpred_sources projects/libpredictor/src/)
|
||||
set(libpred_include projects/libpredictor/include/)
|
||||
|
||||
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
|
||||
include_directories(${fdvm_include})
|
||||
include_directories(${sage_include_1})
|
||||
@@ -113,7 +122,13 @@ set(OMEGA src/SageAnalysisTool/OmegaForSage/add-assert.cpp
|
||||
src/SageAnalysisTool/set.cpp)
|
||||
|
||||
set(PRIV src/PrivateAnalyzer/private_analyzer.cpp
|
||||
src/PrivateAnalyzer/private_analyzer.h)
|
||||
src/PrivateAnalyzer/private_analyzer.h
|
||||
src/PrivateAnalyzer/private_arrays_search.cpp
|
||||
src/PrivateAnalyzer/private_arrays_search.h
|
||||
src/PrivateAnalyzer/range_structures.cpp
|
||||
src/PrivateAnalyzer/range_structures.h
|
||||
src/PrivateAnalyzer/region.cpp
|
||||
src/PrivateAnalyzer/region.h)
|
||||
|
||||
set(FDVM ${fdvm_sources}/acc.cpp
|
||||
${fdvm_sources}/acc_across.cpp
|
||||
@@ -148,40 +163,47 @@ set(PARALLEL_REG src/ParallelizationRegions/ParRegions.cpp
|
||||
src/ParallelizationRegions/resolve_par_reg_conflicts.cpp
|
||||
src/ParallelizationRegions/resolve_par_reg_conflicts.h)
|
||||
|
||||
set(TR_DEAD_CODE src/Transformations/dead_code.cpp
|
||||
src/Transformations/dead_code.h)
|
||||
set(TR_CP src/Transformations/checkpoints.cpp
|
||||
src/Transformations/checkpoints.h)
|
||||
set(TR_VECTOR src/Transformations/array_assign_to_loop.cpp
|
||||
src/Transformations/array_assign_to_loop.h)
|
||||
set(TR_ENDDO_LOOP src/Transformations/enddo_loop_converter.cpp
|
||||
src/Transformations/enddo_loop_converter.h)
|
||||
set(TR_LOOP_NEST src/Transformations/loop_transform.cpp
|
||||
src/Transformations/loop_transform.h)
|
||||
set(TR_LOOP_COMB src/Transformations/loops_combiner.cpp
|
||||
src/Transformations/loops_combiner.h)
|
||||
set(TR_LOOP_SPLIT src/Transformations/loops_splitter.cpp
|
||||
src/Transformations/loops_splitter.h)
|
||||
set(TR_LOOP_UNROLL src/Transformations/loops_unrolling.cpp
|
||||
src/Transformations/loops_unrolling.h)
|
||||
set(TR_PRIV_BR src/Transformations/private_arrays_resizing.cpp
|
||||
src/Transformations/private_arrays_resizing.h)
|
||||
set(TR_PRIV_DEL src/Transformations/private_removing.cpp
|
||||
src/Transformations/private_removing.h)
|
||||
set(TR_SWAP_ARR_DIMS src/Transformations/swap_array_dims.cpp
|
||||
src/Transformations/swap_array_dims.h)
|
||||
set(TR_FUNC_DUP src/Transformations/uniq_call_chain_dup.cpp
|
||||
src/Transformations/uniq_call_chain_dup.h)
|
||||
set(TR_FUNC_PURE src/Transformations/function_purifying.cpp
|
||||
src/Transformations/function_purifying.h)
|
||||
set(TR_GV src/Transformations/fix_common_blocks.cpp
|
||||
src/Transformations/fix_common_blocks.h)
|
||||
set(TR_CONV src/Transformations/convert_to_c.cpp
|
||||
src/Transformations/convert_to_c.h)
|
||||
set(TR_IMPLICIT_NONE src/Transformations/set_implicit_none.cpp
|
||||
src/Transformations/set_implicit_none.h)
|
||||
set(TR_REPLACE_ARRAYS_IN_IO src/Transformations/replace_dist_arrays_in_io.cpp
|
||||
src/Transformations/replace_dist_arrays_in_io.h)
|
||||
set(TR_DEAD_CODE src/Transformations/DeadCodeRemoving/dead_code.cpp
|
||||
src/Transformations/DeadCodeRemoving/dead_code.h)
|
||||
set(TR_CP src/Transformations/CheckPoints/checkpoints.cpp
|
||||
src/Transformations/CheckPoints/checkpoints.h)
|
||||
set(TR_VECTOR src/Transformations/VectorAssignToLoop/array_assign_to_loop.cpp
|
||||
src/Transformations/VectorAssignToLoop/array_assign_to_loop.h)
|
||||
set(TR_ENDDO_LOOP src/Transformations/LoopEndDoConverter/enddo_loop_converter.cpp
|
||||
src/Transformations/LoopEndDoConverter/enddo_loop_converter.h)
|
||||
set(TR_LOOP_NEST src/Transformations/LoopNesting/loop_transform.cpp
|
||||
src/Transformations/LoopNesting/loop_transform.h)
|
||||
set(TR_LOOP_COMB src/Transformations/LoopCombining/loops_combiner.cpp
|
||||
src/Transformations/LoopCombining/loops_combiner.h)
|
||||
set(TR_LOOP_SPLIT src/Transformations/LoopSplitting/loops_splitter.cpp
|
||||
src/Transformations/LoopSplitting/loops_splitter.h)
|
||||
set(TR_LOOP_UNROLL src/Transformations/LoopUnrolling/loops_unrolling.cpp
|
||||
src/Transformations/LoopUnrolling/loops_unrolling.h)
|
||||
set(TR_PRIV_BR src/Transformations/PrivateArrayResizing/private_arrays_resizing.cpp
|
||||
src/Transformations/PrivateArrayResizing/private_arrays_resizing.h)
|
||||
set(TR_PRIV_DEL src/Transformations/PrivateArrayRemoving/private_removing.cpp
|
||||
src/Transformations/PrivateArrayRemoving/private_removing.h)
|
||||
set(TR_SWAP_ARR_DIMS src/Transformations/ArrayDimsSwapping/swap_array_dims.cpp
|
||||
src/Transformations/ArrayDimsSwapping/swap_array_dims.h)
|
||||
set(TR_FUNC_DUP src/Transformations/FunctionDuplication/uniq_call_chain_dup.cpp
|
||||
src/Transformations/FunctionDuplication/uniq_call_chain_dup.h)
|
||||
set(TR_FUNC_PURE src/Transformations/FunctionPurifying/function_purifying.cpp
|
||||
src/Transformations/FunctionPurifying/function_purifying.h)
|
||||
set(TR_GV src/Transformations/GlobalVariables/fix_common_blocks.cpp
|
||||
src/Transformations/GlobalVariables/fix_common_blocks.h)
|
||||
set(TR_CONV src/Transformations/ConvertToC/convert_to_c.cpp
|
||||
src/Transformations/ConvertToC/convert_to_c.h)
|
||||
set(TR_IMPLICIT_NONE src/Transformations/SetImplicitNone/set_implicit_none.cpp
|
||||
src/Transformations/SetImplicitNone/set_implicit_none.h)
|
||||
set(TR_REPLACE_ARRAYS_IN_IO src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.cpp
|
||||
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
|
||||
${TR_DEAD_CODE}
|
||||
@@ -201,7 +223,10 @@ set(TRANSFORMS
|
||||
${TR_CONV}
|
||||
${TR_PRIV_DEL}
|
||||
${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
|
||||
src/CFGraph/IR.h
|
||||
@@ -285,10 +310,6 @@ set(DYNA src/DynamicAnalysis/createParallelRegions.cpp
|
||||
src/DynamicAnalysis/gCov_parser.cpp
|
||||
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
|
||||
src/GraphCall/graph_calls.h
|
||||
src/GraphCall/graph_calls_base.cpp
|
||||
@@ -299,25 +320,20 @@ set(GR_LOOP src/GraphLoop/graph_loops_base.cpp
|
||||
src/GraphLoop/graph_loops.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
|
||||
src/LoopAnalyzer/dep_analyzer.cpp
|
||||
src/LoopAnalyzer/loop_analyzer.cpp
|
||||
src/LoopAnalyzer/loop_analyzer.h)
|
||||
|
||||
set(RENAME_SYMBOLS src/RenameSymbols/rename_symbols.cpp
|
||||
src/RenameSymbols/rename_symbols.h)
|
||||
|
||||
|
||||
set(MAIN src/Sapfor.cpp
|
||||
src/Sapfor.h
|
||||
src/SapforData.h
|
||||
src/Utils/PassManager.h)
|
||||
|
||||
set(PREDICTOR src/Predictor/PredictScheme.cpp
|
||||
src/Predictor/PredictScheme.h)
|
||||
src/Predictor/PredictScheme.h
|
||||
src/Predictor/PredictSchemeWithLibrary.cpp
|
||||
src/Predictor/PredictSchemeWithLibrary.h)
|
||||
|
||||
set(LIBPREDICTOR ${libpred_sources}/cluster.cpp
|
||||
${libpred_sources}/predictor.cpp
|
||||
@@ -400,12 +416,9 @@ set(SOURCE_EXE
|
||||
${DISTR}
|
||||
${DVMH_REG}
|
||||
${DYNA}
|
||||
${EXPR_TRANSFORM}
|
||||
${GR_CALL}
|
||||
${GR_LOOP}
|
||||
${INLINER}
|
||||
${LOOP_ANALYZER}
|
||||
${RENAME_SYMBOLS}
|
||||
${TRANSFORMS}
|
||||
${PARALLEL_REG}
|
||||
${PRIV}
|
||||
@@ -429,7 +442,7 @@ source_group (CFGraph FILES ${CFG})
|
||||
source_group (CFGraph\\DataFlow FILES ${DATA_FLOW})
|
||||
|
||||
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\\LoopEndDoConverter FILES ${TR_ENDDO_LOOP})
|
||||
source_group (Transformations\\LoopNesting FILES ${TR_LOOP_NEST})
|
||||
@@ -437,13 +450,13 @@ source_group (Transformations\\LoopCombining FILES ${TR_LOOP_COMB})
|
||||
source_group (Transformations\\LoopSplitting FILES ${TR_LOOP_SPLIT})
|
||||
source_group (Transformations\\LoopUnrolling FILES ${TR_LOOP_UNROLL})
|
||||
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\\ArrayDimsSwapping FILES ${TR_SWAP_ARR_DIMS})
|
||||
source_group (Transformations\\PrivateArrayResizing FILES ${TR_PRIV_BR})
|
||||
source_group (Transformations\\PrivateArrayRemoving FILES ${TR_PRIV_DEL})
|
||||
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\\ConvertToC FILES ${TR_CONV})
|
||||
source_group (Transformations\\SetImplicitNone FILES ${TR_IMPLICIT_NONE})
|
||||
@@ -485,7 +498,9 @@ else()
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
endif()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_subdirectory(projects/Fdvm)
|
||||
|
||||
Submodule projects/dvm updated: 6a86c96abe...4b7ef11871
Submodule projects/libpredictor updated: d0772cdb57...e6e805a390
@@ -1,5 +1,5 @@
|
||||
#define _LEAK_
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@@ -8,9 +8,9 @@
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "../Utils/CommonBlock.h"
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
#include "SgUtils.h"
|
||||
#include "CommonBlock.h"
|
||||
#include "graph_calls.h"
|
||||
|
||||
#include "dvm.h"
|
||||
#include "IR.h"
|
||||
@@ -1156,12 +1156,15 @@ map<FuncInfo*, vector<BBlock*>> buildCFG(const map<string, CommonBlock*>& common
|
||||
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.);
|
||||
__spf_print(1, " dominator build time is %.3f sec\n", msec / 1000.);
|
||||
}
|
||||
|
||||
if (SgFile::switchToFile(oldFile) == -1)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
for (auto& [func, blocks] : result)
|
||||
removedUnreachableBlocks(blocks);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1237,3 +1240,48 @@ map<FuncInfo*, vector<SAPFOR::BasicBlock*>>
|
||||
|
||||
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());
|
||||
}
|
||||
@@ -156,3 +156,5 @@ static inline void deleteCFG(std::map<FuncInfo*, std::vector<SAPFOR::BasicBlock*
|
||||
}
|
||||
cfg.clear();
|
||||
}
|
||||
|
||||
void removedUnreachableBlocks(std::vector<SAPFOR::BasicBlock*>& blocks);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
|
||||
#include "../../Utils/SgUtils.h"
|
||||
#include "SgUtils.h"
|
||||
#include "../CFGraph.h"
|
||||
#include "../IR.h"
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
|
||||
#include "../../Utils/SgUtils.h"
|
||||
#include "SgUtils.h"
|
||||
#include "../CFGraph.h"
|
||||
#include "../IR.h"
|
||||
#include "../RD_subst.h"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include<vector>
|
||||
#include<set>
|
||||
|
||||
#include "../../Utils/SgUtils.h"
|
||||
#include "SgUtils.h"
|
||||
#include "../CFGraph.h"
|
||||
#include "../IR.h"
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include<vector>
|
||||
#include<set>
|
||||
|
||||
#include "../../Utils/SgUtils.h"
|
||||
#include "SgUtils.h"
|
||||
#include "../CFGraph.h"
|
||||
#include "../IR.h"
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "../Utils/CommonBlock.h"
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
#include "../ExpressionTransform/expr_transform.h"
|
||||
#include "SgUtils.h"
|
||||
#include "CommonBlock.h"
|
||||
#include "graph_calls.h"
|
||||
#include "expr_transform.h"
|
||||
|
||||
#include "dvm.h"
|
||||
#include "IR.h"
|
||||
@@ -395,7 +395,7 @@ static SAPFOR::Argument* processExpression(SgExpression* ex, vector<IR_Block*>&
|
||||
if (ex)
|
||||
{
|
||||
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)
|
||||
{
|
||||
@@ -450,7 +450,7 @@ static SAPFOR::Argument* processExpression(SgExpression* ex, vector<IR_Block*>&
|
||||
return arg1;
|
||||
|
||||
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));
|
||||
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 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));
|
||||
return reg;
|
||||
}
|
||||
@@ -602,7 +602,7 @@ static SAPFOR::Argument* processExpression(SgExpression* ex, vector<IR_Block*>&
|
||||
{
|
||||
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));
|
||||
}
|
||||
else
|
||||
@@ -1572,7 +1572,7 @@ vector<IR_Block*> buildIR(SgStatement* function, const FuncInfo* func, const vec
|
||||
else
|
||||
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)
|
||||
{
|
||||
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);
|
||||
|
||||
// <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->setType(CFG_ARG_TYPE::INSTR);
|
||||
}
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "CFGraph.h"
|
||||
#include "../Utils/CommonBlock.h"
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
#include "CommonBlock.h"
|
||||
|
||||
namespace SAPFOR
|
||||
{
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "../Utils/CommonBlock.h"
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
#include "../ExpressionTransform/expr_transform.h"
|
||||
#include "SgUtils.h"
|
||||
#include "CommonBlock.h"
|
||||
#include "graph_calls.h"
|
||||
#include "expr_transform.h"
|
||||
|
||||
#define PRINT_PROF_INFO 0
|
||||
#define DEBUG_CHECKS 0
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
#include<unordered_map>
|
||||
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "../Utils/CommonBlock.h"
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
#include "SgUtils.h"
|
||||
#include "CommonBlock.h"
|
||||
#include "graph_calls.h"
|
||||
|
||||
#include "CFGraph.h"
|
||||
#include "IR.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "SgUtils.h"
|
||||
#include "CFGraph.h"
|
||||
|
||||
namespace LIVE_VARIABLES
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "../Utils/errors.h"
|
||||
#include "errors.h"
|
||||
#include "private_variables_analysis.h"
|
||||
#include "../GraphLoop/graph_loops.h"
|
||||
#include "graph_loops.h"
|
||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||
#include "../SageAnalysisTool/depGraph.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,
|
||||
map<string, vector<Messages>>& messages)
|
||||
{
|
||||
if (!loop->isFor)
|
||||
if (!loop->isFor())
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__); //should be called only with FOR loops
|
||||
|
||||
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,
|
||||
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)
|
||||
recAnalyzeLoop(inner_loop, loop_body, commonVars, commonArgs, func, messages);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "../GraphLoop/graph_loops.h"
|
||||
#include "SgUtils.h"
|
||||
#include "graph_loops.h"
|
||||
#include "CFGraph.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "CreateInterTree.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "../Utils/utils.h"
|
||||
#include "../GraphCall/graph_calls_func.h"
|
||||
#include "SgUtils.h"
|
||||
#include "utils.h"
|
||||
#include "graph_calls_func.h"
|
||||
|
||||
using std::string;
|
||||
using std::wstring;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "dvm.h"
|
||||
|
||||
#include "../GraphLoop/graph_loops_func.h"
|
||||
#include "graph_loops_func.h"
|
||||
|
||||
struct SpfInterval
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -16,9 +16,9 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "../Distribution/DvmhDirective.h"
|
||||
#include "../GraphLoop/graph_loops.h"
|
||||
#include "graph_loops.h"
|
||||
#include "directive_analyzer.h"
|
||||
#include "../Utils/utils.h"
|
||||
#include "utils.h"
|
||||
|
||||
using std::vector;
|
||||
using std::map;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "../GraphLoop/graph_loops.h"
|
||||
#include "graph_loops.h"
|
||||
|
||||
void UniteNestedDirectives(std::vector<LoopGraph*> &loopGraph);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -15,18 +15,18 @@
|
||||
#include "../Distribution/Distribution.h"
|
||||
#include "../Distribution/DvmhDirective_func.h"
|
||||
|
||||
#include "../Utils/errors.h"
|
||||
#include "errors.h"
|
||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||
#include "directive_parser.h"
|
||||
#include "directive_creator.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "SgUtils.h"
|
||||
#include "../Sapfor.h"
|
||||
#include "../GraphLoop/graph_loops_func.h"
|
||||
#include "../Transformations/loop_transform.h"
|
||||
#include "../ExpressionTransform/expr_transform.h"
|
||||
#include "../GraphCall/graph_calls_func.h"
|
||||
#include "graph_loops_func.h"
|
||||
#include "LoopNesting/loop_transform.h"
|
||||
#include "expr_transform.h"
|
||||
#include "graph_calls_func.h"
|
||||
|
||||
#include "../Utils/AstWrapper.h"
|
||||
#include "AstWrapper.h"
|
||||
|
||||
#define PRINT_DIR_RESULT 0
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "../Distribution/Distribution.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "../GraphLoop/graph_loops.h"
|
||||
#include "../Utils/types.h"
|
||||
#include "errors.h"
|
||||
#include "graph_loops.h"
|
||||
#include "types.h"
|
||||
|
||||
void createParallelDirectives(const std::map<LoopGraph*, std::map<DIST::Array*, ArrayInfo*>> &loopInfo,
|
||||
const std::vector<ParallelRegion*>& regions,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -10,9 +10,9 @@
|
||||
|
||||
#include "../ParallelizationRegions/ParRegions.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_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;
|
||||
|
||||
DIST::Array *tmp = mainArray.arrayRef;
|
||||
@@ -84,7 +84,7 @@ static LoopGraph* createDirectiveForLoop(LoopGraph *currentLoop, MapToArray &mai
|
||||
for (int i = 0; i < tmp->GetDimSize(); ++i)
|
||||
{
|
||||
if (i == pos)
|
||||
directive->on.push_back(make_pair(currentLoop->loopSymbol, mainAccess));
|
||||
directive->on.push_back(make_pair(currentLoop->loopSymbol(), mainAccess));
|
||||
else
|
||||
directive->on.push_back(make_pair("*", make_pair(0, 0)));
|
||||
}
|
||||
@@ -122,6 +122,7 @@ static LoopGraph* createDirectiveForLoop(LoopGraph *currentLoop, MapToArray &mai
|
||||
if (found == false)
|
||||
{
|
||||
directive->shadowRenew.push_back(make_pair(key, vector<pair<int, int>>()));
|
||||
directive->shadowRenewCorner.push_back(false);
|
||||
|
||||
const DIST::Array *arrayRef = read;
|
||||
for (int i = 0; i < arrayRef->GetDimSize(); ++i)
|
||||
@@ -808,7 +809,7 @@ void createParallelDirectives(const map<LoopGraph*, map<DIST::Array*, ArrayInfo*
|
||||
for (int i = 0; i < mainArrayOfLoop->GetDimSize(); ++i)
|
||||
{
|
||||
if (i == dimPos)
|
||||
parDir->on2.push_back(make_pair(currLoop->loopSymbol, mainAccess));
|
||||
parDir->on2.push_back(make_pair(currLoop->loopSymbol(), mainAccess));
|
||||
else
|
||||
parDir->on2.push_back(make_pair("*", make_pair(0, 0)));
|
||||
}
|
||||
@@ -1100,7 +1101,7 @@ static bool tryToResolveUnmatchedDims(const map<DIST::Array*, vector<bool>> &dim
|
||||
LoopGraph* tmpL = loop;
|
||||
for (int z = 0; z < nested; ++z)
|
||||
{
|
||||
deprecateToMatch.insert(tmpL->loopSymbol);
|
||||
deprecateToMatch.insert(tmpL->loopSymbol());
|
||||
if (tmpL->children.size())
|
||||
tmpL = tmpL->children[0];
|
||||
else if (z != nested - 1)
|
||||
@@ -1113,7 +1114,7 @@ static bool tryToResolveUnmatchedDims(const map<DIST::Array*, vector<bool>> &dim
|
||||
tmpL = loop->parent;
|
||||
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());
|
||||
if (dow->conditional())
|
||||
@@ -1124,7 +1125,7 @@ static bool tryToResolveUnmatchedDims(const map<DIST::Array*, vector<bool>> &dim
|
||||
}
|
||||
}
|
||||
else
|
||||
deprecateToMatch.insert(tmpL->loopSymbol);
|
||||
deprecateToMatch.insert(tmpL->loopSymbol());
|
||||
tmpL = tmpL->parent;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "directive_omp_parser.h"
|
||||
#include "directive_parser.h"
|
||||
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "SgUtils.h"
|
||||
|
||||
using std::vector;
|
||||
using std::map;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "../Utils/errors.h"
|
||||
#include "errors.h"
|
||||
|
||||
#define SPF_USER_DIR 777
|
||||
#define SPF_USER_DIR_COPY 999
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
@@ -12,10 +12,10 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "directive_parser.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "SgUtils.h"
|
||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||
#include "../Utils/AstWrapper.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "AstWrapper.h"
|
||||
#include "errors.h"
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include <set>
|
||||
#include <map>
|
||||
|
||||
#include "../Utils/AstWrapper.h"
|
||||
#include "../GraphLoop/graph_loops.h"
|
||||
#include "AstWrapper.h"
|
||||
#include "graph_loops.h"
|
||||
#include "../Distribution/DvmhDirective.h"
|
||||
|
||||
struct DvmDirective
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -16,13 +16,13 @@
|
||||
#include "../Distribution/Arrays.h"
|
||||
#include "../Distribution/Distribution.h"
|
||||
#include "../Distribution/DvmhDirective_func.h"
|
||||
#include "../GraphLoop/graph_loops_func.h"
|
||||
#include "../GraphCall/graph_calls_func.h"
|
||||
#include "graph_loops_func.h"
|
||||
#include "graph_calls_func.h"
|
||||
|
||||
#include "../Utils/errors.h"
|
||||
#include "errors.h"
|
||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||
#include "directive_parser.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "SgUtils.h"
|
||||
#include "../Sapfor.h"
|
||||
#include "directive_creator.h"
|
||||
#include "insert_directive.h"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -18,13 +18,13 @@
|
||||
|
||||
#include "dvm.h"
|
||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||
#include "../Utils/types.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "types.h"
|
||||
#include "errors.h"
|
||||
#include "SgUtils.h"
|
||||
#include "../Distribution/Arrays.h"
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
#include "../GraphCall/graph_calls_func.h"
|
||||
#include "../GraphLoop/graph_loops_func.h"
|
||||
#include "graph_calls.h"
|
||||
#include "graph_calls_func.h"
|
||||
#include "graph_loops_func.h"
|
||||
#include "remote_access.h"
|
||||
|
||||
using std::vector;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -17,8 +17,8 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "../Distribution/Arrays.h"
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
#include "../GraphLoop/graph_loops.h"
|
||||
#include "graph_calls.h"
|
||||
#include "graph_loops.h"
|
||||
#include "../ParallelizationRegions/ParRegions.h"
|
||||
#include "remote_access.h"
|
||||
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "../Utils/errors.h"
|
||||
#include "../Utils/utils.h"
|
||||
#include "../GraphLoop/graph_loops_func.h"
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
#include "../GraphCall/graph_calls_func.h"
|
||||
#include "errors.h"
|
||||
#include "utils.h"
|
||||
#include "graph_loops_func.h"
|
||||
#include "graph_calls.h"
|
||||
#include "graph_calls_func.h"
|
||||
#include "directive_parser.h"
|
||||
#include "../Distribution/DvmhDirective_func.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "../ExpressionTransform/expr_transform.h"
|
||||
#include "SgUtils.h"
|
||||
#include "expr_transform.h"
|
||||
|
||||
#include "../CFGraph/CFGraph.h"
|
||||
#include "CFGraph/CFGraph.h"
|
||||
|
||||
#include "shadow.h"
|
||||
#include "dvm.h"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -12,13 +12,13 @@
|
||||
|
||||
#include "dvm.h"
|
||||
#include "../Sapfor.h"
|
||||
#include "../GraphLoop/graph_loops.h"
|
||||
#include "../GraphCall/graph_calls_func.h"
|
||||
#include "graph_loops.h"
|
||||
#include "graph_calls_func.h"
|
||||
#include "../SageAnalysisTool/depInterfaceExt.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "SgUtils.h"
|
||||
#include "errors.h"
|
||||
#include "directive_parser.h"
|
||||
#include "../ExpressionTransform/expr_transform.h"
|
||||
#include "expr_transform.h"
|
||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||
#include "../DirectiveProcessing/directive_omp_parser.h"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "Array.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "../Utils/utils.h"
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
#include "errors.h"
|
||||
#include "utils.h"
|
||||
#include "graph_calls.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
#include <algorithm>
|
||||
#include <climits>
|
||||
#include "DvmhDirectiveBase.h"
|
||||
#include "../Utils/utils.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "../Utils/json.hpp"
|
||||
#include "utils.h"
|
||||
#include "errors.h"
|
||||
#include "json.hpp"
|
||||
|
||||
class Symbol;
|
||||
class Expression;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "Array.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "../Utils/utils.h"
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "errors.h"
|
||||
#include "utils.h"
|
||||
#include "graph_calls.h"
|
||||
#include "SgUtils.h"
|
||||
#include "../DirectiveProcessing/directive_parser.h"
|
||||
#include "../DirectiveProcessing/directive_omp_parser.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);
|
||||
|
||||
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 (itNew->second.first->IsOmpThreadPrivate())
|
||||
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
|
||||
if (itNew->second.first->GetLocation().first == DIST::l_MODULE)
|
||||
@@ -274,8 +276,6 @@ static void findArrayRefs (SgExpression* ex, SgStatement* st, string fName, int
|
||||
else
|
||||
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)
|
||||
itNew->second.first->SetDistributeFlag(DIST::SPF_PRIV);
|
||||
else
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -14,9 +14,9 @@
|
||||
#include "GraphCSR.h"
|
||||
#include "Arrays.h"
|
||||
|
||||
#include "../Utils/errors.h"
|
||||
#include "../Utils/utils.h"
|
||||
#include "../GraphLoop/graph_loops.h"
|
||||
#include "errors.h"
|
||||
#include "utils.h"
|
||||
#include "graph_loops.h"
|
||||
|
||||
using std::vector;
|
||||
using std::set;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../GraphLoop/graph_loops.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "graph_loops.h"
|
||||
#include "errors.h"
|
||||
|
||||
void createDistributionDirs(DIST::GraphCSR<int, double, attrType> &reducedG, DIST::Arrays<int> &allArrays,
|
||||
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 <algorithm>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include "../Utils/types.h"
|
||||
#include "types.h"
|
||||
|
||||
namespace Distribution
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -30,9 +30,9 @@ using namespace std::chrono;
|
||||
#include "Arrays.h"
|
||||
#include "Array.h"
|
||||
#include "Distribution.h"
|
||||
#include "../Utils/utils.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "../Utils/types.h"
|
||||
#include "utils.h"
|
||||
#include "errors.h"
|
||||
#include "types.h"
|
||||
#include "../Distribution/Cycle.h"
|
||||
#include "../VisualizerCalls/get_information.h"
|
||||
#include "../VisualizerCalls/SendMessage.h"
|
||||
@@ -455,15 +455,7 @@ namespace Distribution
|
||||
}
|
||||
|
||||
if (needPrint)
|
||||
{
|
||||
#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);
|
||||
|
||||
}
|
||||
sendMessage_2lvl(4, k, (int)AllCycles.size());
|
||||
|
||||
auto timeR = steady_clock::now();
|
||||
if (countConflicts != 0)
|
||||
@@ -516,7 +508,7 @@ namespace Distribution
|
||||
}
|
||||
|
||||
if (needPrint)
|
||||
sendMessage_2lvl(L"");
|
||||
sendMessage_2lvl(2);
|
||||
|
||||
return make_pair(allOnlySecondType, globalSum);
|
||||
}
|
||||
@@ -572,13 +564,7 @@ namespace Distribution
|
||||
for (int z = 0; z < arraysV.size(); ++z)
|
||||
{
|
||||
const DIST::Array *array = arraysV[z];
|
||||
|
||||
#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);
|
||||
sendMessage_2lvl(5, z, (int)arrays.size());
|
||||
|
||||
vector<vType> verts;
|
||||
|
||||
@@ -605,7 +591,7 @@ namespace Distribution
|
||||
}
|
||||
}
|
||||
}
|
||||
sendMessage_2lvl(L"");
|
||||
sendMessage_2lvl(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -7,12 +7,12 @@
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
#include "../Utils/types.h"
|
||||
#include "types.h"
|
||||
#include "DvmhDirective.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "errors.h"
|
||||
#include "SgUtils.h"
|
||||
#include "../Sapfor.h"
|
||||
#include "../GraphCall/graph_calls_func.h"
|
||||
#include "graph_calls_func.h"
|
||||
|
||||
#include "dvm.h"
|
||||
|
||||
@@ -346,7 +346,7 @@ static vector<SgExpression*>
|
||||
{
|
||||
needToAdd = true;
|
||||
dim_found = true;
|
||||
subs[i] = new SgVarRefExp(findSymbolOrCreate(file, currLoop->loopSymbol));
|
||||
subs[i] = new SgVarRefExp(findSymbolOrCreate(file, currLoop->loopSymbol()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -857,6 +857,11 @@ ParallelDirective::genDirective(File* file, const vector<pair<DIST::Array*, cons
|
||||
shadowRenewShifts[i].resize(shadowRenew[i].second.size());
|
||||
}
|
||||
|
||||
if (shadowRenewCorner.size() == 0)
|
||||
{
|
||||
shadowRenewCorner.resize(shadowRenew.size(), false);
|
||||
}
|
||||
|
||||
string shadowAdd = ", SHADOW_RENEW(";
|
||||
int inserted = 0;
|
||||
|
||||
@@ -899,7 +904,10 @@ ParallelDirective::genDirective(File* file, const vector<pair<DIST::Array*, cons
|
||||
for (auto& elem : genSubscripts(shadowRenew[i1].second, shadowRenewShifts[i1]))
|
||||
newArrayRef->addSubscript(*elem);
|
||||
|
||||
if (shadowRenew[i1].second.size() > 1 && needCorner(shadowArray, shiftsByAccess, loop))
|
||||
bool needCornerFlag = shadowRenew[i1].second.size() > 1 && needCorner(shadowArray, shiftsByAccess, loop);
|
||||
shadowRenewCorner[i1] = needCornerFlag;
|
||||
|
||||
if (needCornerFlag)
|
||||
{
|
||||
SgExpression* tmp = new SgExpression(ARRAY_OP, newArrayRef, NULL, NULL);
|
||||
p->setLhs(*tmp);
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
|
||||
#include "Array.h"
|
||||
#include "DvmhDirectiveBase.h"
|
||||
#include "../Utils/AstWrapper.h"
|
||||
#include "../Utils/types.h"
|
||||
#include "../Utils/utils.h"
|
||||
#include "AstWrapper.h"
|
||||
#include "types.h"
|
||||
#include "utils.h"
|
||||
|
||||
extern int sharedMemoryParallelization;
|
||||
|
||||
@@ -102,6 +102,7 @@ public:
|
||||
// origin_Name uniqName bounds
|
||||
std::vector<std::pair<std::pair<std::string, std::string>, std::vector<std::pair<int, int>>>> shadowRenew;
|
||||
std::vector<std::vector<std::pair<int, int>>> shadowRenewShifts;
|
||||
std::vector<bool> shadowRenewCorner;
|
||||
|
||||
// origin_Name uniqName bounds
|
||||
std::vector<std::pair<std::pair<std::string, std::string>, std::vector<std::pair<int, int>>>> across;
|
||||
@@ -125,6 +126,7 @@ public:
|
||||
privates = copyFrom.privates;
|
||||
shadowRenew = copyFrom.shadowRenew;
|
||||
shadowRenewShifts = copyFrom.shadowRenewShifts;
|
||||
shadowRenewCorner = copyFrom.shadowRenewCorner;
|
||||
across = copyFrom.across;
|
||||
acrossShifts = copyFrom.acrossShifts;
|
||||
remoteAccess = copyFrom.remoteAccess;
|
||||
@@ -151,6 +153,7 @@ public:
|
||||
on.clear();
|
||||
privates.clear();
|
||||
shadowRenew.clear();
|
||||
shadowRenewCorner.clear();
|
||||
across.clear();
|
||||
acrossShifts.clear();
|
||||
reduction.clear();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -10,11 +10,11 @@
|
||||
#include "../Distribution/Array.h"
|
||||
#include "../Distribution/Arrays.h"
|
||||
#include "../Distribution/GraphCSR.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "../Utils/utils.h"
|
||||
#include "../Utils/json.hpp"
|
||||
#include "errors.h"
|
||||
#include "utils.h"
|
||||
#include "json.hpp"
|
||||
|
||||
#include "../GraphCall/graph_calls_func.h"
|
||||
#include "graph_calls_func.h"
|
||||
|
||||
using std::vector;
|
||||
using std::tuple;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "../Utils/json.hpp"
|
||||
#include "json.hpp"
|
||||
|
||||
typedef enum lang : int { LANG_C, LANG_F } language;
|
||||
typedef enum dist : int { BLOCK, NONE } distType;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include "dvm.h"
|
||||
#include "../Utils/types.h"
|
||||
#include "types.h"
|
||||
|
||||
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);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
@@ -19,8 +19,8 @@ extern int passDone;
|
||||
#include "Cycle.h"
|
||||
#include "Arrays.h"
|
||||
#include "Array.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "../Utils/utils.h"
|
||||
#include "errors.h"
|
||||
#include "utils.h"
|
||||
#include "../VisualizerCalls/get_information.h"
|
||||
#include "../VisualizerCalls/SendMessage.h"
|
||||
|
||||
@@ -830,13 +830,13 @@ namespace Distribution
|
||||
color[k] = WHITE;
|
||||
|
||||
findFrom = currentV;
|
||||
#ifdef _WIN32
|
||||
/*#ifdef _WIN32
|
||||
if (needPrint)
|
||||
{
|
||||
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()));
|
||||
}
|
||||
#endif
|
||||
#endif*/
|
||||
__spf_print(PRINT_TIMES && needPrint, "v (tree %d) = %d (with neighb %d) ", t, i, neighbors[i + 1] - neighbors[i]);
|
||||
activeV[activeCounter++] = currentV;
|
||||
FindLoop(cyclesTmp[t], currentV, currentV, numbers);
|
||||
@@ -847,8 +847,8 @@ namespace Distribution
|
||||
maxLoopDim = wasMaxLoopDim;
|
||||
}
|
||||
|
||||
if (needPrint)
|
||||
sendMessage_2lvl(L"");
|
||||
/*if (needPrint)
|
||||
sendMessage_2lvl(2);*/
|
||||
}
|
||||
catch (int code)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <set>
|
||||
#include <tuple>
|
||||
|
||||
#include "../Utils/RationalNum.h"
|
||||
#include "RationalNum.h"
|
||||
|
||||
typedef enum links { RR_link, WR_link, WW_link } LinkType;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "../GraphLoop/graph_loops_func.h"
|
||||
#include "graph_loops_func.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
#include "DvmhRegionInserter.h"
|
||||
#include "DvmhRegions/RegionsMerger.h"
|
||||
#include "../VerificationCode/verifications.h"
|
||||
#include "../Transformations/function_purifying.h"
|
||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||
#include "../DirectiveProcessing/directive_parser.h"
|
||||
#include "FunctionPurifying/function_purifying.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -794,154 +794,6 @@ ArraySet DvmhRegionInserter::get_used_arrs_for_block(SgStatement* st, int usage_
|
||||
return usages;
|
||||
}
|
||||
|
||||
static bool filterFromList(SgStatement* st, const set<string>& idents, bool exclude = false)
|
||||
{
|
||||
bool empty = false;
|
||||
SgExpression* list = st->expr(0);
|
||||
vector<SgExpression*> newList;
|
||||
|
||||
int total = 0;
|
||||
while (list)
|
||||
{
|
||||
if (exclude)
|
||||
{
|
||||
if (idents.find(list->lhs()->symbol()->identifier()) == idents.end())
|
||||
newList.push_back(list->lhs());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (idents.find(list->lhs()->symbol()->identifier()) != idents.end())
|
||||
newList.push_back(list->lhs());
|
||||
}
|
||||
total++;
|
||||
list = list->rhs();
|
||||
}
|
||||
|
||||
if (newList.size() == 0)
|
||||
empty = true;
|
||||
else if (total != newList.size())
|
||||
st->setExpression(0, makeExprList(newList));
|
||||
|
||||
return empty;
|
||||
}
|
||||
|
||||
static string getInterfaceBlock(SgStatement* func, const FuncParam& pars)
|
||||
{
|
||||
string oldFile = current_file->filename();
|
||||
if (!func->switchToFile())
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
auto copy = duplicateProcedure(func, NULL, false, false, false, true);
|
||||
const set<string> idents(pars.identificators.begin(), pars.identificators.end());
|
||||
|
||||
bool need = (func->symbol()->identifier() == string("bl182"));
|
||||
|
||||
//remove all exec
|
||||
SgStatement* st = copy->lexNext();
|
||||
SgStatement* last = copy->lastNodeOfStmt();
|
||||
vector<SgStatement*> toExtract;
|
||||
|
||||
while (st != last)
|
||||
{
|
||||
if (isDVM_stat(st) || isSPF_stat(st))
|
||||
{
|
||||
if (st->variant() != ACC_ROUTINE_DIR)
|
||||
{
|
||||
toExtract.push_back(st);
|
||||
st = st->lexNext();
|
||||
}
|
||||
else
|
||||
st = st->lexNext();
|
||||
}
|
||||
else if (isSgExecutableStatement(st))
|
||||
{
|
||||
SgStatement* next = st->lastNodeOfStmt();
|
||||
if (next != last)
|
||||
next = next->lexNext();
|
||||
toExtract.push_back(st);
|
||||
st = next;
|
||||
}
|
||||
else
|
||||
st = st->lexNext();
|
||||
}
|
||||
|
||||
//remove unused declarations
|
||||
st = copy->lexNext();
|
||||
while (st != last)
|
||||
{
|
||||
const int var = st->variant();
|
||||
|
||||
if (var == VAR_DECL
|
||||
|| var == VAR_DECL_90
|
||||
|| var == DIM_STAT
|
||||
|| var == INTENT_STMT
|
||||
|| var == EXTERN_STAT)
|
||||
{
|
||||
bool empty = filterFromList(st, idents);
|
||||
if (empty)
|
||||
{
|
||||
toExtract.push_back(st);
|
||||
st = st->lexNext();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (!isDVM_stat(st) && !isSPF_stat(st))
|
||||
toExtract.push_back(st);
|
||||
|
||||
if (st->variant() == CONTAINS_STMT)
|
||||
break;
|
||||
st = st->lexNext();
|
||||
}
|
||||
|
||||
for (auto& elem : toExtract)
|
||||
elem->extractStmt();
|
||||
|
||||
string retVal = copy->unparse();
|
||||
|
||||
if (SgFile::switchToFile(oldFile) == -1)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
static void insertInterface(SgStatement* func, const string& iface, const string& fName)
|
||||
{
|
||||
string oldFile = current_file->filename();
|
||||
if (!func->switchToFile())
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
SgStatement* st = func->lexNext();
|
||||
SgStatement* last = func->lastNodeOfStmt();
|
||||
while (st != last)
|
||||
{
|
||||
if (st->variant() == VAR_DECL || st->variant() == VAR_DECL_90)
|
||||
{
|
||||
bool empty = filterFromList(st, { fName }, true);
|
||||
if (empty)
|
||||
{
|
||||
SgStatement* next = st->lexNext();
|
||||
st->extractStmt();
|
||||
st = next;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (isSgExecutableStatement(st))
|
||||
break;
|
||||
st = st->lexNext();
|
||||
}
|
||||
SgStatement* ifaceBlock = new SgStatement(INTERFACE_STMT);
|
||||
addControlEndToStmt(ifaceBlock->thebif);
|
||||
|
||||
ifaceBlock->setlineNumber(getNextNegativeLineNumber()); // st->lineNumber()
|
||||
ifaceBlock->setFileName(st->fileName());
|
||||
st->insertStmtBefore(*ifaceBlock, *st->controlParent());
|
||||
ifaceBlock->lastNodeOfStmt()->addComment(iface.c_str());
|
||||
|
||||
if (SgFile::switchToFile(oldFile) == -1)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
}
|
||||
|
||||
static LoopGraph* getParallelLoop(LoopGraph* loop)
|
||||
{
|
||||
auto prev_st = loop->loop->lexPrev();
|
||||
@@ -1172,7 +1024,7 @@ static bool isPure(SgStatement* func)
|
||||
|
||||
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)
|
||||
@@ -1446,6 +1298,9 @@ static set<DIST::Array*>
|
||||
declStat = SgStatement::getStatementByFileAndLine(decl.first, decl.second);
|
||||
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())
|
||||
{
|
||||
if (st->fileName() == decl.first && st->lineNumber() == decl.second)
|
||||
@@ -1457,7 +1312,7 @@ static set<DIST::Array*>
|
||||
}
|
||||
else
|
||||
{
|
||||
declStat = getFuncStat(declStat);
|
||||
declStat = getFuncStat(declStat, { BLOCK_DATA });
|
||||
if (declStat != main)
|
||||
{
|
||||
declStat = NULL;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "../GraphCall/graph_calls_func.h"
|
||||
#include "../GraphLoop/graph_loops_func.h"
|
||||
#include "../ExpressionTransform/expr_transform.h"
|
||||
#include "graph_calls_func.h"
|
||||
#include "graph_loops_func.h"
|
||||
#include "expr_transform.h"
|
||||
#include "../ParallelizationRegions/ParRegions.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "SgUtils.h"
|
||||
#include "ReadWriteAnalyzer.h"
|
||||
#include "DvmhRegion.h"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../GraphLoop/graph_loops_func.h"
|
||||
#include "../GraphCall/graph_calls_func.h"
|
||||
#include "graph_loops_func.h"
|
||||
#include "graph_calls_func.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "dvm.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "SgUtils.h"
|
||||
#include "VarUsages.h"
|
||||
#include <set>
|
||||
#include <tuple>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "dvm.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "SgUtils.h"
|
||||
#include <string>
|
||||
|
||||
enum class VAR_TYPE { VAR_ARR, VAR_DISTR_ARR, VAR_SCALAR, VAR_ANY, VAR_UNDEFINED };
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
#include "./createParallelRegions.h"
|
||||
|
||||
#include "../CreateInterTree/CreateInterTree.h"
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
#include "graph_calls.h"
|
||||
#include "./gcov_info.h"
|
||||
#include "./gCov_parser_func.h"
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "../Utils/utils.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include "./gcov_info.h"
|
||||
#include "../CreateInterTree/CreateInterTree.h"
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
#include "graph_calls.h"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fstream>
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "dvm.h"
|
||||
#include "gCov_parser_func.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "SgUtils.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "dvm.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "errors.h"
|
||||
#include "gcov_info.h"
|
||||
#include "../CreateInterTree/CreateInterTree.h"
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
|
||||
#include "../Utils/errors.h"
|
||||
#include "errors.h"
|
||||
|
||||
#include "gcov_info.h"
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <map>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../Utils/utils.h"
|
||||
#include "utils.h"
|
||||
|
||||
//make 'class' - need friend for Gcov_info
|
||||
struct Perform
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -14,14 +14,14 @@
|
||||
#include "dvm.h"
|
||||
#include "graph_calls_func.h"
|
||||
|
||||
#include "../CFGraph/CFGraph.h"
|
||||
#include "../GraphLoop/graph_loops_func.h"
|
||||
#include "CFGraph/CFGraph.h"
|
||||
#include "graph_loops_func.h"
|
||||
#include "../DirectiveProcessing/directive_parser.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "../Utils/json.hpp"
|
||||
#include "SgUtils.h"
|
||||
#include "json.hpp"
|
||||
#include "../ParallelizationRegions/ParRegions_func.h"
|
||||
#include "../DynamicAnalysis/gCov_parser_func.h"
|
||||
#include "../ExpressionTransform/expr_transform.h"
|
||||
#include "expr_transform.h"
|
||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||
#include "../VerificationCode/verifications.h"
|
||||
|
||||
@@ -779,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)
|
||||
{
|
||||
if (currF->funcParams.countOfPars == 0)
|
||||
@@ -799,7 +813,12 @@ static void fillInOut(FuncInfo *currF, SgStatement *start, SgStatement *last, co
|
||||
if (st->variant() == ENTRY_STAT)
|
||||
continue;
|
||||
|
||||
if (isSgExecutableStatement(st) == NULL || st->lineNumber() <= 0)
|
||||
if (isSgExecutableStatement(st) == NULL) {
|
||||
checkInTypeDescription(st->expr(0), currF, parNames);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (st->lineNumber() <= 0)
|
||||
continue;
|
||||
|
||||
if (activeOps.size() && activeOps.find(st) == activeOps.end())
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
#include <string>
|
||||
#include <set>
|
||||
|
||||
#include "../Utils/AstWrapper.h"
|
||||
#include "../Utils/utils.h"
|
||||
#include "AstWrapper.h"
|
||||
#include "utils.h"
|
||||
#include "../DirectiveProcessing/shadow.h"
|
||||
#include "../GraphLoop/graph_loops.h"
|
||||
#include "graph_loops.h"
|
||||
|
||||
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",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -10,10 +10,10 @@
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include "../Utils/errors.h"
|
||||
#include "errors.h"
|
||||
#include "graph_calls.h"
|
||||
#include "../Distribution/Distribution.h"
|
||||
#include "../Utils/utils.h"
|
||||
#include "utils.h"
|
||||
#include "../ParallelizationRegions/ParRegions.h"
|
||||
|
||||
using std::vector;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <set>
|
||||
|
||||
#include "graph_calls.h"
|
||||
#include "../GraphLoop/graph_loops.h"
|
||||
#include "graph_loops.h"
|
||||
#include "../ParallelizationRegions/ParRegions.h"
|
||||
#include "Utils/json.hpp"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -12,26 +12,26 @@
|
||||
|
||||
#include "dvm.h"
|
||||
#include "../Sapfor.h"
|
||||
#include "../GraphCall/graph_calls_func.h"
|
||||
#include "graph_calls_func.h"
|
||||
#include "../ParallelizationRegions/ParRegions_func.h"
|
||||
#include "../ExpressionTransform/expr_transform.h"
|
||||
#include "expr_transform.h"
|
||||
|
||||
#include "../Distribution/GraphCSR.h"
|
||||
#include "../Distribution/Arrays.h"
|
||||
#include "../Distribution/Distribution.h"
|
||||
|
||||
#include "graph_loops.h"
|
||||
#include "../Utils/utils.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "utils.h"
|
||||
#include "SgUtils.h"
|
||||
|
||||
#include "../Utils/errors.h"
|
||||
#include "../Utils/AstWrapper.h"
|
||||
#include "../Utils/json.hpp"
|
||||
#include "errors.h"
|
||||
#include "AstWrapper.h"
|
||||
#include "json.hpp"
|
||||
|
||||
#include "../DirectiveProcessing/directive_parser.h"
|
||||
#include "../DynamicAnalysis/gCov_parser_func.h"
|
||||
|
||||
#include "../Transformations/array_assign_to_loop.h"
|
||||
#include "VectorAssignToLoop/array_assign_to_loop.h"
|
||||
|
||||
using std::vector;
|
||||
using std::map;
|
||||
@@ -520,7 +520,7 @@ static void findArrayRef(SgExpression *exp, bool isWirte, set<DIST::Array*>& use
|
||||
{
|
||||
if (exp)
|
||||
{
|
||||
if (exp->variant() == ARRAY_REF)
|
||||
if (isArrayRef(exp))
|
||||
{
|
||||
DIST::Array *arrayRef = NULL;
|
||||
SgSymbol *symbS = OriginalSymbol(exp->symbol());
|
||||
@@ -699,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->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->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->hasSubstringRefs = hasSubstringRef(st);
|
||||
|
||||
@@ -777,7 +782,7 @@ void loopGraphAnalyzer(SgFile *file, vector<LoopGraph*> &loopGraph, const vector
|
||||
newLoop->startEndExpr = std::make_pair((Expression*)NULL, (Expression*)NULL);
|
||||
|
||||
newLoop->loop = new Statement(st);
|
||||
newLoop->loopSymbol = st->symbol() ? st->symbol()->identifier() : "unknown";
|
||||
newLoop->loopSymbols.addMainVar(st->symbol() ? st->symbol()->identifier() : "unknown");
|
||||
findArrayRefs(newLoop);
|
||||
|
||||
SgStatement *lexPrev = st->lexPrev();
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
#include "../Utils/errors.h"
|
||||
#include "../Utils/types.h"
|
||||
#include "errors.h"
|
||||
#include "types.h"
|
||||
#include "../Distribution/DvmhDirective.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 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
|
||||
{
|
||||
private:
|
||||
@@ -70,7 +97,7 @@ public:
|
||||
calculatedCountOfIters = 0;
|
||||
executionTimeInSec = -1.0;
|
||||
inDvmhRegion = 0;
|
||||
isFor = false;
|
||||
loopType = LoopType::NONE;
|
||||
inCanonicalFrom = false;
|
||||
hasAccessToSubArray = false;
|
||||
hasSubstringRefs = false;
|
||||
@@ -113,21 +140,24 @@ public:
|
||||
{
|
||||
return hasUnknownArrayDep || hasUnknownScalarDep || hasGoto || hasPrints || (hasConflicts.size() != 0) || hasStops || hasNonPureProcedures ||
|
||||
hasUnknownArrayAssigns || hasNonRectangularBounds || hasIndirectAccess || hasWritesToNonDistribute || hasDifferentAlignRules || hasDvmIntervals ||
|
||||
!isFor || lastprivateScalars.size() || hasAccessToSubArray || hasSubstringRefs;
|
||||
!isFor() || lastprivateScalars.size() || hasAccessToSubArray || hasSubstringRefs;
|
||||
}
|
||||
|
||||
bool hasLimitsToSplit() const
|
||||
{
|
||||
return hasGoto || hasStops || !isFor || hasPrints;
|
||||
return hasGoto || hasStops || !isFor() || hasPrints;
|
||||
}
|
||||
|
||||
bool hasLimitsToCombine() const
|
||||
{
|
||||
return hasGoto || hasStops || !isFor || hasPrints || linesOfCycle.size();
|
||||
return hasGoto || hasStops || !isFor() || hasPrints || linesOfCycle.size();
|
||||
}
|
||||
|
||||
void addConflictMessages(std::vector<Messages> *messages)
|
||||
{
|
||||
if (messages == NULL)
|
||||
return;
|
||||
|
||||
const int line = altLineNum > 0 ? altLineNum : lineNum;
|
||||
if (hasUnknownArrayDep)
|
||||
messages->push_back(Messages(NOTE, line, R113, L"unknown array dependency prevents parallelization of this loop", 3006));
|
||||
@@ -168,7 +198,7 @@ public:
|
||||
if (hasDvmIntervals)
|
||||
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));
|
||||
|
||||
if (lastprivateScalars.size())
|
||||
@@ -393,6 +423,14 @@ public:
|
||||
|
||||
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:
|
||||
int lineNum;
|
||||
int altLineNum;
|
||||
@@ -407,7 +445,7 @@ public:
|
||||
int startVal, endVal, stepVal;
|
||||
std::tuple<Expression*, Expression*, Expression*> startEndStepVals;
|
||||
|
||||
std::string loopSymbol;
|
||||
InductiveVariables loopSymbols;
|
||||
std::pair<Expression*, Expression*> startEndExpr;
|
||||
|
||||
bool hasGoto;
|
||||
@@ -448,7 +486,7 @@ public:
|
||||
|
||||
bool hasSubstringRefs;
|
||||
|
||||
bool isFor;
|
||||
LoopType loopType;
|
||||
|
||||
bool inCanonicalFrom;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -23,8 +23,8 @@ using std::make_pair;
|
||||
using std::get;
|
||||
|
||||
#include "graph_loops.h"
|
||||
#include "../GraphCall/graph_calls_func.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "graph_calls_func.h"
|
||||
#include "errors.h"
|
||||
#include "../Distribution/Distribution.h"
|
||||
#include "../Distribution/CreateDistributionDirs.h"
|
||||
#include "../ParallelizationRegions/ParRegions.h"
|
||||
@@ -551,7 +551,7 @@ void addToDistributionGraph(const map<LoopGraph*, map<DIST::Array*, ArrayInfo*>>
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!loopAccess.first->isFor)
|
||||
if (!loopAccess.first->isFor())
|
||||
continue;
|
||||
|
||||
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]->countOfIters == 0 && loops[i]->region && loops[i]->isFor)
|
||||
if (loops[i]->countOfIters == 0 && loops[i]->region && loops[i]->isFor())
|
||||
{
|
||||
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",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -8,8 +8,8 @@
|
||||
#include <set>
|
||||
|
||||
#include "dvm.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "SgUtils.h"
|
||||
#include "errors.h"
|
||||
|
||||
using std::set;
|
||||
using std::pair;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -20,8 +20,8 @@
|
||||
#include "dvm.h"
|
||||
#include "loop_analyzer.h"
|
||||
|
||||
#include "../Utils/utils.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "utils.h"
|
||||
#include "SgUtils.h"
|
||||
#include "../ParallelizationRegions/ParRegions_func.h"
|
||||
#include "../SageAnalysisTool/depGraph.h"
|
||||
#include "../SageAnalysisTool/OmegaForSage/include/lang-interf.h"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <tuple>
|
||||
#include <stack>
|
||||
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#if _WIN32 && NDEBUG && __BOOST
|
||||
#include <boost/thread.hpp>
|
||||
@@ -30,25 +30,25 @@ extern int passDone;
|
||||
#include "../Distribution/Arrays.h"
|
||||
#include "../ParallelizationRegions/ParRegions.h"
|
||||
|
||||
#include "../Utils/errors.h"
|
||||
#include "errors.h"
|
||||
#include "../DirectiveProcessing/directive_parser.h"
|
||||
#include "../DirectiveProcessing/directive_creator.h"
|
||||
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "../Utils/AstWrapper.h"
|
||||
#include "SgUtils.h"
|
||||
#include "AstWrapper.h"
|
||||
|
||||
#include "../GraphCall/graph_calls_func.h"
|
||||
#include "../GraphLoop/graph_loops_func.h"
|
||||
#include "graph_calls_func.h"
|
||||
#include "graph_loops_func.h"
|
||||
#include "../ParallelizationRegions/ParRegions_func.h"
|
||||
#include "../DynamicAnalysis/gCov_parser_func.h"
|
||||
|
||||
#include "../ExpressionTransform/expr_transform.h"
|
||||
#include "expr_transform.h"
|
||||
#include "../SageAnalysisTool/depInterfaceExt.h"
|
||||
|
||||
#include "../VisualizerCalls/get_information.h"
|
||||
#include "../VisualizerCalls/SendMessage.h"
|
||||
|
||||
#include "../Transformations/enddo_loop_converter.h"
|
||||
#include "LoopEndDoConverter/enddo_loop_converter.h"
|
||||
|
||||
#include "../DirectiveProcessing/remote_access.h"
|
||||
#include "../DirectiveProcessing/directive_omp_parser.h"
|
||||
@@ -1633,17 +1633,7 @@ void loopAnalyzer(SgFile *file, vector<ParallelRegion*> ®ions, map<tuple<int,
|
||||
createNeededException();
|
||||
|
||||
string fName = file->functions(i)->symbol()->identifier();
|
||||
#if _WIN32
|
||||
if (file->functions(i)->variant() != MODULE_STMT)
|
||||
sendMessage_2lvl(wstring(L"обработка функции '") + wstring(fName.begin(), fName.end()) + L"'");
|
||||
else
|
||||
sendMessage_2lvl(wstring(L"обработка модуля '") + wstring(fName.begin(), fName.end()) + L"'");
|
||||
#else
|
||||
if (file->functions(i)->variant() != MODULE_STMT)
|
||||
sendMessage_2lvl(wstring(L"processing function '") + wstring(fName.begin(), fName.end()) + L"'");
|
||||
else
|
||||
sendMessage_2lvl(wstring(L"processing module '") + wstring(fName.begin(), fName.end()) + L"'");
|
||||
#endif
|
||||
sendMessage_2lvl(0, (file->functions(i)->variant() != MODULE_STMT), fName);
|
||||
|
||||
set<SgSymbol*> delcsSymbViewed;
|
||||
set<SgStatement*> delcsStatViewed;
|
||||
@@ -2188,11 +2178,8 @@ void loopAnalyzer(SgFile *file, vector<ParallelRegion*> ®ions, map<tuple<int,
|
||||
if (!skipDeps)
|
||||
{
|
||||
string fName = file->functions(i)->symbol()->identifier();
|
||||
#ifdef _WIN32
|
||||
sendMessage_2lvl(wstring(L"обработка цикла ") + std::to_wstring(idx) + L"/" + std::to_wstring(convertedLoopInfo.size()));
|
||||
#else
|
||||
sendMessage_2lvl(wstring(L"processing loop ") + std::to_wstring(idx) + L"/" + std::to_wstring(convertedLoopInfo.size()));
|
||||
#endif
|
||||
sendMessage_2lvl(1, idx, (int)convertedLoopInfo.size());
|
||||
|
||||
tryToFindDependencies(loop.first, allLoops, funcWasInit, file, regions, currMessages, collection, funcByName, defUseByPlace);
|
||||
}
|
||||
}
|
||||
@@ -2212,7 +2199,7 @@ void loopAnalyzer(SgFile *file, vector<ParallelRegion*> ®ions, map<tuple<int,
|
||||
LoopGraph *tmpLoop = new LoopGraph();
|
||||
|
||||
tmpLoop->region = reg;
|
||||
tmpLoop->isFor = true;
|
||||
tmpLoop->loopType = LoopType::FOR;
|
||||
|
||||
tmpLoops.push_back(tmpLoop);
|
||||
|
||||
@@ -2340,7 +2327,7 @@ void loopAnalyzer(SgFile *file, vector<ParallelRegion*> ®ions, map<tuple<int,
|
||||
if (parallizeFreeLoops)
|
||||
selectFreeLoopsForParallelization(loopsForFunction, funcName, (regime == DATA_DISTR), regions, messagesForFile);
|
||||
}
|
||||
sendMessage_2lvl(L"");
|
||||
sendMessage_2lvl(2);
|
||||
}
|
||||
else if (regime == COMP_DISTR)
|
||||
{
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include "../GraphLoop/graph_loops.h"
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
#include "graph_loops.h"
|
||||
#include "graph_calls.h"
|
||||
#include "../ParallelizationRegions/ParRegions.h"
|
||||
#include "../SageAnalysisTool/depInterfaceExt.h"
|
||||
#include "../Utils/AstWrapper.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "AstWrapper.h"
|
||||
#include "SgUtils.h"
|
||||
|
||||
#include "dvm.h"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -10,12 +10,12 @@
|
||||
|
||||
#include "dvm.h"
|
||||
#include "ParRegions.h"
|
||||
#include "../Utils/utils.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "../GraphCall/graph_calls_func.h"
|
||||
#include "../GraphLoop/graph_loops.h"
|
||||
#include "utils.h"
|
||||
#include "SgUtils.h"
|
||||
#include "graph_calls_func.h"
|
||||
#include "graph_loops.h"
|
||||
#include "../Distribution/Distribution.h"
|
||||
#include "../ExpressionTransform/expr_transform.h"
|
||||
#include "expr_transform.h"
|
||||
|
||||
using std::vector;
|
||||
using std::string;
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
#include "../Distribution/DvmhDirective.h"
|
||||
#include "../Distribution/GraphCSR.h"
|
||||
#include "../Distribution/Distribution.h"
|
||||
#include "../Utils/AstWrapper.h"
|
||||
#include "AstWrapper.h"
|
||||
|
||||
#include "../Utils/json.hpp"
|
||||
#include "json.hpp"
|
||||
|
||||
#if __SPF
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "SgUtils.h"
|
||||
#endif
|
||||
|
||||
struct ParallelRegionLines
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "ParRegions.h"
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
#include "../GraphLoop/graph_loops.h"
|
||||
#include "graph_calls.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 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 <string>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "ParRegions.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "SgUtils.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);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -11,14 +11,14 @@
|
||||
#include "ParRegions_func.h"
|
||||
#include "resolve_par_reg_conflicts.h"
|
||||
|
||||
#include "../GraphCall/graph_calls_func.h"
|
||||
#include "../GraphLoop/graph_loops_func.h"
|
||||
#include "graph_calls_func.h"
|
||||
#include "graph_loops_func.h"
|
||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||
#include "../DirectiveProcessing/directive_creator.h"
|
||||
#include "../DirectiveProcessing/insert_directive.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "../ExpressionTransform/expr_transform.h"
|
||||
#include "../Transformations/function_purifying.h"
|
||||
#include "SgUtils.h"
|
||||
#include "expr_transform.h"
|
||||
#include "FunctionPurifying/function_purifying.h"
|
||||
|
||||
using std::map;
|
||||
using std::pair;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "ParRegions.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
#include "SgUtils.h"
|
||||
#include "errors.h"
|
||||
#include "graph_calls.h"
|
||||
|
||||
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);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -16,13 +16,14 @@
|
||||
#include "../DynamicAnalysis/gcov_info.h"
|
||||
#include "../DynamicAnalysis/gCov_parser_func.h"
|
||||
#include "PredictScheme.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "SgUtils.h"
|
||||
#include "../DirectiveProcessing/directive_parser.h"
|
||||
#include "../Distribution/DvmhDirective.h"
|
||||
#include "../GraphLoop/graph_loops_func.h"
|
||||
#include "../ExpressionTransform/expr_transform.h"
|
||||
#include "graph_loops_func.h"
|
||||
#include "expr_transform.h"
|
||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||
#include "../CFGraph/CFGraph.h"
|
||||
#include "CFGraph/CFGraph.h"
|
||||
#include "../Utils/utils.h"
|
||||
|
||||
#include "json.hpp"
|
||||
|
||||
@@ -36,6 +37,109 @@ using std::tuple;
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
void runPredictSchemeOld(SgProject &project,
|
||||
vector<vector<size_t>> &topologies,
|
||||
vector<ParallelRegion*> ¶llelRegions,
|
||||
map<string, vector<LoopGraph*>> &loopGraph,
|
||||
map<string, vector<SpfInterval*>> &intervals,
|
||||
map<string, vector<Messages>> &SPF_messages)
|
||||
{
|
||||
int maxSizeDist = 0;
|
||||
for (int z = 0; z < parallelRegions.size(); ++z)
|
||||
{
|
||||
const DataDirective &dataDirectives = parallelRegions[z]->GetDataDir();
|
||||
const vector<int> ¤tVariant = parallelRegions[z]->GetCurrentVariant();
|
||||
|
||||
auto &tmp = dataDirectives.distrRules;
|
||||
vector<pair<DIST::Array*, const DistrVariant*>> currentVar;
|
||||
for (int z1 = 0; z1 < currentVariant.size(); ++z1)
|
||||
currentVar.push_back(std::make_pair(tmp[z1].first, &tmp[z1].second[currentVariant[z1]]));
|
||||
|
||||
for (auto &elem : currentVar)
|
||||
{
|
||||
DIST::Array *array = elem.first;
|
||||
const DistrVariant *var = elem.second;
|
||||
|
||||
int countBlock = 0;
|
||||
for (int z = 0; z < var->distRule.size(); ++z)
|
||||
if (var->distRule[z] == dist::BLOCK)
|
||||
++countBlock;
|
||||
maxSizeDist = std::max(maxSizeDist, countBlock);
|
||||
}
|
||||
}
|
||||
|
||||
SpfInterval *mainIterval = getMainInterval(&project, intervals, SPF_messages);
|
||||
topologies.clear();
|
||||
if (maxSizeDist)
|
||||
{
|
||||
const int procNum = 8;
|
||||
//TODO:
|
||||
//topologies = getTopologies(procNum, maxSizeDist);
|
||||
throw -10;
|
||||
|
||||
const int countOfTop = topologies.size();
|
||||
if (countOfTop < 0)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
for (auto &inter : intervals)
|
||||
initTimeForIntervalTree(countOfTop, inter.second);
|
||||
|
||||
for (int z = 0; z < parallelRegions.size(); ++z)
|
||||
{
|
||||
const DataDirective &dataDirectives = parallelRegions[z]->GetDataDir();
|
||||
const vector<int> ¤tVariant = parallelRegions[z]->GetCurrentVariant();
|
||||
DIST::Arrays<int> &allArrays = parallelRegions[z]->GetAllArraysToModify();
|
||||
|
||||
auto &tmp = dataDirectives.distrRules;
|
||||
vector<pair<DIST::Array*, const DistrVariant*>> currentVar;
|
||||
for (int z1 = 0; z1 < currentVariant.size(); ++z1)
|
||||
currentVar.push_back(std::make_pair(tmp[z1].first, &tmp[z1].second[currentVariant[z1]]));
|
||||
|
||||
map<LoopGraph*, ParallelDirective*> parallelDirs;
|
||||
vector<std::tuple<DIST::Array*, vector<long>, pair<string, int>>> allSingleRemotes;
|
||||
for (int i = project.numberOfFiles() - 1; i >= 0; --i)
|
||||
{
|
||||
SgFile *file = &(project.file(i));
|
||||
auto fountInfo = findAllDirectives(file, getObjectForFileFromMap(file->filename(), loopGraph), parallelRegions[z]->GetId());
|
||||
parallelDirs.insert(fountInfo.begin(), fountInfo.end());
|
||||
|
||||
auto fountRem = findAllSingleRemotes(file, parallelRegions[z]->GetId(), parallelRegions);
|
||||
allSingleRemotes.insert(allSingleRemotes.end(), fountRem.begin(), fountRem.end());
|
||||
}
|
||||
//TODO!
|
||||
//int err = predictScheme(parallelRegions[z], currentVar, allArrays.GetArrays(), parallelDirs, intervals, SPF_messages, allSingleRemotes, maxSizeDist, procNum);
|
||||
/*if (err != 0)
|
||||
internalExit = err;*/
|
||||
}
|
||||
|
||||
vector<SpfInterval*> tmp = { mainIterval };
|
||||
aggregatePredictedTimes(tmp);
|
||||
|
||||
int idx = 0;
|
||||
int best = -1;
|
||||
double bestSpeedUp = 0;
|
||||
for (auto &top : topologies)
|
||||
{
|
||||
string outStr = "";
|
||||
for (auto &elem : top)
|
||||
outStr += std::to_string(elem) + " ";
|
||||
double currS = mainIterval->exec_time / mainIterval->predictedTimes[idx];
|
||||
__spf_print(1, "%d: speed up %f for top. %s\n", idx, currS, outStr.c_str());
|
||||
|
||||
if (best == -1 || bestSpeedUp < currS)
|
||||
{
|
||||
bestSpeedUp = currS;
|
||||
best = idx;
|
||||
}
|
||||
++idx;
|
||||
}
|
||||
__spf_print(1, "best topology %d with speed up %f\n", best, bestSpeedUp);
|
||||
}
|
||||
else
|
||||
for (auto &inter : intervals)
|
||||
initTimeForIntervalTree(0, inter.second);
|
||||
}
|
||||
|
||||
static void fillParallel(SgExpression *exp, ParallelStats &parStats, int &totalScoreComm)
|
||||
{
|
||||
if (exp)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "dvm.h"
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
#include "../Utils/json.hpp"
|
||||
#include "graph_calls.h"
|
||||
#include "json.hpp"
|
||||
|
||||
class ParallelStats
|
||||
{
|
||||
@@ -61,3 +61,5 @@ void processFileToPredict(SgFile *file, PredictorStats &predictorCounts);
|
||||
|
||||
void calculateStatsForPredictor(const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo, const std::map<std::string, std::map<int, Gcov_info>>& gCovInfo);
|
||||
void parseDvmDirForPredictor(const std::map<std::tuple<int, std::string, std::string>, std::pair<DIST::Array*, DIST::ArrayAccessInfo*>>& declaredArrays, const std::map<std::string, CommonBlock*>& commonBlocks, const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo, const std::map<std::string, std::map<int, Gcov_info>>& gCovInfo);
|
||||
|
||||
void runPredictSchemeOld(SgProject &project, std::vector<std::vector<size_t>> &topologies, std::vector<ParallelRegion*> ¶llelRegions, std::map<std::string, std::vector<LoopGraph*>> &loopGraph, std::map<std::string, std::vector<SpfInterval*>> &intervals, std::map<std::string, std::vector<Messages>> &SPF_messages);
|
||||
|
||||
439
src/Predictor/PredictSchemeWithLibrary.cpp
Normal file
439
src/Predictor/PredictSchemeWithLibrary.cpp
Normal file
@@ -0,0 +1,439 @@
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
#include "dvm.h"
|
||||
#include "PredictSchemeWithLibrary.h"
|
||||
#include "../../projects/libpredictor/include/libpredict/predictor.h"
|
||||
#include "../DirectiveProcessing/directive_parser.h"
|
||||
#include "../Distribution/DvmhDirective.h"
|
||||
#include "../ParallelizationRegions/ParRegions.h"
|
||||
#include "../GraphLoop/graph_loops_func.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "../Utils/utils.h"
|
||||
|
||||
using std::map;
|
||||
using std::pair;
|
||||
using std::string;
|
||||
using std::tuple;
|
||||
using std::vector;
|
||||
|
||||
map<size_t, size_t> createTemplateIdMapping(const vector<ParallelRegion*>& parallelRegions)
|
||||
{
|
||||
size_t maxArrayId = 0;
|
||||
for (int z = 0; z < parallelRegions.size(); ++z) {
|
||||
const DataDirective& dataDirectives = parallelRegions[z]->GetDataDir();
|
||||
|
||||
for (const auto& distrRule : dataDirectives.distrRules) {
|
||||
if (distrRule.first && !distrRule.first->IsTemplate()) {
|
||||
maxArrayId = std::max(maxArrayId, (size_t)distrRule.first->GetId());
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& alignRule : dataDirectives.alignRules) {
|
||||
if (alignRule.alignArray && !alignRule.alignArray->IsTemplate()) {
|
||||
maxArrayId = std::max(maxArrayId, (size_t)alignRule.alignArray->GetId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
map<size_t, size_t> templateIdMapping;
|
||||
size_t nextTemplateId = maxArrayId + 1;
|
||||
for (int z = 0; z < parallelRegions.size(); ++z) {
|
||||
const DataDirective& dataDirectives = parallelRegions[z]->GetDataDir();
|
||||
|
||||
for (const auto& distrRule : dataDirectives.distrRules) {
|
||||
if (distrRule.first && distrRule.first->IsTemplate()) {
|
||||
size_t originalId = distrRule.first->GetId();
|
||||
if (templateIdMapping.find(originalId) == templateIdMapping.end()) {
|
||||
templateIdMapping[originalId] = nextTemplateId++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& alignRule : dataDirectives.alignRules) {
|
||||
if (alignRule.alignWith && alignRule.alignWith->IsTemplate()) {
|
||||
size_t originalId = alignRule.alignWith->GetId();
|
||||
if (templateIdMapping.find(originalId) == templateIdMapping.end()) {
|
||||
templateIdMapping[originalId] = nextTemplateId++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return templateIdMapping;
|
||||
}
|
||||
|
||||
PrecomputedLibpredictParams precomputeLibpredictParams(
|
||||
SgProject& project,
|
||||
const vector<ParallelRegion*>& parallelRegions,
|
||||
const map<string, vector<LoopGraph*>>& loopGraph,
|
||||
const map<size_t, size_t>& templateIdMapping)
|
||||
{
|
||||
PrecomputedLibpredictParams result;
|
||||
|
||||
// distribute and align from parallelRegions
|
||||
for (int z = 0; z < parallelRegions.size(); ++z) {
|
||||
const DataDirective& dataDirectives = parallelRegions[z]->GetDataDir();
|
||||
const vector<int>& currentVariant = parallelRegions[z]->GetCurrentVariant();
|
||||
const DIST::Arrays<int>& allArrays = parallelRegions[z]->GetAllArrays();
|
||||
|
||||
auto& tmp = dataDirectives.distrRules;
|
||||
vector<pair<DIST::Array*, const DistrVariant*>> currentVar;
|
||||
for (int z1 = 0; z1 < currentVariant.size(); ++z1) {
|
||||
currentVar.push_back(std::make_pair(tmp[z1].first, &tmp[z1].second[currentVariant[z1]]));
|
||||
}
|
||||
|
||||
// distribute
|
||||
for (const auto& distrRule : currentVar) {
|
||||
DIST::Array* array = distrRule.first;
|
||||
const DistrVariant* variant = distrRule.second;
|
||||
|
||||
if (array && variant && !array->IsNotDistribute()) {
|
||||
PrecomputedDistributeParams params;
|
||||
|
||||
size_t originalId = array->GetId();
|
||||
params.arrayId = originalId;
|
||||
|
||||
if (array->IsTemplate()) {
|
||||
auto it = templateIdMapping.find(originalId);
|
||||
if (it != templateIdMapping.end()) {
|
||||
params.arrayId = it->second;
|
||||
}
|
||||
}
|
||||
|
||||
params.elemSize = array->GetTypeSize();
|
||||
params.array = array;
|
||||
|
||||
const auto& arraySizes = array->GetSizes();
|
||||
for (int dim = 0; dim < array->GetDimSize(); ++dim) {
|
||||
size_t dimSize = arraySizes[dim].second - arraySizes[dim].first + 1;
|
||||
|
||||
if (dim < variant->distRule.size() && variant->distRule[dim] == dist::BLOCK) {
|
||||
params.axisDistributions.emplace_back(dimSize, libpredict::TypeDistribute::BLOCK);
|
||||
} else {
|
||||
params.axisDistributions.emplace_back(dimSize, libpredict::TypeDistribute::NONE);
|
||||
}
|
||||
}
|
||||
|
||||
const auto& shadowSpec = array->GetShadowSpec();
|
||||
for (int dim = 0; dim < shadowSpec.size() && dim < array->GetDimSize(); ++dim) {
|
||||
if (dim < variant->distRule.size() && variant->distRule[dim] == dist::BLOCK) {
|
||||
params.shadowEdges.emplace_back(shadowSpec[dim].first, shadowSpec[dim].second);
|
||||
}
|
||||
}
|
||||
|
||||
result.distributeParams.push_back(params);
|
||||
}
|
||||
}
|
||||
|
||||
// align
|
||||
for (const auto& alignRule : dataDirectives.alignRules) {
|
||||
DIST::Array* alignArray = alignRule.alignArray;
|
||||
DIST::Array* alignWithArray = alignRule.alignWith;
|
||||
|
||||
if (alignArray && alignWithArray && !alignArray->IsNotDistribute()) {
|
||||
PrecomputedAlignParams params;
|
||||
|
||||
params.arrayId = alignArray->GetId();
|
||||
size_t originalDistributedArrayId = alignWithArray->GetId();
|
||||
params.distributedArrayId = originalDistributedArrayId;
|
||||
|
||||
if (alignWithArray->IsTemplate()) {
|
||||
auto it = templateIdMapping.find(originalDistributedArrayId);
|
||||
if (it != templateIdMapping.end()) {
|
||||
params.distributedArrayId = it->second;
|
||||
}
|
||||
}
|
||||
|
||||
params.elemSize = alignArray->GetTypeSize();
|
||||
params.alignArray = alignArray;
|
||||
params.alignWithArray = alignWithArray;
|
||||
|
||||
const auto& arraySizes = alignArray->GetSizes();
|
||||
for (int dim = 0; dim < alignArray->GetDimSize(); ++dim) {
|
||||
size_t dimSize = arraySizes[dim].second - arraySizes[dim].first + 1;
|
||||
params.dimensions.push_back(dimSize);
|
||||
}
|
||||
|
||||
for (int dim = 0; dim < alignWithArray->GetDimSize(); ++dim) {
|
||||
bool found = false;
|
||||
for (int i = 0; i < alignRule.alignRuleWith.size(); ++i) {
|
||||
const auto& ruleWith = alignRule.alignRuleWith[i];
|
||||
if (ruleWith.first == dim) {
|
||||
const auto& rule = ruleWith.second;
|
||||
if (rule.first == 0) {
|
||||
// constant
|
||||
params.distributionExpressions.emplace_back(rule.second);
|
||||
} else {
|
||||
// linear expression a * I + b
|
||||
params.distributionExpressions.emplace_back(i, rule.first, rule.second);
|
||||
}
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
// There is no rule for this measurement
|
||||
params.distributionExpressions.emplace_back();
|
||||
}
|
||||
}
|
||||
|
||||
const auto& shadowSpec = alignArray->GetShadowSpec();
|
||||
for (int dim = 0; dim < shadowSpec.size() && dim < alignArray->GetDimSize(); ++dim) {
|
||||
params.shadowEdges.emplace_back(shadowSpec[dim].first, shadowSpec[dim].second);
|
||||
}
|
||||
|
||||
result.alignParams.push_back(params);
|
||||
}
|
||||
}
|
||||
|
||||
// shadow_renew
|
||||
map<LoopGraph*, ParallelDirective*> parallelDirs;
|
||||
for (int i = project.numberOfFiles() - 1; i >= 0; --i) {
|
||||
SgFile* file = &(project.file(i));
|
||||
auto fountInfo = findAllDirectives(
|
||||
file,
|
||||
getObjectForFileFromMap(file->filename(), const_cast<map<string, vector<LoopGraph*>>&>(loopGraph)),
|
||||
parallelRegions[z]->GetId());
|
||||
parallelDirs.insert(fountInfo.begin(), fountInfo.end());
|
||||
}
|
||||
|
||||
for (auto& dirPair : parallelDirs) {
|
||||
LoopGraph* loopPtr = dirPair.first;
|
||||
ParallelDirective* directive = dirPair.second;
|
||||
|
||||
if (directive && !directive->shadowRenew.empty()) {
|
||||
for (size_t shadowIdx = 0; shadowIdx < directive->shadowRenew.size(); ++shadowIdx) {
|
||||
const auto& shadowRenewItem = directive->shadowRenew[shadowIdx];
|
||||
const string& arrayName = shadowRenewItem.first.second; // uniqName
|
||||
const vector<pair<int, int>>& bounds = shadowRenewItem.second;
|
||||
|
||||
DIST::Array* shadowArray = allArrays.GetArrayByName(arrayName);
|
||||
if (shadowArray == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (shadowArray && !shadowArray->IsNotDistribute()) {
|
||||
PrecomputedShadowRenewParams params;
|
||||
|
||||
params.arrayId = shadowArray->GetId();
|
||||
params.shadowArray = shadowArray;
|
||||
|
||||
for (const auto& bound : bounds) {
|
||||
params.shadow_renew.emplace_back(static_cast<size_t>(bound.first),
|
||||
static_cast<size_t>(bound.second));
|
||||
}
|
||||
|
||||
params.corner = directive->shadowRenewCorner[shadowIdx];
|
||||
params.number_loop_iterations = loopPtr ? static_cast<size_t>(loopPtr->countOfIters) : 1;
|
||||
|
||||
result.shadowRenewParams.push_back(params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
double runLibpredictCalc(const vector<size_t>& topology,
|
||||
const string& clusterConfStr,
|
||||
const PrecomputedLibpredictParams& precomputedParams,
|
||||
map<string, vector<Messages>>& SPF_messages)
|
||||
{
|
||||
libpredict::RetInitGrid retInitGrid = libpredict::InitGrid(topology[0], topology[1], topology[2], topology[3]);
|
||||
|
||||
if (retInitGrid != libpredict::INIT_GRID_SUCCESS) {
|
||||
__spf_print(1, "ERROR: Failed to initialize libpredict grid with topology: %zu %zu %zu %zu, return code: %d\n",
|
||||
topology[0], topology[1], topology[2], topology[3], (int)retInitGrid);
|
||||
|
||||
std::wstring messageR, messageE;
|
||||
__spf_printToLongBuf(messageE, L"Failed to initialize libpredict grid with topology: %zu %zu %zu %zu, return code: %d",
|
||||
topology[0], topology[1], topology[2], topology[3], (int)retInitGrid);
|
||||
__spf_printToLongBuf(messageR, R207);
|
||||
getObjectForFileFromMap(clusterConfStr.c_str(), SPF_messages).push_back(Messages(ERROR, 1, messageR, messageE, 1064));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// distribute
|
||||
for (const auto& params : precomputedParams.distributeParams) {
|
||||
libpredict::RetDistribute retDistribute = libpredict::Distribute(
|
||||
params.arrayId, params.elemSize, params.axisDistributions, params.shadowEdges);
|
||||
|
||||
if (retDistribute != libpredict::DISTRIBUTE_SUCCESS) {
|
||||
__spf_print(1, "ERROR: Failed to distribute array '%s' (id=%zu) with libpredict, return code: %d\n",
|
||||
params.array->GetShortName().c_str(), params.arrayId, (int)retDistribute);
|
||||
|
||||
std::wstring messageR, messageE;
|
||||
__spf_printToLongBuf(messageE, L"Failed to distribute array '%s' with libpredict, return code: %d",
|
||||
to_wstring(params.array->GetShortName()).c_str(), (int)retDistribute);
|
||||
__spf_printToLongBuf(messageR, R208);
|
||||
getObjectForFileFromMap(params.array->GetDeclInfo().begin()->first.c_str(), SPF_messages).push_back(Messages(ERROR, params.array->GetDeclInfo().begin()->second, messageR, messageE, 1065));
|
||||
}
|
||||
}
|
||||
|
||||
// align
|
||||
for (const auto& params : precomputedParams.alignParams) {
|
||||
libpredict::RetAlign retAlign = libpredict::Align(
|
||||
params.arrayId, params.distributedArrayId, params.elemSize,
|
||||
params.dimensions, params.distributionExpressions, params.shadowEdges);
|
||||
|
||||
if (retAlign != libpredict::ALIGN_SUCCESS) {
|
||||
__spf_print(1, "ERROR: Failed to align array '%s' (id=%zu) with array '%s' (id=%zu), return code: %d\n",
|
||||
params.alignArray->GetShortName().c_str(), params.arrayId,
|
||||
params.alignWithArray->GetShortName().c_str(), params.distributedArrayId, (int)retAlign);
|
||||
|
||||
std::wstring messageR, messageE;
|
||||
__spf_printToLongBuf(messageE, L"Failed to align array '%s' with array '%s' using libpredict, return code: %d",
|
||||
to_wstring(params.alignArray->GetShortName()).c_str(),
|
||||
to_wstring(params.alignWithArray->GetShortName()).c_str(), (int)retAlign);
|
||||
__spf_printToLongBuf(messageR, R209);
|
||||
getObjectForFileFromMap(params.alignArray->GetDeclInfo().begin()->first.c_str(), SPF_messages).push_back(Messages(ERROR, params.alignArray->GetDeclInfo().begin()->second, messageR, messageE, 1066));
|
||||
}
|
||||
}
|
||||
|
||||
// shadow_renew
|
||||
for (const auto& params : precomputedParams.shadowRenewParams) {
|
||||
libpredict::RetShadowRenew retShadowRenew = libpredict::ShadowRenew(
|
||||
params.arrayId, params.shadow_renew, params.corner, params.number_loop_iterations);
|
||||
|
||||
if (retShadowRenew != libpredict::SHADOW_RENEW_SUCCESS) {
|
||||
__spf_print(1, "ERROR: Failed to process shadow_renew for array '%s' (id=%zu), return code: %d\n",
|
||||
params.shadowArray->GetShortName().c_str(), params.arrayId, (int)retShadowRenew);
|
||||
|
||||
std::wstring messageR, messageE;
|
||||
__spf_printToLongBuf(messageE, L"Failed to process shadow_renew for array '%s' with libpredict, return code: %d",
|
||||
to_wstring(params.shadowArray->GetShortName()).c_str(), (int)retShadowRenew);
|
||||
__spf_printToLongBuf(messageR, R210);
|
||||
getObjectForFileFromMap(params.shadowArray->GetDeclInfo().begin()->first.c_str(), SPF_messages).push_back(Messages(ERROR, params.shadowArray->GetDeclInfo().begin()->second, messageR, messageE, 1067));
|
||||
}
|
||||
}
|
||||
|
||||
return libpredict::GetTime();
|
||||
}
|
||||
|
||||
void runPredictScheme(SgProject& project,
|
||||
vector<vector<size_t>>& topologies,
|
||||
const vector<ParallelRegion*>& parallelRegions,
|
||||
map<string, vector<LoopGraph*>>& loopGraph,
|
||||
map<string, vector<Messages>>& SPF_messages)
|
||||
{
|
||||
// calculating maximum dimension of distribution
|
||||
int maxSizeDist = 0;
|
||||
for (int z = 0; z < parallelRegions.size(); ++z) {
|
||||
const DataDirective& dataDirectives = parallelRegions[z]->GetDataDir();
|
||||
const vector<int>& currentVariant = parallelRegions[z]->GetCurrentVariant();
|
||||
|
||||
auto& tmp = dataDirectives.distrRules;
|
||||
vector<const DistrVariant*> currentVar;
|
||||
for (int z1 = 0; z1 < currentVariant.size(); ++z1) {
|
||||
currentVar.push_back(&tmp[z1].second[currentVariant[z1]]);
|
||||
}
|
||||
|
||||
for (auto var : currentVar) {
|
||||
int countBlock = 0;
|
||||
for (int z = 0; z < var->distRule.size(); ++z) {
|
||||
if (var->distRule[z] == dist::BLOCK) {
|
||||
++countBlock;
|
||||
}
|
||||
}
|
||||
maxSizeDist = std::max(maxSizeDist, countBlock);
|
||||
}
|
||||
}
|
||||
|
||||
// calculating name of a cluster configuration file
|
||||
string clusterConfStr;
|
||||
if (project.numberOfFiles() > 0) {
|
||||
string firstFilePath = project.fileName(0);
|
||||
|
||||
size_t lastSlash = firstFilePath.find_last_of("/\\");
|
||||
clusterConfStr = firstFilePath.substr(0, lastSlash + 1) + "cluster.conf";
|
||||
}
|
||||
|
||||
// creating template ID display to avoid conflicts
|
||||
map<size_t, size_t> templateIdMapping = createTemplateIdMapping(parallelRegions);
|
||||
|
||||
// Precomputing parameters of directive functions from libpredict
|
||||
PrecomputedLibpredictParams precomputedParams = precomputeLibpredictParams(
|
||||
project, parallelRegions, loopGraph, templateIdMapping);
|
||||
|
||||
// iterating through topologies to find most optimal one
|
||||
topologies = vector<vector<size_t>>();
|
||||
if (maxSizeDist) {
|
||||
if (maxSizeDist > 4) {
|
||||
maxSizeDist = 4;
|
||||
}
|
||||
|
||||
// Initialize cluster
|
||||
int procCount = 0;
|
||||
libpredict::RetInitCluster retInitCluster = libpredict::InitCluster(clusterConfStr, procCount);
|
||||
|
||||
if (retInitCluster != libpredict::INIT_CLUSTER_SUCCESS) {
|
||||
__spf_print(1, "ERROR: Failed to initialize libpredict cluster with config: %s, return code: %d\n", clusterConfStr.c_str(), (int)retInitCluster);
|
||||
|
||||
std::wstring messageR, messageE;
|
||||
__spf_printToLongBuf(messageE, L"Failed to initialize libpredict cluster with config: %s, return code: %d",
|
||||
to_wstring(clusterConfStr).c_str(), (int)retInitCluster);
|
||||
__spf_printToLongBuf(messageR, R206);
|
||||
getObjectForFileFromMap(clusterConfStr.c_str(), SPF_messages).push_back(Messages(ERROR, 1, messageR, messageE, 1063));
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t n1 = 2; n1 <= procCount; ++n1) {
|
||||
for (size_t n2 = 1; n2 <= n1 && n1 * n2 <= procCount; ++n2) {
|
||||
if (n2 != 1 && maxSizeDist < 2 || n2 == 1 && maxSizeDist == 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (size_t n3 = 1; n3 <= n2 && n1 * n2 * n3 <= procCount; ++n3) {
|
||||
if (n3 != 1 && maxSizeDist < 3 || n3 == 1 && maxSizeDist == 3) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (size_t n4 = 1; n4 <= n3 && n1 * n2 * n3 * n4 <= procCount; ++n4) {
|
||||
if (n4 != 1 && maxSizeDist < 4 || n4 == 1 && maxSizeDist == 4) {
|
||||
continue;
|
||||
}
|
||||
|
||||
topologies.push_back(vector<size_t>{n1, n2, n3, n4});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vector<size_t> best;
|
||||
double bestTime = std::numeric_limits<double>::max();
|
||||
for (auto& topology : topologies) {
|
||||
double currTime = runLibpredictCalc(topology, clusterConfStr, precomputedParams, SPF_messages);
|
||||
|
||||
string outStr = "";
|
||||
for (const auto& elem : topology) {
|
||||
outStr += std::to_string(elem) + " ";
|
||||
}
|
||||
__spf_print(1, "topology %s has time %f\n", outStr.c_str(), currTime);
|
||||
|
||||
if (currTime == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (currTime < bestTime) {
|
||||
bestTime = currTime;
|
||||
best = topology;
|
||||
}
|
||||
}
|
||||
string outStr;
|
||||
for (const auto& elem : best) {
|
||||
outStr += std::to_string(elem) + " ";
|
||||
}
|
||||
|
||||
__spf_print(1, "best topology %s with time %f\n", outStr.c_str(), bestTime);
|
||||
} else {
|
||||
__spf_print(1, "impossible to calculate best topology: project does not contain distribution directives\n");
|
||||
}
|
||||
}
|
||||
57
src/Predictor/PredictSchemeWithLibrary.h
Normal file
57
src/Predictor/PredictSchemeWithLibrary.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "dvm.h"
|
||||
#include "graph_calls.h"
|
||||
#include "../../projects/libpredictor/include/libpredict/predictor.h"
|
||||
|
||||
struct PrecomputedDistributeParams {
|
||||
size_t arrayId;
|
||||
size_t elemSize;
|
||||
std::vector<libpredict::DistributeAxisRule> axisDistributions;
|
||||
std::vector<std::pair<size_t, size_t>> shadowEdges;
|
||||
DIST::Array* array;
|
||||
};
|
||||
|
||||
struct PrecomputedAlignParams {
|
||||
size_t arrayId;
|
||||
size_t distributedArrayId;
|
||||
size_t elemSize;
|
||||
std::vector<size_t> dimensions;
|
||||
std::vector<libpredict::AlignDisplay> distributionExpressions;
|
||||
std::vector<std::pair<size_t, size_t>> shadowEdges;
|
||||
DIST::Array* alignArray;
|
||||
DIST::Array* alignWithArray;
|
||||
};
|
||||
|
||||
struct PrecomputedShadowRenewParams {
|
||||
size_t arrayId;
|
||||
std::vector<std::pair<size_t, size_t>> shadow_renew;
|
||||
bool corner;
|
||||
size_t number_loop_iterations;
|
||||
DIST::Array* shadowArray;
|
||||
};
|
||||
|
||||
struct PrecomputedLibpredictParams {
|
||||
std::vector<PrecomputedDistributeParams> distributeParams;
|
||||
std::vector<PrecomputedAlignParams> alignParams;
|
||||
std::vector<PrecomputedShadowRenewParams> shadowRenewParams;
|
||||
};
|
||||
|
||||
PrecomputedLibpredictParams precomputeLibpredictParams(
|
||||
SgProject& project,
|
||||
const std::vector<ParallelRegion*>& parallelRegions,
|
||||
const std::map<std::string, std::vector<LoopGraph*>>& loopGraph,
|
||||
const std::map<size_t, size_t>& templateIdMapping);
|
||||
|
||||
void runPredictScheme(SgProject& project,
|
||||
std::vector<std::vector<size_t>>& topologies,
|
||||
const std::vector<ParallelRegion*>& parallelRegions,
|
||||
std::map<std::string, std::vector<LoopGraph*>>& loopGraph,
|
||||
std::map<std::string, std::vector<Messages>>& SPF_messages);
|
||||
|
||||
double runLibpredictCalc(const std::vector<size_t>& topology,
|
||||
const std::string& clusterConfStr,
|
||||
const PrecomputedLibpredictParams& precomputedParams,
|
||||
std::map<std::string, std::vector<Messages>>& SPF_messages);
|
||||
@@ -1,5 +1,5 @@
|
||||
#define _LEAK_
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
@@ -9,10 +9,10 @@
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
#include "graph_calls.h"
|
||||
#include "private_analyzer.h"
|
||||
#include "dvm.h"
|
||||
#include "../CFGraph/CFGraph.h"
|
||||
#include "CFGraph/CFGraph.h"
|
||||
|
||||
using std::vector;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "dvm.h"
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
#include "graph_calls.h"
|
||||
|
||||
extern void Private_Vars_Analyzer(SgStatement* start);
|
||||
void PrivateAnalyzer(SgFile *file, std::vector<FuncInfo*> &funcs);
|
||||
|
||||
141
src/PrivateAnalyzer/private_arrays_search.cpp
Normal file
141
src/PrivateAnalyzer/private_arrays_search.cpp
Normal file
@@ -0,0 +1,141 @@
|
||||
#include <map>
|
||||
#include <unordered_set>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include <numeric>
|
||||
#include <iostream>
|
||||
|
||||
#include "private_arrays_search.h"
|
||||
#include "range_structures.h"
|
||||
#include "region.h"
|
||||
#include "SgUtils.h"
|
||||
#include "graph_loops.h"
|
||||
#include "CFGraph/CFGraph.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
static void Collapse(Region* region)
|
||||
{
|
||||
if (region->getBasickBlocks().empty())
|
||||
return;
|
||||
|
||||
for (auto& [arrayName, arrayRanges] : region->getHeader()->array_out)
|
||||
{
|
||||
for (Region* byBlock : region->getBasickBlocks())
|
||||
{
|
||||
AccessingSet intersection = byBlock->array_def[arrayName].Intersect(arrayRanges);
|
||||
region->array_def[arrayName] = region->array_def[arrayName].Union(intersection);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& byBlock : region->getBasickBlocks())
|
||||
{
|
||||
for (auto& [arrayName, arrayRanges] : byBlock->array_use)
|
||||
{
|
||||
AccessingSet diff = byBlock->array_use[arrayName].Diff(byBlock->array_in[arrayName]);
|
||||
region->array_use[arrayName] = region->array_use[arrayName].Union(diff);
|
||||
}
|
||||
}
|
||||
ArrayAccessingIndexes useUnion;
|
||||
for (auto& byBlock : region->getBasickBlocks())
|
||||
for (auto& [arrayName, arrayRanges] : byBlock->array_use)
|
||||
useUnion[arrayName] = useUnion[arrayName].Union(byBlock->array_use[arrayName]);
|
||||
|
||||
for (auto& [arrayName, arrayRanges] : useUnion)
|
||||
region->array_priv[arrayName] = useUnion[arrayName].Diff(region->array_use[arrayName]);
|
||||
|
||||
for (Region* prevBlock : region->getHeader()->getPrevRegions())
|
||||
prevBlock->replaceInNextRegions(region, region->getHeader());
|
||||
|
||||
for (Region* nextBlock : region->getHeader()->getNextRegions())
|
||||
nextBlock->replaceInPrevRegions(region, region->getHeader());
|
||||
}
|
||||
|
||||
static void SolveDataFlowIteratively(Region* DFG)
|
||||
{
|
||||
unordered_set<Region*> worklist(DFG->getBasickBlocks());
|
||||
do
|
||||
{
|
||||
Region* b = *worklist.begin();
|
||||
ArrayAccessingIndexes newIn;
|
||||
bool flagFirst = true;
|
||||
for (Region* prevBlock : b->getPrevRegions())
|
||||
{
|
||||
if (flagFirst)
|
||||
{
|
||||
newIn = prevBlock->array_out;
|
||||
flagFirst = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (prevBlock->array_out.empty())
|
||||
{
|
||||
newIn.clear();
|
||||
continue;
|
||||
}
|
||||
for (const auto& [arrayName, accessSet] : prevBlock->array_out)
|
||||
{
|
||||
if (newIn.find(arrayName) != newIn.end())
|
||||
newIn[arrayName] = newIn[arrayName].Intersect(accessSet);
|
||||
else
|
||||
newIn[arrayName] = AccessingSet();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
b->array_in = move(newIn);
|
||||
ArrayAccessingIndexes newOut;
|
||||
if (b->array_def.empty())
|
||||
newOut = b->array_in;
|
||||
else if (b->array_in.empty())
|
||||
newOut = b->array_def;
|
||||
else
|
||||
{
|
||||
for (auto& [arrayName, accessSet] : b->array_def)
|
||||
{
|
||||
if (newOut.find(arrayName) != newOut.end())
|
||||
newOut[arrayName] = b->array_def[arrayName].Union(b->array_in[arrayName]);
|
||||
else
|
||||
newOut[arrayName] = accessSet;
|
||||
}
|
||||
}
|
||||
|
||||
/* can not differ */
|
||||
if (newOut != b->array_out)
|
||||
b->array_out = newOut;
|
||||
else
|
||||
worklist.erase(b);
|
||||
}
|
||||
while (!worklist.empty());
|
||||
}
|
||||
|
||||
static void SolveDataFlow(Region* DFG)
|
||||
{
|
||||
if (!DFG)
|
||||
return;
|
||||
|
||||
SolveDataFlowIteratively(DFG);
|
||||
for (Region* subRegion : DFG->getSubRegions())
|
||||
SolveDataFlow(subRegion);
|
||||
Collapse(DFG);
|
||||
}
|
||||
|
||||
map<LoopGraph*, ArrayAccessingIndexes> FindPrivateArrays(map<string, vector<LoopGraph*>> &loopGraph, map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR)
|
||||
{
|
||||
map<LoopGraph*, ArrayAccessingIndexes> result;
|
||||
for (const auto& [loopName, loops] : loopGraph)
|
||||
{
|
||||
for (const auto& loop : loops)
|
||||
{
|
||||
for (const auto& [funcInfo, blocks]: FullIR)
|
||||
{
|
||||
Region* loopRegion = new Region(loop, blocks);
|
||||
SolveDataFlow(loopRegion);
|
||||
result[loop] = loopRegion->array_priv;
|
||||
delete(loopRegion);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
12
src/PrivateAnalyzer/private_arrays_search.h
Normal file
12
src/PrivateAnalyzer/private_arrays_search.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "range_structures.h"
|
||||
#include "graph_loops.h"
|
||||
#include "CFGraph/CFGraph.h"
|
||||
|
||||
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);
|
||||
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 <cstdlib>
|
||||
@@ -6,9 +6,9 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "../Utils/errors.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "../Utils/utils.h"
|
||||
#include "errors.h"
|
||||
#include "SgUtils.h"
|
||||
#include "utils.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);
|
||||
|
||||
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();
|
||||
set<SgStatement*> toRemove;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -7,8 +7,8 @@
|
||||
#include <vector>
|
||||
|
||||
#include "FileInfo.h"
|
||||
#include "../Utils/utils.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "utils.h"
|
||||
#include "errors.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -22,8 +22,8 @@
|
||||
#include <thread>
|
||||
#include <stack>
|
||||
|
||||
#include "../Utils/errors.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "errors.h"
|
||||
#include "SgUtils.h"
|
||||
#include "../VisualizerCalls/get_information.h"
|
||||
#include "../VisualizerCalls/SendMessage.h"
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
using namespace std;
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -293,11 +294,8 @@ static vector<string> parseList(vector<FileInfo>& listOfProject,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
sendMessage_2lvl(L" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> '" + to_wstring(file) + L"'");
|
||||
#else
|
||||
sendMessage_2lvl(L" processing file '" + to_wstring(file) + L"'");
|
||||
#endif
|
||||
sendMessage_2lvl(3, file);
|
||||
|
||||
StdCapture::Init();
|
||||
string errorMessage = "";
|
||||
try
|
||||
@@ -443,20 +441,12 @@ static int dumpErrors(const vector<FileInfo>& listOfProject, const vector<string
|
||||
if (errors[z] == "")
|
||||
{
|
||||
FILE* ferr = fopen(file.errPath.c_str(), "w");
|
||||
if (!ferr)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
fclose(ferr);
|
||||
if (ferr)
|
||||
fclose(ferr);
|
||||
++z;
|
||||
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 = "";
|
||||
vector<string> splited;
|
||||
splitString(errors[z], '\n', splited);
|
||||
@@ -475,13 +465,22 @@ static int dumpErrors(const vector<FileInfo>& listOfProject, const vector<string
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
fclose(fout);
|
||||
fclose(ferr);
|
||||
++z;
|
||||
}
|
||||
|
||||
@@ -576,11 +575,8 @@ static void parseFiles(int& iters, vector<string>& errors, vector<FileInfo>& lis
|
||||
|
||||
do
|
||||
{
|
||||
#ifdef _WIN32
|
||||
sendMessage_1lvl(L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> " + std::to_wstring((iters + 1)) + L" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
#else
|
||||
sendMessage_1lvl(L"running " + std::to_wstring((iters + 1)) + L" iteration of syntax analisys");
|
||||
#endif
|
||||
sendMessage_1lvl(0, iters + 1);
|
||||
|
||||
errors = parseList(listOfProject, iters != 0, parseForInlining, mapModuleDeps, moduleDelc, modDirectOrder, isFromConsole);
|
||||
changed = createMapOfUse(errors, listOfProject, mapModuleDeps);
|
||||
if (iters != 0)
|
||||
@@ -713,7 +709,7 @@ int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int pars
|
||||
|
||||
if (pathSplit.size() < 2)
|
||||
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__);
|
||||
string fullPath = "";
|
||||
for (int z = 0; z < pathSplit.size() - 2; ++z)
|
||||
@@ -745,9 +741,9 @@ int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int pars
|
||||
else
|
||||
fileNameFixed = (toAdd.substr(0, 2) == "./") ? toAdd.substr(2) : toAdd;
|
||||
|
||||
const string optPath = fullPath + "visualiser_data/options/" + fileNameFixed + ".opt";
|
||||
const string errPath = fullPath + "visualiser_data/options/" + fileNameFixed + ".err";
|
||||
const string outPath = fullPath + "visualiser_data/options/" + fileNameFixed + ".out";
|
||||
const string optPath = fullPath + VISUALIZER_DATA_PATH + "/options/" + fileNameFixed + ".opt";
|
||||
const string errPath = fullPath + VISUALIZER_DATA_PATH + "/options/" + fileNameFixed + ".err";
|
||||
const string outPath = fullPath + VISUALIZER_DATA_PATH + "/options/" + fileNameFixed + ".out";
|
||||
|
||||
const string fileText = readFileToStr(toAdd);
|
||||
|
||||
@@ -809,6 +805,8 @@ void parseFiles(int argc, char** argv)
|
||||
printf(" run parsing for inlining\n");
|
||||
|
||||
int rethrow = parseFiles(errors, listOfProject, filesCompilationOrder, isInline, true);
|
||||
int errCount = dumpErrors(listOfProject, errors, messages);
|
||||
|
||||
if (rethrow == 0)
|
||||
{
|
||||
for (auto& err : errors)
|
||||
@@ -838,5 +836,7 @@ void parseFiles(int argc, char** argv)
|
||||
}
|
||||
else
|
||||
printf("Parsing was completed with errors, throw code %d, errors count %d\n", rethrow, code);
|
||||
|
||||
dumpMessages(false, messages, VISUALIZER_DATA_PATH);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../Utils/leak_detector.h"
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -6,8 +6,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "../Utils/errors.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "errors.h"
|
||||
#include "SgUtils.h"
|
||||
|
||||
#include "StdCapture.h"
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "leak_detector.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
@@ -9,14 +11,15 @@
|
||||
#include <algorithm>
|
||||
#include <tuple>
|
||||
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "../CFGraph/CFGraph.h"
|
||||
#include "CFGraph/CFGraph.h"
|
||||
#include "CFGraph/IR.h"
|
||||
#include "Distribution/Array.h"
|
||||
#include "dvm.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
#include "../GraphCall/graph_calls_func.h"
|
||||
|
||||
#include "errors.h"
|
||||
#include "SgUtils.h"
|
||||
#include "graph_calls.h"
|
||||
#include "graph_calls_func.h"
|
||||
|
||||
#include "projectParameters.h"
|
||||
|
||||
@@ -37,6 +40,9 @@ enum class MODE
|
||||
AFTER
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -426,10 +432,11 @@ void findParameters(ResultSet& foundParameters,
|
||||
toAdd->setFileId(stmt_before->getFileId());
|
||||
toAdd->setProject(stmt_before->getProject());
|
||||
|
||||
if (mode == MODE::AFTER)
|
||||
//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());
|
||||
stmt_before->insertStmtBefore(*toAdd, *stmt_before->controlParent());*/
|
||||
|
||||
foundParameters.insert(make_tuple(stmt_before->fileName(), stmt_before->lineNumber(), var_name));
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "../Utils/utils.h"
|
||||
#include "graph_calls.h"
|
||||
#include "errors.h"
|
||||
#include "utils.h"
|
||||
#include "sage++user.h"
|
||||
#include "definesValues.h"
|
||||
#include "set.h"
|
||||
|
||||
@@ -15,8 +15,8 @@ extern "C" void removeFromCollection(void *pointer);
|
||||
#endif
|
||||
extern int passDone;
|
||||
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "graph_calls.h"
|
||||
#include "errors.h"
|
||||
#include "../VisualizerCalls/get_information.h"
|
||||
|
||||
#include "sage++user.h"
|
||||
|
||||
204
src/Sapfor.cpp
204
src/Sapfor.cpp
@@ -24,8 +24,6 @@
|
||||
#include "ParallelizationRegions/resolve_par_reg_conflicts.h"
|
||||
#include "ParallelizationRegions/expand_extract_reg.h"
|
||||
|
||||
#include "Transformations/replace_dist_arrays_in_io.h"
|
||||
|
||||
#include "Distribution/Distribution.h"
|
||||
#include "Distribution/GraphCSR.h"
|
||||
#include "Distribution/Arrays.h"
|
||||
@@ -55,9 +53,11 @@
|
||||
#include "VerificationCode/verifications.h"
|
||||
#include "Distribution/CreateDistributionDirs.h"
|
||||
#include "PrivateAnalyzer/private_analyzer.h"
|
||||
#include "ExpressionTransform/expr_transform.h"
|
||||
#include "PrivateAnalyzer/private_arrays_search.h"
|
||||
#include "expr_transform.h"
|
||||
|
||||
#include "Predictor/PredictScheme.h"
|
||||
#include "Predictor/PredictSchemeWithLibrary.h"
|
||||
#include "Predictor/PredictorModel.h"
|
||||
#include "SageAnalysisTool/depInterfaceExt.h"
|
||||
#include "DvmhRegions/DvmhRegionInserter.h"
|
||||
@@ -71,24 +71,26 @@
|
||||
#include "VisualizerCalls/SendMessage.h"
|
||||
#include "VisualizerCalls/BuildGraph.h"
|
||||
|
||||
#include "Transformations/enddo_loop_converter.h"
|
||||
#include "Transformations/loop_transform.h"
|
||||
#include "Transformations/array_assign_to_loop.h"
|
||||
#include "Transformations/private_arrays_resizing.h"
|
||||
#include "Transformations/loops_splitter.h"
|
||||
#include "Transformations/loops_combiner.h"
|
||||
#include "Transformations/loops_unrolling.h"
|
||||
#include "Transformations/uniq_call_chain_dup.h"
|
||||
#include "Transformations/checkpoints.h"
|
||||
#include "Transformations/swap_array_dims.h"
|
||||
#include "Transformations/function_purifying.h"
|
||||
#include "Transformations/private_removing.h"
|
||||
#include "Transformations/fix_common_blocks.h"
|
||||
#include "Transformations/convert_to_c.h"
|
||||
#include "Transformations/set_implicit_none.h"
|
||||
#include "Transformations/dead_code.h"
|
||||
#include "Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.h"
|
||||
#include "Transformations/LoopEndDoConverter/enddo_loop_converter.h"
|
||||
#include "Transformations/LoopNesting/loop_transform.h"
|
||||
#include "Transformations/VectorAssignToLoop/array_assign_to_loop.h"
|
||||
#include "Transformations/PrivateArrayResizing/private_arrays_resizing.h"
|
||||
#include "Transformations/LoopSplitting/loops_splitter.h"
|
||||
#include "Transformations/LoopCombining/loops_combiner.h"
|
||||
#include "Transformations/LoopUnrolling/loops_unrolling.h"
|
||||
#include "Transformations/FunctionDuplication/uniq_call_chain_dup.h"
|
||||
#include "Transformations/CheckPoints/checkpoints.h"
|
||||
#include "Transformations/ArrayDimsSwapping/swap_array_dims.h"
|
||||
#include "Transformations/FunctionPurifying/function_purifying.h"
|
||||
#include "Transformations/PrivateArrayRemoving/private_removing.h"
|
||||
#include "Transformations/GlobalVariables/fix_common_blocks.h"
|
||||
#include "Transformations/ConvertToC/convert_to_c.h"
|
||||
#include "Transformations/SetImplicitNone/set_implicit_none.h"
|
||||
#include "Transformations/DeadCodeRemoving/dead_code.h"
|
||||
#include "Transformations/RenameSymbols/rename_symbols.h"
|
||||
#include "Transformations/FunctionInlining/inliner.h"
|
||||
|
||||
#include "RenameSymbols/rename_symbols.h"
|
||||
#include "ProjectParameters/projectParameters.h"
|
||||
|
||||
#include "CFGraph/IR.h"
|
||||
@@ -98,8 +100,6 @@
|
||||
#include "CFGraph/live_variable_analysis.h"
|
||||
#include "CFGraph/private_variables_analysis.h"
|
||||
|
||||
#include "Inliner/inliner.h"
|
||||
|
||||
#include "dvm.h"
|
||||
#include "Sapfor.h"
|
||||
#include "Utils/PassManager.h"
|
||||
@@ -399,11 +399,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
__spf_print(DEBUG_LVL1, "RUN PASS with name %s\n", passNames[curr_regime]);
|
||||
|
||||
auto toSendStrMessage = string(passNames[curr_regime]);
|
||||
#ifdef _WIN32
|
||||
sendMessage_1lvl(wstring(L"выполняется проход '") + wstring(toSendStrMessage.begin(), toSendStrMessage.end()) + L"'");
|
||||
#else
|
||||
sendMessage_1lvl(wstring(L"running pass '") + wstring(toSendStrMessage.begin(), toSendStrMessage.end()) + L"'");
|
||||
#endif
|
||||
sendMessage_1lvl(1, toSendStrMessage);
|
||||
|
||||
const int n = project.numberOfFiles();
|
||||
bool verifyOK = true;
|
||||
@@ -451,11 +447,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
SgFile *file = &(project.file(i));
|
||||
|
||||
toSendStrMessage = file->filename();
|
||||
#ifdef _WIN32
|
||||
sendMessage_2lvl(wstring(L"обработка файла '") + wstring(toSendStrMessage.begin(), toSendStrMessage.end()) + L"'");
|
||||
#else
|
||||
sendMessage_2lvl(wstring(L"processing file '") + wstring(toSendStrMessage.begin(), toSendStrMessage.end()) + L"'");
|
||||
#endif
|
||||
sendMessage_2lvl(3, toSendStrMessage);
|
||||
sendMessage_progress(std::to_wstring((int)(((double)(n - i) / n) * 100)));
|
||||
|
||||
const char *file_name = file->filename();
|
||||
@@ -909,7 +901,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
else if (curr_regime == ADD_TEMPL_TO_USE_ONLY)
|
||||
fixUseOnlyStmt(file, parallelRegions);
|
||||
else if (curr_regime == GCOV_PARSER)
|
||||
parse_gcovfile(file, consoleMode == 1 ? file_name : "./visualiser_data/gcov/" + string(file_name), getObjectForFileFromMap(file_name, gCovInfo), keepFiles);
|
||||
parse_gcovfile(file, consoleMode == 1 ? file_name : string(VISUALIZER_DATA_PATH) + "/gcov/" + file_name, getObjectForFileFromMap(file_name, gCovInfo), keepFiles);
|
||||
else if(curr_regime == PRIVATE_ARRAYS_EXPANSION)
|
||||
{
|
||||
auto founded = loopGraph.find(file->filename());
|
||||
@@ -961,7 +953,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
vector<string> include_functions;
|
||||
|
||||
createInterTree(file, getObjectForFileFromMap(file_name, intervals), removeNestedIntervals, getObjectForFileFromMap(file_name, SPF_messages));
|
||||
assignCallsToFile(consoleMode == 1 ? file_name : "./visualiser_data/gcov/" + string(file_name), getObjectForFileFromMap(file_name, intervals));
|
||||
assignCallsToFile(consoleMode == 1 ? file_name : string(VISUALIZER_DATA_PATH) + "/gcov/" + file_name, getObjectForFileFromMap(file_name, intervals));
|
||||
removeNodes(intervals_threshold, getObjectForFileFromMap(file_name, intervals), include_functions);
|
||||
}
|
||||
else if (curr_regime == INSERT_INTER_TREE)
|
||||
@@ -1028,6 +1020,8 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
if(func->funcPointer->variant() != ENTRY_STAT)
|
||||
countOfTransform += removeDeadCode(func->funcPointer, allFuncInfo, commonBlocks);
|
||||
}
|
||||
else if (curr_regime == FIND_PRIVATE_ARRAYS)
|
||||
FindPrivateArrays(loopGraph, fullIR);
|
||||
else if (curr_regime == TEST_PASS)
|
||||
{
|
||||
//test pass
|
||||
@@ -1056,7 +1050,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
throw -11;
|
||||
}
|
||||
|
||||
sendMessage_2lvl(wstring(L""));
|
||||
sendMessage_2lvl(2);
|
||||
// ********************************** ///
|
||||
/// SECOND AGGREGATION STEP ///
|
||||
// ********************************** ///
|
||||
@@ -1288,7 +1282,6 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
detectCopies(allFuncInfo);
|
||||
fillInterfaceBlock(allFuncInfo);
|
||||
intentInsertToInterfaces(allFuncInfo);
|
||||
createInterfacesForAssumedSize(allFuncInfo);
|
||||
|
||||
//this call is only for testing
|
||||
//setPureStatus(allFuncInfo);
|
||||
@@ -1712,7 +1705,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
}
|
||||
else if (curr_regime == GCOV_PARSER)
|
||||
{
|
||||
parseTimesDvmStatisticFile((consoleMode == 1) ? string("statistic.txt") : "./visualiser_data/statistic/" + string("statistic.txt"), intervals);
|
||||
parseTimesDvmStatisticFile((consoleMode == 1) ? string("statistic.txt") : string(VISUALIZER_DATA_PATH) + "/statistic/statistic.txt", intervals);
|
||||
|
||||
//fixed count, devide by value from PROG_HEDR
|
||||
SgStatement* mainUnit = findMainUnit(&project, SPF_messages);
|
||||
@@ -1736,103 +1729,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
}
|
||||
}
|
||||
else if (curr_regime == PREDICT_SCHEME)
|
||||
{
|
||||
int maxSizeDist = 0;
|
||||
for (int z = 0; z < parallelRegions.size(); ++z)
|
||||
{
|
||||
const DataDirective &dataDirectives = parallelRegions[z]->GetDataDir();
|
||||
const vector<int> ¤tVariant = parallelRegions[z]->GetCurrentVariant();
|
||||
|
||||
auto &tmp = dataDirectives.distrRules;
|
||||
vector<pair<DIST::Array*, const DistrVariant*>> currentVar;
|
||||
for (int z1 = 0; z1 < currentVariant.size(); ++z1)
|
||||
currentVar.push_back(make_pair(tmp[z1].first, &tmp[z1].second[currentVariant[z1]]));
|
||||
|
||||
for (auto &elem : currentVar)
|
||||
{
|
||||
DIST::Array *array = elem.first;
|
||||
const DistrVariant *var = elem.second;
|
||||
|
||||
int countBlock = 0;
|
||||
for (int z = 0; z < var->distRule.size(); ++z)
|
||||
if (var->distRule[z] == dist::BLOCK)
|
||||
++countBlock;
|
||||
maxSizeDist = std::max(maxSizeDist, countBlock);
|
||||
}
|
||||
}
|
||||
|
||||
SpfInterval *mainIterval = getMainInterval(&project, intervals, SPF_messages);
|
||||
topologies.clear();
|
||||
if (maxSizeDist)
|
||||
{
|
||||
const int procNum = 8;
|
||||
//TODO:
|
||||
//topologies = getTopologies(procNum, maxSizeDist);
|
||||
throw -10;
|
||||
|
||||
const int countOfTop = topologies.size();
|
||||
if (countOfTop < 0)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
for (auto &inter : intervals)
|
||||
initTimeForIntervalTree(countOfTop, inter.second);
|
||||
|
||||
for (int z = 0; z < parallelRegions.size(); ++z)
|
||||
{
|
||||
const DataDirective &dataDirectives = parallelRegions[z]->GetDataDir();
|
||||
const vector<int> ¤tVariant = parallelRegions[z]->GetCurrentVariant();
|
||||
DIST::Arrays<int> &allArrays = parallelRegions[z]->GetAllArraysToModify();
|
||||
|
||||
auto &tmp = dataDirectives.distrRules;
|
||||
vector<pair<DIST::Array*, const DistrVariant*>> currentVar;
|
||||
for (int z1 = 0; z1 < currentVariant.size(); ++z1)
|
||||
currentVar.push_back(make_pair(tmp[z1].first, &tmp[z1].second[currentVariant[z1]]));
|
||||
|
||||
map<LoopGraph*, ParallelDirective*> parallelDirs;
|
||||
vector<std::tuple<DIST::Array*, vector<long>, pair<string, int>>> allSingleRemotes;
|
||||
for (int i = n - 1; i >= 0; --i)
|
||||
{
|
||||
SgFile *file = &(project.file(i));
|
||||
auto fountInfo = findAllDirectives(file, getObjectForFileFromMap(file->filename(), loopGraph), parallelRegions[z]->GetId());
|
||||
parallelDirs.insert(fountInfo.begin(), fountInfo.end());
|
||||
|
||||
auto fountRem = findAllSingleRemotes(file, parallelRegions[z]->GetId(), parallelRegions);
|
||||
allSingleRemotes.insert(allSingleRemotes.end(), fountRem.begin(), fountRem.end());
|
||||
}
|
||||
//TODO!
|
||||
//int err = predictScheme(parallelRegions[z], currentVar, allArrays.GetArrays(), parallelDirs, intervals, SPF_messages, allSingleRemotes, maxSizeDist, procNum);
|
||||
/*if (err != 0)
|
||||
internalExit = err;*/
|
||||
}
|
||||
|
||||
vector<SpfInterval*> tmp = { mainIterval };
|
||||
aggregatePredictedTimes(tmp);
|
||||
|
||||
int idx = 0;
|
||||
int best = -1;
|
||||
double bestSpeedUp = 0;
|
||||
for (auto &top : topologies)
|
||||
{
|
||||
string outStr = "";
|
||||
for (auto &elem : top)
|
||||
outStr += std::to_string(elem) + " ";
|
||||
double currS = mainIterval->exec_time / mainIterval->predictedTimes[idx];
|
||||
__spf_print(1, "%d: speed up %f for top. %s\n", idx, currS, outStr.c_str());
|
||||
|
||||
if (best == -1 || bestSpeedUp < currS)
|
||||
{
|
||||
bestSpeedUp = currS;
|
||||
best = idx;
|
||||
}
|
||||
++idx;
|
||||
}
|
||||
__spf_print(1, "best topology %d with speed up %f\n", best, bestSpeedUp);
|
||||
}
|
||||
else
|
||||
for (auto &inter : intervals)
|
||||
initTimeForIntervalTree(0, inter.second);
|
||||
|
||||
}
|
||||
runPredictScheme(project, topologies, parallelRegions, loopGraph, SPF_messages);
|
||||
else if (curr_regime == CREATE_INTER_TREE)
|
||||
{
|
||||
if (keepFiles)
|
||||
@@ -1922,12 +1819,14 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
calculateStatsForPredictor(allFuncInfo, gCovInfo);
|
||||
parseDvmDirForPredictor(declaredArrays, commonBlocks, allFuncInfo, gCovInfo);
|
||||
}
|
||||
else if (curr_regime == TRANSFORM_ASSUMED_SIZE_PARAMETERS)
|
||||
transformAssumedSizeParameters(allFuncInfo);
|
||||
|
||||
const float elapsed = duration_cast<milliseconds>(high_resolution_clock::now() - timeForPass).count() / 1000.;
|
||||
const float elapsedGlobal = duration_cast<milliseconds>(high_resolution_clock::now() - globalTime).count() / 1000.;
|
||||
__spf_print(1, "PROFILE: time for this pass = %f sec (total %f sec)\n", elapsed, elapsedGlobal);
|
||||
|
||||
sendMessage_2lvl(wstring(L""));
|
||||
sendMessage_2lvl(2);
|
||||
if (internalExit != 0)
|
||||
throw -1;
|
||||
|
||||
@@ -2157,6 +2056,8 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam
|
||||
runAnalysis(*project, REMOVE_COPIES, false);
|
||||
runAnalysis(*project, SWAP_LOOPS, false);
|
||||
|
||||
runPass(TRANSFORM_ASSUMED_SIZE_PARAMETERS, proj_name, folderName);
|
||||
|
||||
if (folderName || consoleMode)
|
||||
runAnalysis(*project, UNPARSE_FILE, true, additionalName.c_str(), folderName);
|
||||
}
|
||||
@@ -2224,9 +2125,8 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam
|
||||
|
||||
runAnalysis(*project, CALCULATE_STATS_SCHEME, false);
|
||||
|
||||
//TODO: need to rewrite this to new algo
|
||||
/*if (!folderName && !consoleMode || predictOn)
|
||||
runAnalysis(*project, PREDICT_SCHEME, false); */
|
||||
if (!folderName && !consoleMode || predictOn)
|
||||
runAnalysis(*project, PREDICT_SCHEME, false);
|
||||
|
||||
runAnalysis(*project, REMOVE_COPIES, false);
|
||||
runAnalysis(*project, SWAP_LOOPS, false);
|
||||
@@ -2372,7 +2272,6 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam
|
||||
case LOOPS_COMBINER:
|
||||
case FIX_COMMON_BLOCKS:
|
||||
case TEST_PASS:
|
||||
case FIND_PARAMETERS:
|
||||
case SET_IMPLICIT_NONE:
|
||||
runAnalysis(*project, curr_regime, false);
|
||||
case SUBST_EXPR_RD_AND_UNPARSE:
|
||||
@@ -2640,7 +2539,10 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (curr_regime == INSERT_PARALLEL_DIRS_NODIST)
|
||||
{
|
||||
ignoreArrayDistributeState = true;
|
||||
sharedMemoryParallelization = 1;
|
||||
}
|
||||
|
||||
if (runAsClient)
|
||||
{
|
||||
@@ -2662,32 +2564,12 @@ int main(int argc, char **argv)
|
||||
printStackTrace();
|
||||
printf("exception occurred\n");
|
||||
|
||||
json byFileArray = json::array();
|
||||
for (auto& byFile : SPF_messages)
|
||||
{
|
||||
json inFile;
|
||||
inFile["file"] = byFile.first;
|
||||
|
||||
json messages = json::array();
|
||||
for (auto& message : byFile.second)
|
||||
{
|
||||
message.print(byFile.first);
|
||||
messages.push_back(message.toJson());
|
||||
}
|
||||
inFile["messages"] = messages;
|
||||
byFileArray.push_back(inFile);
|
||||
}
|
||||
json allMessages;
|
||||
allMessages["allMessage"] = byFileArray;
|
||||
|
||||
FILE* outF = fopen("dump_messages.json", "w");
|
||||
fprintf(outF, "%s", allMessages.dump().c_str());
|
||||
fclose(outF);
|
||||
dumpMessages(true, SPF_messages, VISUALIZER_DATA_PATH);
|
||||
}
|
||||
dumpMessages(false, SPF_messages, VISUALIZER_DATA_PATH);
|
||||
|
||||
deleteAllAllocatedData(withDel);
|
||||
|
||||
|
||||
#if _WIN32 && _DEBUG
|
||||
if (leakMemDump)
|
||||
{
|
||||
|
||||
@@ -183,6 +183,10 @@ enum passes {
|
||||
SET_IMPLICIT_NONE,
|
||||
RENAME_INLCUDES,
|
||||
|
||||
FIND_PRIVATE_ARRAYS,
|
||||
|
||||
TRANSFORM_ASSUMED_SIZE_PARAMETERS,
|
||||
|
||||
TEST_PASS,
|
||||
EMPTY_PASS
|
||||
};
|
||||
@@ -367,6 +371,9 @@ static void setPassValues()
|
||||
passNames[SET_IMPLICIT_NONE] = "SET_IMPLICIT_NONE";
|
||||
passNames[RENAME_INLCUDES] = "RENAME_INLCUDES";
|
||||
passNames[INSERT_NO_DISTR_FLAGS_FROM_GUI] = "INSERT_NO_DISTR_FLAGS_FROM_GUI";
|
||||
passNames[FIND_PRIVATE_ARRAYS] = "FIND_PRIVATE_ARRAYS";
|
||||
|
||||
passNames[TRANSFORM_ASSUMED_SIZE_PARAMETERS] = "TRANSFORM_ASSUMED_SIZE_PARAMETERS";
|
||||
|
||||
passNames[TEST_PASS] = "TEST_PASS";
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ bool withTemplateInfo = false;
|
||||
bool inlcudeAllFiles = false; // for pass INSERT_INLCUDES
|
||||
bool runAsClient = false; // run console project as client for Visualizer
|
||||
bool printSymbTable = false;
|
||||
const char* VISUALIZER_DATA_PATH = "visualiser_data";
|
||||
|
||||
uint64_t currentAvailMemory = 0;
|
||||
int QUALITY; // quality of conflicts search in graph
|
||||
@@ -131,7 +132,7 @@ std::map<std::string, PredictorStats> allPredictorStats;
|
||||
|
||||
//for DVM INTERVALS
|
||||
std::map<std::string, std::vector<SpfInterval*>> intervals; // file -> intervals
|
||||
std::vector<std::vector<long>> topologies; // current topologies
|
||||
std::vector<std::vector<size_t>> topologies; // current topologies
|
||||
//
|
||||
|
||||
//for GCOV_PARSER
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
#include "../Distribution/Array.h"
|
||||
#include "dvm.h"
|
||||
|
||||
#include "../Utils/errors.h"
|
||||
#include "../Utils/utils.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "errors.h"
|
||||
#include "utils.h"
|
||||
#include "SgUtils.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user