added json for SPF_GetAllDeclaratedArrays pass
This commit is contained in:
@@ -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["array_name"] = place.first;
|
||||||
|
elem["array_loc"] = 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);
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define VERSION_SPF "2416"
|
#define VERSION_SPF "2417"
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user