10 Commits

6 changed files with 40 additions and 14 deletions

View File

@@ -497,7 +497,7 @@ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
endif()
endif()

View File

@@ -124,16 +124,30 @@ static void SolveDataFlow(Region* DFG)
map<LoopGraph*, ArrayAccessingIndexes> FindPrivateArrays(map<string, vector<LoopGraph*>> &loopGraph, map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR)
{
map<LoopGraph*, ArrayAccessingIndexes> result;
for (const auto& [loopName, loops] : loopGraph)
for (const auto& [fileName, loops] : loopGraph)
{
SgFile::switchToFile(fileName);
for (const auto& loop : loops)
{
SgStatement* search_func = loop->loop->GetOriginal();
while (search_func && (!isSgProgHedrStmt(search_func)))
search_func = search_func->controlParent();
for (const auto& [funcInfo, blocks]: FullIR)
{
Region* loopRegion = new Region(loop, blocks);
SolveDataFlow(loopRegion);
result[loop] = loopRegion->array_priv;
delete(loopRegion);
if (funcInfo->fileName == fileName && funcInfo->funcPointer->GetOriginal() == search_func)
{
Region* loopRegion = new Region(loop, blocks);
if (loopRegion->getBasickBlocks().size() <= 1)
{
delete(loopRegion);
continue;
}
SolveDataFlow(loopRegion);
result[loop] = loopRegion->array_priv;
delete(loopRegion);
}
}
}
}

View File

@@ -1019,8 +1019,6 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
if(func->funcPointer->variant() != ENTRY_STAT)
countOfTransform += removeDeadCode(func->funcPointer, allFuncInfo, commonBlocks);
}
else if (curr_regime == FIND_PRIVATE_ARRAYS)
FindPrivateArrays(loopGraph, fullIR);
else if (curr_regime == TEST_PASS)
{
//test pass
@@ -1916,6 +1914,8 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
}
else if (curr_regime == TRANSFORM_ASSUMED_SIZE_PARAMETERS)
transformAssumedSizeParameters(allFuncInfo);
else if (curr_regime == FIND_PRIVATE_ARRAYS)
auto result = FindPrivateArrays(loopGraph, fullIR);
const float elapsed = duration_cast<milliseconds>(high_resolution_clock::now() - timeForPass).count() / 1000.;
const float elapsedGlobal = duration_cast<milliseconds>(high_resolution_clock::now() - globalTime).count() / 1000.;

View File

@@ -17,6 +17,14 @@ using std::pair;
#define DEBUG_TRACE 0
static bool hasArrayRef(SgExpression* ex)
{
if (ex)
return isArrayRef(ex) || hasArrayRef(ex->lhs()) || hasArrayRef(ex->rhs());
return false;
}
static inline bool isArrayDeclaration(SgStatement* st)
{
return isSgDeclarationStatement(st) || isSgVarListDeclStmt(st) || isSgNestedVarListDeclStmt(st);
@@ -201,11 +209,15 @@ static bool populateDistributedIoArrays(map<SgSymbol*, set<SgStatement*>>& array
if (!arg)
return false;
if (!isArrayRef(arg))
if (hasArrayRef(arg))
{
if (isArrayRef(arg) && arg->lhs())
need_replace = true;
}
else
{
return false;
if (arg->lhs())
need_replace = true;
}
}
else
{

View File

@@ -1,3 +1,3 @@
#pragma once
#define VERSION_SPF "2445"
#define VERSION_SPF "2446"