fixed replace_dist_array pass: added more file switching

This commit is contained in:
ALEXks
2025-07-27 08:52:28 +03:00
parent 80eac5b957
commit 278fc1ff9c
2 changed files with 5 additions and 16 deletions

View File

@@ -74,10 +74,7 @@ static void populateDistributedIoArrays(map<SgSymbol*, set<SgStatement*>>& array
{ {
SgExpression* fmt = stat->expr(1); SgExpression* fmt = stat->expr(1);
if (!fmt || fmt->variant() != SPEC_PAIR || fmt->lhs()->variant() != KEYWORD_VAL) if (!fmt || fmt->variant() != SPEC_PAIR || fmt->lhs()->variant() != KEYWORD_VAL)
{
printInternalError(convertFileName(__FILE__).c_str(), __LINE__); printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
return;
}
if (fmt->rhs()->variant() != KEYWORD_VAL || fmt->rhs()->sunparse() != "*") if (fmt->rhs()->variant() != KEYWORD_VAL || fmt->rhs()->sunparse() != "*")
need_replace = true; need_replace = true;
@@ -104,10 +101,7 @@ static void populateDistributedIoArrays(map<SgSymbol*, set<SgStatement*>>& array
{ {
auto *kv = spec->lhs(); auto *kv = spec->lhs();
if (!kv || kv->variant() != SPEC_PAIR || !kv->rhs()) if (!kv || kv->variant() != SPEC_PAIR || !kv->rhs())
{
printInternalError(convertFileName(__FILE__).c_str(), __LINE__); printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
return;
}
if (kv->rhs()->variant() != KEYWORD_VAL || kv->rhs()->sunparse() != "*") if (kv->rhs()->variant() != KEYWORD_VAL || kv->rhs()->sunparse() != "*")
{ {
@@ -368,11 +362,8 @@ void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
{ {
const auto& filename = linesByFile.first; const auto& filename = linesByFile.first;
if (SgFile::switchToFile(filename) < 0) if (SgFile::switchToFile(filename) == -1)
{
printInternalError(convertFileName(__FILE__).c_str(), __LINE__); printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
return;
}
for (auto& lines : linesByFile.second) for (auto& lines : linesByFile.second)
{ {
@@ -481,9 +472,7 @@ void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
insertPlace->insertStmtAfter(*stat, *st); insertPlace->insertStmtAfter(*stat, *st);
} }
else else
{
copied = copyArray(place, array_p, linesByFile.second, suffix + to_string(region->GetId()), fileName, newDeclsToInclude, copied_syms); copied = copyArray(place, array_p, linesByFile.second, suffix + to_string(region->GetId()), fileName, newDeclsToInclude, copied_syms);
}
SgStatement* decl = SgStatement::getStatementByFileAndLine(place.first, place.second); SgStatement* decl = SgStatement::getStatementByFileAndLine(place.first, place.second);
@@ -504,6 +493,9 @@ void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
decl->addComment(dir_str.c_str()); decl->addComment(dir_str.c_str());
} }
created_copies.insert({ array_to_copy, copied.second }); created_copies.insert({ array_to_copy, copied.second });
if (curr_stmt->switchToFile() == -1)
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
} }
} }
@@ -517,10 +509,7 @@ void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
if (it != created_copies.end()) if (it != created_copies.end())
replaceArrayInFragment(p.first, p.second, it->second, last_io_bound, curr_stmt, filename); replaceArrayInFragment(p.first, p.second, it->second, last_io_bound, curr_stmt, filename);
else else
{
printInternalError(convertFileName(__FILE__).c_str(), __LINE__); printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
return;
}
} }
} }

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define VERSION_SPF "2439" #define VERSION_SPF "2440"