REMOVE_DIST_ARRAYS_FROM_IO: consider array declarations from common blocks and dimension statements

This commit is contained in:
2025-10-01 18:54:55 +03:00
parent cad0a0b217
commit 453105d273

View File

@@ -17,6 +17,11 @@ using std::pair;
#define DEBUG_TRACE 0 #define DEBUG_TRACE 0
static inline bool isArrayDeclaration(SgStatement* st)
{
return isSgDeclarationStatement(st) || st->variant() == DIM_STAT || st->variant() == COMM_STAT;
}
static SgExpression* findExprWithVariant(SgExpression* exp, int variant) static SgExpression* findExprWithVariant(SgExpression* exp, int variant)
{ {
if (exp) if (exp)
@@ -644,18 +649,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 +671,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