Merge branch 'master' into analyze_loops_with_IR
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +1,6 @@
|
||||
[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
|
||||
|
||||
@@ -23,6 +23,8 @@ 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/)
|
||||
|
||||
include_directories(src)
|
||||
#Sage lib includes
|
||||
@@ -33,6 +35,8 @@ 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)
|
||||
@@ -76,7 +80,8 @@ 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/module_utils.cpp
|
||||
src/Utils/json.hpp)
|
||||
|
||||
set(OMEGA src/SageAnalysisTool/OmegaForSage/add-assert.cpp
|
||||
src/SageAnalysisTool/OmegaForSage/affine.cpp
|
||||
@@ -315,6 +320,15 @@ 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
|
||||
src/ProjectManipulation/StdCapture.h
|
||||
@@ -403,6 +417,7 @@ set(SOURCE_EXE
|
||||
${VS_CALLS}
|
||||
${MAIN}
|
||||
${PREDICTOR}
|
||||
${LIBPREDICTOR}
|
||||
${PARSER}
|
||||
${PPPA}
|
||||
${ZLIB}
|
||||
@@ -457,7 +472,8 @@ source_group (VisualizerCalls FILES ${VS_CALLS})
|
||||
source_group (VisualizerCalls\\GraphLayout FILES ${GR_LAYOUT})
|
||||
|
||||
source_group (_SapforMain FILES ${MAIN})
|
||||
source_group (Predictor FILES ${PREDICTOR})
|
||||
source_group (Predictor\\Analyzer FILES ${PREDICTOR})
|
||||
source_group (Predictor\\Library FILES ${LIBPREDICTOR})
|
||||
source_group (Parser FILES ${PARSER})
|
||||
source_group (PPPA\\PPPA FILES ${PPPA})
|
||||
source_group (PPPA\\ZLib FILES ${ZLIB})
|
||||
|
||||
Submodule projects/dvm updated: c00e381812...3a567d7582
1
projects/libpredictor
Submodule
1
projects/libpredictor
Submodule
Submodule projects/libpredictor added at d0772cdb57
@@ -1601,7 +1601,7 @@ static bool matchParallelAndDist(const pair<DIST::Array*, const DistrVariant*>&
|
||||
parallelOn = NULL;
|
||||
for (auto& refOn : realRefs)
|
||||
{
|
||||
linkWithTempl = parallelOn->GetLinksWithTemplate(regionId);
|
||||
linkWithTempl = refOn->GetLinksWithTemplate(regionId);
|
||||
int z = 0;
|
||||
for (int k = 0; k < linkWithTempl.size(); ++k)
|
||||
if (linkWithTempl[k] != -1)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "DvmhDirectiveBase.h"
|
||||
#include "../Utils/utils.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "../Utils/json.hpp"
|
||||
|
||||
class Symbol;
|
||||
class Expression;
|
||||
@@ -20,6 +21,7 @@ struct FuncInfo;
|
||||
#define MAP std::map
|
||||
#define SET std::set
|
||||
#define TO_STR std::to_string
|
||||
#define JSON nlohmann::json
|
||||
|
||||
#if __SPF
|
||||
extern int sharedMemoryParallelization;
|
||||
@@ -104,7 +106,7 @@ namespace Distribution
|
||||
MAP<STRING, SET<int>> usagePlaces;
|
||||
|
||||
VECTOR<bool> mappedDims;
|
||||
VECTOR<bool> depracateToDistribute;
|
||||
VECTOR<bool> deprecateToDistribute;
|
||||
|
||||
bool ompThreadPrivate;
|
||||
bool privateInLoop;
|
||||
@@ -169,7 +171,7 @@ namespace Distribution
|
||||
sizes.resize(dimSize);
|
||||
sizesExpr.resize(dimSize);
|
||||
mappedDims.resize(dimSize);
|
||||
depracateToDistribute.resize(dimSize);
|
||||
deprecateToDistribute.resize(dimSize);
|
||||
|
||||
for (int z = 0; z < dimSize; ++z)
|
||||
{
|
||||
@@ -177,7 +179,7 @@ namespace Distribution
|
||||
PAIR<int, int> initVal = std::make_pair(0, 0);
|
||||
sizesExpr[z] = std::make_pair(std::make_pair((Expression*)NULL, initVal), std::make_pair((Expression*)NULL, initVal));
|
||||
mappedDims[z] = false;
|
||||
depracateToDistribute[z] = false;
|
||||
deprecateToDistribute[z] = false;
|
||||
}
|
||||
|
||||
GenUniqKey();
|
||||
@@ -212,7 +214,7 @@ namespace Distribution
|
||||
uniqKey = copy.uniqKey;
|
||||
containsInRegions = copy.containsInRegions;
|
||||
mappedDims = copy.mappedDims;
|
||||
depracateToDistribute = copy.depracateToDistribute;
|
||||
deprecateToDistribute = copy.deprecateToDistribute;
|
||||
ompThreadPrivate = copy.ompThreadPrivate;
|
||||
privateInLoop = copy.privateInLoop;
|
||||
inEquivalence = copy.inEquivalence;
|
||||
@@ -224,7 +226,7 @@ namespace Distribution
|
||||
int countToRem = 0;
|
||||
for (int z = 0; z < dimSize; ++z)
|
||||
{
|
||||
if (!mappedDims[z] || depracateToDistribute[z])
|
||||
if (!mappedDims[z] || deprecateToDistribute[z])
|
||||
{
|
||||
needToRemove = true;
|
||||
countToRem++;
|
||||
@@ -244,19 +246,19 @@ namespace Distribution
|
||||
|
||||
for (int z = 0; z < dimSize; ++z)
|
||||
{
|
||||
if (mappedDims[z] && !depracateToDistribute[z])
|
||||
if (mappedDims[z] && !deprecateToDistribute[z])
|
||||
{
|
||||
newSizes.push_back(sizes[z]);
|
||||
newSizesExpr.push_back(sizesExpr[z]);
|
||||
newMappedDims.push_back(mappedDims[z]);
|
||||
newDepr.push_back(depracateToDistribute[z]);
|
||||
newDepr.push_back(deprecateToDistribute[z]);
|
||||
}
|
||||
}
|
||||
|
||||
sizes = newSizes;
|
||||
sizesExpr = newSizesExpr;
|
||||
mappedDims = newMappedDims;
|
||||
depracateToDistribute = newDepr;
|
||||
deprecateToDistribute = newDepr;
|
||||
dimSize = (int)sizes.size();
|
||||
|
||||
return false;
|
||||
@@ -424,45 +426,61 @@ namespace Distribution
|
||||
|
||||
void ClearShadowSpecs() { allShadowSpecs.clear(); }
|
||||
|
||||
STRING toString()
|
||||
JSON toJson()
|
||||
{
|
||||
STRING retVal = "";
|
||||
retVal += TO_STR(id);
|
||||
retVal += "#" + name;
|
||||
retVal += "#" + shortName;
|
||||
retVal += "#" + TO_STR(dimSize);
|
||||
retVal += "#" + TO_STR(typeSize);
|
||||
retVal += "#" + TO_STR(isNonDistribute);
|
||||
JSON retVal;
|
||||
|
||||
retVal += "#" + TO_STR(locationPos.first);
|
||||
retVal += "#" + locationPos.second;
|
||||
retVal["id"] = (int64_t)id;
|
||||
retVal["name"] = name;
|
||||
retVal["shortName"] = shortName;
|
||||
retVal["packedAddress"] = std::to_string((long long)this);
|
||||
|
||||
retVal += "#" + TO_STR(sizes.size());
|
||||
for (int i = 0; i < sizes.size(); ++i)
|
||||
retVal += "#" + TO_STR(sizes[i].first) + "#" + TO_STR(sizes[i].second);
|
||||
retVal["dimSize"] = dimSize;
|
||||
retVal["typeSize"] = typeSize;
|
||||
retVal["state"] = (int)isNonDistribute;
|
||||
retVal["location"] = (int)locationPos.first;
|
||||
retVal["locName"] = locationPos.second;
|
||||
|
||||
retVal += "#" + TO_STR(depracateToDistribute.size());
|
||||
for (int i = 0; i < depracateToDistribute.size(); ++i)
|
||||
retVal += "#" + TO_STR((int)depracateToDistribute[i]);
|
||||
retVal["isTemplFlag"] = (int)isTemplFlag;
|
||||
retVal["isLoopArrayFlag"] = (int)isLoopArrayFlag;
|
||||
|
||||
retVal += "#" + TO_STR(mappedDims.size());
|
||||
JSON deprToDist = nlohmann::json::array();
|
||||
for (int i = 0; i < deprecateToDistribute.size(); ++i)
|
||||
deprToDist.push_back((int)deprecateToDistribute[i]);
|
||||
retVal["deprecateToDist"] = deprToDist;
|
||||
|
||||
JSON mappedDimsJ = nlohmann::json::array();
|
||||
for (int i = 0; i < mappedDims.size(); ++i)
|
||||
retVal += "#" + TO_STR((int)mappedDims[i]);
|
||||
mappedDimsJ.push_back((int)mappedDims[i]);
|
||||
retVal["mappedDims"] = mappedDimsJ;
|
||||
|
||||
retVal += "#" + TO_STR(templateInfo.size());
|
||||
for (auto it = templateInfo.begin(); it != templateInfo.end(); ++it)
|
||||
retVal += "#" + TO_STR(it->first) + it->second->toString();
|
||||
JSON sizesJ = nlohmann::json::array();
|
||||
for (int i = 0; i < sizes.size(); ++i)
|
||||
{
|
||||
JSON pair;
|
||||
pair["key"] = sizes[i].first;
|
||||
pair["value"] = sizes[i].second;
|
||||
sizesJ.push_back(pair);
|
||||
}
|
||||
retVal["sizes"] = sizesJ;
|
||||
|
||||
retVal += "#" + TO_STR((int)isTemplFlag);
|
||||
retVal += "|" + TO_STR((int)isLoopArrayFlag);
|
||||
retVal += "|" + TO_STR(declPlaces.size());
|
||||
JSON regions = nlohmann::json::array();
|
||||
for (auto& reg : containsInRegions)
|
||||
regions.push_back(reg);
|
||||
retVal["regions"] = regions;
|
||||
|
||||
for (auto &place : declPlaces)
|
||||
retVal += "|" + place.first + "|" + TO_STR(place.second);
|
||||
|
||||
retVal += "|" + TO_STR(containsInRegions.size());
|
||||
for (auto ® : containsInRegions)
|
||||
retVal += "|" + reg;
|
||||
JSON declPlacesJ = nlohmann::json::array();
|
||||
for (auto& place : declPlaces)
|
||||
{
|
||||
JSON elem;
|
||||
elem["file"] = place.first;
|
||||
elem["line"] = place.second;
|
||||
|
||||
declPlacesJ.push_back(elem);
|
||||
}
|
||||
retVal["declPlaces"] = declPlacesJ;
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -587,13 +605,13 @@ namespace Distribution
|
||||
{
|
||||
if (dim >= dimSize)
|
||||
return;
|
||||
depracateToDistribute[dim] = value;
|
||||
deprecateToDistribute[dim] = value;
|
||||
}
|
||||
|
||||
void DeprecateAllDims()
|
||||
{
|
||||
for (int dim = 0; dim < dimSize; ++dim)
|
||||
depracateToDistribute[dim] = true;
|
||||
deprecateToDistribute[dim] = true;
|
||||
}
|
||||
|
||||
bool IsDimDepracated(const int dim) const
|
||||
@@ -603,9 +621,9 @@ namespace Distribution
|
||||
else
|
||||
{
|
||||
if (templateDimsOrder.size() == 0)
|
||||
return depracateToDistribute[dim];
|
||||
return deprecateToDistribute[dim];
|
||||
else
|
||||
return depracateToDistribute[templateDimsOrder[dim]];
|
||||
return deprecateToDistribute[templateDimsOrder[dim]];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -613,11 +631,11 @@ namespace Distribution
|
||||
{
|
||||
bool ret = true;
|
||||
for (int z = 0; z < dimSize; ++z)
|
||||
ret = ret && depracateToDistribute[z];
|
||||
ret = ret && deprecateToDistribute[z];
|
||||
return ret;
|
||||
}
|
||||
|
||||
const VECTOR<bool>& GetDeprecetedDims() const { return depracateToDistribute; }
|
||||
const VECTOR<bool>& GetDeprecetedDims() const { return deprecateToDistribute; }
|
||||
|
||||
int GetTypeSize() const { return typeSize; }
|
||||
|
||||
|
||||
@@ -199,15 +199,6 @@ static set<string> fillUsedSymbols(SgStatement *loop)
|
||||
return usedS;
|
||||
}
|
||||
|
||||
static string correctSymbolModuleName(const string& origFull)
|
||||
{
|
||||
auto it = origFull.find("::");
|
||||
if (it == string::npos)
|
||||
return origFull;
|
||||
else
|
||||
return origFull.substr(it + 2);
|
||||
}
|
||||
|
||||
static SgStatement* getModuleScope(const string& origFull, vector<SgStatement*>& moduleList, SgStatement *local)
|
||||
{
|
||||
auto it = origFull.find("::");
|
||||
@@ -959,7 +950,7 @@ ParallelDirective::genDirective(File* file, const vector<pair<DIST::Array*, cons
|
||||
SgSymbol* redS;
|
||||
string clearName = correctSymbolModuleName(red);
|
||||
if (clearName != red)
|
||||
redS = getNameInLocation(parentFunc, clearName, getModuleScope(red, moduleList, parentFunc)->symbol()->identifier());
|
||||
redS = getNameInLocation(parentFunc, red, getModuleScope(red, moduleList, parentFunc)->symbol()->identifier());
|
||||
else
|
||||
redS = findSymbolOrCreate(file, clearName, NULL, parentFunc);
|
||||
|
||||
@@ -1017,12 +1008,12 @@ ParallelDirective::genDirective(File* file, const vector<pair<DIST::Array*, cons
|
||||
string clearName2 = correctSymbolModuleName(get<1>(list));
|
||||
|
||||
if (clearName1 != get<0>(list))
|
||||
redS1 = getNameInLocation(parentFunc, clearName1, getModuleScope(get<0>(list), moduleList, parentFunc)->symbol()->identifier());
|
||||
redS1 = getNameInLocation(parentFunc, get<0>(list), getModuleScope(get<0>(list), moduleList, parentFunc)->symbol()->identifier());
|
||||
else
|
||||
redS1 = findSymbolOrCreate(file, clearName1, NULL, parentFunc);
|
||||
|
||||
if (clearName2 != get<1>(list))
|
||||
redS2 = getNameInLocation(parentFunc, clearName2, getModuleScope(get<1>(list), moduleList, parentFunc)->symbol()->identifier());
|
||||
redS2 = getNameInLocation(parentFunc, get<1>(list), getModuleScope(get<1>(list), moduleList, parentFunc)->symbol()->identifier());
|
||||
else
|
||||
redS2 = findSymbolOrCreate(file, clearName2, NULL, parentFunc);
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include "../Distribution/GraphCSR.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "../Utils/utils.h"
|
||||
#include "../Utils/json.hpp"
|
||||
|
||||
#include "../GraphCall/graph_calls_func.h"
|
||||
|
||||
using std::vector;
|
||||
@@ -27,6 +29,8 @@ using std::make_pair;
|
||||
using std::min;
|
||||
using std::max;
|
||||
|
||||
using nlohmann::json;
|
||||
|
||||
template<typename setT>
|
||||
static void uniteSets(const set<setT> &first, const set<setT> &second, set<setT> &result)
|
||||
{
|
||||
@@ -732,30 +736,34 @@ string AlignRuleBase::GenRuleBase() const
|
||||
return retVal;
|
||||
}
|
||||
|
||||
string AlignRuleBase::toString()
|
||||
json AlignRuleBase::toJson()
|
||||
{
|
||||
string retVal = "";
|
||||
json retVal;
|
||||
|
||||
if (alignArray)
|
||||
retVal += "#" + std::to_string((long long)alignArray);
|
||||
else
|
||||
retVal += "#-1";
|
||||
retVal["packedAlignArrayAddress"] = alignArray ? std::to_string((long long)alignArray) : std::to_string((long long)-1);
|
||||
retVal["packedAlignWithAddress"] = alignWith ? std::to_string((long long)alignWith) : std::to_string((long long)-1);
|
||||
|
||||
if (alignWith)
|
||||
retVal += "#" + std::to_string((long long)alignWith);
|
||||
else
|
||||
retVal += "#-1";
|
||||
json alignRules = json::array();
|
||||
for (auto& rule : alignRule)
|
||||
{
|
||||
json pair;
|
||||
pair["key"] = rule.first;
|
||||
pair["value"] = rule.second;
|
||||
alignRules.push_back(pair);
|
||||
}
|
||||
retVal["alignRule"] = alignRules;
|
||||
|
||||
retVal += "#" + std::to_string(alignRule.size());
|
||||
for (int i = 0; i < alignRule.size(); ++i)
|
||||
retVal += "#" + std::to_string(alignRule[i].first) + "#" + std::to_string(alignRule[i].second);
|
||||
|
||||
retVal += "#" + std::to_string(alignRuleWith.size());
|
||||
for (int i = 0; i < alignRuleWith.size(); ++i)
|
||||
retVal += "#" + std::to_string(alignRuleWith[i].first)
|
||||
+ "#" + std::to_string(alignRuleWith[i].second.first)
|
||||
+ "#" + std::to_string(alignRuleWith[i].second.second);
|
||||
json alignRuleWithJ = json::array();
|
||||
for (auto& [dimNum, AB] : alignRuleWith)
|
||||
{
|
||||
json tuple;
|
||||
tuple["dimNum"] = dimNum;
|
||||
tuple["a"] = AB.first;
|
||||
tuple["b"] = AB.second;
|
||||
|
||||
alignRuleWithJ.push_back(tuple);
|
||||
}
|
||||
retVal["alignRuleWith"] = alignRuleWithJ;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "../Utils/json.hpp"
|
||||
|
||||
typedef enum lang : int { LANG_C, LANG_F } language;
|
||||
typedef enum dist : int { BLOCK, NONE } distType;
|
||||
typedef std::pair<std::pair<int, int>, std::pair<int, int>> attrType;
|
||||
@@ -48,7 +50,7 @@ public:
|
||||
|
||||
public:
|
||||
std::string GenRuleBase() const;
|
||||
std::string toString();
|
||||
nlohmann::json toJson();
|
||||
|
||||
public:
|
||||
DIST::Array *alignArray;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
#define DVMH_REG_RD 0
|
||||
#define DVMH_REG_WT 1
|
||||
|
||||
@@ -835,19 +834,21 @@ 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)
|
||||
{
|
||||
SgStatement* next = st->lexNext();
|
||||
st->extractStmt();
|
||||
st = next;
|
||||
toExtract.push_back(st);
|
||||
st = st->lexNext();
|
||||
}
|
||||
else
|
||||
st = st->lexNext();
|
||||
@@ -869,6 +870,7 @@ 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
|
||||
@@ -878,9 +880,8 @@ static string getInterfaceBlock(SgStatement* func, const FuncParam& pars)
|
||||
bool empty = filterFromList(st, idents);
|
||||
if (empty)
|
||||
{
|
||||
SgStatement* next = st->lexNext();
|
||||
toExtract.push_back(st);
|
||||
st = next;
|
||||
st = st->lexNext();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -1428,21 +1429,15 @@ static set<DIST::Array*>
|
||||
|
||||
for (auto& realArray : realRef)
|
||||
{
|
||||
if (added.count(realArray) != 0 || !realArray->IsNotDistribute())
|
||||
if (added.count(realArray) != 0)
|
||||
continue;
|
||||
|
||||
if (!realArray->IsNotDistribute())
|
||||
continue;
|
||||
|
||||
SgStatement* declStat = NULL;
|
||||
|
||||
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
|
||||
if (realArray->GetLocation().first == DIST::l_COMMON)
|
||||
{
|
||||
commonArrays.insert(realArray);
|
||||
auto decls = realArray->GetDeclInfo();
|
||||
@@ -1471,6 +1466,19 @@ static set<DIST::Array*>
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (realArray->GetLocation().first == DIST::l_MODULE)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
else
|
||||
{
|
||||
if (std::count(usedAll.begin(), usedAll.end(), realArray) == 0)
|
||||
{
|
||||
auto declInfo = *realArray->GetDeclInfo().begin();
|
||||
declStat = SgStatement::getStatementByFileAndLine(declInfo.first, declInfo.second);
|
||||
checkNull(declStat, convertFileName(__FILE__).c_str(), __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
if (declStat)
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#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"
|
||||
@@ -37,6 +38,8 @@ using std::cout;
|
||||
using std::endl;
|
||||
using std::stack;
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
//TODO: improve parameter checking
|
||||
@@ -2592,4 +2595,71 @@ void setInlineAttributeToCalls(const map<string, FuncInfo*>& allFunctions,
|
||||
}
|
||||
}
|
||||
|
||||
static json convertToJson(const FuncInfo* currFunc) {
|
||||
json func;
|
||||
|
||||
if (currFunc)
|
||||
{
|
||||
func["funcName"] = currFunc->funcName;
|
||||
func["line"] = currFunc->linesNum.first;
|
||||
func["lineEnd"] = currFunc->linesNum.second;
|
||||
func["isMain"] = (int)currFunc->isMain;
|
||||
func["needToInline"] = (int)currFunc->needToInline;
|
||||
func["doNotInline"] = (int)currFunc->doNotInline;
|
||||
func["doNotAnalyze"] = (int)currFunc->doNotAnalyze;
|
||||
|
||||
json func_pars = json::array();
|
||||
|
||||
for (int z = 0; z < currFunc->funcParams.countOfPars; ++z)
|
||||
{
|
||||
json par;
|
||||
par["inoutType"] = currFunc->funcParams.inout_types[z];
|
||||
par["identificator"] = currFunc->funcParams.identificators[z];
|
||||
par["parameterT"] = string(paramNames[currFunc->funcParams.parametersT[z]]);
|
||||
|
||||
func_pars.push_back(par);
|
||||
}
|
||||
|
||||
func["params"] = func_pars;
|
||||
|
||||
json calls_from = json::array();
|
||||
for (const auto& call_from : currFunc->callsFromDetailed)
|
||||
{
|
||||
json call;
|
||||
call["line"] = call_from.detailCallsFrom.second;
|
||||
call["funcName"] = call_from.detailCallsFrom.first;
|
||||
|
||||
calls_from.push_back(call);
|
||||
}
|
||||
func["callsFrom"] = calls_from;
|
||||
}
|
||||
return func;
|
||||
}
|
||||
|
||||
json convertToJson(const map<string, vector<FuncInfo*>>& funcsByFileMap) {
|
||||
json loopsByFile = json::array();
|
||||
|
||||
for (auto& byFile : funcsByFileMap)
|
||||
{
|
||||
json func;
|
||||
const string& file = byFile.first;
|
||||
|
||||
json func_array = json::array();
|
||||
for (auto& func : byFile.second)
|
||||
{
|
||||
auto conv = convertToJson(func);
|
||||
if (!conv.empty())
|
||||
func_array.push_back(conv);
|
||||
}
|
||||
|
||||
func["file"] = file;
|
||||
func["functions"] = func_array;
|
||||
|
||||
loopsByFile.push_back(func);
|
||||
}
|
||||
|
||||
json allFuncs;
|
||||
allFuncs["allFunctions"] = loopsByFile;
|
||||
return allFuncs;
|
||||
}
|
||||
#undef DEBUG
|
||||
|
||||
@@ -378,33 +378,6 @@ 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,6 +7,7 @@
|
||||
#include "graph_calls.h"
|
||||
#include "../GraphLoop/graph_loops.h"
|
||||
#include "../ParallelizationRegions/ParRegions.h"
|
||||
#include "Utils/json.hpp"
|
||||
|
||||
namespace Distribution
|
||||
{
|
||||
@@ -23,7 +24,6 @@ int CreateCallGraphViz(const char *fileName, const std::map<std::string, std::ve
|
||||
int CreateFuncInfo(const char *fileName, const std::map<std::string, std::vector<FuncInfo*>> &funcByFile);
|
||||
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,5 +53,6 @@ void findContainsFunctions(SgStatement *st, std::vector<SgStatement*> &found, co
|
||||
void correctNameIfContains(SgStatement* call, SgExpression* exCall, std::string& name, const std::vector<SgStatement*>& containsFunctions, const std::string& prefix);
|
||||
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,6 +40,8 @@ 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)
|
||||
{
|
||||
@@ -918,7 +920,7 @@ void* LoopGraph::getRealStat(const char* file) const
|
||||
}
|
||||
|
||||
extern int PASSES_DONE[EMPTY_PASS];
|
||||
static void printToBuffer(const LoopGraph *currLoop, const int childSize, char buf[512])
|
||||
static int getLoopState(const LoopGraph* currLoop)
|
||||
{
|
||||
int loopState = 0; // 0 - unknown, 1 - good, 2 - bad
|
||||
if (PASSES_DONE[CREATE_TEMPLATE_LINKS] ||
|
||||
@@ -934,49 +936,92 @@ static void printToBuffer(const LoopGraph *currLoop, const int childSize, char b
|
||||
if (currLoop->hasLimitsToParallel())
|
||||
loopState = 2;
|
||||
}
|
||||
sprintf(buf, "#%d#%d#%d#%d#%d#%d#%d#%d",
|
||||
currLoop->lineNum, currLoop->lineNumAfterLoop, currLoop->perfectLoop, currLoop->hasGoto, currLoop->hasPrints, childSize, loopState,
|
||||
currLoop->hasNonRectangularBounds);
|
||||
|
||||
return loopState;
|
||||
}
|
||||
|
||||
static int calculateNormalChildSize(const LoopGraph *currLoop)
|
||||
static json convertToJson(const LoopGraph* currLoop)
|
||||
{
|
||||
int count = 0;
|
||||
for (auto &elem : currLoop->children)
|
||||
count += (elem->lineNum > 0) ? 1 : 0;
|
||||
return count;
|
||||
}
|
||||
json loop;
|
||||
|
||||
void convertToString(const LoopGraph *currLoop, string &result)
|
||||
{
|
||||
if (currLoop && currLoop->lineNum > 0)
|
||||
{
|
||||
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);
|
||||
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;
|
||||
|
||||
result += "#" + std::to_string(currLoop->linesOfExternalGoTo.size());
|
||||
for (int i = 0; i < currLoop->linesOfExternalGoTo.size(); ++i)
|
||||
result += "#" + std::to_string(currLoop->linesOfExternalGoTo[i]);
|
||||
json calls = json::array();
|
||||
for (auto& [func, line] : currLoop->calls)
|
||||
{
|
||||
json call;
|
||||
call["line"] = line;
|
||||
call["funcName"] = func;
|
||||
|
||||
result += "#" + std::to_string(currLoop->linesOfInternalGoTo.size());
|
||||
for (int i = 0; i < currLoop->linesOfInternalGoTo.size(); ++i)
|
||||
result += "#" + std::to_string(currLoop->linesOfInternalGoTo[i]);
|
||||
|
||||
result += "#" + std::to_string(currLoop->linesOfIO.size());
|
||||
for (auto& i : currLoop->linesOfIO)
|
||||
result += "#" + std::to_string(i);
|
||||
|
||||
result += "#" + std::to_string(currLoop->linesOfStop.size());
|
||||
for (auto& i : currLoop->linesOfStop)
|
||||
result += "#" + std::to_string(i);
|
||||
|
||||
for (int i = 0; i < (int)currLoop->children.size(); ++i)
|
||||
convertToString(currLoop->children[i], result);
|
||||
calls.push_back(call);
|
||||
}
|
||||
loop["funcCalls"] = calls;
|
||||
|
||||
json e_gotos = json::array();
|
||||
for (auto& line : currLoop->linesOfExternalGoTo)
|
||||
e_gotos.push_back(line);
|
||||
loop["extGotos"] = e_gotos;
|
||||
|
||||
json i_gotos = json::array();
|
||||
for (auto& line : currLoop->linesOfInternalGoTo)
|
||||
i_gotos.push_back(line);
|
||||
loop["intGotos"] = i_gotos;
|
||||
|
||||
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;
|
||||
}
|
||||
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,7 +497,6 @@ void processLoopInformationForFunction(std::map<LoopGraph*, std::map<DIST::Array
|
||||
void addToDistributionGraph(const std::map<LoopGraph*, std::map<DIST::Array*, ArrayInfo*>>& loopInfo, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls);
|
||||
void 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,8 +2,10 @@
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "graph_loops.h"
|
||||
#include "../Distribution/DvmhDirective.h"
|
||||
#include "Utils/json.hpp"
|
||||
|
||||
struct SpfInterval;
|
||||
|
||||
@@ -18,3 +20,5 @@ 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);
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "../Distribution/Distribution.h"
|
||||
#include "../Utils/AstWrapper.h"
|
||||
|
||||
#include "../Utils/json.hpp"
|
||||
|
||||
#if __SPF
|
||||
#include "../Utils/SgUtils.h"
|
||||
#endif
|
||||
@@ -235,35 +237,42 @@ public:
|
||||
return retVal;
|
||||
}
|
||||
|
||||
std::string toString()
|
||||
nlohmann::json toJson()
|
||||
{
|
||||
std::string retVal = "";
|
||||
nlohmann::json retVal;
|
||||
|
||||
retVal += "#" + std::to_string(regionId);
|
||||
retVal += "#" + originalName;
|
||||
retVal += "#" + std::to_string(lines.size());
|
||||
retVal["packedRegionId"] = std::to_string(regionId);
|
||||
retVal["originalName"] = originalName;
|
||||
|
||||
for (auto it = lines.begin(); it != lines.end(); ++it)
|
||||
nlohmann::json arrays = nlohmann::json::array();
|
||||
for (auto& array : allArrays.GetArrays())
|
||||
arrays.push_back(array->toJson());
|
||||
retVal["packedArrays"] = arrays;
|
||||
|
||||
nlohmann::json linesInfo = nlohmann::json::array();
|
||||
for (auto& [file, linesByFile] : lines)
|
||||
{
|
||||
retVal += "|" + it->first + "|";
|
||||
retVal += std::to_string(it->second.size());
|
||||
for (int i = 0; i < it->second.size(); ++i)
|
||||
retVal += "#" + std::to_string(it->second[i].lines.first) + "#" + std::to_string(it->second[i].lines.second);
|
||||
nlohmann::json linesRegs;
|
||||
nlohmann::json lines = nlohmann::json::array();
|
||||
|
||||
for (auto& elem : linesByFile)
|
||||
{
|
||||
JSON pair;
|
||||
pair["key"] = elem.lines.first;
|
||||
pair["value"] = elem.lines.second;
|
||||
lines.push_back(pair);
|
||||
}
|
||||
linesRegs["file"] = file;
|
||||
linesRegs["lines"] = lines;
|
||||
|
||||
const std::set<DIST::Array*> &arrays = allArrays.GetArrays();
|
||||
retVal += "#" + std::to_string(arrays.size());
|
||||
|
||||
//create map<array_address, DIST::Array_toString()>
|
||||
for (auto it = arrays.begin(); it != arrays.end(); ++it)
|
||||
{
|
||||
retVal += "#" + std::to_string((long long)(*it));
|
||||
retVal += "#" + (*it)->toString();
|
||||
linesInfo.push_back(linesRegs);
|
||||
}
|
||||
retVal["regionsLines"] = linesInfo;
|
||||
|
||||
retVal += "#" + std::to_string(dataDirectives.alignRules.size());
|
||||
for (int i = 0; i < dataDirectives.alignRules.size(); ++i)
|
||||
retVal += dataDirectives.alignRules[i].toString();
|
||||
nlohmann::json alignRules = nlohmann::json::array();
|
||||
for (auto& rule : dataDirectives.alignRules)
|
||||
alignRules.push_back(rule.toJson());
|
||||
retVal["alignRules"] = alignRules;
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -215,6 +215,8 @@ void calculateStatsForPredictor(const map<string, vector<FuncInfo*>>& allFuncInf
|
||||
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();
|
||||
|
||||
@@ -225,10 +227,12 @@ void calculateStatsForPredictor(const map<string, vector<FuncInfo*>>& allFuncInf
|
||||
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))
|
||||
if (!isSgExecutableStatement(st) || isDVM_stat(st) || isSPF_stat(st) ||
|
||||
!__gcov_doesThisLineExecuted(byFile.first, st->lineNumber()))
|
||||
continue;
|
||||
|
||||
int line = st->lineNumber();
|
||||
@@ -428,6 +432,7 @@ 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();
|
||||
@@ -445,9 +450,11 @@ static void parallelDir(const map<DIST::Array*, int>& byPos, SgExpression* spec,
|
||||
}
|
||||
|
||||
for (int z = execs.size() - 1; z > 0; --z)
|
||||
if (execs[z - 1] != 0)
|
||||
execs[z] /= execs[z - 1];
|
||||
|
||||
auto& info = getInfo(before, gcov);
|
||||
if (info.getExecutedCount() && loopSymbs.size() > 1)
|
||||
execs[0] /= info.getExecutedCount();
|
||||
|
||||
parallel["iterations_count"] = execs;
|
||||
@@ -501,8 +508,6 @@ static void parallelDir(const map<DIST::Array*, int>& byPos, SgExpression* spec,
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
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;
|
||||
@@ -589,6 +594,9 @@ void parseDvmDirForPredictor(const map<tuple<int, string, string>, pair<DIST::Ar
|
||||
|
||||
for (auto st = stat->lexNext(); st != stat->lastNodeOfStmt(); st = st->lexNext())
|
||||
{
|
||||
if (!__gcov_doesThisLineExecuted(byFile.first, st->lineNumber()))
|
||||
continue;
|
||||
|
||||
SgExpression* list;
|
||||
SgExpression* dup;
|
||||
auto line = 0;
|
||||
@@ -596,7 +604,10 @@ 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)->symbol(), st->expr(0)->lhs(), st, st->expr(1), gcov, directives, commonBlocks, allFuncInfo);
|
||||
parallelDir(byPos, st->expr(2),
|
||||
st->expr(0) ? st->expr(0)->symbol() : NULL,
|
||||
st->expr(0) ? st->expr(0)->lhs() : NULL,
|
||||
st, st->expr(1), gcov, directives, commonBlocks, allFuncInfo);
|
||||
break;
|
||||
case DVM_VAR_DECL: // TODO
|
||||
{
|
||||
@@ -615,6 +626,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()));
|
||||
list = list->rhs();
|
||||
}
|
||||
@@ -627,6 +639,9 @@ 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;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <vector>
|
||||
#include "dvm.h"
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
#include "../Utils/json.hpp"
|
||||
|
||||
class ParallelStats
|
||||
{
|
||||
@@ -11,10 +12,10 @@ public:
|
||||
RemoteCount = ShadowCount = ReductionCount = AcrossCount = 0;
|
||||
}
|
||||
|
||||
int RemoteCount;
|
||||
int ShadowCount;
|
||||
int ReductionCount;
|
||||
int AcrossCount;
|
||||
int RemoteCount = 0;
|
||||
int ShadowCount = 0;
|
||||
int ReductionCount = 0;
|
||||
int AcrossCount = 0;
|
||||
};
|
||||
|
||||
class PredictorStats
|
||||
@@ -27,28 +28,32 @@ public:
|
||||
}
|
||||
|
||||
ParallelStats ParallelStat;
|
||||
int ParallelCount;
|
||||
int RemoteCount;
|
||||
int RedistributeCount;
|
||||
int IntervalCount;
|
||||
int TotalScoreComm;
|
||||
int TotalScorePar;
|
||||
int TotalScoreDist;
|
||||
int ParallelCount = 0;
|
||||
int RemoteCount = 0;
|
||||
int RedistributeCount = 0;
|
||||
int IntervalCount = 0;
|
||||
int TotalScoreComm = 0;
|
||||
int TotalScorePar = 0;
|
||||
int TotalScoreDist = 0;
|
||||
|
||||
std::string to_string()
|
||||
nlohmann::json toJson()
|
||||
{
|
||||
std::string res = "";
|
||||
res += std::to_string(ParallelCount) + "|";
|
||||
res += std::to_string(RemoteCount) + "|";
|
||||
res += std::to_string(RedistributeCount) + "|";
|
||||
res += std::to_string(IntervalCount) + "|";
|
||||
nlohmann::json stat;
|
||||
|
||||
res += std::to_string(ParallelStat.RemoteCount) + "|";
|
||||
res += std::to_string(ParallelStat.ShadowCount) + "|";
|
||||
res += std::to_string(ParallelStat.ReductionCount) + "|";
|
||||
res += std::to_string(ParallelStat.AcrossCount);
|
||||
stat["ParallelCount"] = ParallelCount;
|
||||
stat["RemoteCount"] = RemoteCount;
|
||||
stat["RedistributeCount"] = RedistributeCount;
|
||||
stat["IntervalCount"] = IntervalCount;
|
||||
|
||||
return res;
|
||||
stat["PS_RemoteCount"] = ParallelStat.RemoteCount;
|
||||
stat["PS_ShadowCount"] = ParallelStat.ShadowCount;
|
||||
stat["PS_ReductionCount"] = ParallelStat.ReductionCount;
|
||||
stat["PS_AcrossCount"] = ParallelStat.AcrossCount;
|
||||
|
||||
//TODO: need to improve
|
||||
// (summed.TotalScoreComm != 0 ? 1.0 / summed.TotalScoreComm : 0.0) + (double)summed.TotalScorePar * 1000 + (countOfDist == 0 ? -5000 : countOfDist);
|
||||
stat["TotalScore"] = -1 * (ParallelStat.RemoteCount + ParallelStat.ShadowCount + ParallelStat.ReductionCount + ParallelStat.AcrossCount);
|
||||
return stat;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -387,7 +387,50 @@ static string shiftLines(const string &in, const map<string, const FileInfo*> &m
|
||||
return newStr;
|
||||
}
|
||||
|
||||
static int dumpErrors(const vector<FileInfo>& listOfProject, const vector<string>& errors)
|
||||
static void addMessage(const string& in, const map<string, const FileInfo*>& mapOfFiles,
|
||||
const FileInfo* currF, map<string, vector<Messages>>& messages, typeMessage type)
|
||||
{
|
||||
int byNum = 0;
|
||||
|
||||
auto it = in.find("on line ");
|
||||
if (it != string::npos)
|
||||
it += strlen("on line ");
|
||||
|
||||
int line = 0;
|
||||
sscanf(in.c_str() + it, "%d", &line);
|
||||
|
||||
auto it1 = in.find("of", it + 1);
|
||||
if (it1 == string::npos)
|
||||
return;
|
||||
it1 += 3;
|
||||
|
||||
string fileN = in.substr(it1, in.find(':', it1) - it1);
|
||||
auto itF = mapOfFiles.find(fileN);
|
||||
if (itF != mapOfFiles.end() && itF->second != currF)
|
||||
{
|
||||
byNum = itF->second->includesAdded;
|
||||
if (byNum != 0)
|
||||
{
|
||||
if (line - byNum <= 0)
|
||||
{
|
||||
//return in;
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
}
|
||||
else
|
||||
line -= byNum;
|
||||
}
|
||||
}
|
||||
|
||||
const string newStr = in.substr(0, it) + std::to_string(line) + in.substr(in.find(' ', it + 1));
|
||||
|
||||
wstring messageE, messageR;
|
||||
__spf_printToLongBuf(messageE, L"%s", to_wstring(newStr).c_str());
|
||||
__spf_printToLongBuf(messageR, L"%s", to_wstring(newStr).c_str());
|
||||
|
||||
messages[fileN].push_back(Messages(type, line, messageR, messageE, 6000));
|
||||
}
|
||||
|
||||
static int dumpErrors(const vector<FileInfo>& listOfProject, const vector<string>& errors, map<string, vector<Messages>>& messages)
|
||||
{
|
||||
int errorsCount = 0;
|
||||
map<string, const FileInfo*> mapOfFiles;
|
||||
@@ -420,9 +463,13 @@ static int dumpErrors(const vector<FileInfo>& listOfProject, const vector<string
|
||||
for (auto& elem : splited)
|
||||
{
|
||||
if (elem.find("Warning 308") != string::npos)
|
||||
{
|
||||
addMessage(elem, mapOfFiles, &file, messages, WARR);
|
||||
outS += shiftLines(elem, mapOfFiles, &file) + "\n";
|
||||
}
|
||||
else if (elem.find("Error") != string::npos)
|
||||
{
|
||||
addMessage(elem, mapOfFiles, &file, messages, ERROR);
|
||||
errS += shiftLines(elem, mapOfFiles, &file) + "\n";
|
||||
errorsCount++;
|
||||
}
|
||||
@@ -652,7 +699,7 @@ static int parseFiles(vector<string>& errors, vector<FileInfo>& listOfProject, v
|
||||
return rethrow;
|
||||
}
|
||||
|
||||
int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int parseForInlining)
|
||||
int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int parseForInlining, map<string, vector<Messages>>& messages)
|
||||
{
|
||||
FILE* list = fopen(proj, "r");
|
||||
if (!list)
|
||||
@@ -723,7 +770,7 @@ int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int pars
|
||||
vector<string> errors;
|
||||
|
||||
int rethrow = parseFiles(errors, listOfProject, filesCompilationOrder, parseForInlining);
|
||||
int errCount = dumpErrors(listOfProject, errors);
|
||||
int errCount = dumpErrors(listOfProject, errors, messages);
|
||||
|
||||
if (rethrow != 0)
|
||||
throw rethrow;
|
||||
@@ -732,6 +779,8 @@ int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int pars
|
||||
|
||||
void parseFiles(int argc, char** argv)
|
||||
{
|
||||
map<string, vector<Messages>> messages;
|
||||
|
||||
bool isInline = false;
|
||||
auto result = splitCommandLineForParse(argv, argc, isInline);
|
||||
if (result.second.size() == 0)
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
int parseFiles(const char* proj, std::vector<std::string>& filesCompilationOrder, int parseForInlining);
|
||||
int parseFiles(const char* proj, std::vector<std::string>& filesCompilationOrder, int parseForInlining, std::map<std::string, std::vector<Messages>>& messages);
|
||||
void parseFiles(int argc, char** argv);
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
#include "DvmhRegions/LoopChecker.h"
|
||||
#include "DvmhRegions/ReadWriteAnalyzer.h"
|
||||
#include "Utils/utils.h"
|
||||
#include "Utils/json.hpp"
|
||||
#include "Distribution/Array.h"
|
||||
|
||||
#include "VisualizerCalls/get_information.h"
|
||||
@@ -108,6 +109,7 @@ using namespace std;
|
||||
using std::chrono::high_resolution_clock;
|
||||
using std::chrono::duration_cast;
|
||||
using std::chrono::milliseconds;
|
||||
using json = nlohmann::json;
|
||||
|
||||
int PASSES_DONE[EMPTY_PASS];
|
||||
bool PASSES_DONE_INIT = false;
|
||||
@@ -332,7 +334,8 @@ 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& [_, incls] : itI->second)
|
||||
for (auto& incl : incls)
|
||||
if (allIncludeFiles.find(incl) != allIncludeFiles.end())
|
||||
allIncludeFiles.erase(incl);
|
||||
}
|
||||
@@ -828,20 +831,27 @@ 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, set<string>()));
|
||||
fileIt = includeDependencies.insert(fileIt, make_pair(file_name, map<int, set<string>>()));
|
||||
|
||||
set<string> modFiles;
|
||||
for (auto& elem : moduleDecls)
|
||||
modFiles.insert(elem.second);
|
||||
|
||||
for (SgStatement *first = file->firstStatement(); first; first = first->lexNext())
|
||||
SgStatement* lastFromFile = NULL;
|
||||
for (SgStatement *st = file->firstStatement(); st; st = st->lexNext())
|
||||
{
|
||||
if (strcmp(file_name, first->fileName()))
|
||||
{
|
||||
if (first->variant() == MODULE_STMT && modFiles.find(first->fileName()) != modFiles.end())
|
||||
first = first->lastNodeOfStmt();
|
||||
if (st->variant() == MODULE_STMT && modFiles.find(st->fileName()) != modFiles.end())
|
||||
st = st->lastNodeOfStmt();
|
||||
else
|
||||
fileIt->second.insert(first->fileName());
|
||||
{
|
||||
if (strcmp(file_name, st->fileName()))
|
||||
{
|
||||
if (lastFromFile == NULL)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
fileIt->second[lastFromFile->lineNumber()].insert(st->fileName());
|
||||
}
|
||||
else
|
||||
lastFromFile = st;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1573,6 +1583,7 @@ 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)
|
||||
{
|
||||
@@ -1607,14 +1618,17 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
set<string> includedToThisFile;
|
||||
if (itDep != includeDependencies.end())
|
||||
{
|
||||
for (auto &inclDep : itDep->second)
|
||||
for (auto& [_, incls] : itDep->second)
|
||||
{
|
||||
auto comm = commentsToInclude.find(inclDep);
|
||||
for (auto& incl : incls)
|
||||
{
|
||||
auto comm = commentsToInclude.find(incl);
|
||||
if (comm != commentsToInclude.end())
|
||||
for (auto &allComm : comm->second)
|
||||
for (auto& allComm : comm->second)
|
||||
includedToThisFile.insert(allComm.second.begin(), allComm.second.end());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int z = 0; z < parallelRegions.size(); ++z)
|
||||
{
|
||||
@@ -2046,7 +2060,7 @@ static void findFunctionsToInclude(bool needToAddErrors)
|
||||
SPF_messages[byFile.first].push_back(message);
|
||||
else
|
||||
{
|
||||
if (message.type != ERROR)
|
||||
if (message.getType() != ERROR)
|
||||
SPF_messages[byFile.first].push_back(message);
|
||||
else
|
||||
lastErrors[byFile.first].push_back(message);
|
||||
@@ -2221,8 +2235,7 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam
|
||||
runPass(GROUP_ACTUAL_AND_REMOTE, proj_name, folderName);
|
||||
|
||||
runAnalysis(*project, CALCULATE_STATS_SCHEME, false);
|
||||
for (auto& elem : allPredictorStats)
|
||||
__spf_print(1, " stat for file %s: %s\n", elem.first.c_str(), elem.second.to_string().c_str());
|
||||
|
||||
//TODO: need to rewrite this to new algo
|
||||
/*if (!folderName && !consoleMode || predictOn)
|
||||
runAnalysis(*project, PREDICT_SCHEME, false); */
|
||||
@@ -2390,7 +2403,7 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam
|
||||
break;
|
||||
case PARSE_FILES:
|
||||
{
|
||||
int err = parseFiles(proj_name, filesCompilationOrder, parseForInlining);
|
||||
int err = parseFiles(proj_name, filesCompilationOrder, parseForInlining, SPF_messages);
|
||||
if (err != 0)
|
||||
throw err;
|
||||
}
|
||||
@@ -2659,26 +2672,28 @@ 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)
|
||||
{
|
||||
string toPrint = "";
|
||||
for (int z = 0; z < message.engMessage.size(); ++z)
|
||||
toPrint += message.engMessage[z];
|
||||
string type;
|
||||
if (message.type == WARR)
|
||||
type = "WARR";
|
||||
else if (message.type == ERROR)
|
||||
type = "ERROR";
|
||||
else if (message.type == NOTE)
|
||||
type = "NOTE";
|
||||
else
|
||||
type = "UNKN";
|
||||
message.print(byFile.first);
|
||||
messages.push_back(message.toJson());
|
||||
}
|
||||
inFile["messages"] = messages;
|
||||
byFileArray.push_back(inFile);
|
||||
}
|
||||
json allMessages;
|
||||
allMessages["allMessage"] = byFileArray;
|
||||
|
||||
printf("%s - [#%d: %s: line %d]: %s\n", type.c_str(), message.group, byFile.first.c_str(), message.line, toPrint.c_str());
|
||||
}
|
||||
}
|
||||
FILE* outF = fopen("dump_messages.json", "w");
|
||||
fprintf(outF, "%s", allMessages.dump().c_str());
|
||||
fclose(outF);
|
||||
}
|
||||
|
||||
deleteAllAllocatedData(withDel);
|
||||
|
||||
@@ -85,7 +85,7 @@ std::map<std::string, std::map<int, std::set<std::string>>> commentsToInclude;
|
||||
//
|
||||
|
||||
//for INSERT_INCLUDES
|
||||
std::map<std::string, std::set<std::string>> filesToInclude; // file -> includes
|
||||
std::map<std::string, std::map<int, std::set<std::string>>> filesToInclude; // file -> includes [nearest line, include]
|
||||
//
|
||||
|
||||
//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::set<std::string>> includeDependencies; // file -> includes
|
||||
std::map<std::string, std::map<int, std::set<std::string>>> includeDependencies; // file -> includes [nearest line, include]
|
||||
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,6 +309,8 @@ 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);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include "json.hpp"
|
||||
|
||||
#ifdef __SPF
|
||||
#include "dvm.h"
|
||||
#endif
|
||||
@@ -143,6 +145,9 @@ enum typeMessage { WARR, ERROR, NOTE };
|
||||
// 06 "%s clause can be used only once."
|
||||
// 07 "Variable '%s' can't be used in FILES and EXCEPT clauses at the same time."
|
||||
|
||||
// 6000 PARSER GROUP
|
||||
//
|
||||
|
||||
extern int langOfMessages;
|
||||
struct Messages
|
||||
{
|
||||
@@ -164,18 +169,41 @@ public:
|
||||
engMessage.erase(engMessage.begin() + engMessage.size() - 1);
|
||||
}
|
||||
|
||||
std::wstring toString() const
|
||||
nlohmann::json toJson() const
|
||||
{
|
||||
std::wstring retVal = L"|";
|
||||
retVal += std::to_wstring((int)type) + L" ";
|
||||
retVal += std::to_wstring(line) + L" ";
|
||||
retVal += std::to_wstring(group);
|
||||
retVal += L"|" + value;
|
||||
return retVal;
|
||||
nlohmann::json resVal;
|
||||
|
||||
resVal["line"] = line;
|
||||
resVal["group"] = group;
|
||||
resVal["value"] = std::string(value.begin(), value.end());
|
||||
resVal["type"] = (int)type;
|
||||
return resVal;
|
||||
}
|
||||
|
||||
std::string getString() const { return std::string(engMessage.begin(), engMessage.end()); }
|
||||
public:
|
||||
typeMessage getType() const { return type; }
|
||||
int getLine() const { return line; }
|
||||
|
||||
void print(const std::string& file) const
|
||||
{
|
||||
std::string toPrint = "";
|
||||
for (int z = 0; z < engMessage.size(); ++z)
|
||||
toPrint += engMessage[z];
|
||||
|
||||
std::string typeStr;
|
||||
if (type == WARR)
|
||||
typeStr = "WARR";
|
||||
else if (type == ERROR)
|
||||
typeStr = "ERROR";
|
||||
else if (type == NOTE)
|
||||
typeStr = "NOTE";
|
||||
else
|
||||
typeStr = "UNKN";
|
||||
|
||||
printf("%s - [#%d: %s: line %d]: %s\n", typeStr.c_str(), group, file.c_str(), line, toPrint.c_str());
|
||||
}
|
||||
|
||||
auto getUniqKey() const { return std::make_tuple(type, group, line, value); }
|
||||
private:
|
||||
typeMessage type;
|
||||
int group;
|
||||
int line;
|
||||
|
||||
22828
src/Utils/json.hpp
Normal file
22828
src/Utils/json.hpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -309,9 +309,18 @@ static void getModuleSymbols(SgStatement* func, set<SgSymbol*>& symbs)
|
||||
|
||||
SgSymbol* s = func->symbol()->next();
|
||||
while (s)
|
||||
{
|
||||
if (func->variant() == MODULE_STMT)
|
||||
{
|
||||
if (s->scope() && s->scope()->symbol() && s->scope()->symbol()->identifier())
|
||||
if (s->scope()->symbol()->identifier() == currScope)
|
||||
symbs.insert(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IS_BY_USE(s) && s->scope() && s->scope()->symbol()->identifier() == currScope)
|
||||
symbs.insert(s);
|
||||
}
|
||||
s = s->next();
|
||||
}
|
||||
}
|
||||
@@ -325,18 +334,18 @@ const set<SgSymbol*>& getModuleSymbols(SgStatement *func)
|
||||
set<SgSymbol*> symbs;
|
||||
getModuleSymbols(func, symbs);
|
||||
|
||||
//if function in contains
|
||||
//if function or module in contains
|
||||
auto cp = func->controlParent();
|
||||
if (isSgProgHedrStmt(cp))
|
||||
if (isSgProgHedrStmt(cp) || cp->variant() == MODULE_STMT)
|
||||
getModuleSymbols(cp, symbs);
|
||||
|
||||
symbolsForFunc[func->symbol()->identifier()] = symbs;
|
||||
return symbs;
|
||||
}
|
||||
|
||||
SgSymbol* getNameInLocation(SgStatement* func, const string& varName, const string& locName)
|
||||
static void findSymbol(SgStatement* func, const string& varName, const string& locName,
|
||||
map<string, SgSymbol*>& altNames)
|
||||
{
|
||||
map<string, SgSymbol*> altNames;
|
||||
for (const auto& s : getModuleSymbols(func))
|
||||
{
|
||||
SgSymbol* orig = OriginalSymbol(s);
|
||||
@@ -344,11 +353,22 @@ SgSymbol* getNameInLocation(SgStatement* func, const string& varName, const stri
|
||||
if (orig->identifier() == varName && orig->scope()->symbol()->identifier() == locName)
|
||||
altNames[s->identifier()] = s;
|
||||
}
|
||||
}
|
||||
|
||||
SgSymbol* getNameInLocation(SgStatement* func, const string& varName, const string& locName)
|
||||
{
|
||||
const string clearName = correctSymbolModuleName(varName);
|
||||
|
||||
map<string, SgSymbol*> altNames;
|
||||
findSymbol(func, varName, locName, altNames);
|
||||
|
||||
if (altNames.size() == 0 && clearName != varName)
|
||||
findSymbol(func, clearName, locName, altNames);
|
||||
|
||||
if (altNames.size() > 0)
|
||||
return altNames.begin()->second;
|
||||
else {
|
||||
__spf_print(1, "%s %s %s\n", func->symbol()->identifier(), varName.c_str(), locName.c_str());
|
||||
__spf_print(1, "%s (%s %s) %s\n", func->symbol()->identifier(), clearName.c_str(), varName.c_str(), locName.c_str());
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
}
|
||||
|
||||
@@ -384,6 +404,15 @@ SgSymbol* getNameInLocation(SgSymbol* curr, SgStatement* location)
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
string correctSymbolModuleName(const string& origFull)
|
||||
{
|
||||
auto it = origFull.find("::");
|
||||
if (it == string::npos)
|
||||
return origFull;
|
||||
else
|
||||
return origFull.substr(it + 2);
|
||||
}
|
||||
|
||||
namespace Distribution
|
||||
{
|
||||
const string Array::GetNameInLocation(void* location_p) const
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
std::string correctSymbolModuleName(const std::string& origFull);
|
||||
const std::set<SgSymbol*>& getModuleSymbols(SgStatement* func);
|
||||
void getModulesAndFunctions(SgFile* file, std::vector<SgStatement*>& modulesAndFunctions);
|
||||
void findModulesInFile(SgFile* file, std::vector<SgStatement*>& modules);
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "../Distribution/Arrays.h"
|
||||
#include "../DynamicAnalysis/gcov_info.h"
|
||||
#include "../ParallelizationRegions/ParRegions.h"
|
||||
#include "json.hpp"
|
||||
|
||||
#if __SPF
|
||||
#include "acc_analyzer.h"
|
||||
@@ -42,6 +43,7 @@ using std::set;
|
||||
using std::vector;
|
||||
using std::string;
|
||||
using std::wstring;
|
||||
using json = nlohmann::json;
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
#include <filesystem>
|
||||
@@ -427,7 +429,7 @@ static map<string, vector<Messages>> removeCopies(map<string, vector<Messages>>
|
||||
map<tuple<typeMessage, int, int, wstring>, const Messages*> uniq;
|
||||
for (auto& message : byFile.second)
|
||||
{
|
||||
auto key = make_tuple(message.type, message.group, message.line, message.value);
|
||||
auto key = message.getUniqKey();
|
||||
/*string tmp = "";
|
||||
for (auto& s : message.toString())
|
||||
tmp += (char)s;
|
||||
@@ -460,7 +462,7 @@ static void convertGlobalMessagesBuffer(short *&result, int *&resultSize)
|
||||
bool waschanged = false;
|
||||
for (auto &message : byFile.second)
|
||||
{
|
||||
if (message.line > 0)
|
||||
if (message.getLine() > 0)
|
||||
newVal.push_back(message);
|
||||
else
|
||||
waschanged = true;
|
||||
@@ -470,22 +472,30 @@ static void convertGlobalMessagesBuffer(short *&result, int *&resultSize)
|
||||
byFile.second = newVal;
|
||||
}
|
||||
|
||||
wstring val = L"";
|
||||
val += std::to_wstring(copySPF_messages.size());
|
||||
for (auto it = copySPF_messages.begin(); it != copySPF_messages.end(); ++it)
|
||||
json allMessages = json::array();
|
||||
for (auto& byFile : copySPF_messages)
|
||||
{
|
||||
val += L"|" + to_wstring(it->first.c_str()) + L"|" + std::to_wstring(it->second.size());
|
||||
for (int k = 0; k < it->second.size(); ++k)
|
||||
val += it->second[k].toString();
|
||||
json inFile;
|
||||
inFile["file"] = byFile.first;
|
||||
|
||||
json array = json::array();
|
||||
for (auto& message : byFile.second)
|
||||
{
|
||||
json msg = message.toJson();
|
||||
array.push_back(msg);
|
||||
}
|
||||
inFile["messages"] = array;
|
||||
allMessages.push_back(inFile);
|
||||
}
|
||||
|
||||
const unsigned len = (unsigned)val.size();
|
||||
result = new short[len + 1];
|
||||
allocated.insert(result);
|
||||
json all;
|
||||
all["allMessages"] = allMessages;
|
||||
|
||||
result[len] = '\0';
|
||||
for (unsigned i = 0; i < len; ++i)
|
||||
result[i] = val[i];
|
||||
const string str = all.dump();
|
||||
const unsigned len = (unsigned)str.size();
|
||||
|
||||
copyStringToShort(result, str);
|
||||
allocated.insert(result);
|
||||
|
||||
resultSize = new int[1];
|
||||
resultSize[0] = (int)len;
|
||||
@@ -1687,3 +1697,15 @@ set<string> fillDistributedArrays(const DataDirective& dataDirectives,
|
||||
distrArrays.insert(shortName ? elem->GetShortName() : elem->GetName());
|
||||
return distrArrays;
|
||||
}
|
||||
|
||||
void copyStringToShort(short*& result, const string& resVal, bool withEnd)
|
||||
{
|
||||
result = new short[resVal.size() + 1];
|
||||
allocated.insert(result);
|
||||
|
||||
for (int i = 0; i < resVal.size(); ++i)
|
||||
result[i] = resVal[i];
|
||||
|
||||
if (withEnd)
|
||||
result[resVal.size()] = (short)'\0';
|
||||
}
|
||||
@@ -96,3 +96,5 @@ std::vector<std::string> splitAndArgvCreate(const std::string& options);
|
||||
|
||||
std::set<DIST::Array*> fillDistributedArraysD(const DataDirective& dataDirectives, const std::map<DIST::Array*, std::tuple<int, std::string, std::string>>& tableOfUniqNamesByArray, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls, bool onlyCommon = false);
|
||||
std::set<std::string> fillDistributedArrays(const DataDirective& dataDirectives, const std::map<DIST::Array*, std::tuple<int, std::string, std::string>>& tableOfUniqNamesByArray, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls, bool onlyCommon = false, bool shortName = false);
|
||||
|
||||
void copyStringToShort(short*& result, const std::string& resVal, bool withEnd = true);
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION_SPF "2401"
|
||||
#define VERSION_SPF "2422"
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "../LoopAnalyzer/loop_analyzer.h"
|
||||
#include "../DirectiveProcessing/insert_directive.h"
|
||||
#include "../ProjectManipulation/PerfAnalyzer.h"
|
||||
#include "Utils/json.hpp"
|
||||
|
||||
#include "BuildGraph.h"
|
||||
|
||||
@@ -61,6 +62,7 @@ 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;
|
||||
@@ -216,18 +218,6 @@ static bool tryOpenProjectFile(const char *project)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void copyStringToShort(short *&result, const string &resVal, bool withEnd = true)
|
||||
{
|
||||
result = new short[resVal.size() + 1];
|
||||
allocated.insert(result);
|
||||
|
||||
for (int i = 0; i < resVal.size(); ++i)
|
||||
result[i] = resVal[i];
|
||||
|
||||
if (withEnd)
|
||||
result[resVal.size()] = (short)'\0';
|
||||
}
|
||||
|
||||
volatile int passDone = 0;
|
||||
static volatile int rethrow = 0;
|
||||
static void runPassesLoop(const vector<passes> &passesToRun, const char *prName, const char *folderNameChar)
|
||||
@@ -463,14 +453,15 @@ int SPF_ParseFilesWithOrder(void*& context, int winHandler, short* options, shor
|
||||
{
|
||||
runPassesForVisualizer(projName, { PARSE_FILES });
|
||||
|
||||
string resVal = "";
|
||||
for (auto& elem : filesCompilationOrder)
|
||||
{
|
||||
if (resVal == "")
|
||||
resVal += elem;
|
||||
else
|
||||
resVal += "|" + elem;
|
||||
}
|
||||
json filesArray = json::array();
|
||||
|
||||
for (auto& file : filesCompilationOrder)
|
||||
filesArray.push_back(file);
|
||||
|
||||
json filesOrder;
|
||||
filesOrder["allFiles"] = filesArray;
|
||||
|
||||
string resVal = filesOrder.dump();
|
||||
copyStringToShort(result, resVal);
|
||||
retSize = 0;
|
||||
}
|
||||
@@ -510,26 +501,7 @@ int SPF_GetGraphLoops(void*& context, int winHandler, short *options, short *pro
|
||||
{
|
||||
runPassesForVisualizer(projName, { LOOP_GRAPH } );
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
string resVal = convertToJson(loopGraph).dump();
|
||||
copyStringToShort(result, resVal);
|
||||
retSize = (int)resVal.size() + 1;
|
||||
}
|
||||
@@ -569,15 +541,7 @@ int SPF_GetGraphFunctions(void*& context, int winHandler, short *options, short
|
||||
{
|
||||
runPassesForVisualizer(projName, { FILL_PAR_REGIONS_LINES } );
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
string resVal = convertToJson(allFuncInfo).dump();
|
||||
copyStringToShort(result, resVal);
|
||||
retSize = (int)resVal.size() + 1;
|
||||
}
|
||||
@@ -667,11 +631,19 @@ int SPF_GetGraphFunctionPositions(void*& context, int winHandler, short *options
|
||||
|
||||
auto positions = buildLocationOfGraph(allFuncInfo, iters, coef, 0.9 * w, 0.9 * h, sendVisible ? &visible : NULL);
|
||||
|
||||
string resVal = "";
|
||||
resVal = to_string(positions.size());
|
||||
for (auto& elem : positions)
|
||||
resVal += "|" + elem.first + "|" + to_string(elem.second.first) + "|" + to_string(elem.second.second);
|
||||
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 = allPositions.dump();
|
||||
copyStringToShort(result, resVal);
|
||||
retSize = (int)resVal.size() + 1;
|
||||
}
|
||||
@@ -697,61 +669,6 @@ 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];
|
||||
@@ -838,15 +755,17 @@ int SPF_GetArrayDistribution(void*& context, int winHandler, short *options, sho
|
||||
else
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
string resVal = "";
|
||||
resVal += to_string(parallelRegions.size());
|
||||
for (int i = 0; i < parallelRegions.size(); ++i)
|
||||
resVal += parallelRegions[i]->toString();
|
||||
json regions = json::array();
|
||||
for (auto& reg : parallelRegions)
|
||||
{
|
||||
json currReg = reg->toJson();
|
||||
regions.push_back(currReg);
|
||||
}
|
||||
|
||||
//__spf_print(1, "==============\n");
|
||||
//__spf_print(1, "%s\n", resVal.c_str());
|
||||
//__spf_print(1, "==============\n");
|
||||
json allRegions;
|
||||
allRegions["allRegions"] = regions;
|
||||
|
||||
string resVal = allRegions.dump();
|
||||
copyStringToShort(result, resVal);
|
||||
retSize = (int)resVal.size() + 1;
|
||||
}
|
||||
@@ -1135,7 +1054,6 @@ int SPF_CreateParallelVariant(void*& context, int winHandler, short *options, sh
|
||||
printf("SAPFOR: set all info done\n");
|
||||
runPassesForVisualizer(projName, { INSERT_PARALLEL_DIRS }, folderName);
|
||||
|
||||
string predictRes = "";
|
||||
PredictorStats summed;
|
||||
for (auto &predFile : allPredictorStats)
|
||||
{
|
||||
@@ -1152,43 +1070,10 @@ int SPF_CreateParallelVariant(void*& context, int winHandler, short *options, sh
|
||||
summed.TotalScoreDist += predFile.second.TotalScoreDist;
|
||||
summed.TotalScorePar += predFile.second.TotalScorePar;
|
||||
}
|
||||
predictRes += summed.to_string();
|
||||
//predictRes += "|" + to_string((summed.TotalScoreComm != 0 ? 1.0 / summed.TotalScoreComm : 0.0 )+ (double)summed.TotalScorePar * 1000 + (countOfDist == 0 ? -5000 : countOfDist));
|
||||
if (countOfDist == 0)
|
||||
predictRes += "|x";
|
||||
else
|
||||
predictRes += "|" + to_string(-1 * (summed.ParallelStat.AcrossCount + summed.ParallelStat.RemoteCount + summed.RedistributeCount + summed.RemoteCount));
|
||||
//predictRes += "|0";
|
||||
|
||||
//TODO: need to rewrite to new algo
|
||||
/*if (folderName == NULL)
|
||||
{
|
||||
SpfInterval *mainIterval = getMainInterval(project, intervals);
|
||||
const int idxBest = mainIterval->getBestTimeIdx();
|
||||
double speedUpBest = 1;
|
||||
int procCount = 1;
|
||||
string topo = "";
|
||||
if (idxBest != -1 && mainIterval->exec_time != 0)
|
||||
{
|
||||
speedUpBest = mainIterval->exec_time / mainIterval->predictedTimes[idxBest];
|
||||
topo += "[";
|
||||
for (int z = 0; z < topologies[idxBest].size(); ++z)
|
||||
{
|
||||
topo += to_string(topologies[idxBest][z]);
|
||||
procCount *= topologies[idxBest][z];
|
||||
if (z != topologies[idxBest].size() - 1)
|
||||
topo += "x";
|
||||
}
|
||||
topo += "]";
|
||||
}
|
||||
char buf[256];
|
||||
sprintf(buf, "%.2f", speedUpBest / procCount * 100.0);
|
||||
predictRes += "|" + string(buf) + topo;
|
||||
}
|
||||
else
|
||||
predictRes += "|0";*/
|
||||
|
||||
string predictRes = summed.toJson().dump();
|
||||
copyStringToShort(predictorStats, predictRes);
|
||||
|
||||
__spf_print(1, " statistic to send: %s\n", predictRes.c_str());
|
||||
retSize = (int)predictRes.size();
|
||||
}
|
||||
@@ -1228,8 +1113,6 @@ int SPF_GetArrayLinks(void*& context, int winHandler, short *options, short *pro
|
||||
{
|
||||
runPassesForVisualizer(projName, { CALL_GRAPH2 } );
|
||||
|
||||
string resVal = "";
|
||||
|
||||
map<DIST::Array*, set<DIST::Array*>> linkedArrays;
|
||||
for (auto& inMap : arrayLinksByFuncCalls)
|
||||
{
|
||||
@@ -1243,17 +1126,24 @@ int SPF_GetArrayLinks(void*& context, int winHandler, short *options, short *pro
|
||||
linkedArrays[ref].insert(toAdd);
|
||||
}
|
||||
|
||||
|
||||
json allLinks = json::array();
|
||||
for (auto& array : linkedArrays)
|
||||
{
|
||||
resVal += to_string(array.first->GetId()) + "|" + to_string(array.second.size()) + "|";
|
||||
json currLink;
|
||||
currLink["id"] = array.first->GetId();
|
||||
|
||||
json links = json::array();
|
||||
for (auto& link : array.second)
|
||||
resVal += to_string(link->GetId()) + "|";
|
||||
links.push_back(link->GetId());
|
||||
currLink["links"] = links;
|
||||
|
||||
allLinks.push_back(currLink);
|
||||
}
|
||||
|
||||
if (resVal[resVal.size() - 1] == '|')
|
||||
resVal.erase(resVal.size() - 1);
|
||||
json links;
|
||||
links["allLinks"] = allLinks;
|
||||
|
||||
string resVal = links.dump();
|
||||
copyStringToShort(result, resVal);
|
||||
retSize = (int)resVal.size() + 1;
|
||||
}
|
||||
@@ -1380,13 +1270,12 @@ int SPF_GetIntrinsics(void*& context, short *&result)
|
||||
return (int)resVal.size() + 1;
|
||||
}
|
||||
|
||||
extern map<string, set<string>> includeDependencies;
|
||||
extern map<string, map<int, 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;
|
||||
@@ -1394,22 +1283,30 @@ int SPF_GetIncludeDependencies(void*& context, int winHandler, short *options, s
|
||||
{
|
||||
runPassesForVisualizer(projName, { BUILD_INCLUDE_DEPENDENCIES });
|
||||
|
||||
int i = 0;
|
||||
for (auto &deps : includeDependencies)
|
||||
json inc_array = json::array();
|
||||
for (const auto& deps : includeDependencies)
|
||||
{
|
||||
if (i != 0)
|
||||
resVal += "@";
|
||||
resVal += deps.first + "@";
|
||||
int k = 0;
|
||||
for (auto &incl : deps.second)
|
||||
json includes;
|
||||
includes["file"] = deps.first;
|
||||
|
||||
json array = json::array();
|
||||
for (const auto& [line, incls] : deps.second)
|
||||
{
|
||||
if (k != 0)
|
||||
resVal += "|";
|
||||
resVal += incl;
|
||||
++k;
|
||||
for (auto& incl : incls)
|
||||
{
|
||||
json elem;
|
||||
elem["line"] = line;
|
||||
elem["dependencyFileName"] = incl;
|
||||
array.push_back(elem);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
includes["includes"] = array;
|
||||
inc_array.push_back(includes);
|
||||
}
|
||||
|
||||
json allIncludes;
|
||||
allIncludes["allIncludes"] = inc_array;
|
||||
string resVal = allIncludes.dump();
|
||||
|
||||
copyStringToShort(result, resVal);
|
||||
retSize = (int)resVal.size() + 1;
|
||||
@@ -1446,15 +1343,7 @@ int SPF_SetFunctionsToInclude(void*& context, int winHandler, short *options, sh
|
||||
{
|
||||
runPassesForVisualizer(projName, { FIND_FUNC_TO_INCLUDE });
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
string resVal = convertToJson(allFuncInfo).dump();
|
||||
copyStringToShort(result, resVal);
|
||||
retSize = (int)resVal.size() + 1;
|
||||
}
|
||||
@@ -1492,14 +1381,17 @@ int SPF_GetAllDeclaratedArrays(void*& context, int winHandler, short *options, s
|
||||
{
|
||||
runPassesForVisualizer(projName, { GET_ALL_ARRAY_DECL });
|
||||
|
||||
string resVal = "";
|
||||
for (auto f = declaredArrays.begin(); f != declaredArrays.end(); ++f)
|
||||
json arrays = json::array();
|
||||
for (const auto& [_, array] : declaredArrays)
|
||||
{
|
||||
if (f != declaredArrays.begin())
|
||||
resVal += "@";
|
||||
resVal += f->second.first->toString();
|
||||
json jArray = array.first->toJson();
|
||||
arrays.push_back(jArray);
|
||||
}
|
||||
|
||||
json allArrays;
|
||||
allArrays["allArrays"] = arrays;
|
||||
string resVal = allArrays.dump();
|
||||
|
||||
copyStringToShort(result, resVal);
|
||||
retSize = (int)resVal.size() + 1;
|
||||
}
|
||||
@@ -1540,18 +1432,32 @@ int SPF_GetFileLineInfo(void*& context, int winHandler, short *options, short *p
|
||||
{
|
||||
runPassesForVisualizer(projName, { FILE_LINE_INFO });
|
||||
|
||||
string resVal = "";
|
||||
for (auto it = lineInfo.begin(); it != lineInfo.end(); ++it)
|
||||
json metric_array = json::array();
|
||||
for (const auto& fileInfo : lineInfo)
|
||||
{
|
||||
if (it != lineInfo.begin())
|
||||
resVal += "@";
|
||||
json fileMetric;
|
||||
|
||||
auto itD = dirsInfo.find(it->first);
|
||||
if (itD == dirsInfo.end())
|
||||
resVal += it->first + "@" + to_string(it->second) + "_0_0";
|
||||
else
|
||||
resVal += it->first + "@" + to_string(it->second) + "_" + to_string(itD->second.first.size()) + "_" + to_string(itD->second.second.size());
|
||||
fileMetric["file"] = fileInfo.first;
|
||||
fileMetric["linesCount"] = fileInfo.second;
|
||||
|
||||
auto it = dirsInfo.find(fileInfo.first);
|
||||
if (it == dirsInfo.end())
|
||||
{
|
||||
fileMetric["numSPF"] = 0;
|
||||
fileMetric["numDVM"] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fileMetric["numSPF"] = (int)it->second.first.size();
|
||||
fileMetric["numDVM"] = (int)it->second.second.size();
|
||||
}
|
||||
|
||||
metric_array.push_back(fileMetric);
|
||||
}
|
||||
|
||||
json allMetrics;
|
||||
allMetrics["allMetrics"] = metric_array;
|
||||
string resVal = allMetrics.dump();
|
||||
|
||||
copyStringToShort(result, resVal);
|
||||
retSize = (int)resVal.size() + 1;
|
||||
@@ -2251,38 +2157,43 @@ int SPF_InlineProcedures(void*& context, int winHandler, short* options, short*
|
||||
}
|
||||
|
||||
|
||||
extern map<string, set<string>> filesToInclude;
|
||||
int SPF_InsertIncludesPass(void*& context, int winHandler, short *options, short *projName, short *folderName, char *filesToInclude,
|
||||
extern map<string, map<int, set<string>>> filesToInclude;
|
||||
int SPF_InsertIncludesPass(void*& context, int winHandler, short *options, short *projName, short *folderName, char *visFilesToInclude,
|
||||
short *&output, int *&outputSize, short *&outputMessage, int *&outputMessageSize)
|
||||
{
|
||||
MessageManager::clearCache();
|
||||
MessageManager::setWinHandler(winHandler);
|
||||
|
||||
if (filesToInclude == NULL)
|
||||
if (visFilesToInclude == NULL)
|
||||
return -2;
|
||||
|
||||
vector<string> splited;
|
||||
//printf("%s\n", conv);
|
||||
splitString(filesToInclude, '|', splited);
|
||||
splitString(visFilesToInclude, '|', splited);
|
||||
|
||||
if (splited.size() == 0)
|
||||
return -3;
|
||||
|
||||
::filesToInclude.clear();
|
||||
for (int i = 0; i < splited.size(); ++i)
|
||||
filesToInclude.clear();
|
||||
unsigned i = 0;
|
||||
while (i < splited.size())
|
||||
{
|
||||
string file = splited[i];
|
||||
string file = splited[i++];
|
||||
int num = 0;
|
||||
if (sscanf(splited[i + 1].c_str(), "%d", &num) == -1)
|
||||
return -3;
|
||||
if (sscanf(splited[i++].c_str(), "%d", &num) == -1)
|
||||
return -4;
|
||||
|
||||
__spf_print(1, "file = %s:\n", file.c_str());
|
||||
for (int k = i + 2; k < i + 2 + num; ++k)
|
||||
for (int k = i; k < i + 2 * num; k += 2)
|
||||
{
|
||||
::filesToInclude[file].insert(splited[k]);
|
||||
__spf_print(1, " include = %s\n", splited[k].c_str());
|
||||
int line = 0;
|
||||
if (sscanf(splited[k].c_str(), "%d", &line) == -1)
|
||||
return -5;
|
||||
|
||||
filesToInclude[file][line].insert(splited[k + 1]);
|
||||
__spf_print(1, " include = [%d %s]\n", line, splited[k + 1].c_str());
|
||||
}
|
||||
i += 1 + num;
|
||||
i += 2 * num;
|
||||
}
|
||||
return simpleTransformPass(INSERT_INCLUDES, options, projName, folderName, output, outputSize, outputMessage, outputMessageSize);
|
||||
}
|
||||
@@ -2309,17 +2220,29 @@ int SPF_GetGCovInfo(void*& context, int winHandler, short *options, short *projN
|
||||
{
|
||||
runPassesForVisualizer(projName, { GCOV_PARSER });
|
||||
|
||||
string resVal = "";
|
||||
bool first = true;
|
||||
for (auto &byFile : gCovInfo)
|
||||
json gcov_array = json::array();
|
||||
for (auto& byFile : gCovInfo)
|
||||
{
|
||||
if (!first)
|
||||
resVal += "@";
|
||||
resVal += byFile.first + "@";
|
||||
for (auto &elem : byFile.second)
|
||||
resVal += to_string(elem.first) + " " + to_string(elem.second.getExecutedCount()) + " ";
|
||||
first = false;
|
||||
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);
|
||||
}
|
||||
|
||||
json allGCov;
|
||||
allGCov["allGCov"] = gcov_array;
|
||||
string resVal = allGCov.dump();
|
||||
|
||||
copyStringToShort(result, resVal);
|
||||
retSize = (int)resVal.size();
|
||||
@@ -2496,8 +2419,6 @@ 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