diff --git a/sapfor/experts/Sapfor_2017/CMakeLists.txt b/sapfor/experts/Sapfor_2017/CMakeLists.txt index d30abc3..ddf04a6 100644 --- a/sapfor/experts/Sapfor_2017/CMakeLists.txt +++ b/sapfor/experts/Sapfor_2017/CMakeLists.txt @@ -337,7 +337,9 @@ set(PROJ_MAN _src/ProjectManipulation/ParseFiles.cpp _src/ProjectManipulation/PerfAnalyzer.cpp _src/ProjectManipulation/PerfAnalyzer.h _src/ProjectManipulation/FileInfo.cpp - _src/ProjectManipulation/FileInfo.h) + _src/ProjectManipulation/FileInfo.h + _src/ProjectManipulation/ConvertFiles.cpp + _src/ProjectManipulation/ConvertFiles.h) set(PARSER ${parser_sources}/cftn.c ${parser_sources}/errors.c diff --git a/sapfor/experts/Sapfor_2017/_src/ProjectManipulation/ConvertFiles.cpp b/sapfor/experts/Sapfor_2017/_src/ProjectManipulation/ConvertFiles.cpp new file mode 100644 index 0000000..c4ba01e --- /dev/null +++ b/sapfor/experts/Sapfor_2017/_src/ProjectManipulation/ConvertFiles.cpp @@ -0,0 +1,21 @@ +#include "../Utils/leak_detector.h" + +#include +#include + +#include +#include + +#include "../Utils/errors.h" +#include "../Utils/SgUtils.h" + +#include "ConvertFiles.h" + +using namespace std; + +extern int convert_file(int argc, char* argv[], const char* proj_name); + +void convertFiles(int argc, char* argv[], const char* proj_name) +{ + convert_file(argc, argv, proj_name); +} \ No newline at end of file diff --git a/sapfor/experts/Sapfor_2017/_src/ProjectManipulation/ConvertFiles.h b/sapfor/experts/Sapfor_2017/_src/ProjectManipulation/ConvertFiles.h new file mode 100644 index 0000000..30c2046 --- /dev/null +++ b/sapfor/experts/Sapfor_2017/_src/ProjectManipulation/ConvertFiles.h @@ -0,0 +1,3 @@ +#pragma once + +void convertFiles(int argc, char* argv[], const char* proj_name = "dvm.proj"); diff --git a/sapfor/experts/Sapfor_2017/_src/ProjectManipulation/ParseFiles.cpp b/sapfor/experts/Sapfor_2017/_src/ProjectManipulation/ParseFiles.cpp index 27c92ac..a039c0f 100644 --- a/sapfor/experts/Sapfor_2017/_src/ProjectManipulation/ParseFiles.cpp +++ b/sapfor/experts/Sapfor_2017/_src/ProjectManipulation/ParseFiles.cpp @@ -312,14 +312,13 @@ static vector parseList(vector& listOfProject, sendMessage_2lvl(L" обработка файла '" + to_wstring(file) + L"'"); #else sendMessage_2lvl(L" processing file '" + to_wstring(file) + L"'"); -#endif - StdCapture stdCapture; - stdCapture.Init(); +#endif + StdCapture::Init(); string errorMessage = ""; try { set filesModified; - stdCapture.BeginCapture(); + StdCapture::BeginCapture(); if (needToInclude) filesModified = applyModuleDeclsForFile(&elem, mapFiles, moduleDelc, mapModuleDeps, modDirectOrder, optSplited, needToIncludeForInline); else if (needToIncludeForInline) // TODO for modules @@ -334,22 +333,22 @@ static vector parseList(vector& listOfProject, } elem.error = retCode; - stdCapture.EndCapture(); - errorMessage = stdCapture.GetCapture(); + StdCapture::EndCapture(); + errorMessage = StdCapture::GetCapture(); checkRetCode(elem, errorMessage); } catch (int err) { - stdCapture.EndCapture(); - errorMessage = stdCapture.GetCapture(); + StdCapture::EndCapture(); + errorMessage = StdCapture::GetCapture(); if (needToInclude || needToIncludeForInline) restoreOriginalText(listOfProject); } catch (...) { - stdCapture.EndCapture(); - errorMessage = stdCapture.GetCapture(); + StdCapture::EndCapture(); + errorMessage = StdCapture::GetCapture(); if (needToInclude || needToIncludeForInline) restoreOriginalText(listOfProject); diff --git a/sapfor/experts/Sapfor_2017/_src/ProjectManipulation/PerfAnalyzer.cpp b/sapfor/experts/Sapfor_2017/_src/ProjectManipulation/PerfAnalyzer.cpp index e16206f..c3ee28c 100644 --- a/sapfor/experts/Sapfor_2017/_src/ProjectManipulation/PerfAnalyzer.cpp +++ b/sapfor/experts/Sapfor_2017/_src/ProjectManipulation/PerfAnalyzer.cpp @@ -8,8 +8,6 @@ #include "../Utils/errors.h" #include "../Utils/SgUtils.h" -#include "../VisualizerCalls/get_information.h" -#include "../VisualizerCalls/SendMessage.h" #include "StdCapture.h" @@ -26,13 +24,22 @@ int pppaAnalyzer(const char* options) for (int z = 0; z < splited.size(); ++z) argv[z] = (char*)splited[z].c_str(); - StdCapture stdCapture; - stdCapture.Init(); + StdCapture::Init(); string errorMessage = ""; int retCode = pppa_analyzer(splited.size(), argv); - stdCapture.EndCapture(); - errorMessage = stdCapture.GetCapture(); + StdCapture::EndCapture(); + errorMessage = StdCapture::GetCapture(); delete []argv; return retCode; } + +void pppaAnalyzer(int argc, char** argv) +{ + int code = pppa_analyzer(argc, argv); + if (code == 0) + printf("PPPA was completed successfully\n"); + else + printf("PPPA was completed with error code %d\n", code); + exit(0); +} diff --git a/sapfor/experts/Sapfor_2017/_src/ProjectManipulation/PerfAnalyzer.h b/sapfor/experts/Sapfor_2017/_src/ProjectManipulation/PerfAnalyzer.h index 5e81a81..70f806d 100644 --- a/sapfor/experts/Sapfor_2017/_src/ProjectManipulation/PerfAnalyzer.h +++ b/sapfor/experts/Sapfor_2017/_src/ProjectManipulation/PerfAnalyzer.h @@ -1,3 +1,4 @@ #pragma once -int pppaAnalyzer(const char* options); \ No newline at end of file +int pppaAnalyzer(const char* options); +void pppaAnalyzer(int argc, char** argv); diff --git a/sapfor/experts/Sapfor_2017/_src/ProjectManipulation/StdCapture.h b/sapfor/experts/Sapfor_2017/_src/ProjectManipulation/StdCapture.h index b0ab35b..8a3b8c9 100644 --- a/sapfor/experts/Sapfor_2017/_src/ProjectManipulation/StdCapture.h +++ b/sapfor/experts/Sapfor_2017/_src/ProjectManipulation/StdCapture.h @@ -30,18 +30,18 @@ #define STD_ERR_FD (fileno(stderr)) #endif +static int m_pipe[2]; +static int m_oldStdOut; +static int m_oldStdErr; +static bool m_capturing; +static std::mutex m_mutex; +static std::string m_captured; + class StdCapture { - int m_pipe[2]; - int m_oldStdOut; - int m_oldStdErr; - bool m_capturing; - std::mutex m_mutex; - std::string m_captured; - enum PIPES { READ, WRITE }; - int secure_dup(int src) + static int secure_dup(int src) { int ret = -1; bool fd_blocked = false; @@ -55,7 +55,7 @@ class StdCapture return ret; } - void secure_pipe(int* pipes) + static void secure_pipe(int* pipes) { int ret = -1; bool fd_blocked = false; @@ -73,7 +73,7 @@ class StdCapture } while (ret < 0); } - void secure_dup2(int src, int dest) + static void secure_dup2(int src, int dest) { int ret = -1; bool fd_blocked = false; @@ -86,7 +86,7 @@ class StdCapture } while (ret < 0); } - void secure_close(int& fd) + static void secure_close(int& fd) { int ret = -1; bool fd_blocked = false; @@ -102,7 +102,7 @@ class StdCapture } public: - void Init() + static void Init() { // make stdout & stderr streams unbuffered // so that we don't need to flush the streams @@ -113,7 +113,7 @@ public: setvbuf(stderr, NULL, _IONBF, 0); } - void BeginCapture() + static void BeginCapture() { std::lock_guard lock(m_mutex); if (m_capturing) @@ -130,13 +130,13 @@ public: #endif } - bool IsCapturing() + static bool IsCapturing() { std::lock_guard lock(m_mutex); return m_capturing; } - void EndCapture() + static void EndCapture() { std::lock_guard lock(m_mutex); if (!m_capturing) @@ -182,7 +182,7 @@ public: m_capturing = false; } - std::string GetCapture() + static std::string GetCapture() { std::lock_guard lock(m_mutex); return m_captured; diff --git a/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp b/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp index ccd563d..c7851fe 100644 --- a/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp @@ -34,6 +34,8 @@ #include "Utils/errors.h" #include "Utils/SgUtils.h" #include "ProjectManipulation/ParseFiles.h" +#include "ProjectManipulation/PerfAnalyzer.h" +#include "ProjectManipulation/ConvertFiles.h" #include "LoopAnalyzer/loop_analyzer.h" #include "LoopAnalyzer/loop_analyzer_nodist.h" @@ -2566,8 +2568,6 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam } } -extern int pppa_analyzer(int argv, char** argc); - int main(int argc, char **argv) { int leakMemDump = 0; @@ -2730,17 +2730,12 @@ int main(int argc, char **argv) parallizeFreeLoops = 1; else if (string(curr_arg) == "-parse") parseFiles(argc - (i + 1), argv + (i + 1)); + else if (string(curr_arg) == "-pppa") + pppaAnalyzer(argc - (i + 1), argv + (i + 1)); + else if (string(curr_arg) == "-fdvm") + convertFiles(argc - (i + 1), argv + (i + 1)); else if (string(curr_arg) == "-mpi") mpiProgram = 1; - else if (string(curr_arg) == "-pppa") - { - int code = pppa_analyzer(argc - i, argv + i); - if (code == 0) - printf("PPPA was completed successfully\n"); - else - printf("PPPA was completed with error code %d\n", code); - exit(0); - } else if (string(curr_arg) == "-client") { runAsClient = true; diff --git a/sapfor/experts/Sapfor_2017/_src/Utils/utils.cpp b/sapfor/experts/Sapfor_2017/_src/Utils/utils.cpp index 90531e3..61e438b 100644 --- a/sapfor/experts/Sapfor_2017/_src/Utils/utils.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Utils/utils.cpp @@ -151,6 +151,8 @@ void printHelp(const char **passNames, const int lastPass) printf(" -allVars get all parallel versions\n"); printf(" -var N get specific parallel version, N=1,2,..\n"); printf(" -parse run parser with next option (-inl option allow to parse project for -inlineH/I regime)\n"); + printf(" -pppa run performance statistic analyzer \n"); + printf(" -fdvm run fdvm convertation\n"); printf(" -inlineH run hierarchical inlining for all functions called from 'funcName'\n"); printf(" -inlineI run incremental inlining for function 'funcName' on 'lineNum' of 'fileName'\n"); printf(" -passInfo print passes information\n"); diff --git a/sapfor/experts/Sapfor_2017/_src/Utils/version.h b/sapfor/experts/Sapfor_2017/_src/Utils/version.h index 855d4b4..21fd553 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 "2276" +#define VERSION_SPF "2277"