2 Commits

Author SHA1 Message Date
ALEXks
a241d1ec45 added json for SPF_GetArrayDistribution pass 2025-05-17 18:49:46 +03:00
ALEXks
d06f360cf6 added json for SPF_GetAllDeclaratedArrays pass 2025-05-11 08:33:50 +03:00
3 changed files with 15 additions and 27 deletions

View File

@@ -199,6 +199,15 @@ 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("::");
@@ -950,7 +959,7 @@ ParallelDirective::genDirective(File* file, const vector<pair<DIST::Array*, cons
SgSymbol* redS;
string clearName = correctSymbolModuleName(red);
if (clearName != red)
redS = getNameInLocation(parentFunc, red, getModuleScope(red, moduleList, parentFunc)->symbol()->identifier());
redS = getNameInLocation(parentFunc, clearName, getModuleScope(red, moduleList, parentFunc)->symbol()->identifier());
else
redS = findSymbolOrCreate(file, clearName, NULL, parentFunc);
@@ -1008,12 +1017,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, get<0>(list), getModuleScope(get<0>(list), moduleList, parentFunc)->symbol()->identifier());
redS1 = getNameInLocation(parentFunc, clearName1, getModuleScope(get<0>(list), moduleList, parentFunc)->symbol()->identifier());
else
redS1 = findSymbolOrCreate(file, clearName1, NULL, parentFunc);
if (clearName2 != get<1>(list))
redS2 = getNameInLocation(parentFunc, get<1>(list), getModuleScope(get<1>(list), moduleList, parentFunc)->symbol()->identifier());
redS2 = getNameInLocation(parentFunc, clearName2, getModuleScope(get<1>(list), moduleList, parentFunc)->symbol()->identifier());
else
redS2 = findSymbolOrCreate(file, clearName2, NULL, parentFunc);

View File

@@ -343,9 +343,9 @@ const set<SgSymbol*>& getModuleSymbols(SgStatement *func)
return symbs;
}
static void findSymbol(SgStatement* func, const string& varName, const string& locName,
map<string, SgSymbol*>& altNames)
SgSymbol* getNameInLocation(SgStatement* func, const string& varName, const string& locName)
{
map<string, SgSymbol*> altNames;
for (const auto& s : getModuleSymbols(func))
{
SgSymbol* orig = OriginalSymbol(s);
@@ -353,22 +353,11 @@ static void findSymbol(SgStatement* func, const string& varName, const string& l
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) %s\n", func->symbol()->identifier(), clearName.c_str(), varName.c_str(), locName.c_str());
__spf_print(1, "%s %s %s\n", func->symbol()->identifier(), varName.c_str(), locName.c_str());
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
}
@@ -404,15 +393,6 @@ 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

View File

@@ -1,6 +1,5 @@
#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);