fixed functions purifying
This commit is contained in:
@@ -1129,9 +1129,6 @@ void DvmhRegionInserter::createInterfaceBlockForOutCalls(FuncInfo* func)
|
|||||||
if (func->interfaceBlocks.find(callFrom->funcName) == func->interfaceBlocks.end()
|
if (func->interfaceBlocks.find(callFrom->funcName) == func->interfaceBlocks.end()
|
||||||
&& isPure(callFrom->funcPointer->GetOriginal()))
|
&& isPure(callFrom->funcPointer->GetOriginal()))
|
||||||
{
|
{
|
||||||
if (callFrom->fileName != func->fileName)
|
|
||||||
insertRoutine(func->funcPointer->GetOriginal());
|
|
||||||
|
|
||||||
func->interfaceBlocks[callFrom->funcName] = callFrom;
|
func->interfaceBlocks[callFrom->funcName] = callFrom;
|
||||||
insertInterface(func->funcPointer, getInterfaceBlock(callFrom->funcPointer->GetOriginal(), callFrom->funcParams), callFrom->funcName);
|
insertInterface(func->funcPointer, getInterfaceBlock(callFrom->funcPointer->GetOriginal(), callFrom->funcParams), callFrom->funcName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2137,8 +2137,18 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
|||||||
regionInserter->addUsedWriteArrays(usedWriteArraysInRegions);
|
regionInserter->addUsedWriteArrays(usedWriteArraysInRegions);
|
||||||
|
|
||||||
setPureStatus(regionInserter->getParallelFunctions());
|
setPureStatus(regionInserter->getParallelFunctions());
|
||||||
|
}
|
||||||
|
|
||||||
//create interface for 'parallel' functions and
|
for (int i = n - 1, k = 0; i >= 0; --i, ++k)
|
||||||
|
{
|
||||||
|
SgFile* file = &(project.file(i));
|
||||||
|
|
||||||
|
DvmhRegionInserter* regionInserter = inserters[k];
|
||||||
|
|
||||||
|
for (auto& func : regionInserter->getParallelFunctions())
|
||||||
|
createInterfacesForOutCalls(func);
|
||||||
|
|
||||||
|
// create interface for 'parallel' functions and
|
||||||
// insert ROUTINE directive if needed
|
// insert ROUTINE directive if needed
|
||||||
regionInserter->createInterfaceBlockForParallelFunctions();
|
regionInserter->createInterfaceBlockForParallelFunctions();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,15 @@ bool checkOutCalls(const set<string>& outCalls)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void createInterfacesForOutCalls(FuncInfo* func) {
|
||||||
|
if (func->isPure && !func->isMain)
|
||||||
|
{
|
||||||
|
bool hasOutCalls = checkOutCalls(func->callsFrom);
|
||||||
|
if (hasOutCalls)
|
||||||
|
DvmhRegionInserter::createInterfaceBlockForOutCalls(func);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void setPureStatus(FuncInfo* func)
|
static void setPureStatus(FuncInfo* func)
|
||||||
{
|
{
|
||||||
if (func->isPure && !func->isMain)
|
if (func->isPure && !func->isMain)
|
||||||
@@ -52,13 +61,10 @@ static void setPureStatus(FuncInfo* func)
|
|||||||
for (int z = 0; z < func->funcParams.countOfPars; ++z)
|
for (int z = 0; z < func->funcParams.countOfPars; ++z)
|
||||||
hasOut |= func->funcParams.isArgOut(z);
|
hasOut |= func->funcParams.isArgOut(z);
|
||||||
bool hasPure = (header->expr(2) != NULL) || ((header->symbol()->attributes() & PURE_BIT) != 0);
|
bool hasPure = (header->expr(2) != NULL) || ((header->symbol()->attributes() & PURE_BIT) != 0);
|
||||||
bool hasOutCalls = checkOutCalls(func->callsFrom);
|
|
||||||
bool hasIO = func->linesOfIO.size() || func->linesOfStop.size();
|
bool hasIO = func->linesOfIO.size() || func->linesOfStop.size();
|
||||||
|
|
||||||
//TODO: with hasOutCalls
|
if (!hasPure && !hasIO && ((isFunc == false) || (isFunc && hasOut == false)))
|
||||||
if (!hasPure && !hasIO && !hasOutCalls && ((isFunc == false) || (isFunc && hasOut == false)))
|
{
|
||||||
{
|
|
||||||
DvmhRegionInserter::createInterfaceBlockForOutCalls(func);
|
|
||||||
header->setExpression(2, new SgExpression(PURE_OP));
|
header->setExpression(2, new SgExpression(PURE_OP));
|
||||||
header->symbol()->setAttribute(header->symbol()->attributes() | PURE_BIT);
|
header->symbol()->setAttribute(header->symbol()->attributes() | PURE_BIT);
|
||||||
}
|
}
|
||||||
@@ -76,6 +82,10 @@ void setPureStatus(const map<string, vector<FuncInfo*>>& allFuncInfo)
|
|||||||
for (auto& funcByFile : allFuncInfo)
|
for (auto& funcByFile : allFuncInfo)
|
||||||
for (auto& func : funcByFile.second)
|
for (auto& func : funcByFile.second)
|
||||||
setPureStatus(func);
|
setPureStatus(func);
|
||||||
|
|
||||||
|
for (auto& funcByFile : allFuncInfo)
|
||||||
|
for (auto& func : funcByFile.second)
|
||||||
|
createInterfacesForOutCalls(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
map<SgStatement*, set<string>> fillFromIntent(SgStatement* header)
|
map<SgStatement*, set<string>> fillFromIntent(SgStatement* header)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ bool checkOutCalls(const std::set<std::string>& outCalls);
|
|||||||
std::map<SgStatement*, std::set<std::string>> fillFromIntent(SgStatement* header);
|
std::map<SgStatement*, std::set<std::string>> fillFromIntent(SgStatement* header);
|
||||||
void intentInsert(const std::vector<FuncInfo*>& allFuncInfo);
|
void intentInsert(const std::vector<FuncInfo*>& allFuncInfo);
|
||||||
void intentInsertToInterfaces(const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo);
|
void intentInsertToInterfaces(const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo);
|
||||||
|
void createInterfacesForOutCalls(FuncInfo* func);
|
||||||
void setPureStatus(const std::set<FuncInfo*>& funcInfo);
|
void setPureStatus(const std::set<FuncInfo*>& funcInfo);
|
||||||
void setPureStatus(const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo);
|
void setPureStatus(const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo);
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define VERSION_SPF "2237"
|
#define VERSION_SPF "2238"
|
||||||
|
|||||||
Reference in New Issue
Block a user