code refactoring
This commit is contained in:
@@ -337,7 +337,9 @@ set(PROJ_MAN _src/ProjectManipulation/ParseFiles.cpp
|
|||||||
_src/ProjectManipulation/PerfAnalyzer.cpp
|
_src/ProjectManipulation/PerfAnalyzer.cpp
|
||||||
_src/ProjectManipulation/PerfAnalyzer.h
|
_src/ProjectManipulation/PerfAnalyzer.h
|
||||||
_src/ProjectManipulation/FileInfo.cpp
|
_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
|
set(PARSER ${parser_sources}/cftn.c
|
||||||
${parser_sources}/errors.c
|
${parser_sources}/errors.c
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#include "../Utils/leak_detector.h"
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#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);
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
void convertFiles(int argc, char* argv[], const char* proj_name = "dvm.proj");
|
||||||
@@ -312,14 +312,13 @@ static vector<string> parseList(vector<FileInfo>& listOfProject,
|
|||||||
sendMessage_2lvl(L" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> '" + to_wstring(file) + L"'");
|
sendMessage_2lvl(L" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> '" + to_wstring(file) + L"'");
|
||||||
#else
|
#else
|
||||||
sendMessage_2lvl(L" processing file '" + to_wstring(file) + L"'");
|
sendMessage_2lvl(L" processing file '" + to_wstring(file) + L"'");
|
||||||
#endif
|
#endif
|
||||||
StdCapture stdCapture;
|
StdCapture::Init();
|
||||||
stdCapture.Init();
|
|
||||||
string errorMessage = "";
|
string errorMessage = "";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
set<FileInfo*> filesModified;
|
set<FileInfo*> filesModified;
|
||||||
stdCapture.BeginCapture();
|
StdCapture::BeginCapture();
|
||||||
if (needToInclude)
|
if (needToInclude)
|
||||||
filesModified = applyModuleDeclsForFile(&elem, mapFiles, moduleDelc, mapModuleDeps, modDirectOrder, optSplited, needToIncludeForInline);
|
filesModified = applyModuleDeclsForFile(&elem, mapFiles, moduleDelc, mapModuleDeps, modDirectOrder, optSplited, needToIncludeForInline);
|
||||||
else if (needToIncludeForInline) // TODO for modules
|
else if (needToIncludeForInline) // TODO for modules
|
||||||
@@ -334,22 +333,22 @@ static vector<string> parseList(vector<FileInfo>& listOfProject,
|
|||||||
}
|
}
|
||||||
|
|
||||||
elem.error = retCode;
|
elem.error = retCode;
|
||||||
stdCapture.EndCapture();
|
StdCapture::EndCapture();
|
||||||
errorMessage = stdCapture.GetCapture();
|
errorMessage = StdCapture::GetCapture();
|
||||||
checkRetCode(elem, errorMessage);
|
checkRetCode(elem, errorMessage);
|
||||||
}
|
}
|
||||||
catch (int err)
|
catch (int err)
|
||||||
{
|
{
|
||||||
stdCapture.EndCapture();
|
StdCapture::EndCapture();
|
||||||
errorMessage = stdCapture.GetCapture();
|
errorMessage = StdCapture::GetCapture();
|
||||||
|
|
||||||
if (needToInclude || needToIncludeForInline)
|
if (needToInclude || needToIncludeForInline)
|
||||||
restoreOriginalText(listOfProject);
|
restoreOriginalText(listOfProject);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
stdCapture.EndCapture();
|
StdCapture::EndCapture();
|
||||||
errorMessage = stdCapture.GetCapture();
|
errorMessage = StdCapture::GetCapture();
|
||||||
|
|
||||||
if (needToInclude || needToIncludeForInline)
|
if (needToInclude || needToIncludeForInline)
|
||||||
restoreOriginalText(listOfProject);
|
restoreOriginalText(listOfProject);
|
||||||
|
|||||||
@@ -8,8 +8,6 @@
|
|||||||
|
|
||||||
#include "../Utils/errors.h"
|
#include "../Utils/errors.h"
|
||||||
#include "../Utils/SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "../VisualizerCalls/get_information.h"
|
|
||||||
#include "../VisualizerCalls/SendMessage.h"
|
|
||||||
|
|
||||||
#include "StdCapture.h"
|
#include "StdCapture.h"
|
||||||
|
|
||||||
@@ -26,13 +24,22 @@ int pppaAnalyzer(const char* options)
|
|||||||
for (int z = 0; z < splited.size(); ++z)
|
for (int z = 0; z < splited.size(); ++z)
|
||||||
argv[z] = (char*)splited[z].c_str();
|
argv[z] = (char*)splited[z].c_str();
|
||||||
|
|
||||||
StdCapture stdCapture;
|
StdCapture::Init();
|
||||||
stdCapture.Init();
|
|
||||||
string errorMessage = "";
|
string errorMessage = "";
|
||||||
int retCode = pppa_analyzer(splited.size(), argv);
|
int retCode = pppa_analyzer(splited.size(), argv);
|
||||||
stdCapture.EndCapture();
|
StdCapture::EndCapture();
|
||||||
errorMessage = stdCapture.GetCapture();
|
errorMessage = StdCapture::GetCapture();
|
||||||
|
|
||||||
delete []argv;
|
delete []argv;
|
||||||
return retCode;
|
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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
int pppaAnalyzer(const char* options);
|
int pppaAnalyzer(const char* options);
|
||||||
|
void pppaAnalyzer(int argc, char** argv);
|
||||||
|
|||||||
@@ -30,18 +30,18 @@
|
|||||||
#define STD_ERR_FD (fileno(stderr))
|
#define STD_ERR_FD (fileno(stderr))
|
||||||
#endif
|
#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
|
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 };
|
enum PIPES { READ, WRITE };
|
||||||
|
|
||||||
int secure_dup(int src)
|
static int secure_dup(int src)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
bool fd_blocked = false;
|
bool fd_blocked = false;
|
||||||
@@ -55,7 +55,7 @@ class StdCapture
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void secure_pipe(int* pipes)
|
static void secure_pipe(int* pipes)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
bool fd_blocked = false;
|
bool fd_blocked = false;
|
||||||
@@ -73,7 +73,7 @@ class StdCapture
|
|||||||
} while (ret < 0);
|
} while (ret < 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void secure_dup2(int src, int dest)
|
static void secure_dup2(int src, int dest)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
bool fd_blocked = false;
|
bool fd_blocked = false;
|
||||||
@@ -86,7 +86,7 @@ class StdCapture
|
|||||||
} while (ret < 0);
|
} while (ret < 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void secure_close(int& fd)
|
static void secure_close(int& fd)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
bool fd_blocked = false;
|
bool fd_blocked = false;
|
||||||
@@ -102,7 +102,7 @@ class StdCapture
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void Init()
|
static void Init()
|
||||||
{
|
{
|
||||||
// make stdout & stderr streams unbuffered
|
// make stdout & stderr streams unbuffered
|
||||||
// so that we don't need to flush the streams
|
// so that we don't need to flush the streams
|
||||||
@@ -113,7 +113,7 @@ public:
|
|||||||
setvbuf(stderr, NULL, _IONBF, 0);
|
setvbuf(stderr, NULL, _IONBF, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BeginCapture()
|
static void BeginCapture()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_mutex);
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
if (m_capturing)
|
if (m_capturing)
|
||||||
@@ -130,13 +130,13 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsCapturing()
|
static bool IsCapturing()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_mutex);
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
return m_capturing;
|
return m_capturing;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EndCapture()
|
static void EndCapture()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_mutex);
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
if (!m_capturing)
|
if (!m_capturing)
|
||||||
@@ -182,7 +182,7 @@ public:
|
|||||||
m_capturing = false;
|
m_capturing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetCapture()
|
static std::string GetCapture()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_mutex);
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
return m_captured;
|
return m_captured;
|
||||||
|
|||||||
@@ -34,6 +34,8 @@
|
|||||||
#include "Utils/errors.h"
|
#include "Utils/errors.h"
|
||||||
#include "Utils/SgUtils.h"
|
#include "Utils/SgUtils.h"
|
||||||
#include "ProjectManipulation/ParseFiles.h"
|
#include "ProjectManipulation/ParseFiles.h"
|
||||||
|
#include "ProjectManipulation/PerfAnalyzer.h"
|
||||||
|
#include "ProjectManipulation/ConvertFiles.h"
|
||||||
|
|
||||||
#include "LoopAnalyzer/loop_analyzer.h"
|
#include "LoopAnalyzer/loop_analyzer.h"
|
||||||
#include "LoopAnalyzer/loop_analyzer_nodist.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 main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int leakMemDump = 0;
|
int leakMemDump = 0;
|
||||||
@@ -2730,17 +2730,12 @@ int main(int argc, char **argv)
|
|||||||
parallizeFreeLoops = 1;
|
parallizeFreeLoops = 1;
|
||||||
else if (string(curr_arg) == "-parse")
|
else if (string(curr_arg) == "-parse")
|
||||||
parseFiles(argc - (i + 1), argv + (i + 1));
|
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")
|
else if (string(curr_arg) == "-mpi")
|
||||||
mpiProgram = 1;
|
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")
|
else if (string(curr_arg) == "-client")
|
||||||
{
|
{
|
||||||
runAsClient = true;
|
runAsClient = true;
|
||||||
|
|||||||
@@ -151,6 +151,8 @@ void printHelp(const char **passNames, const int lastPass)
|
|||||||
printf(" -allVars get all parallel versions\n");
|
printf(" -allVars get all parallel versions\n");
|
||||||
printf(" -var N get specific parallel version, N=1,2,..\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(" -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 <funcName> run hierarchical inlining for all functions called from 'funcName'\n");
|
printf(" -inlineH <funcName> run hierarchical inlining for all functions called from 'funcName'\n");
|
||||||
printf(" -inlineI <funcName> <lineNum> <fileName> run incremental inlining for function 'funcName' on 'lineNum' of 'fileName'\n");
|
printf(" -inlineI <funcName> <lineNum> <fileName> run incremental inlining for function 'funcName' on 'lineNum' of 'fileName'\n");
|
||||||
printf(" -passInfo print passes information\n");
|
printf(" -passInfo print passes information\n");
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define VERSION_SPF "2276"
|
#define VERSION_SPF "2277"
|
||||||
|
|||||||
Reference in New Issue
Block a user