4 Commits

4 changed files with 82 additions and 10 deletions

View File

@@ -9,6 +9,7 @@
#include "DvmhDirectiveBase.h" #include "DvmhDirectiveBase.h"
#include "../Utils/utils.h" #include "../Utils/utils.h"
#include "../Utils/errors.h" #include "../Utils/errors.h"
#include "../Utils/json.hpp"
class Symbol; class Symbol;
class Expression; class Expression;
@@ -20,6 +21,7 @@ struct FuncInfo;
#define MAP std::map #define MAP std::map
#define SET std::set #define SET std::set
#define TO_STR std::to_string #define TO_STR std::to_string
#define JSON nlohmann::json
#if __SPF #if __SPF
extern int sharedMemoryParallelization; extern int sharedMemoryParallelization;
@@ -424,6 +426,7 @@ namespace Distribution
void ClearShadowSpecs() { allShadowSpecs.clear(); } void ClearShadowSpecs() { allShadowSpecs.clear(); }
//TODO: to remove
STRING toString() STRING toString()
{ {
STRING retVal = ""; STRING retVal = "";
@@ -466,6 +469,63 @@ namespace Distribution
return retVal; return retVal;
} }
JSON toJson()
{
JSON retVal;
retVal["id"] = (int64_t)id;
retVal["name"] = name;
retVal["shortName"] = shortName;
retVal["dimSize"] = dimSize;
retVal["typeSize"] = typeSize;
retVal["state"] = (int)isNonDistribute;
retVal["location"] = (int)locationPos.first;
retVal["locName"] = locationPos.second;
retVal["isTemplFlag"] = (int)isTemplFlag;
retVal["isLoopArrayFlag"] = (int)isLoopArrayFlag;
JSON deprToDist = nlohmann::json::array();
for (int i = 0; i < depracateToDistribute.size(); ++i)
deprToDist.push_back((int)depracateToDistribute[i]);
retVal["depracateToDist"] = deprToDist;
JSON mappedDimsJ = nlohmann::json::array();
for (int i = 0; i < mappedDims.size(); ++i)
mappedDimsJ.push_back((int)mappedDims[i]);
retVal["mappedDims"] = mappedDimsJ;
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;
JSON regions = nlohmann::json::array();
for (auto& reg : containsInRegions)
regions.push_back(reg);
retVal["regions"] = regions;
JSON declPlacesJ = nlohmann::json::array();
for (auto& place : declPlaces)
{
JSON elem;
elem["file"] = place.first;
elem["line"] = place.second;
declPlacesJ.push_back(elem);
}
retVal["declPlaces"] = declPlacesJ;
return retVal;
}
Array* GetTemplateArray(const uint64_t regionId, bool withCheck = true) Array* GetTemplateArray(const uint64_t regionId, bool withCheck = true)
{ {
TemplateLink *currLink = getTemlateInfo(regionId, withCheck); TemplateLink *currLink = getTemlateInfo(regionId, withCheck);

View File

@@ -309,9 +309,18 @@ static void getModuleSymbols(SgStatement* func, set<SgSymbol*>& symbs)
SgSymbol* s = func->symbol()->next(); SgSymbol* s = func->symbol()->next();
while (s) 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) if (IS_BY_USE(s) && s->scope() && s->scope()->symbol()->identifier() == currScope)
symbs.insert(s); symbs.insert(s);
}
s = s->next(); s = s->next();
} }
} }
@@ -325,9 +334,9 @@ const set<SgSymbol*>& getModuleSymbols(SgStatement *func)
set<SgSymbol*> symbs; set<SgSymbol*> symbs;
getModuleSymbols(func, symbs); getModuleSymbols(func, symbs);
//if function in contains //if function or module in contains
auto cp = func->controlParent(); auto cp = func->controlParent();
if (isSgProgHedrStmt(cp)) if (isSgProgHedrStmt(cp) || cp->variant() == MODULE_STMT)
getModuleSymbols(cp, symbs); getModuleSymbols(cp, symbs);
symbolsForFunc[func->symbol()->identifier()] = symbs; symbolsForFunc[func->symbol()->identifier()] = symbs;

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define VERSION_SPF "2415" #define VERSION_SPF "2417"

View File

@@ -1416,14 +1416,17 @@ int SPF_GetAllDeclaratedArrays(void*& context, int winHandler, short *options, s
{ {
runPassesForVisualizer(projName, { GET_ALL_ARRAY_DECL }); runPassesForVisualizer(projName, { GET_ALL_ARRAY_DECL });
string resVal = ""; json arrays = json::array();
for (auto f = declaredArrays.begin(); f != declaredArrays.end(); ++f) for (const auto& [_, array] : declaredArrays)
{ {
if (f != declaredArrays.begin()) json jArray = array.first->toJson();
resVal += "@"; arrays.push_back(jArray);
resVal += f->second.first->toString();
} }
json allArrays;
allArrays["allArrays"] = arrays;
string resVal = allArrays.dump();
copyStringToShort(result, resVal); copyStringToShort(result, resVal);
retSize = (int)resVal.size() + 1; retSize = (int)resVal.size() + 1;
} }