egormayorov #72

Merged
Alexander_KS merged 17 commits from egormayorov into master 2025-12-29 18:26:19 +00:00
3 changed files with 25 additions and 13 deletions
Showing only changes of commit af85311480 - Show all commits

View File

@@ -235,11 +235,10 @@ static vector<OperatorInfo> analyzeOperatorsInLoop(SgForStmt* loop, const vector
static map<string, vector<SgStatement*>> findVariableDefinitions(SgForStmt* loop, vector<OperatorInfo>& operators) { static map<string, vector<SgStatement*>> findVariableDefinitions(SgForStmt* loop, vector<OperatorInfo>& operators) {
map<string, vector<SgStatement*>> varDefinitions; map<string, vector<SgStatement*>> varDefinitions;
for (auto& op : operators) { for (auto& op : operators)
for (const string& var : op.definedVars) { for (const string& var : op.definedVars)
varDefinitions[var].push_back(op.stmt); varDefinitions[var].push_back(op.stmt);
}
}
return varDefinitions; return varDefinitions;
} }
@@ -369,12 +368,9 @@ static vector<SgStatement*> optimizeOperatorOrder(SgForStmt* loop,
stmtToOpInfo[op.stmt] = &op; stmtToOpInfo[op.stmt] = &op;
bool changed = true; bool changed = true;
int iterations = 0;
const int MAX_ITERATIONS = 50;
while (changed && iterations < MAX_ITERATIONS) { while (changed) {
changed = false; changed = false;
iterations++;
for (int i = operators.size() - 1; i >= 0; i--) { for (int i = operators.size() - 1; i >= 0; i--) {
if (!operators[i].isMovable) if (!operators[i].isMovable)
@@ -434,6 +430,7 @@ static vector<SgStatement*> optimizeOperatorOrder(SgForStmt* loop,
break; break;
} }
} }
if (usesDefinedVar) { if (usesDefinedVar) {
targetPos = j; targetPos = j;
break; break;
@@ -566,6 +563,7 @@ static vector<SgStatement*> optimizeOperatorOrder(SgForStmt* loop,
} }
} }
} }
if (dependencyViolation) if (dependencyViolation)
break; break;
} }
@@ -656,7 +654,9 @@ static bool applyOperatorReordering(SgForStmt* loop, const vector<SgStatement*>&
if (extractedSet.find(stmt) != extractedSet.end()) { if (extractedSet.find(stmt) != extractedSet.end()) {
SgStatement* stmtToInsert = stmtToExtracted[stmt]; SgStatement* stmtToInsert = stmtToExtracted[stmt];
if (!stmtToInsert) continue;
if (!stmtToInsert)
continue;
SgStatement* insertAfter = loop; SgStatement* insertAfter = loop;
@@ -732,8 +732,10 @@ vector<SAPFOR::BasicBlock*> findFuncBlocksByFuncStatement(SgStatement *st, const
for (auto& func: FullIR) { for (auto& func: FullIR) {
if (func.first->funcPointer->getCurrProcessFile() == forSt->getCurrProcessFile() if (func.first->funcPointer->getCurrProcessFile() == forSt->getCurrProcessFile()
&& func.first->funcPointer->lineNumber() == forSt->lineNumber()) && func.first->funcPointer->lineNumber() == forSt->lineNumber())
{
result = func.second; result = func.second;
} }
}
return result; return result;
} }
@@ -770,7 +772,8 @@ map<SgForStmt*, vector<SAPFOR::BasicBlock*>> findAndAnalyzeLoops(SgStatement *st
static void processLoopRecursively(SgForStmt* loop, const vector<SAPFOR::BasicBlock*>& blocks, static void processLoopRecursively(SgForStmt* loop, const vector<SAPFOR::BasicBlock*>& blocks,
const map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR) { const map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR) {
if (!loop) return; if (!loop)
return;
SgStatement* loopStart = loop->lexNext(); SgStatement* loopStart = loop->lexNext();
SgStatement* loopEnd = loop->lastNodeOfStmt(); SgStatement* loopEnd = loop->lastNodeOfStmt();

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define VERSION_SPF "2450" #define VERSION_SPF "2451"

View File

@@ -1802,6 +1802,13 @@ int SPF_InsertPrivateArrayDirectives(void*& context, int winHandler, short* opti
return simpleTransformPass(FIND_PRIVATE_ARRAYS, options, projName, folderName, output, outputMessage); return simpleTransformPass(FIND_PRIVATE_ARRAYS, options, projName, folderName, output, outputMessage);
} }
int SPF_MoveOperators(void*& context, int winHandler, short* options, short* projName, short* folderName, string& output, string& outputMessage)
{
MessageManager::clearCache();
MessageManager::setWinHandler(winHandler);
return simpleTransformPass(MOVE_OPERATORS, 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)
@@ -2510,6 +2517,8 @@ const wstring Sapfor_RunTransformation(const char* transformName_c, const char*
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") else if (whichRun == "SPF_InsertPrivateArrayDirectives")
retCode = SPF_InsertPrivateArrayDirectives(context, winHandler, optSh, projSh, fold, output, outputMessage); retCode = SPF_InsertPrivateArrayDirectives(context, winHandler, optSh, projSh, fold, output, outputMessage);
else if (whichRun == "SPF_MoveOperators")
retCode = SPF_MoveOperators(context, winHandler, optSh, projSh, fold, output, outputMessage);
else if (whichRun == "SPF_CreateParallelVariant") else if (whichRun == "SPF_CreateParallelVariant")
{ {
vector<string> splited; vector<string> splited;