From 763be1857ac5790dcaeade7b31382c152bb38c8a Mon Sep 17 00:00:00 2001 From: ALEXks Date: Sun, 24 Mar 2024 15:13:53 +0300 Subject: [PATCH] fixed and improved private array resizing pass --- sapfor/experts/Sapfor_2017/_src/Sapfor.cpp | 15 +- .../private_arrays_resizing.cpp | 271 +++++++++++++----- .../Transformations/private_arrays_resizing.h | 2 +- .../experts/Sapfor_2017/_src/Utils/utils.cpp | 8 +- .../experts/Sapfor_2017/_src/Utils/version.h | 2 +- .../_src/VisualizerCalls/get_information.cpp | 12 +- 6 files changed, 220 insertions(+), 90 deletions(-) diff --git a/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp b/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp index c73372a..8ab8e47 100644 --- a/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp @@ -1061,11 +1061,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne { auto founded = loopGraph.find(file->filename()); if (founded != loopGraph.end()) - { - int err = privateArraysResizing(file, founded->second, getObjectForFileFromMap(file_name, SPF_messages), usersDirectives, true); - if (err != 0) - internalExit = -1; - } + privateArraysResizing(file, founded->second, getObjectForFileFromMap(file_name, SPF_messages), countOfTransform, usersDirectives, true); } else if (curr_regime == PRIVATE_ARRAYS_SHRINKING_ANALYSIS) { @@ -1077,11 +1073,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne { auto founded = loopGraph.find(file->filename()); if (founded != loopGraph.end()) - { - int err = privateArraysResizing(file, founded->second, getObjectForFileFromMap(file_name, SPF_messages), usersDirectives, false); - if (err != 0) - internalExit = -1; - } + privateArraysResizing(file, founded->second, getObjectForFileFromMap(file_name, SPF_messages), countOfTransform, usersDirectives, false); } else if(curr_regime == LOOPS_SPLITTER) { @@ -1195,7 +1187,8 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne if (internalExit < 0) throw -1; - bool applyFor = (curr_regime == LOOPS_SPLITTER || curr_regime == LOOPS_COMBINER || curr_regime == PRIVATE_REMOVING); + bool applyFor = (curr_regime == LOOPS_SPLITTER || curr_regime == LOOPS_COMBINER || curr_regime == PRIVATE_REMOVING || + curr_regime == PRIVATE_ARRAYS_EXPANSION || curr_regime == PRIVATE_ARRAYS_SHRINKING); if ((countOfTransform == 0 || internalExit > 0) && applyFor) { SgStatement* mainUnit = findMainUnit(&project, SPF_messages); diff --git a/sapfor/experts/Sapfor_2017/_src/Transformations/private_arrays_resizing.cpp b/sapfor/experts/Sapfor_2017/_src/Transformations/private_arrays_resizing.cpp index 4021b21..8a7d656 100644 --- a/sapfor/experts/Sapfor_2017/_src/Transformations/private_arrays_resizing.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Transformations/private_arrays_resizing.cpp @@ -135,13 +135,17 @@ static const string constructNewBoundName(const char *oldName, int loopLineNumbe return newName; } -static SgSymbol* createNewArrayNameSymbol(SgExpression* declaration, bool isExpansion) +static SgSymbol* createNewArrayNameSymbol(SgExpression* declaration, bool isExpansion, bool canBeStatic) { SgType* type = new SgType(T_ARRAY); char* newNameStr = constructNewArrayName(declaration->symbol()->identifier(), isExpansion); - SgSymbol* newName = new SgSymbol(VARIABLE_NAME, newNameStr, type, NULL); - newName->setAttribute(declaration->symbol()->attributes()); + SgSymbol* newName = new SgSymbol(VARIABLE_NAME, newNameStr, type, NULL); + auto attrs = declaration->symbol()->attributes(); + if (!canBeStatic) + attrs |= ALLOCATABLE_BIT; + + newName->setAttribute(attrs); return newName; } @@ -155,7 +159,17 @@ static void fillLoopBoundExprs(const LoopGraph* forLoop, int depthOfResize, cons { if (indexes[j] && isEqSymbols(loopStmt->doName(), indexes[j])) { - bounds[j] = new SgExpression(DDOT, loopStmt->start()->copyPtr(), loopStmt->end()->copyPtr(), NULL); + //TODO: add MIN and MAX call for bounds + if (curLoop->stepVal == 0) + { + __spf_print(1, "unknown step sign of loop on line %d\n", curLoop->lineNum); + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); + } + + if (curLoop->stepVal > 0) + bounds[j] = new SgExpression(DDOT, loopStmt->start()->copyPtr(), loopStmt->end()->copyPtr(), NULL); + else + bounds[j] = new SgExpression(DDOT, loopStmt->end()->copyPtr(), loopStmt->start()->copyPtr(), NULL); break; } } @@ -335,7 +349,7 @@ static SgSymbol* alterExtendArrayDeclaration(const LoopGraph* forLoop, SgStateme SgExpression* array = findSymbolInExprList(arraySymbol, declarationStmt->expr(0)); SgExpression* newArray = array->copyPtr(); - newArraySymbol = createNewArrayNameSymbol(newArray, true); + newArraySymbol = createNewArrayNameSymbol(newArray, true, canBeStatic); if (newArraySymbol == NULL) printInternalError(convertFileName(__FILE__).c_str(), __LINE__); @@ -350,13 +364,14 @@ static SgSymbol* alterExtendArrayDeclaration(const LoopGraph* forLoop, SgStateme return newArraySymbol; } -static SgSymbol* alterShrinkArrayDeclaration(SgStatement *declarationStatement, SgSymbol *arraySymbol, vector &dimensions) +static SgSymbol* alterShrinkArrayDeclaration(SgStatement *declarationStatement, SgSymbol *arraySymbol, + vector &dimensions, bool canBeStatic) { SgSymbol *newArraySymbol = NULL; SgExpression *array = findSymbolInExprList(arraySymbol, declarationStatement->expr(0)); SgExpression *newArray = array->copyPtr(); - newArraySymbol = createNewArrayNameSymbol(newArray, false); + newArraySymbol = createNewArrayNameSymbol(newArray, false, canBeStatic); reduceArray(dimensions, newArray, newArraySymbol); @@ -369,35 +384,25 @@ static SgSymbol* alterShrinkArrayDeclaration(SgStatement *declarationStatement, return newArraySymbol; } -static void extendArrayRefsInExpr(const vector& indexes, SgExpression* expr, SgSymbol* arraySymbol, - SgSymbol* newArraySymbol, const vector& lowBounds) +static void extendArrayRefsInExpr(const vector& indexes, SgExpression* expr, + SgSymbol* arraySymbol, SgSymbol* newArraySymbol, + const vector& lowBounds) { - SgExpression *lhs = expr->lhs(), *rhs = expr->rhs(); - - if (lhs) + if (expr) { - if (isArrayRef(lhs) && isEqSymbols(arraySymbol, lhs->symbol())) - extendArrayRef(indexes, lhs, newArraySymbol, lowBounds); - else if (lhs->variant() == VAR_REF && isEqSymbols(arraySymbol, lhs->symbol())) - { - SgExpression* extended = extendArrayRef(indexes, lhs, newArraySymbol, lowBounds); - expr->setLhs(extended); - } - else - extendArrayRefsInExpr(indexes, lhs, arraySymbol, newArraySymbol, lowBounds); - } + extendArrayRefsInExpr(indexes, expr->lhs(), arraySymbol, newArraySymbol, lowBounds); + extendArrayRefsInExpr(indexes, expr->rhs(), arraySymbol, newArraySymbol, lowBounds); - if (rhs) - { - if (isArrayRef(rhs) && isEqSymbols(arraySymbol, rhs->symbol())) - extendArrayRef(indexes, rhs, newArraySymbol, lowBounds); - else if (rhs->variant() == VAR_REF && isEqSymbols(arraySymbol, rhs->symbol())) + if (isArrayRef(expr) && isEqSymbols(arraySymbol, expr->symbol())) + extendArrayRef(indexes, expr, newArraySymbol, lowBounds); + else if (expr->variant() == VAR_REF && isEqSymbols(arraySymbol, expr->symbol())) { - SgExpression* extended = extendArrayRef(indexes, rhs, newArraySymbol, lowBounds); - expr->setRhs(extended); + SgExpression* extended = extendArrayRef(indexes, expr, newArraySymbol, lowBounds); + + expr->setSymbol(extended->symbol()); + expr->setLhs(extended->lhs()); + expr->setRhs(extended->rhs()); } - else - extendArrayRefsInExpr(indexes, rhs, arraySymbol, newArraySymbol, lowBounds); } } @@ -406,18 +411,22 @@ static void extendArrayRefs(const vector &indexes, SgStatement *st, S { for (int i = 0; i < 3; ++i) { - if (st->expr(i)) + if (st->variant() == PROC_STAT) { - if (isArrayRef(st->expr(i)) && isEqSymbols(arraySymbol, st->expr(i)->symbol())) - extendArrayRef(indexes, st->expr(i), newArraySymbol, lowBounds); - else if (st->expr(i)->variant() == VAR_REF && isEqSymbols(arraySymbol, st->expr(i)->symbol())) + SgCallStmt* call = isSgCallStmt(st); + for (int arg = 0; arg < call->numberOfArgs(); ++arg) { - SgExpression* extended = extendArrayRef(indexes, st->expr(i), newArraySymbol, lowBounds); - st->setExpression(i, *extended); + auto argRef = call->arg(arg); + if ((isArrayRef(argRef) || argRef->variant() == VAR_REF) && isEqSymbols(argRef->symbol(), arraySymbol)) + { + __spf_print(1, "unsupported private array extension under call on line %d\n", st->lineNumber()); + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); + } } - else - extendArrayRefsInExpr(indexes, st->expr(i), arraySymbol, newArraySymbol, lowBounds); } + + if (st->expr(i)) + extendArrayRefsInExpr(indexes, st->expr(i), arraySymbol, newArraySymbol, lowBounds); } } @@ -428,6 +437,8 @@ static SgStatement* createNewDeclarationStatemnet(SgStatement *loop, SgStatement { if (isSgExecutableStatement(lastDecl)) break; + if (lastDecl->variant() == CONTAINS_STMT) + break; lastDecl = lastDecl->lexNext(); } @@ -559,7 +570,7 @@ static SgExpression* constructArrayAllocationExp(const LoopGraph* forLoop, SgExp return new SgExpression(EXPR_LIST, arrayRef, (SgExpression*)NULL, (SgSymbol*)NULL); } -static void insertAllocDealloc(const LoopGraph* forLoop, SgSymbol* origArraySymbol, SgSymbol* arraySymbol, +static void insertAllocDealloc(const LoopGraph* forLoop, SgSymbol* origArraySymbol, SgSymbol* arraySymbol, SgSymbol* allocDone, bool isExpansion, const vector* indexes = NULL, const vector* shrinkIndexes = NULL) { SgForStmt *loopStmt = (SgForStmt*)(forLoop->loop->GetOriginal()); @@ -589,11 +600,17 @@ static void insertAllocDealloc(const LoopGraph* forLoop, SgSymbol* origArraySymb new SgExpression(ARRAY_REF, (SgExpression*)NULL, (SgExpression*)NULL, arraySymbol), (SgExpression*)NULL, (SgSymbol*)NULL); - SgStatement *allocate = new SgStatement(ALLOCATE_STMT, (SgLabel*)NULL, (SgSymbol*)NULL, arrayAllocation, (SgExpression*)NULL, (SgExpression*)NULL); - SgStatement *deallocate = new SgStatement(DEALLOCATE_STMT, (SgLabel*)NULL, (SgSymbol*)NULL, arrayDeallocation, (SgExpression*)NULL, (SgExpression*)NULL); + - loopStmt->insertStmtBefore(*allocate, *loopStmt->controlParent()); - loopStmt->lastNodeOfStmt()->insertStmtAfter(*deallocate, *loopStmt->controlParent()); + SgStatement *allocate = new SgStatement(ALLOCATE_STMT, (SgLabel*)NULL, (SgSymbol*)NULL, arrayAllocation, (SgExpression*)NULL, (SgExpression*)NULL); + SgIfStmt* ifSt = new SgIfStmt(SgEqOp(*new SgVarRefExp(allocDone), *new SgValueExp(0)), *allocate); + + loopStmt->insertStmtBefore(*ifSt, *loopStmt->controlParent()); + + + // insert allocates as save + //SgStatement* deallocate = new SgStatement(DEALLOCATE_STMT, (SgLabel*)NULL, (SgSymbol*)NULL, arrayDeallocation, (SgExpression*)NULL, (SgExpression*)NULL); + //loopStmt->lastNodeOfStmt()->insertStmtAfter(*deallocate, *loopStmt->controlParent()); } static bool containsFunctionCall(SgExpression* exp) @@ -781,6 +798,61 @@ static void renamePrivateVarsInAttributes(const vector& attrs, con } } +static void removePrivateVarsInAttributes(const vector& attrs, const map& symbols) +{ + for (SgStatement* st : attrs) + { + if (st->variant() != SPF_ANALYSIS_DIR) + return; + + SgExpression* exprList = st->expr(0); + vector newL; + bool remList = false; + while (exprList) + { + if (exprList->lhs()->variant() == ACC_PRIVATE_OP) + { + vector newL; + bool removed = false; + SgExpression* list = exprList->lhs()->lhs(); + while (list) + { + bool found = false; + for (auto& pair : symbols) + { + if (isEqSymbols(pair.first, list->lhs()->symbol())) + found = true; + if (found) + break; + } + if (!found) + newL.push_back(list->lhs()); + else + removed = true; + list = list->rhs(); + } + + if (removed) + { + if (newL.size() == 0) + remList = true; + else + { + exprList->lhs()->setLhs(makeExprList(newL)); + newL.push_back(exprList->lhs()); + } + } + } + else + newL.push_back(exprList->lhs()); + exprList = exprList->rhs(); + } + + if (remList) + st->setExpression(0, makeExprList(newL)); + } +} + static int getArrayDimensionality(SgSymbol* array) { if (array->type()->variant() != T_ARRAY) @@ -975,7 +1047,7 @@ static int fillIndexesToExtend(const LoopGraph* loop, int origDim, int depthOfRe return 0; } -static SgSymbol* shrinkArray(const LoopGraph *forLoop, SgSymbol *arraySymbol, vector &indexes) +static SgSymbol* shrinkArray(const LoopGraph *forLoop, SgSymbol *arraySymbol, vector &indexes, SgSymbol *allocDone) { int maxDepth = forLoop->perfectLoop; const LoopGraph *curLoop = forLoop; @@ -1005,16 +1077,17 @@ static SgSymbol* shrinkArray(const LoopGraph *forLoop, SgSymbol *arraySymbol, ve SgStatement *originalDeclaration = declaratedInStmt(arraySymbol); SgStatement *copiedDeclaration = createNewDeclarationStatemnet(forLoop->loop->GetOriginal(), originalDeclaration, arraySymbol); + bool canBeStatic = !(!reduceToVariable && isAllocatable(arraySymbol)); SgSymbol *newSymbol = reduceToVariable ? createReducedToVariableArray(copiedDeclaration, forLoop->lineNum, arraySymbol) - : alterShrinkArrayDeclaration(copiedDeclaration, arraySymbol, indexes); + : alterShrinkArrayDeclaration(copiedDeclaration, arraySymbol, indexes, canBeStatic); if (newSymbol) { SgForStmt *loopStmt = (SgForStmt*)(forLoop->loop->GetOriginal()); if (!reduceToVariable && isAllocatable(arraySymbol)) - insertAllocDealloc(forLoop, arraySymbol, newSymbol, false, NULL, &indexes); + insertAllocDealloc(forLoop, arraySymbol, newSymbol, false, allocDone, NULL, &indexes); for (SgStatement *st = loopStmt->lexNext(); st != loopStmt->lastNodeOfStmt()->lexNext(); st = st->lexNext()) if (st->variant() != ALLOCATE_STMT && st->variant() != DEALLOCATE_STMT) @@ -1026,7 +1099,7 @@ static SgSymbol* shrinkArray(const LoopGraph *forLoop, SgSymbol *arraySymbol, ve return NULL; } -static SgSymbol* resizeArray(const LoopGraph *forLoop, SgSymbol *arraySymbol, int depthOfResize) +static SgSymbol* resizeArray(const LoopGraph *forLoop, SgSymbol *arraySymbol, int depthOfResize, SgSymbol *allocDone) { if (depthOfResize < 0 || depthOfResize > forLoop->perfectLoop) depthOfResize = forLoop->perfectLoop; @@ -1074,7 +1147,8 @@ static SgSymbol* resizeArray(const LoopGraph *forLoop, SgSymbol *arraySymbol, in { SgForStmt *loopStmt = (SgForStmt*)(forLoop->loop->GetOriginal()); if (!canBeStatic || isAllocatable(newArraySymbol)) - insertAllocDealloc(forLoop, arraySymbol, newArraySymbol, true, &indexes, NULL); + insertAllocDealloc(forLoop, arraySymbol, newArraySymbol, allocDone, true, &indexes, NULL); + for (SgStatement *st = loopStmt->lexNext(); st != loopStmt->lastNodeOfStmt()->lexNext(); st = st->lexNext()) if (st->variant() != ALLOCATE_STMT && st->variant() != DEALLOCATE_STMT) extendArrayRefs(indexes, st, arraySymbol, newArraySymbol, lowBounds); @@ -1257,13 +1331,27 @@ void analyzeShrinking(SgFile* file, const vector& loopGraphs, vector } } +static void createAllocDoneSymbol(map& allocDoneByFunc, SgStatement* func) +{ + if (allocDoneByFunc.find(func) == allocDoneByFunc.end()) + { + auto newName = (string("spf_") + string(func->symbol()->identifier()) + "_alloc_"); + allocDoneByFunc[func] = new SgSymbol(VARIABLE_NAME, newName.c_str(), SgTypeInt(), func); + } +} + //Вычислять размер массива с учётом шага цикла - //TODO -int privateArraysResizing(SgFile *file, const vector &loopGraphs, vector &messages, - const map, set>& usersDirectives, bool isExpand) +void privateArraysResizing(SgFile *file, const vector &loopGraphs, vector &messages, int& countOfTransform, + const map, set>& usersDirectives, bool isExpand) { map mapLoopGraph; createMapLoopGraph(loopGraphs, mapLoopGraph); + map allocDoneByFunc; + map usedAllocDoneByFunc; + + map> saveDecls; + for (auto &loopPair : mapLoopGraph) { LoopGraph *loop = loopPair.second; @@ -1275,6 +1363,9 @@ int privateArraysResizing(SgFile *file, const vector &loopGraphs, ve auto attrPrivInCode = getAttributes(loopSt, set{ SPF_ANALYSIS_DIR }); auto arrayPrivates = fillPrivates(usersDirectives, loop); + auto func = getFuncStat(loopSt); + + set symbolsToDecl; if (arrayPrivates.size() == 0) { @@ -1284,9 +1375,7 @@ int privateArraysResizing(SgFile *file, const vector &loopGraphs, ve else __spf_printToBuf(str, "Can not do PRIVATE SHRINK for this loop - privates not found"); - //TODO: - //messages.push_back(Messages(NOTE, loop->lineNum, str, 2008)); - __spf_print(1, "%s on line %d\n", str.c_str(), loop->lineNum); + __spf_print(0, "%s on line %d\n", str.c_str(), loop->lineNum); } else { @@ -1301,7 +1390,9 @@ int privateArraysResizing(SgFile *file, const vector &loopGraphs, ve symbols.clear(); if (list->lhs()->variant() == SPF_EXPAND_OP && isExpand) - { + { + createAllocDoneSymbol(allocDoneByFunc, func); + int deep = -1; if (list->lhs()->lhs() != NULL) { @@ -1311,15 +1402,25 @@ int privateArraysResizing(SgFile *file, const vector &loopGraphs, ve } for (SgSymbol* privArr : arrayPrivates) - { - SgSymbol* newSymbol = resizeArray(loop, privArr, deep); + { + SgSymbol* newSymbol = resizeArray(loop, privArr, deep, allocDoneByFunc[func]); + if (newSymbol) + { symbols.insert(std::make_pair(privArr, newSymbol)); + usedAllocDoneByFunc[func] = allocDoneByFunc[func]; + countOfTransform++; + + if (isAllocatable(newSymbol)) + symbolsToDecl.insert(newSymbol); + } } - renamePrivateVarsInAttributes(attrPrivInCode, symbols); + removePrivateVarsInAttributes(attrPrivInCode, symbols); } else if (list->lhs()->variant() == SPF_SHRINK_OP && !isExpand) { + createAllocDoneSymbol(allocDoneByFunc, func); + SgExprListExp* listExp = isSgExprListExp(list->lhs()->lhs()); checkNull(listExp, convertFileName(__FILE__).c_str(), __LINE__); @@ -1335,9 +1436,17 @@ int privateArraysResizing(SgFile *file, const vector &loopGraphs, ve if (!indexes.empty() && !skip) { - SgSymbol* newSymbol = shrinkArray(loop, privArr, indexes); + SgSymbol* newSymbol = shrinkArray(loop, privArr, indexes, allocDoneByFunc[func]); + if (newSymbol) + { symbols.insert(std::make_pair(privArr, newSymbol)); + usedAllocDoneByFunc[func] = allocDoneByFunc[func]; + countOfTransform++; + + if (isAllocatable(newSymbol)) + symbolsToDecl.insert(newSymbol); + } } } renamePrivateVarsInAttributes(attrPrivInCode, symbols); @@ -1348,23 +1457,39 @@ int privateArraysResizing(SgFile *file, const vector &loopGraphs, ve list = list->rhs(); } - SgExpression *ex = NULL; - SgExpression *p = NULL; - for (int z = 0; z < newL.size(); ++z) - { - if (z == 0) - p = ex = newL[z]; - else - { - ex->setRhs(newL[z]); - ex = ex->rhs(); - } - } - attr->setExpression(0, p); + attr->setExpression(0, makeExprList(newL, false)); //__spf_print(1, "set new %d attributes to line %d\n", newL.size(), loop->lineNum); } } + + for (auto& elem : symbolsToDecl) + saveDecls[func].push_back(new SgVarRefExp(elem)); } - return 0; + for (auto& funcPair : saveDecls) + { + auto func = funcPair.first; + if (usedAllocDoneByFunc.find(func) == usedAllocDoneByFunc.end()) + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); + + SgSymbol* allocVar = usedAllocDoneByFunc[func]; + auto list = makeExprList(funcPair.second); + SgStatement* save = new SgStatement(SAVE_DECL, NULL, NULL, list); + + SgStatement* st = func->lexNext(); + while (!isSgExecutableStatement(st)) + { + if (st->variant() == CONTAINS_STMT) + break; + st = st->lexNext(); + } + + vector init = { new SgValueExp(-1) }; + makeDeclaration(func, { allocVar }, &init); + + st->insertStmtBefore(*save, *func); + + SgAssignStmt* assign = new SgAssignStmt(*new SgVarRefExp(allocVar), *new SgVarRefExp(allocVar) + *new SgValueExp(1)); + st->insertStmtBefore(*assign, *func); + } } diff --git a/sapfor/experts/Sapfor_2017/_src/Transformations/private_arrays_resizing.h b/sapfor/experts/Sapfor_2017/_src/Transformations/private_arrays_resizing.h index 05a1c55..1ad162d 100644 --- a/sapfor/experts/Sapfor_2017/_src/Transformations/private_arrays_resizing.h +++ b/sapfor/experts/Sapfor_2017/_src/Transformations/private_arrays_resizing.h @@ -5,5 +5,5 @@ #include -int privateArraysResizing(SgFile *file, const std::vector &loopGraphs, std::vector &messages, const std::map, std::set>& usersDirectives, bool isExpand); +void privateArraysResizing(SgFile *file, const std::vector &loopGraphs, std::vector &messages, int& countOfTransform, const std::map, std::set>& usersDirectives, bool isExpand); void analyzeShrinking(SgFile* file, const std::vector& loopGraphs, std::vector& messages, const std::map, std::set>& usersDirectives); \ No newline at end of file diff --git a/sapfor/experts/Sapfor_2017/_src/Utils/utils.cpp b/sapfor/experts/Sapfor_2017/_src/Utils/utils.cpp index 61e438b..3accd34 100644 --- a/sapfor/experts/Sapfor_2017/_src/Utils/utils.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Utils/utils.cpp @@ -184,6 +184,7 @@ extern int staticShadowAnalysis; extern int keepDvmDirectives; extern int ignoreIO; extern int keepSpfDirs; +extern int maxShadowWidth; const string printVersionAsFortranComm() { @@ -199,13 +200,14 @@ const string printVersionAsFortranComm() ret += "! *** shadow optimization\n"; if (keepDvmDirectives) ret += "! *** consider DVMH directives\n"; + if (keepSpfDirs) + ret += "! *** save SPF directives\n"; if (mpiProgram) ret += "! *** MPI program regime (shared memory parallelization)\n"; if (ignoreIO) ret += "! *** ignore I/O checker for arrays (DVM I/O limitations)\n"; - if (keepSpfDirs) - ret += "! *** save SPF directives\n"; - + if (maxShadowWidth > 0) + ret += "! *** maximum shadow width is " + std::to_string(maxShadowWidth) + " percent\n"; ret += "! *** generated by SAPFOR\n"; return ret; diff --git a/sapfor/experts/Sapfor_2017/_src/Utils/version.h b/sapfor/experts/Sapfor_2017/_src/Utils/version.h index 6f967cf..fabd458 100644 --- a/sapfor/experts/Sapfor_2017/_src/Utils/version.h +++ b/sapfor/experts/Sapfor_2017/_src/Utils/version.h @@ -1,3 +1,3 @@ #pragma once -#define VERSION_SPF "2291" +#define VERSION_SPF "2292" diff --git a/sapfor/experts/Sapfor_2017/_src/VisualizerCalls/get_information.cpp b/sapfor/experts/Sapfor_2017/_src/VisualizerCalls/get_information.cpp index dc3a5a9..10fe288 100644 --- a/sapfor/experts/Sapfor_2017/_src/VisualizerCalls/get_information.cpp +++ b/sapfor/experts/Sapfor_2017/_src/VisualizerCalls/get_information.cpp @@ -1904,13 +1904,21 @@ int SPF_InsertPrivateFromGUI(void*& context, int winHandler, short* options, sho } int SPF_RemoveDeadCode(void*& context, int winHandler, short* options, short* projName, short* folderName, short*& output, - int*& outputSize, short*& outputMessage, int*& outputMessageSize) + int*& outputSize, short*& outputMessage, int*& outputMessageSize) { MessageManager::clearCache(); MessageManager::setWinHandler(winHandler); return simpleTransformPass(REMOVE_DEAD_CODE_AND_UNPARSE, options, projName, folderName, output, outputSize, outputMessage, outputMessageSize); } +int SPF_InsertImplicitNone(void*& context, int winHandler, short* options, short* projName, short* folderName, short*& output, + int*& outputSize, short*& outputMessage, int*& outputMessageSize) +{ + MessageManager::clearCache(); + MessageManager::setWinHandler(winHandler); + return simpleTransformPass(SET_IMPLICIT_NONE, options, projName, folderName, output, outputSize, outputMessage, outputMessageSize); +} + static inline void convertBackSlash(char *str, int strL) { for (int z = 0; z < strL; ++z) @@ -2625,6 +2633,8 @@ const wstring Sapfor_RunTransformation(const char* transformName_c, const char* retCode = SPF_InsertPrivateFromGUI(context, winHandler, optSh, projSh, fold, output, outputSize, outputMessage, outputMessageSize); else if (whichRun == "SPF_RemoveDeadCode") retCode = SPF_RemoveDeadCode(context, winHandler, optSh, projSh, fold, output, outputSize, outputMessage, outputMessageSize); + else if (whichRun == "SPF_InsertImplicitNone") + retCode = SPF_InsertImplicitNone(context, winHandler, optSh, projSh, fold, output, outputSize, outputMessage, outputMessageSize); else { if (showDebug)