Compare commits
1 Commits
aec4ddab67
...
11f8d3804d
| Author | SHA1 | Date | |
|---|---|---|---|
| 11f8d3804d |
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,6 +1,3 @@
|
||||
[submodule "projects/dvm"]
|
||||
path = projects/dvm
|
||||
url = https://dvmguest:dvmguest@dvm.keldysh.ru/dvm-system/dvm
|
||||
[submodule "projects/libpredictor"]
|
||||
path = projects/libpredictor
|
||||
url = https://dvmguest:dvmguest@dvm.keldysh.ru/sapfor/dvm-perfm
|
||||
|
||||
@@ -13,18 +13,16 @@ add_definitions("-D YYDEBUG")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
set(fdvm_include projects/dvm/fdvmh/include/fdvmh/)
|
||||
set(fdvm_sources projects/dvm/fdvmh/tools/fdvmh/)
|
||||
set(sage_include_1 projects/dvm/fdvmh/include/sage/lib/)
|
||||
set(sage_include_2 projects/dvm/fdvmh/include/sage/h/)
|
||||
set(libdb_sources projects/dvm/fdvmh/lib/sage/db/)
|
||||
set(sage_sources projects/dvm/fdvmh/lib/sage/sage/)
|
||||
set(sagepp_sources projects/dvm/fdvmh/lib/sage/sage++/)
|
||||
set(parser_sources projects/dvm/fdvmh/tools/parser/)
|
||||
set(pppa_sources projects/dvm/pppa/src/)
|
||||
set(zlib_sources projects/dvm/third-party/Zlib/)
|
||||
set(libpred_sources projects/libpredictor/src/)
|
||||
set(libpred_include projects/libpredictor/include/)
|
||||
set(fdvm_include projects/dvm/fdvmh/include/fdvmh/)
|
||||
set(fdvm_sources projects/dvm/fdvmh/tools/fdvmh/)
|
||||
set(sage_include_1 projects/dvm/fdvmh/include/sage/lib/)
|
||||
set(sage_include_2 projects/dvm/fdvmh/include/sage/h/)
|
||||
set(libdb_sources projects/dvm/fdvmh/lib/sage/db/)
|
||||
set(sage_sources projects/dvm/fdvmh/lib/sage/sage/)
|
||||
set(sagepp_sources projects/dvm/fdvmh/lib/sage/sage++/)
|
||||
set(parser_sources projects/dvm/fdvmh/tools/parser/)
|
||||
set(pppa_sources projects/dvm/pppa/src/)
|
||||
set(zlib_sources projects/dvm/third-party/Zlib/)
|
||||
|
||||
include_directories(src)
|
||||
#Sage lib includes
|
||||
@@ -35,8 +33,6 @@ include_directories(${sage_include_2})
|
||||
include_directories(${zlib_sources}/include)
|
||||
#PPPA includes
|
||||
include_directories(${pppa_sources})
|
||||
#Libpredictor includes
|
||||
include_directories(${libpred_include})
|
||||
|
||||
set(PR_PARAM src/ProjectParameters/projectParameters.cpp
|
||||
src/ProjectParameters/projectParameters.h)
|
||||
@@ -58,7 +54,7 @@ set(VS_CALLS src/VisualizerCalls/get_information.cpp
|
||||
src/VisualizerCalls/SendMessage.h
|
||||
src/VisualizerCalls/BuildGraph.cpp
|
||||
src/VisualizerCalls/BuildGraph.h)
|
||||
|
||||
|
||||
set(VERIF src/VerificationCode/CorrectVarDecl.cpp
|
||||
src/VerificationCode/IncludeChecker.cpp
|
||||
src/VerificationCode/StructureChecker.cpp
|
||||
@@ -80,8 +76,7 @@ set(UTILS src/Utils/AstWrapper.h
|
||||
src/Utils/utils.h
|
||||
src/Utils/version.h
|
||||
src/Utils/module_utils.h
|
||||
src/Utils/module_utils.cpp
|
||||
src/Utils/json.hpp)
|
||||
src/Utils/module_utils.cpp)
|
||||
|
||||
set(OMEGA src/SageAnalysisTool/OmegaForSage/add-assert.cpp
|
||||
src/SageAnalysisTool/OmegaForSage/affine.cpp
|
||||
@@ -316,15 +311,6 @@ set(MAIN src/Sapfor.cpp
|
||||
|
||||
set(PREDICTOR src/Predictor/PredictScheme.cpp
|
||||
src/Predictor/PredictScheme.h)
|
||||
|
||||
set(LIBPREDICTOR ${libpred_sources}/cluster.cpp
|
||||
${libpred_sources}/predictor.cpp
|
||||
${libpred_sources}/transfer.cpp
|
||||
${libpred_sources}/utils.cpp
|
||||
${libpred_include}/libpredict/predictor.h
|
||||
${libpred_include}/internal/cluster.h
|
||||
${libpred_include}/internal/transfer.h
|
||||
${libpred_include}/internal/utils.h)
|
||||
|
||||
set(PROJ_MAN src/ProjectManipulation/ParseFiles.cpp
|
||||
src/ProjectManipulation/ParseFiles.h
|
||||
@@ -414,7 +400,6 @@ set(SOURCE_EXE
|
||||
${VS_CALLS}
|
||||
${MAIN}
|
||||
${PREDICTOR}
|
||||
${LIBPREDICTOR}
|
||||
${PARSER}
|
||||
${PPPA}
|
||||
${ZLIB}
|
||||
@@ -469,8 +454,7 @@ source_group (VisualizerCalls FILES ${VS_CALLS})
|
||||
source_group (VisualizerCalls\\GraphLayout FILES ${GR_LAYOUT})
|
||||
|
||||
source_group (_SapforMain FILES ${MAIN})
|
||||
source_group (Predictor\\Analyzer FILES ${PREDICTOR})
|
||||
source_group (Predictor\\Library FILES ${LIBPREDICTOR})
|
||||
source_group (Predictor FILES ${PREDICTOR})
|
||||
source_group (Parser FILES ${PARSER})
|
||||
source_group (PPPA\\PPPA FILES ${PPPA})
|
||||
source_group (PPPA\\ZLib FILES ${ZLIB})
|
||||
|
||||
Submodule projects/dvm updated: a711f8ebfd...c00e381812
Submodule projects/libpredictor deleted from d0772cdb57
@@ -17,6 +17,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
#define DVMH_REG_RD 0
|
||||
#define DVMH_REG_WT 1
|
||||
|
||||
@@ -834,21 +835,19 @@ static string getInterfaceBlock(SgStatement* func, const FuncParam& pars)
|
||||
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();
|
||||
SgStatement* next = st->lexNext();
|
||||
st->extractStmt();
|
||||
st = next;
|
||||
}
|
||||
else
|
||||
st = st->lexNext();
|
||||
@@ -870,7 +869,6 @@ static string getInterfaceBlock(SgStatement* func, const FuncParam& pars)
|
||||
while (st != last)
|
||||
{
|
||||
const int var = st->variant();
|
||||
|
||||
if (var == VAR_DECL
|
||||
|| var == VAR_DECL_90
|
||||
|| var == DIM_STAT
|
||||
@@ -880,8 +878,9 @@ static string getInterfaceBlock(SgStatement* func, const FuncParam& pars)
|
||||
bool empty = filterFromList(st, idents);
|
||||
if (empty)
|
||||
{
|
||||
SgStatement* next = st->lexNext();
|
||||
toExtract.push_back(st);
|
||||
st = st->lexNext();
|
||||
st = next;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -1429,15 +1428,21 @@ static set<DIST::Array*>
|
||||
|
||||
for (auto& realArray : realRef)
|
||||
{
|
||||
if (added.count(realArray) != 0)
|
||||
continue;
|
||||
|
||||
if (!realArray->IsNotDistribute())
|
||||
if (added.count(realArray) != 0 || !realArray->IsNotDistribute())
|
||||
continue;
|
||||
|
||||
SgStatement* declStat = NULL;
|
||||
|
||||
if (realArray->GetLocation().first == DIST::l_COMMON)
|
||||
if (realArray->GetLocation().first != DIST::l_COMMON)
|
||||
{
|
||||
if (std::count(usedAll.begin(), usedAll.end(), realArray) == 0)
|
||||
{
|
||||
auto declInfo = *realArray->GetDeclInfo().begin();
|
||||
declStat = SgStatement::getStatementByFileAndLine(declInfo.first, declInfo.second);
|
||||
checkNull(declStat, convertFileName(__FILE__).c_str(), __LINE__);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
commonArrays.insert(realArray);
|
||||
auto decls = realArray->GetDeclInfo();
|
||||
@@ -1466,19 +1471,6 @@ static set<DIST::Array*>
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (realArray->GetLocation().first == DIST::l_MODULE)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
else
|
||||
{
|
||||
if (std::count(usedAll.begin(), usedAll.end(), realArray) == 0)
|
||||
{
|
||||
auto declInfo = *realArray->GetDeclInfo().begin();
|
||||
declStat = SgStatement::getStatementByFileAndLine(declInfo.first, declInfo.second);
|
||||
checkNull(declStat, convertFileName(__FILE__).c_str(), __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
if (declStat)
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include "../GraphLoop/graph_loops_func.h"
|
||||
#include "../DirectiveProcessing/directive_parser.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "../Utils/json.hpp"
|
||||
#include "../ParallelizationRegions/ParRegions_func.h"
|
||||
#include "../DynamicAnalysis/gCov_parser_func.h"
|
||||
#include "../ExpressionTransform/expr_transform.h"
|
||||
@@ -38,8 +37,6 @@ using std::cout;
|
||||
using std::endl;
|
||||
using std::stack;
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
//TODO: improve parameter checking
|
||||
@@ -2595,71 +2592,4 @@ void setInlineAttributeToCalls(const map<string, FuncInfo*>& allFunctions,
|
||||
}
|
||||
}
|
||||
|
||||
static json convertToJson(const FuncInfo* currFunc) {
|
||||
json func;
|
||||
|
||||
if (currFunc)
|
||||
{
|
||||
func["funcName"] = currFunc->funcName;
|
||||
func["line"] = currFunc->linesNum.first;
|
||||
func["lineEnd"] = currFunc->linesNum.second;
|
||||
func["isMain"] = (int)currFunc->isMain;
|
||||
func["needToInline"] = (int)currFunc->needToInline;
|
||||
func["doNotInline"] = (int)currFunc->doNotInline;
|
||||
func["doNotAnalyze"] = (int)currFunc->doNotAnalyze;
|
||||
|
||||
json func_pars = json::array();
|
||||
|
||||
for (int z = 0; z < currFunc->funcParams.countOfPars; ++z)
|
||||
{
|
||||
json par;
|
||||
par["inoutType"] = currFunc->funcParams.inout_types[z];
|
||||
par["identificator"] = currFunc->funcParams.identificators[z];
|
||||
par["parameterT"] = string(paramNames[currFunc->funcParams.parametersT[z]]);
|
||||
|
||||
func_pars.push_back(par);
|
||||
}
|
||||
|
||||
func["params"] = func_pars;
|
||||
|
||||
json calls_from = json::array();
|
||||
for (const auto& call_from : currFunc->callsFromDetailed)
|
||||
{
|
||||
json call;
|
||||
call["line"] = call_from.detailCallsFrom.second;
|
||||
call["funcName"] = call_from.detailCallsFrom.first;
|
||||
|
||||
calls_from.push_back(call);
|
||||
}
|
||||
func["callsFrom"] = calls_from;
|
||||
}
|
||||
return func;
|
||||
}
|
||||
|
||||
json convertToJson(const map<string, vector<FuncInfo*>>& funcsByFileMap) {
|
||||
json loopsByFile = json::array();
|
||||
|
||||
for (auto& byFile : funcsByFileMap)
|
||||
{
|
||||
json func;
|
||||
const string& file = byFile.first;
|
||||
|
||||
json func_array = json::array();
|
||||
for (auto& func : byFile.second)
|
||||
{
|
||||
auto conv = convertToJson(func);
|
||||
if (!conv.empty())
|
||||
func_array.push_back(conv);
|
||||
}
|
||||
|
||||
func["file"] = file;
|
||||
func["functions"] = func_array;
|
||||
|
||||
loopsByFile.push_back(func);
|
||||
}
|
||||
|
||||
json allFuncs;
|
||||
allFuncs["allFunctions"] = loopsByFile;
|
||||
return allFuncs;
|
||||
}
|
||||
#undef DEBUG
|
||||
|
||||
@@ -378,6 +378,33 @@ FuncInfo* isUserFunctionInProject(const string &func)
|
||||
return ret;
|
||||
}
|
||||
|
||||
string convertToString(const FuncInfo *currFunc)
|
||||
{
|
||||
string result = "";
|
||||
if (currFunc)
|
||||
{
|
||||
result += "|" + currFunc->funcName + "|" + to_string(currFunc->linesNum.first) +
|
||||
"#" + to_string(currFunc->linesNum.second) +
|
||||
"#" + to_string(currFunc->callsFromDetailed.size()) +
|
||||
"#" + to_string(currFunc->needToInline) + "#" + to_string(currFunc->doNotInline) +
|
||||
"#" + to_string(currFunc->doNotAnalyze) + "#" + to_string((int)currFunc->isMain);
|
||||
|
||||
result += "#" + to_string(currFunc->funcParams.countOfPars);
|
||||
if (currFunc->funcParams.countOfPars)
|
||||
{
|
||||
for (int z = 0; z < currFunc->funcParams.countOfPars; ++z)
|
||||
{
|
||||
result += "#" + currFunc->funcParams.identificators[z] + "#" + to_string(currFunc->funcParams.inout_types[z]);
|
||||
result += "#" + string(paramNames[currFunc->funcParams.parametersT[z]]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < currFunc->callsFromDetailed.size(); ++i)
|
||||
result += "|" + currFunc->callsFromDetailed[i].detailCallsFrom.first + "|" + to_string(currFunc->callsFromDetailed[i].detailCallsFrom.second);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Find dead functions and fill callTo / callFrom information
|
||||
void findDeadFunctionsAndFillCalls(map<string, vector<FuncInfo*>> &allFuncInfo, map<string, vector<Messages>> &allMessages, bool noPrint)
|
||||
{
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "graph_calls.h"
|
||||
#include "../GraphLoop/graph_loops.h"
|
||||
#include "../ParallelizationRegions/ParRegions.h"
|
||||
#include "Utils/json.hpp"
|
||||
|
||||
namespace Distribution
|
||||
{
|
||||
@@ -24,6 +23,7 @@ int CreateCallGraphViz(const char *fileName, const std::map<std::string, std::ve
|
||||
int CreateFuncInfo(const char *fileName, const std::map<std::string, std::vector<FuncInfo*>> &funcByFile);
|
||||
std::string removeString(const std::string &toRemove, const std::string &inStr);
|
||||
FuncInfo* isUserFunctionInProject(const std::string &func);
|
||||
std::string convertToString(const FuncInfo *currFunc);
|
||||
void findDeadFunctionsAndFillCalls(std::map<std::string, std::vector<FuncInfo*>> &allFuncInfo, std::map<std::string, std::vector<Messages>> &allMessages, bool noPrint = false);
|
||||
void createLinksBetweenFormalAndActualParams(std::map<std::string, std::vector<FuncInfo*>> &allFuncInfo, std::map<DIST::Array*, std::set<DIST::Array*>> &arrayLinksByFuncCalls,
|
||||
const std::map<std::tuple<int, std::string, std::string>, std::pair<DIST::Array*, DIST::ArrayAccessInfo*>> &declaredArrays,
|
||||
@@ -53,6 +53,5 @@ void findContainsFunctions(SgStatement *st, std::vector<SgStatement*> &found, co
|
||||
void correctNameIfContains(SgStatement* call, SgExpression* exCall, std::string& name, const std::vector<SgStatement*>& containsFunctions, const std::string& prefix);
|
||||
int countPerfectLoopNest(SgStatement* st);
|
||||
void setInlineAttributeToCalls(const std::map<std::string, FuncInfo*>& allFunctions, const std::map<std::string, std::set<std::pair<std::string, int>>>& inDataChains, const std::map<std::string, std::vector<SgStatement*>>& hiddenData);
|
||||
nlohmann::json convertToJson(const std::map<std::string, std::vector<FuncInfo*>>& funcsByFile);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -26,11 +26,11 @@
|
||||
|
||||
#include "../Utils/errors.h"
|
||||
#include "../Utils/AstWrapper.h"
|
||||
#include "../Utils/json.hpp"
|
||||
|
||||
#include "../DirectiveProcessing/directive_parser.h"
|
||||
#include "../DynamicAnalysis/gCov_parser_func.h"
|
||||
|
||||
#include "../GraphCall/graph_calls_func.h"
|
||||
#include "../Transformations/array_assign_to_loop.h"
|
||||
|
||||
using std::vector;
|
||||
@@ -40,8 +40,6 @@ using std::string;
|
||||
using std::wstring;
|
||||
using std::pair;
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
#define DEBUG 0
|
||||
static inline void insertLabels(SgExpression *lb, map<int, vector<int>> &gotoLabels, const int line)
|
||||
{
|
||||
@@ -920,7 +918,7 @@ void* LoopGraph::getRealStat(const char* file) const
|
||||
}
|
||||
|
||||
extern int PASSES_DONE[EMPTY_PASS];
|
||||
static int getLoopState(const LoopGraph* currLoop)
|
||||
static void printToBuffer(const LoopGraph *currLoop, const int childSize, char buf[512])
|
||||
{
|
||||
int loopState = 0; // 0 - unknown, 1 - good, 2 - bad
|
||||
if (PASSES_DONE[CREATE_TEMPLATE_LINKS] ||
|
||||
@@ -936,92 +934,49 @@ static int getLoopState(const LoopGraph* currLoop)
|
||||
if (currLoop->hasLimitsToParallel())
|
||||
loopState = 2;
|
||||
}
|
||||
|
||||
return loopState;
|
||||
sprintf(buf, "#%d#%d#%d#%d#%d#%d#%d#%d",
|
||||
currLoop->lineNum, currLoop->lineNumAfterLoop, currLoop->perfectLoop, currLoop->hasGoto, currLoop->hasPrints, childSize, loopState,
|
||||
currLoop->hasNonRectangularBounds);
|
||||
}
|
||||
|
||||
static json convertToJson(const LoopGraph* currLoop)
|
||||
static int calculateNormalChildSize(const LoopGraph *currLoop)
|
||||
{
|
||||
json loop;
|
||||
int count = 0;
|
||||
for (auto &elem : currLoop->children)
|
||||
count += (elem->lineNum > 0) ? 1 : 0;
|
||||
return count;
|
||||
}
|
||||
|
||||
void convertToString(const LoopGraph *currLoop, string &result)
|
||||
{
|
||||
if (currLoop && currLoop->lineNum > 0)
|
||||
{
|
||||
loop["file"] = currLoop->fileName;
|
||||
loop["line"] = currLoop->lineNum;
|
||||
loop["lineNumAfterLoop"] = currLoop->lineNumAfterLoop;
|
||||
loop["perfectLoop"] = currLoop->perfectLoop;
|
||||
loop["loopState"] = getLoopState(currLoop);
|
||||
loop["hasNonRectangularBounds"] = (int)currLoop->hasNonRectangularBounds;
|
||||
char buf[512];
|
||||
result += "#" + std::to_string(currLoop->calls.size());
|
||||
for (int i = 0; i < currLoop->calls.size(); ++i)
|
||||
result += "#" + currLoop->calls[i].first + "#" + std::to_string(currLoop->calls[i].second);
|
||||
printToBuffer(currLoop, calculateNormalChildSize(currLoop), buf);
|
||||
result += string(buf);
|
||||
|
||||
json calls = json::array();
|
||||
for (auto& [func, line] : currLoop->calls)
|
||||
{
|
||||
json call;
|
||||
call["line"] = line;
|
||||
call["funcName"] = func;
|
||||
result += "#" + std::to_string(currLoop->linesOfExternalGoTo.size());
|
||||
for (int i = 0; i < currLoop->linesOfExternalGoTo.size(); ++i)
|
||||
result += "#" + std::to_string(currLoop->linesOfExternalGoTo[i]);
|
||||
|
||||
calls.push_back(call);
|
||||
}
|
||||
loop["funcCalls"] = calls;
|
||||
result += "#" + std::to_string(currLoop->linesOfInternalGoTo.size());
|
||||
for (int i = 0; i < currLoop->linesOfInternalGoTo.size(); ++i)
|
||||
result += "#" + std::to_string(currLoop->linesOfInternalGoTo[i]);
|
||||
|
||||
json e_gotos = json::array();
|
||||
for (auto& line : currLoop->linesOfExternalGoTo)
|
||||
e_gotos.push_back(line);
|
||||
loop["extGotos"] = e_gotos;
|
||||
result += "#" + std::to_string(currLoop->linesOfIO.size());
|
||||
for (auto& i : currLoop->linesOfIO)
|
||||
result += "#" + std::to_string(i);
|
||||
|
||||
json i_gotos = json::array();
|
||||
for (auto& line : currLoop->linesOfInternalGoTo)
|
||||
i_gotos.push_back(line);
|
||||
loop["intGotos"] = i_gotos;
|
||||
result += "#" + std::to_string(currLoop->linesOfStop.size());
|
||||
for (auto& i : currLoop->linesOfStop)
|
||||
result += "#" + std::to_string(i);
|
||||
|
||||
json ios = json::array();
|
||||
for (auto& line : currLoop->linesOfIO)
|
||||
ios.push_back(line);
|
||||
loop["ios"] = ios;
|
||||
|
||||
json stops = json::array();
|
||||
for (auto& line : currLoop->linesOfStop)
|
||||
stops.push_back(line);
|
||||
loop["stops"] = stops;
|
||||
|
||||
json children = json::array();
|
||||
for (const auto& ch : currLoop->children)
|
||||
{
|
||||
auto conv = convertToJson(ch);
|
||||
if (!conv.empty())
|
||||
children.push_back(conv);
|
||||
}
|
||||
loop["children"] = children;
|
||||
for (int i = 0; i < (int)currLoop->children.size(); ++i)
|
||||
convertToString(currLoop->children[i], result);
|
||||
}
|
||||
return loop;
|
||||
}
|
||||
|
||||
json convertToJson(const map<string, vector<LoopGraph*>>& loopsByFileMap)
|
||||
{
|
||||
json loopsByFile = json::array();
|
||||
|
||||
for (auto& byFile : loopsByFileMap)
|
||||
{
|
||||
json loop;
|
||||
const string& file = byFile.first;
|
||||
|
||||
json loops_array = json::array();
|
||||
for (auto& loop : byFile.second)
|
||||
{
|
||||
auto conv = convertToJson(loop);
|
||||
if (!conv.empty())
|
||||
loops_array.push_back(conv);
|
||||
}
|
||||
|
||||
loop["file"] = file;
|
||||
loop["loops"] = loops_array;
|
||||
|
||||
loopsByFile.push_back(loop);
|
||||
}
|
||||
|
||||
json allLoops;
|
||||
allLoops["allLoops"] = loopsByFile;
|
||||
return allLoops;
|
||||
}
|
||||
|
||||
void createMapLoopGraph(const vector<LoopGraph*> &loops, map<int, LoopGraph*> &mapGraph)
|
||||
|
||||
@@ -497,6 +497,7 @@ void processLoopInformationForFunction(std::map<LoopGraph*, std::map<DIST::Array
|
||||
void addToDistributionGraph(const std::map<LoopGraph*, std::map<DIST::Array*, ArrayInfo*>>& loopInfo, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls);
|
||||
void selectFreeLoopsForParallelization(const std::vector<LoopGraph*>& loops, const std::string& funcName, bool isDistribute, const std::vector<ParallelRegion*>& regions, std::vector<Messages>& messagesForFile);
|
||||
|
||||
void convertToString(const LoopGraph* currLoop, std::string& result);
|
||||
int printLoopGraph(const char* fileName, const std::map<std::string, std::vector<LoopGraph*>>& loopGraph, bool withRegs = false);
|
||||
void checkCountOfIter(std::map<std::string, std::vector<LoopGraph*>>& loopGraph, const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo, std::map<std::string, std::vector<Messages>>& SPF_messages);
|
||||
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "graph_loops.h"
|
||||
#include "../Distribution/DvmhDirective.h"
|
||||
#include "Utils/json.hpp"
|
||||
|
||||
struct SpfInterval;
|
||||
|
||||
@@ -19,6 +17,4 @@ bool checkRegionEntries(SgStatement *begin, SgStatement *end, const std::map<std
|
||||
bool recSymbolFind(SgExpression *ex, const std::string &symb, const int var);
|
||||
void completeFillOfArrayUsageBetweenProc(const std::map<std::string, std::vector<LoopGraph*>>& loopGraph, const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo);
|
||||
bool detectMpiCalls(SgProject* proj, std::map<std::string, std::vector<Messages>>& SPF_messages);
|
||||
int calculateLoopIters(SgExpression* start, SgExpression* end, SgExpression* step, std::tuple<int, int, int>& result);
|
||||
|
||||
nlohmann::json convertToJson(const std::map<std::string, std::vector<LoopGraph*>>& loopsByFile);
|
||||
int calculateLoopIters(SgExpression* start, SgExpression* end, SgExpression* step, std::tuple<int, int, int>& result);
|
||||
@@ -14,13 +14,13 @@
|
||||
|
||||
#include "dvm.h"
|
||||
#include "../DynamicAnalysis/gcov_info.h"
|
||||
#include "../DynamicAnalysis/gCov_parser_func.h"
|
||||
#include "PredictScheme.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
#include "../DirectiveProcessing/directive_parser.h"
|
||||
#include "../Distribution/DvmhDirective.h"
|
||||
#include "../GraphLoop/graph_loops_func.h"
|
||||
#include "../ExpressionTransform/expr_transform.h"
|
||||
#include "../DirectiveProcessing/directive_parser.h"
|
||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||
#include "../CFGraph/CFGraph.h"
|
||||
|
||||
@@ -208,31 +208,27 @@ void calculateStatsForPredictor(const map<string, vector<FuncInfo*>>& allFuncInf
|
||||
uint64_t paralle_exec = 0;
|
||||
uint64_t lines_count = 0;
|
||||
|
||||
if (st->variant() == DVM_PARALLEL_ON_DIR)
|
||||
if (st->variant() == DVM_PARALLEL_ON_DIR)
|
||||
{
|
||||
auto loop = st->lexNext();
|
||||
checkNull(loop, convertFileName(__FILE__).c_str(), __LINE__);
|
||||
if (loop->variant() != FOR_NODE)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
if (__gcov_doesThisLineExecuted(byFile.first, loop->lineNumber()))
|
||||
{
|
||||
calculateForParallelLoop(loop, gcov, paralle_exec, lines_count);
|
||||
st = loop->lastNodeOfStmt();
|
||||
calculateForParallelLoop(loop, gcov, paralle_exec, lines_count);
|
||||
st = loop->lastNodeOfStmt();
|
||||
|
||||
parallel_exec_count += paralle_exec;
|
||||
count_of_parallel_lines += lines_count;
|
||||
parallel_exec_count += paralle_exec;
|
||||
count_of_parallel_lines += lines_count;
|
||||
|
||||
__spf_print(1, " PAR LOOP [%d %s] total exec %llu, total exec lines %llu, avg %.16e\n",
|
||||
loop->lineNumber(), byFile.first.c_str(), paralle_exec, lines_count, paralle_exec / (double)lines_count);
|
||||
}
|
||||
__spf_print(1, " PAR LOOP [%d %s] total exec %llu, total exec lines %llu, avg %.16e\n",
|
||||
loop->lineNumber(), byFile.first.c_str(), paralle_exec, lines_count, paralle_exec / (double)lines_count);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto st = stat->lexNext(); st != stat->lastNodeOfStmt(); st = st->lexNext())
|
||||
{
|
||||
if (!isSgExecutableStatement(st) || isDVM_stat(st) || isSPF_stat(st) ||
|
||||
!__gcov_doesThisLineExecuted(byFile.first, st->lineNumber()))
|
||||
if (!isSgExecutableStatement(st) || isDVM_stat(st) || isSPF_stat(st))
|
||||
continue;
|
||||
|
||||
int line = st->lineNumber();
|
||||
@@ -432,7 +428,6 @@ static void parallelDir(const map<DIST::Array*, int>& byPos, SgExpression* spec,
|
||||
parallel["loops_count"] = loopSymbs.size();
|
||||
|
||||
SgStatement* loop = isSgForStmt(st->lexNext());
|
||||
|
||||
if (loop == NULL)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
SgStatement* lastNode = loop->lastNodeOfStmt();
|
||||
@@ -449,13 +444,11 @@ static void parallelDir(const map<DIST::Array*, int>& byPos, SgExpression* spec,
|
||||
loop = loop->lexNext();
|
||||
}
|
||||
|
||||
for (int z = execs.size() - 1; z > 0; --z)
|
||||
if (execs[z - 1] != 0)
|
||||
execs[z] /= execs[z - 1];
|
||||
for (int z = execs.size() - 1; z > 0; --z)
|
||||
execs[z] /= execs[z - 1];
|
||||
|
||||
auto& info = getInfo(before, gcov);
|
||||
if (info.getExecutedCount() && loopSymbs.size() > 1)
|
||||
execs[0] /= info.getExecutedCount();
|
||||
execs[0] /= info.getExecutedCount();
|
||||
|
||||
parallel["iterations_count"] = execs;
|
||||
|
||||
@@ -508,6 +501,8 @@ static void parallelDir(const map<DIST::Array*, int>& byPos, SgExpression* spec,
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
auto cfg = buildCFGforCurrentFunc(func, SAPFOR::CFG_Settings(true, false, false, true, false, false, true), commonBlocks, allFuncInfo);
|
||||
if (cfg.size() != 1)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
//TODO IP analysis
|
||||
|
||||
unsigned countOfAccess = 0;
|
||||
@@ -594,9 +589,6 @@ void parseDvmDirForPredictor(const map<tuple<int, string, string>, pair<DIST::Ar
|
||||
|
||||
for (auto st = stat->lexNext(); st != stat->lastNodeOfStmt(); st = st->lexNext())
|
||||
{
|
||||
if (!__gcov_doesThisLineExecuted(byFile.first, st->lineNumber()))
|
||||
continue;
|
||||
|
||||
SgExpression* list;
|
||||
SgExpression* dup;
|
||||
auto line = 0;
|
||||
@@ -604,10 +596,7 @@ void parseDvmDirForPredictor(const map<tuple<int, string, string>, pair<DIST::Ar
|
||||
switch (st->variant())
|
||||
{
|
||||
case DVM_PARALLEL_ON_DIR:
|
||||
parallelDir(byPos, st->expr(2),
|
||||
st->expr(0) ? st->expr(0)->symbol() : NULL,
|
||||
st->expr(0) ? st->expr(0)->lhs() : NULL,
|
||||
st, st->expr(1), gcov, directives, commonBlocks, allFuncInfo);
|
||||
parallelDir(byPos, st->expr(2), st->expr(0)->symbol(), st->expr(0)->lhs(), st, st->expr(1), gcov, directives, commonBlocks, allFuncInfo);
|
||||
break;
|
||||
case DVM_VAR_DECL: // TODO
|
||||
{
|
||||
@@ -626,8 +615,7 @@ void parseDvmDirForPredictor(const map<tuple<int, string, string>, pair<DIST::Ar
|
||||
list = st->expr(0);
|
||||
while (list)
|
||||
{
|
||||
if (type->lhs()) // if ALIGN A(...) with B(...)
|
||||
directives["align"].push_back(parseAlign(byPos, list->lhs()->symbol(), type->rhs()->symbol(), type->lhs(), type->rhs()->lhs(), st->lineNumber()));
|
||||
directives["align"].push_back(parseAlign(byPos, list->lhs()->symbol(), type->rhs()->symbol(), type->lhs(), type->rhs()->lhs(), st->lineNumber()));
|
||||
list = list->rhs();
|
||||
}
|
||||
}
|
||||
@@ -639,9 +627,6 @@ void parseDvmDirForPredictor(const map<tuple<int, string, string>, pair<DIST::Ar
|
||||
case DVM_ALIGN_DIR:
|
||||
directives["align"].push_back(parseAlign(byPos, st->expr(0)->lhs()->symbol(), st->expr(2)->symbol(), st->expr(1), st->expr(2)->lhs(), st->lineNumber()));
|
||||
break;
|
||||
case DVM_REALIGN_DIR:
|
||||
directives["realign"].push_back(parseAlign(byPos, st->expr(0)->lhs()->symbol(), st->expr(2)->symbol(), st->expr(1), st->expr(2)->lhs(), st->lineNumber()));
|
||||
break;
|
||||
case DVM_SHADOW_DIR:
|
||||
//dirs << "1;" << "SHADOW;" << st->expr(0)->unparse() << "(" << st->expr(1)->unparse() << ");\n";
|
||||
break;
|
||||
|
||||
@@ -331,7 +331,7 @@ static string unparseProjectIfNeed(SgFile* file, const int curr_regime, const bo
|
||||
unparseToBuf = removeIncludeStatsAndUnparse(file, file_name, fout_name.c_str(), allIncludeFiles, out_free_form == 1, moduleUsesByFile,
|
||||
moduleDecls, getObjectForFileFromMap(file_name, exctactedModuleStats), toString, false, true);
|
||||
auto itI = filesToInclude.find(file_name);
|
||||
for (auto& [_, incl] : itI->second)
|
||||
for (auto& incl : itI->second)
|
||||
if (allIncludeFiles.find(incl) != allIncludeFiles.end())
|
||||
allIncludeFiles.erase(incl);
|
||||
}
|
||||
@@ -827,27 +827,20 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
{
|
||||
auto fileIt = includeDependencies.find(file_name);
|
||||
if (fileIt == includeDependencies.end())
|
||||
fileIt = includeDependencies.insert(fileIt, make_pair(file_name, vector<pair<int, string>>()));
|
||||
fileIt = includeDependencies.insert(fileIt, make_pair(file_name, set<string>()));
|
||||
|
||||
set<string> modFiles;
|
||||
for (auto& elem : moduleDecls)
|
||||
modFiles.insert(elem.second);
|
||||
|
||||
SgStatement* lastFromFile = NULL;
|
||||
for (SgStatement *st = file->firstStatement(); st; st = st->lexNext())
|
||||
for (SgStatement *first = file->firstStatement(); first; first = first->lexNext())
|
||||
{
|
||||
if (st->variant() == MODULE_STMT && modFiles.find(st->fileName()) != modFiles.end())
|
||||
st = st->lastNodeOfStmt();
|
||||
else
|
||||
if (strcmp(file_name, first->fileName()))
|
||||
{
|
||||
if (strcmp(file_name, st->fileName()))
|
||||
{
|
||||
if (lastFromFile == NULL)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
fileIt->second.push_back(make_pair(lastFromFile->lineNumber(), st->fileName()));
|
||||
}
|
||||
if (first->variant() == MODULE_STMT && modFiles.find(first->fileName()) != modFiles.end())
|
||||
first = first->lastNodeOfStmt();
|
||||
else
|
||||
lastFromFile = st;
|
||||
fileIt->second.insert(first->fileName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1568,7 +1561,6 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
{
|
||||
if (keepFiles)
|
||||
printLoopGraph("_loopGraph.txt", loopGraph);
|
||||
//printf("%s\n", convertToJson(loopGraph).dump(2).c_str());
|
||||
}
|
||||
else if (curr_regime == FILL_COMMON_BLOCKS)
|
||||
{
|
||||
@@ -1603,9 +1595,9 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
set<string> includedToThisFile;
|
||||
if (itDep != includeDependencies.end())
|
||||
{
|
||||
for (auto& [_, incl] : itDep->second)
|
||||
for (auto &inclDep : itDep->second)
|
||||
{
|
||||
auto comm = commentsToInclude.find(incl);
|
||||
auto comm = commentsToInclude.find(inclDep);
|
||||
if (comm != commentsToInclude.end())
|
||||
for (auto &allComm : comm->second)
|
||||
includedToThisFile.insert(allComm.second.begin(), allComm.second.end());
|
||||
|
||||
@@ -85,7 +85,7 @@ std::map<std::string, std::map<int, std::set<std::string>>> commentsToInclude;
|
||||
//
|
||||
|
||||
//for INSERT_INCLUDES
|
||||
std::map<std::string, std::vector<std::pair<int, std::string>>> filesToInclude; // file -> includes [nearest line, include]
|
||||
std::map<std::string, std::set<std::string>> filesToInclude; // file -> includes
|
||||
//
|
||||
|
||||
//for PASSES DEPENDENSIES
|
||||
@@ -96,7 +96,7 @@ std::set<passes> passesIgnoreStateDone;
|
||||
//for files info
|
||||
std::map<std::string, int> lineInfo; // file -> lines count
|
||||
std::map<std::string, std::pair<std::set<int>, std::set<int>>> dirsInfo; // file -> dirs <lines SPF, lines DVM> count
|
||||
std::map<std::string, std::vector<std::pair<int, std::string>>> includeDependencies; // file -> includes [nearest line, include]
|
||||
std::map<std::string, std::set<std::string>> includeDependencies; // file -> includes
|
||||
std::vector<std::string> filesCompilationOrder; // order of files for unite to one file
|
||||
std::map<std::string, std::map<SgStatement*, std::vector<SgStatement*>>> exctactedModuleStats; // file -> hided excluded modules
|
||||
//
|
||||
|
||||
@@ -309,8 +309,6 @@ void InitPassesDependencies(map<passes, vector<passes>> &passDepsIn, set<passes>
|
||||
|
||||
Pass(REMOVE_OMP_DIRS) <= Pass(REMOVE_OMP_DIRS_TRANSFORM);
|
||||
|
||||
Pass(VERIFY_INCLUDES) <= Pass(RENAME_INLCUDES);
|
||||
|
||||
list({ CALL_GRAPH2, REVERT_SUBST_EXPR_RD }) <= Pass(REMOVE_DEAD_CODE);
|
||||
list({ REMOVE_DEAD_CODE, CONVERT_LOOP_TO_ASSIGN, RESTORE_LOOP_FROM_ASSIGN }) <= Pass(REMOVE_DEAD_CODE_AND_UNPARSE);
|
||||
|
||||
|
||||
22828
src/Utils/json.hpp
22828
src/Utils/json.hpp
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION_SPF "2415"
|
||||
#define VERSION_SPF "2401"
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||
#include "../DirectiveProcessing/insert_directive.h"
|
||||
#include "../ProjectManipulation/PerfAnalyzer.h"
|
||||
#include "Utils/json.hpp"
|
||||
|
||||
#include "BuildGraph.h"
|
||||
|
||||
@@ -62,7 +61,6 @@ using std::pair;
|
||||
using std::tuple;
|
||||
using std::to_string;
|
||||
using std::make_pair;
|
||||
using json = nlohmann::json;
|
||||
|
||||
extern set<short*> allocated;
|
||||
extern set<int*> allocatedInt;
|
||||
@@ -512,7 +510,26 @@ int SPF_GetGraphLoops(void*& context, int winHandler, short *options, short *pro
|
||||
{
|
||||
runPassesForVisualizer(projName, { LOOP_GRAPH } );
|
||||
|
||||
string resVal = convertToJson(loopGraph).dump();
|
||||
string resVal = "";
|
||||
for (auto f = loopGraph.begin(); f != loopGraph.end(); ++f)
|
||||
{
|
||||
if (resVal != "")
|
||||
resVal += "|";
|
||||
|
||||
int realLoops = 0;
|
||||
for (int i = 0; i < f->second.size(); ++i)
|
||||
if (f->second[i]->lineNum > 0)
|
||||
realLoops++;
|
||||
|
||||
resVal += f->first + "|" + to_string(realLoops);
|
||||
for (int i = 0; i < f->second.size(); ++i)
|
||||
{
|
||||
string localRes = "";
|
||||
convertToString(f->second[i], localRes);
|
||||
resVal += localRes;
|
||||
}
|
||||
}
|
||||
|
||||
copyStringToShort(result, resVal);
|
||||
retSize = (int)resVal.size() + 1;
|
||||
}
|
||||
@@ -552,7 +569,15 @@ int SPF_GetGraphFunctions(void*& context, int winHandler, short *options, short
|
||||
{
|
||||
runPassesForVisualizer(projName, { FILL_PAR_REGIONS_LINES } );
|
||||
|
||||
string resVal = convertToJson(allFuncInfo).dump();
|
||||
string resVal = "";
|
||||
resVal = to_string(allFuncInfo.size());
|
||||
for (auto f = allFuncInfo.begin(); f != allFuncInfo.end(); ++f)
|
||||
{
|
||||
resVal += "|" + f->first + "|" + to_string(f->second.size());
|
||||
for (int i = 0; i < f->second.size(); ++i)
|
||||
resVal += convertToString(f->second[i]);
|
||||
}
|
||||
|
||||
copyStringToShort(result, resVal);
|
||||
retSize = (int)resVal.size() + 1;
|
||||
}
|
||||
@@ -641,20 +666,12 @@ int SPF_GetGraphFunctionPositions(void*& context, int winHandler, short *options
|
||||
}
|
||||
|
||||
auto positions = buildLocationOfGraph(allFuncInfo, iters, coef, 0.9 * w, 0.9 * h, sendVisible ? &visible : NULL);
|
||||
|
||||
json pos_array= json::array();
|
||||
for (auto& [fname, coords] : positions) {
|
||||
json elem;
|
||||
elem["functionName"] = fname;
|
||||
elem["x"] = (double)coords.first;
|
||||
elem["y"] = (double)coords.second;
|
||||
pos_array.push_back(elem);
|
||||
}
|
||||
|
||||
json allPositions;
|
||||
allPositions["allPositions"] = pos_array;
|
||||
string resVal = "";
|
||||
resVal = to_string(positions.size());
|
||||
for (auto& elem : positions)
|
||||
resVal += "|" + elem.first + "|" + to_string(elem.second.first) + "|" + to_string(elem.second.second);
|
||||
|
||||
string resVal = allPositions.dump();
|
||||
copyStringToShort(result, resVal);
|
||||
retSize = (int)resVal.size() + 1;
|
||||
}
|
||||
@@ -680,6 +697,61 @@ int SPF_GetGraphFunctionPositions(void*& context, int winHandler, short *options
|
||||
return retSize;
|
||||
}
|
||||
|
||||
int SPF_GetGraphVizOfFunctions(void*& context, short *options, short *projName, short *&result, short *&output, int *&outputSize,
|
||||
short *&outputMessage, int *&outputMessageSize)
|
||||
{
|
||||
MessageManager::clearCache();
|
||||
clearGlobalMessagesBuffer();
|
||||
setOptions(options);
|
||||
|
||||
int retSize = -1;
|
||||
try
|
||||
{
|
||||
runPassesForVisualizer(projName, { FILL_PAR_REGIONS_LINES });
|
||||
|
||||
map<string, CallV> V;
|
||||
vector<string> E;
|
||||
CreateCallGraphViz(NULL, allFuncInfo, V, E);
|
||||
|
||||
string graph = to_string(V.size()) += "|";
|
||||
for (auto &v : V)
|
||||
graph += v.second.to_string() + "|";
|
||||
|
||||
graph += to_string(E.size()) + "|";
|
||||
for (auto &e : E)
|
||||
graph += e + "|";
|
||||
//erase last "|"
|
||||
graph.erase(graph.end() - 1);
|
||||
|
||||
copyStringToShort(result, graph);
|
||||
retSize = (int)graph.size();
|
||||
|
||||
if (showDebug)
|
||||
printf("GraphViz: '%s'\n", graph.c_str());
|
||||
}
|
||||
catch (int ex)
|
||||
{
|
||||
try { __spf_print(1, "catch code %d\n", ex); }
|
||||
catch (...) {}
|
||||
if (ex == -99)
|
||||
return -99;
|
||||
else
|
||||
retSize = -1;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
retSize = -1;
|
||||
}
|
||||
|
||||
//convertBuffers(outputMessage, outputMessageSize, output, outputSize);
|
||||
|
||||
if (showDebug)
|
||||
printf("SAPFOR: return from DLL\n");
|
||||
|
||||
MessageManager::setWinHandler(-1);
|
||||
return retSize;
|
||||
}
|
||||
|
||||
extern int PASSES_DONE[EMPTY_PASS];
|
||||
extern int *ALGORITHMS_DONE[EMPTY_ALGO];
|
||||
extern const char *passNames[EMPTY_PASS + 1];
|
||||
@@ -1308,12 +1380,13 @@ int SPF_GetIntrinsics(void*& context, short *&result)
|
||||
return (int)resVal.size() + 1;
|
||||
}
|
||||
|
||||
extern map<string, vector<pair<int, string>>> includeDependencies;
|
||||
extern map<string, set<string>> includeDependencies;
|
||||
int SPF_GetIncludeDependencies(void*& context, int winHandler, short *options, short *projName, short *&result, short*& output, int*& outputSize,
|
||||
short*& outputMessage, int*& outputMessageSize)
|
||||
{
|
||||
MessageManager::clearCache();
|
||||
MessageManager::setWinHandler(winHandler);
|
||||
string resVal = "";
|
||||
|
||||
setOptions(options);
|
||||
int retSize = 0;
|
||||
@@ -1321,28 +1394,23 @@ int SPF_GetIncludeDependencies(void*& context, int winHandler, short *options, s
|
||||
{
|
||||
runPassesForVisualizer(projName, { BUILD_INCLUDE_DEPENDENCIES });
|
||||
|
||||
json inc_array = json::array();
|
||||
for (const auto& deps : includeDependencies)
|
||||
int i = 0;
|
||||
for (auto &deps : includeDependencies)
|
||||
{
|
||||
json includes;
|
||||
includes["file"] = deps.first;
|
||||
|
||||
json array = json::array();
|
||||
for (const auto& [line, incl] : deps.second)
|
||||
if (i != 0)
|
||||
resVal += "@";
|
||||
resVal += deps.first + "@";
|
||||
int k = 0;
|
||||
for (auto &incl : deps.second)
|
||||
{
|
||||
json elem;
|
||||
elem["line"] = line;
|
||||
elem["dependencyFileName"] = incl;
|
||||
array.push_back(elem);
|
||||
if (k != 0)
|
||||
resVal += "|";
|
||||
resVal += incl;
|
||||
++k;
|
||||
}
|
||||
includes["includes"] = array;
|
||||
inc_array.push_back(includes);
|
||||
++i;
|
||||
}
|
||||
|
||||
json allIncludes;
|
||||
allIncludes["allIncludes"] = inc_array;
|
||||
string resVal = allIncludes.dump();
|
||||
|
||||
copyStringToShort(result, resVal);
|
||||
retSize = (int)resVal.size() + 1;
|
||||
}
|
||||
@@ -1378,7 +1446,15 @@ int SPF_SetFunctionsToInclude(void*& context, int winHandler, short *options, sh
|
||||
{
|
||||
runPassesForVisualizer(projName, { FIND_FUNC_TO_INCLUDE });
|
||||
|
||||
string resVal = convertToJson(allFuncInfo).dump();
|
||||
string resVal = "";
|
||||
resVal = to_string(allFuncInfo.size());
|
||||
for (auto f = allFuncInfo.begin(); f != allFuncInfo.end(); ++f)
|
||||
{
|
||||
resVal += "|" + f->first + "|" + to_string(f->second.size());
|
||||
for (int i = 0; i < f->second.size(); ++i)
|
||||
resVal += convertToString(f->second[i]);
|
||||
}
|
||||
|
||||
copyStringToShort(result, resVal);
|
||||
retSize = (int)resVal.size() + 1;
|
||||
}
|
||||
@@ -1464,33 +1540,19 @@ int SPF_GetFileLineInfo(void*& context, int winHandler, short *options, short *p
|
||||
{
|
||||
runPassesForVisualizer(projName, { FILE_LINE_INFO });
|
||||
|
||||
json metric_array = json::array();
|
||||
for (const auto& fileInfo : lineInfo)
|
||||
string resVal = "";
|
||||
for (auto it = lineInfo.begin(); it != lineInfo.end(); ++it)
|
||||
{
|
||||
json fileMetric;
|
||||
if (it != lineInfo.begin())
|
||||
resVal += "@";
|
||||
|
||||
fileMetric["file"] = fileInfo.first;
|
||||
fileMetric["linesCount"] = fileInfo.second;
|
||||
|
||||
auto it = dirsInfo.find(fileInfo.first);
|
||||
if (it == dirsInfo.end())
|
||||
{
|
||||
fileMetric["numSPF"] = 0;
|
||||
fileMetric["numDVM"] = 0;
|
||||
}
|
||||
auto itD = dirsInfo.find(it->first);
|
||||
if (itD == dirsInfo.end())
|
||||
resVal += it->first + "@" + to_string(it->second) + "_0_0";
|
||||
else
|
||||
{
|
||||
fileMetric["numSPF"] = (int)it->second.first.size();
|
||||
fileMetric["numDVM"] = (int)it->second.second.size();
|
||||
}
|
||||
|
||||
metric_array.push_back(fileMetric);
|
||||
resVal += it->first + "@" + to_string(it->second) + "_" + to_string(itD->second.first.size()) + "_" + to_string(itD->second.second.size());
|
||||
}
|
||||
|
||||
json allMetrics;
|
||||
allMetrics["allMetrics"] = metric_array;
|
||||
string resVal = allMetrics.dump();
|
||||
|
||||
copyStringToShort(result, resVal);
|
||||
retSize = (int)resVal.size() + 1;
|
||||
}
|
||||
@@ -2189,44 +2251,38 @@ int SPF_InlineProcedures(void*& context, int winHandler, short* options, short*
|
||||
}
|
||||
|
||||
|
||||
extern map<string, vector<pair<int, string>>> filesToInclude;
|
||||
int SPF_InsertIncludesPass(void*& context, int winHandler, short *options, short *projName, short *folderName, char *visFilesToInclude,
|
||||
extern map<string, set<string>> filesToInclude;
|
||||
int SPF_InsertIncludesPass(void*& context, int winHandler, short *options, short *projName, short *folderName, char *filesToInclude,
|
||||
short *&output, int *&outputSize, short *&outputMessage, int *&outputMessageSize)
|
||||
{
|
||||
MessageManager::clearCache();
|
||||
MessageManager::setWinHandler(winHandler);
|
||||
|
||||
if (visFilesToInclude == NULL)
|
||||
if (filesToInclude == NULL)
|
||||
return -2;
|
||||
|
||||
vector<string> splited;
|
||||
//printf("%s\n", conv);
|
||||
splitString(visFilesToInclude, '|', splited);
|
||||
splitString(filesToInclude, '|', splited);
|
||||
|
||||
if (splited.size() == 0)
|
||||
return -3;
|
||||
|
||||
filesToInclude.clear();
|
||||
unsigned i = 0;
|
||||
while (i < splited.size())
|
||||
::filesToInclude.clear();
|
||||
for (int i = 0; i < splited.size(); ++i)
|
||||
{
|
||||
string file = splited[i++];
|
||||
string file = splited[i];
|
||||
int num = 0;
|
||||
if (sscanf(splited[i++].c_str(), "%d", &num) == -1)
|
||||
return -4;
|
||||
if (sscanf(splited[i + 1].c_str(), "%d", &num) == -1)
|
||||
return -3;
|
||||
|
||||
__spf_print(1, "file = %s:\n", file.c_str());
|
||||
for (int k = i; k < i + 2 * num; k += 2)
|
||||
for (int k = i + 2; k < i + 2 + num; ++k)
|
||||
{
|
||||
int line = 0;
|
||||
if (sscanf(splited[k].c_str(), "%d", &line) == -1)
|
||||
return -5;
|
||||
|
||||
auto pair = make_pair(line, splited[k + 1]);
|
||||
filesToInclude[file].push_back(pair);
|
||||
__spf_print(1, " include = [%d %s]\n", pair.first, pair.second.c_str());
|
||||
::filesToInclude[file].insert(splited[k]);
|
||||
__spf_print(1, " include = %s\n", splited[k].c_str());
|
||||
}
|
||||
i += 2 * num;
|
||||
i += 1 + num;
|
||||
}
|
||||
return simpleTransformPass(INSERT_INCLUDES, options, projName, folderName, output, outputSize, outputMessage, outputMessageSize);
|
||||
}
|
||||
@@ -2253,30 +2309,18 @@ int SPF_GetGCovInfo(void*& context, int winHandler, short *options, short *projN
|
||||
{
|
||||
runPassesForVisualizer(projName, { GCOV_PARSER });
|
||||
|
||||
json gcov_array = json::array();
|
||||
for (auto& byFile : gCovInfo)
|
||||
string resVal = "";
|
||||
bool first = true;
|
||||
for (auto &byFile : gCovInfo)
|
||||
{
|
||||
json fileGCov;
|
||||
fileGCov["file"] = byFile.first;
|
||||
|
||||
json info_array = json::array();
|
||||
for (auto& elem : byFile.second)
|
||||
{
|
||||
json item;
|
||||
item["line"] = elem.first;
|
||||
item["execution"] = elem.second.getExecutedCount();
|
||||
|
||||
info_array.push_back(item);
|
||||
}
|
||||
fileGCov["lines"] = info_array;
|
||||
|
||||
gcov_array.push_back(fileGCov);
|
||||
if (!first)
|
||||
resVal += "@";
|
||||
resVal += byFile.first + "@";
|
||||
for (auto &elem : byFile.second)
|
||||
resVal += to_string(elem.first) + " " + to_string(elem.second.getExecutedCount()) + " ";
|
||||
first = false;
|
||||
}
|
||||
|
||||
json allGCov;
|
||||
allGCov["allGCov"] = gcov_array;
|
||||
string resVal = allGCov.dump();
|
||||
|
||||
copyStringToShort(result, resVal);
|
||||
retSize = (int)resVal.size();
|
||||
}
|
||||
@@ -2452,6 +2496,8 @@ const wstring Sapfor_RunAnalysis(const char* analysisName_c, const char* options
|
||||
retCode = SPF_GetGraphFunctions(context, winHandler, optSh, projSh, result, output, outputSize, outputMessage, outputMessageSize);
|
||||
else if (whichRun == "SPF_GetGraphFunctionPositions")
|
||||
retCode = SPF_GetGraphFunctionPositions(context, winHandler, optSh, projSh, result, output, outputSize, outputMessage, outputMessageSize);
|
||||
else if (whichRun == "SPF_GetGraphVizOfFunctions")
|
||||
retCode = SPF_GetGraphVizOfFunctions(context, optSh, projSh, result, output, outputSize, outputMessage, outputMessageSize);
|
||||
else if (whichRun == "SPF_GetArrayDistribution")
|
||||
retCode = SPF_GetArrayDistribution(context, winHandler, optSh, projSh, result, output, outputSize, outputMessage, outputMessageSize, 0);
|
||||
else if (whichRun == "SPF_GetArrayDistributionOnlyAnalysis")
|
||||
|
||||
Reference in New Issue
Block a user