Merge branch 'master' into o.nikitin_private_arrays
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -310,8 +310,17 @@ static void getModuleSymbols(SgStatement* func, set<SgSymbol*>& symbs)
|
||||
SgSymbol* s = func->symbol()->next();
|
||||
while (s)
|
||||
{
|
||||
if (IS_BY_USE(s) && s->scope() && s->scope()->symbol()->identifier() == currScope)
|
||||
symbs.insert(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;
|
||||
@@ -1686,4 +1696,16 @@ set<string> fillDistributedArrays(const DataDirective& dataDirectives,
|
||||
for (auto& elem : ret)
|
||||
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 "2415"
|
||||
#define VERSION_SPF "2422"
|
||||
|
||||
Reference in New Issue
Block a user