From 11cc671416c9bd3ac52855c4cc312cb130bc7a9e Mon Sep 17 00:00:00 2001 From: ALEXks Date: Sun, 20 Apr 2025 21:34:31 +0300 Subject: [PATCH] fixed dumping statistics --- src/Predictor/PredictScheme.cpp | 34 +++++++++++++++++++++------------ src/Utils/version.h | 2 +- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/Predictor/PredictScheme.cpp b/src/Predictor/PredictScheme.cpp index 9c90184..46ffff6 100644 --- a/src/Predictor/PredictScheme.cpp +++ b/src/Predictor/PredictScheme.cpp @@ -14,13 +14,13 @@ #include "dvm.h" #include "../DynamicAnalysis/gcov_info.h" +#include "../DynamicAnalysis/gCov_parser_func.h" #include "PredictScheme.h" #include "../Utils/SgUtils.h" #include "../DirectiveProcessing/directive_parser.h" #include "../Distribution/DvmhDirective.h" #include "../GraphLoop/graph_loops_func.h" #include "../ExpressionTransform/expr_transform.h" -#include "../DirectiveProcessing/directive_parser.h" #include "../LoopAnalyzer/loop_analyzer.h" #include "../CFGraph/CFGraph.h" @@ -208,27 +208,31 @@ void calculateStatsForPredictor(const map>& allFuncInf uint64_t paralle_exec = 0; uint64_t lines_count = 0; - if (st->variant() == DVM_PARALLEL_ON_DIR) + if (st->variant() == DVM_PARALLEL_ON_DIR) { auto loop = st->lexNext(); checkNull(loop, convertFileName(__FILE__).c_str(), __LINE__); if (loop->variant() != FOR_NODE) printInternalError(convertFileName(__FILE__).c_str(), __LINE__); - calculateForParallelLoop(loop, gcov, paralle_exec, lines_count); - st = loop->lastNodeOfStmt(); + if (__gcov_doesThisLineExecuted(byFile.first, loop->lineNumber())) + { + calculateForParallelLoop(loop, gcov, paralle_exec, lines_count); + st = loop->lastNodeOfStmt(); - parallel_exec_count += paralle_exec; - count_of_parallel_lines += lines_count; + parallel_exec_count += paralle_exec; + count_of_parallel_lines += lines_count; - __spf_print(1, " PAR LOOP [%d %s] total exec %llu, total exec lines %llu, avg %.16e\n", - loop->lineNumber(), byFile.first.c_str(), paralle_exec, lines_count, paralle_exec / (double)lines_count); + __spf_print(1, " PAR LOOP [%d %s] total exec %llu, total exec lines %llu, avg %.16e\n", + loop->lineNumber(), byFile.first.c_str(), paralle_exec, lines_count, paralle_exec / (double)lines_count); + } } } for (auto st = stat->lexNext(); st != stat->lastNodeOfStmt(); st = st->lexNext()) { - if (!isSgExecutableStatement(st) || isDVM_stat(st) || isSPF_stat(st)) + if (!isSgExecutableStatement(st) || isDVM_stat(st) || isSPF_stat(st) || + !__gcov_doesThisLineExecuted(byFile.first, st->lineNumber())) continue; int line = st->lineNumber(); @@ -428,6 +432,7 @@ static void parallelDir(const map& byPos, SgExpression* spec, parallel["loops_count"] = loopSymbs.size(); SgStatement* loop = isSgForStmt(st->lexNext()); + if (loop == NULL) printInternalError(convertFileName(__FILE__).c_str(), __LINE__); SgStatement* lastNode = loop->lastNodeOfStmt(); @@ -444,11 +449,13 @@ static void parallelDir(const map& byPos, SgExpression* spec, loop = loop->lexNext(); } - for (int z = execs.size() - 1; z > 0; --z) - execs[z] /= execs[z - 1]; + for (int z = execs.size() - 1; z > 0; --z) + if (execs[z - 1] != 0) + execs[z] /= execs[z - 1]; auto& info = getInfo(before, gcov); - execs[0] /= info.getExecutedCount(); + if (info.getExecutedCount()) + execs[0] /= info.getExecutedCount(); parallel["iterations_count"] = execs; @@ -587,6 +594,9 @@ void parseDvmDirForPredictor(const map, pairlexNext(); st != stat->lastNodeOfStmt(); st = st->lexNext()) { + if (!__gcov_doesThisLineExecuted(byFile.first, st->lineNumber())) + continue; + SgExpression* list; SgExpression* dup; auto line = 0; diff --git a/src/Utils/version.h b/src/Utils/version.h index 0bbe90a..4127406 100644 --- a/src/Utils/version.h +++ b/src/Utils/version.h @@ -1,3 +1,3 @@ #pragma once -#define VERSION_SPF "2409" +#define VERSION_SPF "2410"