From e64ee54c2a744d2866895b89b4c32e9bcc1e4752 Mon Sep 17 00:00:00 2001 From: ALEXks Date: Fri, 4 Oct 2024 15:27:47 +0300 Subject: [PATCH] fixed actuals --- dvm/fdvm/trunk/fdvm/acc.cpp | 11 +++- dvm/fdvm/trunk/fdvm/dvm.cpp | 15 +++-- .../DirectiveProcessing/insert_directive.cpp | 6 +- .../_src/Distribution/DvmhDirective.cpp | 8 --- .../_src/DvmhRegions/DvmhRegionInserter.cpp | 59 +++++++++++-------- .../_src/DvmhRegions/ReadWriteAnalyzer.cpp | 9 ++- .../Sapfor_2017/_src/Utils/SgUtils.cpp | 10 ++-- .../experts/Sapfor_2017/_src/Utils/SgUtils.h | 11 +++- .../experts/Sapfor_2017/_src/Utils/version.h | 2 +- 9 files changed, 79 insertions(+), 52 deletions(-) diff --git a/dvm/fdvm/trunk/fdvm/acc.cpp b/dvm/fdvm/trunk/fdvm/acc.cpp index 502b1ee..1f1729f 100644 --- a/dvm/fdvm/trunk/fdvm/acc.cpp +++ b/dvm/fdvm/trunk/fdvm/acc.cpp @@ -1224,6 +1224,13 @@ int TestLocal(SgExpression *list) return (0); } +int is_deleted_module_symbol(SgSymbol *s) +{ + if (!strcmp("***", s->identifier())) + return 1; + return 0; +} + void EnterDataRegionForVariablesInMainProgram(SgStatement *st) { symb_list *sl; @@ -1237,7 +1244,7 @@ void EnterDataRegionForVariablesInMainProgram(SgStatement *st) s = cur_func->symbol()->next(); while (IS_BY_USE(s)) { - if (IS_ARRAY(s) && s->variant() == VARIABLE_NAME && !IS_ALLOCATABLE(s) && !IS_POINTER_F90(s) && !HEADER(s) ) + if (!is_deleted_module_symbol(s) && IS_ARRAY(s) && s->variant() == VARIABLE_NAME && !IS_ALLOCATABLE(s) && !IS_POINTER_F90(s) && !HEADER(s) ) st->insertStmtAfter(*DataEnter(new SgVarRefExp(s),ConstRef(0)),*st->controlParent()); s = s->next(); } @@ -1257,7 +1264,7 @@ void ExitDataRegionForVariablesInMainProgram(SgStatement *st) s=cur_func->symbol()->next(); while (IS_BY_USE(s)) { - if (IS_ARRAY(s) && s->variant() == VARIABLE_NAME && !IS_ALLOCATABLE(s) && !IS_POINTER_F90(s) && !HEADER(s) ) + if (!is_deleted_module_symbol(s) && IS_ARRAY(s) && s->variant() == VARIABLE_NAME && !IS_ALLOCATABLE(s) && !IS_POINTER_F90(s) && !HEADER(s) ) InsertNewStatementBefore(DataExit(new SgVarRefExp(s),0),st); s = s->next(); } diff --git a/dvm/fdvm/trunk/fdvm/dvm.cpp b/dvm/fdvm/trunk/fdvm/dvm.cpp index 8d58694..cd46e92 100644 --- a/dvm/fdvm/trunk/fdvm/dvm.cpp +++ b/dvm/fdvm/trunk/fdvm/dvm.cpp @@ -246,12 +246,12 @@ int main(int argc, char *argv[]) else if (!strcmp(argv[0], "-no_blocks_info") || !strcmp(argv[0], "-noBI")) options.setOn(NO_BL_INFO); /*ACC*/ else if (!strcmp(argv[0], "-cacheIdx")) - options.setOff(NO_BL_INFO); /*ACC*/ + options.setOff(NO_BL_INFO); /*ACC*/ else if (!strcmp(argv[0], "-Ohost")) /*ACC*/ options.setOn(O_HOST); else if (!strcmp(argv[0], "-noOhost")) /*ACC*/ options.setOff(O_HOST); - else if (!strcmp(argv[0], "-Opl2")) /*ACC*/ + else if (!strcmp(argv[0], "-Opl2")) /*ACC*/ { parloop_by_handler = 2; options.setOn(O_HOST); @@ -4276,8 +4276,11 @@ END_: // end of program unit Extract_Stmt(first_dvm_exec); //extract fname() call for(;pstmt; pstmt= pstmt->next) Extract_Stmt(pstmt->st);// extracting DVM Directives and - //statements (inside the range of ASYNCHRONOUS construct) - return; + //statements (inside the range of ASYNCHRONOUS construct) + if(ACC_program==0 && debug_regim) + if(cur_func->expr(2) && cur_func->expr(2)->variant() == PURE_OP) + cur_func->setExpression(2, NULL); // removing PURE attribute from procedure header + return; } @@ -11305,7 +11308,9 @@ END_: first_dvm_exec->extractStmt(); //extract fname() call for(;pstmt; pstmt= pstmt->next) Extract_Stmt(pstmt->st);// extracting DVM+ACC Directives - + if(debug_regim) + if(cur_func->expr(2) && cur_func->expr(2)->variant()==PURE_OP) + cur_func->setExpression(2, NULL); // removing PURE attribute from procedure header return; } diff --git a/sapfor/experts/Sapfor_2017/_src/DirectiveProcessing/insert_directive.cpp b/sapfor/experts/Sapfor_2017/_src/DirectiveProcessing/insert_directive.cpp index 43daaea..0b58816 100644 --- a/sapfor/experts/Sapfor_2017/_src/DirectiveProcessing/insert_directive.cpp +++ b/sapfor/experts/Sapfor_2017/_src/DirectiveProcessing/insert_directive.cpp @@ -837,9 +837,9 @@ static pair getModuleRename(const map>& b { auto declS = array->GetDeclSymbol(filename, lineRange, getAllFilesInProject())->GetOriginal(); for (auto& elem : byUse) - for (auto& localS : elem.second) - if (OriginalSymbol(localS) == declS) - return make_pair(elem.first, localS->identifier()); + for (auto& localS : setToMapWithSortByStr(elem.second)) + if (OriginalSymbol(localS.second) == declS) + return make_pair(elem.first, localS.second->identifier()); return make_pair("", ""); } diff --git a/sapfor/experts/Sapfor_2017/_src/Distribution/DvmhDirective.cpp b/sapfor/experts/Sapfor_2017/_src/Distribution/DvmhDirective.cpp index 33afba1..59bf212 100644 --- a/sapfor/experts/Sapfor_2017/_src/Distribution/DvmhDirective.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Distribution/DvmhDirective.cpp @@ -172,14 +172,6 @@ static SgExpression* genSgExpr(SgFile *file, const string &letter, const pair setToMapWithSortByStr(const set &setIn) -{ - std::multimap retMap; - for (auto& elem : setIn) - retMap.insert(make_pair(elem->identifier(), elem)); - return retMap; -} - static void fillUsedSymbols(SgExpression* ex, set& used) { if (ex) diff --git a/sapfor/experts/Sapfor_2017/_src/DvmhRegions/DvmhRegionInserter.cpp b/sapfor/experts/Sapfor_2017/_src/DvmhRegions/DvmhRegionInserter.cpp index f051e22..71921f4 100644 --- a/sapfor/experts/Sapfor_2017/_src/DvmhRegions/DvmhRegionInserter.cpp +++ b/sapfor/experts/Sapfor_2017/_src/DvmhRegions/DvmhRegionInserter.cpp @@ -297,7 +297,7 @@ static bool hasLoopsWithDir(LoopGraph* loop) return retVal; } -static void analyzeFunctionParameter(SgExpression* ex, set& except, ArraySet& arrays) +static void analyzeFunctionParameter(SgExpression* ex, set& except, ArraySet& arrays, bool isIntrinsicCall) { if (ex) { @@ -313,45 +313,50 @@ static void analyzeFunctionParameter(SgExpression* ex, set& except, Arra if (ex->lhs() || ex->rhs()) arrays.insert(currArray); else if (!ex->lhs() && !ex->rhs()) - except.insert(ex->symbol()->identifier()); + { + if (isIntrinsicCall) + arrays.insert(currArray); + else + except.insert(ex->symbol()->identifier()); + } } } - analyzeFunctionParameter(ex->lhs(), except, arrays); - analyzeFunctionParameter(ex->rhs(), except, arrays); + analyzeFunctionParameter(ex->lhs(), except, arrays, isIntrinsicCall); + analyzeFunctionParameter(ex->rhs(), except, arrays, isIntrinsicCall); } } -static void analyzeFunctionParameters(SgExpression* paramList, set& except, ArraySet& arrays) +static void analyzeFunctionParameters(SgExpression* paramList, set& except, ArraySet& arrays, bool isIntrinsicCall) { while (paramList) { SgExpression* ex = paramList->lhs(); if (ex->variant() == FUNC_CALL) { - if (!isIntrinsicFunctionName(ex->symbol()->identifier())) - analyzeFunctionParameters(ex->lhs(), except, arrays); + bool isIntrinsic = isIntrinsicFunctionName(ex->symbol()->identifier()); + analyzeFunctionParameters(ex->lhs(), except, arrays, isIntrinsic); } else - analyzeFunctionParameter(ex, except, arrays); - + analyzeFunctionParameter(ex, except, arrays, isIntrinsicCall); + paramList = paramList->rhs(); } } -static void createExceptList(SgExpression* ex, set& except, ArraySet& arrays) +static void createExceptListFromFunctionParameters(SgExpression* ex, set& except, ArraySet& arrays, bool forGetActual) { if (ex) { if (ex->variant() == FUNC_CALL) { - if (!isIntrinsicFunctionName(ex->symbol()->identifier())) - analyzeFunctionParameters(ex->lhs(), except, arrays); + bool isIntrinsic = isIntrinsicFunctionName(ex->symbol()->identifier()) && forGetActual; + analyzeFunctionParameters(ex->lhs(), except, arrays, isIntrinsic); } else { - createExceptList(ex->lhs(), except, arrays); - createExceptList(ex->rhs(), except, arrays); + createExceptListFromFunctionParameters(ex->lhs(), except, arrays, forGetActual); + createExceptListFromFunctionParameters(ex->rhs(), except, arrays, forGetActual); } } } @@ -382,7 +387,6 @@ ArraySet DvmhRegionInserter::excludeRemotes(const ArraySet& block, SgStatement* printInternalError(convertFileName(__FILE__).c_str(), __LINE__); SgStatement* next = remoteDir->lexNext(); - const string leftS = ""; //TODO: record ref! if (next->variant() == ASSIGN_STAT) @@ -402,9 +406,6 @@ ArraySet DvmhRegionInserter::excludeRemotes(const ArraySet& block, SgStatement* for (auto& remArray : remotes) { - if (leftS == OriginalSymbol(remArray->symbol())->identifier()) - continue; - auto arrayR = OriginalSymbol(remArray->symbol()); SgStatement* decl = declaratedInStmt(arrayR); DIST::Array* currArray = getArrayFromDeclarated(decl, arrayR->identifier()); @@ -441,7 +442,7 @@ void DvmhRegionInserter::insertForProcCall(SgStatement* st, bool& skipGetActualI ArraySet arraysToGetActual, arraysToActual; set exceptSymbs; - analyzeFunctionParameters(st->expr(0), exceptSymbs, arraysToGetActual); + analyzeFunctionParameters(st->expr(0), exceptSymbs, arraysToGetActual, false); auto writeArrays = get_used_arrs(st, DVMH_REG_WT); writeArrays = excludePrivates(writeArrays); @@ -526,18 +527,24 @@ SgStatement* DvmhRegionInserter::processSt(SgStatement *st, const vectorvariant() == DVM_REMOTE_ACCESS_DIR && st->variant() == ASSIGN_STAT && readBlocks.size() == 0)) insertActualDirective(block_dir, unite, ACC_GET_ACTUAL_DIR, true); + + writeBlocks = get_used_arrs_for_block(st, DVMH_REG_WT); + writeBlocks = excludePrivates(writeBlocks); + writeBlocks = applyUseFilter(writeBlocks, usedArraysInParallelLoops); + insertActualDirective(st->lastNodeOfStmt()->lexNext(), writeBlocks, ACC_ACTUAL_DIR, false); } return st->lastNodeOfStmt()->lexNext(); @@ -570,7 +577,7 @@ SgStatement* DvmhRegionInserter::processSt(SgStatement *st, const vectorexpr(z), exceptSymbsForGetActual, forGetActual); + createExceptListFromFunctionParameters(st->expr(z), exceptSymbsForGetActual, forGetActual, true); auto readArrays = get_used_arrs(st, DVMH_REG_RD); readArrays = excludePrivates(readArrays); @@ -588,7 +595,7 @@ SgStatement* DvmhRegionInserter::processSt(SgStatement *st, const vectorexpr(z), exceptSymbsForActual, forActual); + createExceptListFromFunctionParameters(st->expr(z), exceptSymbsForActual, forActual, false); auto writeArrays = get_used_arrs(st, DVMH_REG_WT); writeArrays = excludePrivates(writeArrays); diff --git a/sapfor/experts/Sapfor_2017/_src/DvmhRegions/ReadWriteAnalyzer.cpp b/sapfor/experts/Sapfor_2017/_src/DvmhRegions/ReadWriteAnalyzer.cpp index 512e206..40243a7 100644 --- a/sapfor/experts/Sapfor_2017/_src/DvmhRegions/ReadWriteAnalyzer.cpp +++ b/sapfor/experts/Sapfor_2017/_src/DvmhRegions/ReadWriteAnalyzer.cpp @@ -62,10 +62,13 @@ VarUsages ReadWriteAnalyzer::findUsagesInAssignment(SgStatement* st) const // load usages from array indexes VarUsages usages_in_arr_indexing = findUsagesInExpr(st->expr(1)->lhs()); usages.extend(usages_in_arr_indexing); + usages_in_arr_indexing = findUsagesInExpr(st->expr(1)->rhs()); usages.extend(usages_in_arr_indexing); + usages_in_arr_indexing = findUsagesInExpr(st->expr(0)->lhs()); usages.extend(usages_in_arr_indexing); + usages_in_arr_indexing = findUsagesInExpr(st->expr(0)->rhs()); usages.extend(usages_in_arr_indexing); @@ -124,7 +127,8 @@ VarUsages ReadWriteAnalyzer::findUsagesInFuncCall(SgExpression* params_tree, con VarUsages usages; vector inOutTypes; - if (!isIntrinsicFunctionName(func_key.c_str())) + bool isIntrinsic = isIntrinsicFunctionName(func_key.c_str()); + if (!isIntrinsic) { auto it = modified_pars.find(func_key); if (it != modified_pars.end()) @@ -216,7 +220,8 @@ VarUsages ReadWriteAnalyzer::findUsagesInFuncCall(SgExpression* params_tree, con else { usages.insert_read(param); - usages.insert_write(param); + if (!isIntrinsic) + usages.insert_write(param); } findReadUsagesInExpression(param->lhs(), usages); diff --git a/sapfor/experts/Sapfor_2017/_src/Utils/SgUtils.cpp b/sapfor/experts/Sapfor_2017/_src/Utils/SgUtils.cpp index 79b5320..d71bd0a 100644 --- a/sapfor/experts/Sapfor_2017/_src/Utils/SgUtils.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Utils/SgUtils.cpp @@ -2306,10 +2306,12 @@ SgSymbol* getFromModule(const map> &byUse, SgSymbol *orig if (byUse.size()) { - for (auto& elem : byUse) - for (auto& localS : elem.second) - if (OriginalSymbol(localS)->thesymb == orig->thesymb) - return localS; + for (auto& elem : byUse) + { + for (auto& localS : setToMapWithSortByStr(elem.second)) + if (OriginalSymbol(localS.second)->thesymb == orig->thesymb) + return localS.second; + } } return orig; } diff --git a/sapfor/experts/Sapfor_2017/_src/Utils/SgUtils.h b/sapfor/experts/Sapfor_2017/_src/Utils/SgUtils.h index a21237d..6ad3937 100644 --- a/sapfor/experts/Sapfor_2017/_src/Utils/SgUtils.h +++ b/sapfor/experts/Sapfor_2017/_src/Utils/SgUtils.h @@ -108,4 +108,13 @@ void getMaxMinBlockDistribution(SgFile* file, std::pair& min_max); void addPrivatesToArraysFromGUI(SgFile* file, const std::map, std::pair>& declaredArrays, const std::map& distrStateFromGUI); -void shiftLines(SgProject* project, bool print = true); \ No newline at end of file +void shiftLines(SgProject* project, bool print = true); + +template +static inline std::multimap setToMapWithSortByStr(const std::set& setIn) +{ + std::multimap retMap; + for (auto& elem : setIn) + retMap.insert(make_pair(elem->identifier(), elem)); + return retMap; +} \ No newline at end of file diff --git a/sapfor/experts/Sapfor_2017/_src/Utils/version.h b/sapfor/experts/Sapfor_2017/_src/Utils/version.h index 383d187..ca75ac3 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 "2364" +#define VERSION_SPF "2366"