Merge pull request 'arrayJson' (#56) from arrayJson into master
This commit was merged in pull request #56.
This commit is contained in:
@@ -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,48 +426,64 @@ 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);
|
||||
|
||||
retVal += "#" + TO_STR(locationPos.first);
|
||||
retVal += "#" + locationPos.second;
|
||||
JSON retVal;
|
||||
|
||||
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["id"] = (int64_t)id;
|
||||
retVal["name"] = name;
|
||||
retVal["shortName"] = shortName;
|
||||
retVal["packedAddress"] = std::to_string((long long)this);
|
||||
|
||||
retVal += "#" + TO_STR(depracateToDistribute.size());
|
||||
for (int i = 0; i < depracateToDistribute.size(); ++i)
|
||||
retVal += "#" + TO_STR((int)depracateToDistribute[i]);
|
||||
retVal["dimSize"] = dimSize;
|
||||
retVal["typeSize"] = typeSize;
|
||||
retVal["state"] = (int)isNonDistribute;
|
||||
retVal["location"] = (int)locationPos.first;
|
||||
retVal["locName"] = locationPos.second;
|
||||
|
||||
retVal += "#" + TO_STR(mappedDims.size());
|
||||
retVal["isTemplFlag"] = (int)isTemplFlag;
|
||||
retVal["isLoopArrayFlag"] = (int)isLoopArrayFlag;
|
||||
|
||||
JSON deprToDist = nlohmann::json::array();
|
||||
for (int i = 0; i < deprecateToDistribute.size(); ++i)
|
||||
deprToDist.push_back((int)deprecateToDistribute[i]);
|
||||
retVal["deprecateToDist"] = deprToDist;
|
||||
|
||||
JSON mappedDimsJ = nlohmann::json::array();
|
||||
for (int i = 0; i < mappedDims.size(); ++i)
|
||||
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();
|
||||
|
||||
retVal += "#" + TO_STR((int)isTemplFlag);
|
||||
retVal += "|" + TO_STR((int)isLoopArrayFlag);
|
||||
retVal += "|" + TO_STR(declPlaces.size());
|
||||
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;
|
||||
|
||||
for (auto &place : declPlaces)
|
||||
retVal += "|" + place.first + "|" + TO_STR(place.second);
|
||||
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;
|
||||
|
||||
retVal += "|" + TO_STR(containsInRegions.size());
|
||||
for (auto ® : containsInRegions)
|
||||
retVal += "|" + reg;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
Array* GetTemplateArray(const uint64_t regionId, bool withCheck = true)
|
||||
{
|
||||
TemplateLink *currLink = getTemlateInfo(regionId, withCheck);
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
linesInfo.push_back(linesRegs);
|
||||
}
|
||||
retVal["regionsLines"] = linesInfo;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION_SPF "2419"
|
||||
#define VERSION_SPF "2420"
|
||||
|
||||
@@ -766,15 +766,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;
|
||||
}
|
||||
@@ -1419,14 +1421,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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user