Compare commits
11 Commits
cad0a0b217
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0cea2df91 | ||
|
|
4b7df86b8a | ||
| 836894fef1 | |||
| 9ac15eec79 | |||
| 03f565f50b | |||
| 47e2b961e2 | |||
|
|
b95b336372 | ||
| f35d7cb4bd | |||
| 54615e34d4 | |||
| 8752f4a139 | |||
| 453105d273 |
Submodule projects/dvm updated: 4b7ef11871...4d4041a081
@@ -124,18 +124,32 @@ static void SolveDataFlow(Region* DFG)
|
|||||||
map<LoopGraph*, ArrayAccessingIndexes> FindPrivateArrays(map<string, vector<LoopGraph*>> &loopGraph, map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR)
|
map<LoopGraph*, ArrayAccessingIndexes> FindPrivateArrays(map<string, vector<LoopGraph*>> &loopGraph, map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR)
|
||||||
{
|
{
|
||||||
map<LoopGraph*, ArrayAccessingIndexes> result;
|
map<LoopGraph*, ArrayAccessingIndexes> result;
|
||||||
for (const auto& [loopName, loops] : loopGraph)
|
for (const auto& [fileName, loops] : loopGraph)
|
||||||
{
|
{
|
||||||
|
SgFile::switchToFile(fileName);
|
||||||
for (const auto& loop : loops)
|
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)
|
for (const auto& [funcInfo, blocks]: FullIR)
|
||||||
|
{
|
||||||
|
if (funcInfo->fileName == fileName && funcInfo->funcPointer->GetOriginal() == search_func)
|
||||||
{
|
{
|
||||||
Region* loopRegion = new Region(loop, blocks);
|
Region* loopRegion = new Region(loop, blocks);
|
||||||
|
if (loopRegion->getBasickBlocks().size() <= 1)
|
||||||
|
{
|
||||||
|
delete(loopRegion);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
SolveDataFlow(loopRegion);
|
SolveDataFlow(loopRegion);
|
||||||
result[loop] = loopRegion->array_priv;
|
result[loop] = loopRegion->array_priv;
|
||||||
delete(loopRegion);
|
delete(loopRegion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1019,8 +1019,6 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
|||||||
if(func->funcPointer->variant() != ENTRY_STAT)
|
if(func->funcPointer->variant() != ENTRY_STAT)
|
||||||
countOfTransform += removeDeadCode(func->funcPointer, allFuncInfo, commonBlocks);
|
countOfTransform += removeDeadCode(func->funcPointer, allFuncInfo, commonBlocks);
|
||||||
}
|
}
|
||||||
else if (curr_regime == FIND_PRIVATE_ARRAYS)
|
|
||||||
FindPrivateArrays(loopGraph, fullIR);
|
|
||||||
else if (curr_regime == TEST_PASS)
|
else if (curr_regime == TEST_PASS)
|
||||||
{
|
{
|
||||||
//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)
|
else if (curr_regime == TRANSFORM_ASSUMED_SIZE_PARAMETERS)
|
||||||
transformAssumedSizeParameters(allFuncInfo);
|
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 elapsed = duration_cast<milliseconds>(high_resolution_clock::now() - timeForPass).count() / 1000.;
|
||||||
const float elapsedGlobal = duration_cast<milliseconds>(high_resolution_clock::now() - globalTime).count() / 1000.;
|
const float elapsedGlobal = duration_cast<milliseconds>(high_resolution_clock::now() - globalTime).count() / 1000.;
|
||||||
|
|||||||
@@ -17,6 +17,19 @@ using std::pair;
|
|||||||
|
|
||||||
#define DEBUG_TRACE 0
|
#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);
|
||||||
|
}
|
||||||
|
|
||||||
static SgExpression* findExprWithVariant(SgExpression* exp, int variant)
|
static SgExpression* findExprWithVariant(SgExpression* exp, int variant)
|
||||||
{
|
{
|
||||||
if (exp)
|
if (exp)
|
||||||
@@ -167,7 +180,7 @@ static void findArrays(SgExpression* exp, set<SgSymbol*>& arrays)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void populateDistributedIoArrays(map<SgSymbol*, set<SgStatement*>>& arrays,
|
static bool populateDistributedIoArrays(map<SgSymbol*, set<SgStatement*>>& arrays,
|
||||||
SgStatement* stat,
|
SgStatement* stat,
|
||||||
const string& current_file_name,
|
const string& current_file_name,
|
||||||
FuncInfo *current_func)
|
FuncInfo *current_func)
|
||||||
@@ -175,7 +188,7 @@ static void populateDistributedIoArrays(map<SgSymbol*, set<SgStatement*>>& array
|
|||||||
auto var = stat->variant();
|
auto var = stat->variant();
|
||||||
|
|
||||||
if (var != READ_STAT && var != PRINT_STAT && var != WRITE_STAT)
|
if (var != READ_STAT && var != PRINT_STAT && var != WRITE_STAT)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
// check if such IO allowed in dvm:
|
// check if such IO allowed in dvm:
|
||||||
// list should consist only of single array and format string should be *
|
// list should consist only of single array and format string should be *
|
||||||
@@ -185,24 +198,28 @@ static void populateDistributedIoArrays(map<SgSymbol*, set<SgStatement*>>& array
|
|||||||
SgExpression* ioList = stat->expr(0);
|
SgExpression* ioList = stat->expr(0);
|
||||||
|
|
||||||
if (!ioList)
|
if (!ioList)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
if (ioList->variant() != EXPR_LIST)
|
if (ioList->variant() != EXPR_LIST)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
if (ioList->rhs() == NULL)
|
if (ioList->rhs() == NULL)
|
||||||
{
|
{
|
||||||
SgExpression* arg = ioList->lhs();
|
SgExpression* arg = ioList->lhs();
|
||||||
if (!arg)
|
if (!arg)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
if (!isArrayRef(arg))
|
if (hasArrayRef(arg))
|
||||||
return;
|
{
|
||||||
|
if (isArrayRef(arg) && arg->lhs())
|
||||||
if (arg->lhs())
|
|
||||||
need_replace = true;
|
need_replace = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
need_replace = true;
|
need_replace = true;
|
||||||
}
|
}
|
||||||
@@ -220,7 +237,6 @@ static void populateDistributedIoArrays(map<SgSymbol*, set<SgStatement*>>& array
|
|||||||
if (fmt->rhs()->variant() != KEYWORD_VAL || fmt->rhs()->sunparse() != "*")
|
if (fmt->rhs()->variant() != KEYWORD_VAL || fmt->rhs()->sunparse() != "*")
|
||||||
need_replace = true;
|
need_replace = true;
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case READ_STAT:
|
case READ_STAT:
|
||||||
@@ -261,7 +277,9 @@ static void populateDistributedIoArrays(map<SgSymbol*, set<SgStatement*>>& array
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!need_replace)
|
if (!need_replace)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
|
bool ret = false;
|
||||||
|
|
||||||
set<SgSymbol*> found_arrays;
|
set<SgSymbol*> found_arrays;
|
||||||
|
|
||||||
@@ -280,10 +298,13 @@ static void populateDistributedIoArrays(map<SgSymbol*, set<SgStatement*>>& array
|
|||||||
|
|
||||||
if (inserted)
|
if (inserted)
|
||||||
__spf_print(DEBUG_TRACE, "[%d]: add array %s %p\n", stat->lineNumber(), array_p->GetName().c_str(), by_symb);
|
__spf_print(DEBUG_TRACE, "[%d]: add array %s %p\n", stat->lineNumber(), array_p->GetName().c_str(), by_symb);
|
||||||
|
|
||||||
|
ret = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__spf_print(DEBUG_TRACE, "[replace]\n");
|
__spf_print(DEBUG_TRACE, "[replace]\n");
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void replaceArrayRec(SgSymbol* arr, SgSymbol* replace_by, SgExpression* exp, bool& has_read, bool& has_write, bool from_read, bool from_write)
|
static void replaceArrayRec(SgSymbol* arr, SgSymbol* replace_by, SgExpression* exp, bool& has_read, bool& has_write, bool from_read, bool from_write)
|
||||||
@@ -501,12 +522,16 @@ static bool ioReginBorder(SgStatement* stat, SgStatement* last_io_bound)
|
|||||||
STOP_STAT,
|
STOP_STAT,
|
||||||
STOP_NODE,
|
STOP_NODE,
|
||||||
EXIT_STMT,
|
EXIT_STMT,
|
||||||
EXIT_NODE
|
EXIT_NODE,
|
||||||
|
GOTO_NODE
|
||||||
};
|
};
|
||||||
|
|
||||||
if (border_stats.find(var) != border_stats.end())
|
if (border_stats.find(var) != border_stats.end())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (stat->hasLabel())
|
||||||
|
return true;
|
||||||
|
|
||||||
if (last_io_bound && last_io_bound->lastNodeOfStmt() && last_io_bound->lastNodeOfStmt() == stat)
|
if (last_io_bound && last_io_bound->lastNodeOfStmt() && last_io_bound->lastNodeOfStmt() == stat)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -644,18 +669,17 @@ void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
|
|||||||
newDeclsToInclude,
|
newDeclsToInclude,
|
||||||
copied_syms);
|
copied_syms);
|
||||||
|
|
||||||
|
|
||||||
// original declaration statement
|
// original declaration statement
|
||||||
auto *decl_stmt = SgStatement::getStatementByFileAndLine(decl_place.first, decl_place.second);
|
auto *decl_stmt = SgStatement::getStatementByFileAndLine(decl_place.first, decl_place.second);
|
||||||
|
|
||||||
if (!decl_stmt || !isSgDeclarationStatement(decl_stmt))
|
if (!decl_stmt || !isArrayDeclaration(decl_stmt))
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|
||||||
auto dynamic_array = checkAssumedShape(decl_stmt, array_name);
|
auto dynamic_array = checkAssumedShape(decl_stmt, array_name);
|
||||||
|
|
||||||
while (decl_stmt && !isSgExecutableStatement(decl_stmt))
|
while (decl_stmt && !isSgExecutableStatement(decl_stmt))
|
||||||
{
|
{
|
||||||
if (isSgDeclarationStatement(decl_stmt) &&
|
if (isArrayDeclaration(decl_stmt) &&
|
||||||
decl_stmt->expr(0) &&
|
decl_stmt->expr(0) &&
|
||||||
decl_stmt->expr(0)->lhs() &&
|
decl_stmt->expr(0)->lhs() &&
|
||||||
decl_stmt->expr(0)->lhs()->symbol() == copied_symbol.second)
|
decl_stmt->expr(0)->lhs()->symbol() == copied_symbol.second)
|
||||||
@@ -667,7 +691,7 @@ void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// created declaration statement
|
// created declaration statement
|
||||||
if (!decl_stmt || !isSgDeclarationStatement(decl_stmt))
|
if (!decl_stmt || !isArrayDeclaration(decl_stmt))
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|
||||||
// insert !$SPF ANALYSIS(PROCESS_PRIVATE(array)) directive before declaration statement
|
// insert !$SPF ANALYSIS(PROCESS_PRIVATE(array)) directive before declaration statement
|
||||||
@@ -833,7 +857,17 @@ void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
populateDistributedIoArrays(need_replace, curr_stmt, current_file_name, current_func_info);
|
auto need_fix_io = populateDistributedIoArrays(need_replace, curr_stmt, current_file_name, current_func_info);
|
||||||
|
|
||||||
|
// incorrect IO statement with label
|
||||||
|
// move label to dummy statement and insert copy statements between dummy statement and IO
|
||||||
|
if (need_fix_io && curr_stmt->hasLabel())
|
||||||
|
{
|
||||||
|
moveLabelBefore(curr_stmt);
|
||||||
|
if (last_io_bound == curr_stmt) // always true
|
||||||
|
last_io_bound = curr_stmt->lexPrev();
|
||||||
|
}
|
||||||
|
|
||||||
curr_stmt = curr_stmt->lexNext();
|
curr_stmt = curr_stmt->lexNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define VERSION_SPF "2445"
|
#define VERSION_SPF "2447"
|
||||||
|
|||||||
@@ -1793,6 +1793,13 @@ int SPF_RenameIncludes(void*& context, int winHandler, short* options, short* pr
|
|||||||
return simpleTransformPass(RENAME_INLCUDES, options, projName, folderName, output, outputMessage);
|
return simpleTransformPass(RENAME_INLCUDES, options, projName, folderName, output, outputMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SPF_InsertPrivateArrayDirectives(void*& context, int winHandler, short* options, short* projName, short* folderName, string& output, string& outputMessage)
|
||||||
|
{
|
||||||
|
MessageManager::clearCache();
|
||||||
|
MessageManager::setWinHandler(winHandler);
|
||||||
|
return simpleTransformPass(FIND_PRIVATE_ARRAYS, options, projName, folderName, output, outputMessage);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void convertBackSlash(char *str, int strL)
|
static inline void convertBackSlash(char *str, int strL)
|
||||||
{
|
{
|
||||||
for (int z = 0; z < strL; ++z)
|
for (int z = 0; z < strL; ++z)
|
||||||
@@ -2499,6 +2506,8 @@ const wstring Sapfor_RunTransformation(const char* transformName_c, const char*
|
|||||||
retCode = SPF_InsertImplicitNone(context, winHandler, optSh, projSh, fold, output, outputMessage);
|
retCode = SPF_InsertImplicitNone(context, winHandler, optSh, projSh, fold, output, outputMessage);
|
||||||
else if (whichRun == "SPF_RenameIncludes")
|
else if (whichRun == "SPF_RenameIncludes")
|
||||||
retCode = SPF_RenameIncludes(context, winHandler, optSh, projSh, fold, output, outputMessage);
|
retCode = SPF_RenameIncludes(context, winHandler, optSh, projSh, fold, output, outputMessage);
|
||||||
|
else if (whichRun == "SPF_InsertPrivateArrayDirectives")
|
||||||
|
retCode = SPF_InsertPrivateArrayDirectives(context, winHandler, optSh, projSh, fold, output, outputMessage);
|
||||||
else if (whichRun == "SPF_CreateParallelVariant")
|
else if (whichRun == "SPF_CreateParallelVariant")
|
||||||
{
|
{
|
||||||
vector<string> splited;
|
vector<string> splited;
|
||||||
|
|||||||
Reference in New Issue
Block a user