PhoenixHPCProxy  0.8.0
Lightweight HPC proxy
Loading...
Searching...
No Matches
main.cpp File Reference
#include "convertToString.h"
#include "OptionParser.h"
#include "FrontEnd/HeaderParser.h"
#include "BackEnd/backend.h"
#include "BackEnd/backend_proxy_loader.h"
+ Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

OptionParser createOptionParser ()
 Create the OptionParser of this program.
 
bool createSourceFromConfig (const PString &inputFile, const PString &libraryName, const PVecArchLib &vecArchLib, const PString &libDir, const PString &outputDir)
 Create the source from configuration file.
 
int main (int argc, char **argv)
 
void parseVecArchLib (PVecArchLib &vecArchLib, const OptionMode &defaultMode)
 Parse the vector of library architecture.
 
int processFiles (const PVecPath &listInputFile, const PString &libName, const PVecArchLib &vecArchLib, const PPath &libDir, const PPath &outputDir)
 Process all the input files.
 

Function Documentation

◆ createOptionParser()

OptionParser createOptionParser ( )

Create the OptionParser of this program.

Returns
OptionParser of this program

Definition at line 18 of file main.cpp.

18 {
19 OptionParser parser(true, __PROGRAM_VERSION__);
20 parser.setExampleLongOption("phoenix_hpc_proxy --input=file.ph5 --output=output/dir/");
21 parser.setExampleShortOption("phoenix_hpc_proxy -i file1.ph5 file1.ph5 fileN.ph5 -o output/dir/");
22
23 parser.addOption("header", "i", OptionType::FILENAME, true, "list of input headers to be used to describe the main library");
24 std::string libName("lib_shadok");
25 parser.addOption("library", "l", libName, "name of the library to be created");
26
27 parser.addOption("libdir", "d", OptionType::DIRECTORY, false, "directory where the sub libraries are installed");
28
29 parser.addOption("anyarch", "", OptionType::FILENAME, false, "file name of the library to be used for any architectures (kind of security if the other architectures are not found)");
30 parser.addOption("sse", "", OptionType::FILENAME, false, "file name of the library to be used for sse architecture");
31 parser.addOption("sse2", "", OptionType::FILENAME, false, "file name of the library to be used for sse2 architecture");
32 parser.addOption("ssse3", "", OptionType::FILENAME, false, "file name of the library to be used for ssse3 architecture");
33 parser.addOption("sse4.1", "", OptionType::FILENAME, false, "file name of the library to be used for sse4.1 architecture");
34 parser.addOption("sse4.2", "", OptionType::FILENAME, false, "file name of the library to be used for sse4.2 architecture");
35 parser.addOption("avx", "", OptionType::FILENAME, false, "file name of the library to be used for avx architecture");
36 parser.addOption("avx2", "", OptionType::FILENAME, false, "file name of the library to be used for avx2 architecture");
37 parser.addOption("avx512f", "", OptionType::FILENAME, false, "file name of the library to be used for avx512f architecture");
38 parser.addOption("avx512bw", "", OptionType::FILENAME, false, "file name of the library to be used for avx512wb architecture");
39
40 std::string defaultOutputDir(".");
41 parser.addOption("output", "o", defaultOutputDir, "Output directory");
42
43 return parser;
44}

Referenced by main().

+ Here is the caller graph for this function:

◆ createSourceFromConfig()

bool createSourceFromConfig ( const PString & inputFile,
const PString & libraryName,
const PVecArchLib & vecArchLib,
const PString & libDir,
const PString & outputDir )

Create the source from configuration file.

Parameters
inputFile: name of the input file to be used
libraryName: name of the library to be created
vecArchLib: vector of library architecture to be used
libDir: directory where the sub libraries are installed
outputDir: output directory to be used
Returns
true on success, false otherwise

Definition at line 83 of file main.cpp.

85{
86 HeaderParser parser;
87 if(!parser.load(inputFile)){
88 std::cerr << "createSourceFromConfig : cannot parse the input file '"<<inputFile<<"'" << std::endl;
89 return false;
90 }
91 std::string libName(getLibraryFile(vecArchLib));
92 PVecSource vecSource = parser.getVecSource();
93 if(vecSource.size() == 0lu){
94 std::cerr << "createSourceFromConfig : no source to be created" << std::endl;
95 return false;
96 }
97 bool b(cpp_backend(vecSource, libName, outputDir));
98 if(!b){
99 std::cerr << "createSourceFromConfig : cannot save source/header from input file '"<<inputFile<<"'" << std::endl;
100 return b;
101 }
102 b &= cpp_backend_proxy(vecSource, libraryName, vecArchLib, libDir, outputDir);
103 if(!b){
104 std::cerr << "createSourceFromConfig : cannot save source/header ProxyLoader class" << std::endl;
105 return b;
106 }
107 return b;
108}
bool cpp_backend(PSource &source, const PString &libName, const PPath &outputDir)
Save a vector of PSource in the output directory.
Definition backend.cpp:190
bool cpp_backend_proxy(const PVecSource &vecSource, const PString &libraryName, const PVecArchLib &vecArchLib, const PPath &libDir, const PPath &outputDir)
Save ProxyLoader with the corresponding a vector of PSource in the output directory.
Parse the configuration a create the vector of sources.
const PVecSource & getVecSource() const
Get the parsed vector of PSource.
PPath getLibraryFile(const PVecArchLib &vecArch)
Get the first non empty library file name.
std::vector< PSource > PVecSource

References cpp_backend(), cpp_backend_proxy(), getLibraryFile(), and HeaderParser::getVecSource().

Referenced by processFiles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ main()

int main ( int argc,
char ** argv )

Definition at line 128 of file main.cpp.

128 {
129 OptionParser parser = createOptionParser();
130 parser.parseArgument(argc, argv);
131
132 const OptionMode & defaultMode = parser.getDefaultMode();
133 PVecPath listInputFile;
134 defaultMode.getValue(listInputFile, "header");
135
136 PPath outputDir("."), libDir("");
137 PString libName("");
138 defaultMode.getValue(outputDir, "output");
139 defaultMode.getValue(libName, "library");
140 defaultMode.getValue(libDir, "libdir");
141
142 PVecArchLib vecArchLib;
143 parseVecArchLib(vecArchLib, defaultMode);
144
145 return processFiles(listInputFile, libName, vecArchLib, libDir, outputDir);
146}
void parseVecArchLib(PVecArchLib &vecArchLib, const OptionMode &defaultMode)
Parse the vector of library architecture.
Definition main.cpp:50
int processFiles(const PVecPath &listInputFile, const PString &libName, const PVecArchLib &vecArchLib, const PPath &libDir, const PPath &outputDir)
Process all the input files.
Definition main.cpp:118
OptionParser createOptionParser()
Create the OptionParser of this program.
Definition main.cpp:18
std::vector< PArchLib > PVecArchLib

References createOptionParser(), parseVecArchLib(), and processFiles().

+ Here is the call graph for this function:

◆ parseVecArchLib()

void parseVecArchLib ( PVecArchLib & vecArchLib,
const OptionMode & defaultMode )

Parse the vector of library architecture.

Parameters
[out]vecArchLib: vector of libraries architecture
defaultMode: arguments passed to the program

Definition at line 50 of file main.cpp.

50 {
51 std::string libAnyArch(""), libSse(""), libSse2(""), libSsse3(""), libSse41(""), libSse42(""), libAvx(""), libAvx2(""), libAvx512f(""), libAvx512wb("");
52 defaultMode.getValue(libAnyArch, "anyarch");
53 defaultMode.getValue(libSse, "sse");
54 defaultMode.getValue(libSse2, "sse2");
55 defaultMode.getValue(libSsse3, "ssse3");
56 defaultMode.getValue(libSse41, "sse4.1");
57 defaultMode.getValue(libSse42, "sse4.2");
58 defaultMode.getValue(libAvx, "avx");
59 defaultMode.getValue(libAvx2, "avx2");
60 defaultMode.getValue(libAvx512f, "avx512f");
61 defaultMode.getValue(libAvx512wb, "avx512wb");
62
63 addArch(vecArchLib, "anyarch", libAnyArch);
64 addArch(vecArchLib, "sse", libSse);
65 addArch(vecArchLib, "sse2", libSse2);
66 addArch(vecArchLib, "ssse3", libSsse3);
67 addArch(vecArchLib, "sse4.1", libSse41);
68 addArch(vecArchLib, "sse4.2", libSse42);
69 addArch(vecArchLib, "avx", libAvx);
70 addArch(vecArchLib, "avx2", libAvx2);
71 addArch(vecArchLib, "avx512f", libAvx512f);
72 addArch(vecArchLib, "avx512wb", libAvx512wb);
73}
void addArch(PVecArchLib &vecArch, const PString &arch, const PString &libName)
Add a PArchLib in the vector of Architecture if the libName is not empty.

References addArch().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processFiles()

int processFiles ( const PVecPath & listInputFile,
const PString & libName,
const PVecArchLib & vecArchLib,
const PPath & libDir,
const PPath & outputDir )

Process all the input files.

Parameters
listInputFile: list of the input files
libName: name of the library to be created
vecArchLib: vector of library architecture to be used
libDir: directory where the sub libraries are installed
outputDir: output directory to be used
Returns
0 on success, -1 otherwise

Definition at line 118 of file main.cpp.

120{
121 bool b(true);
122 for(PVecPath::const_iterator it(listInputFile.begin()); it != listInputFile.end(); ++it){
123 b &= createSourceFromConfig(*it, libName, vecArchLib, libDir, outputDir);
124 }
125 return b - 1;
126}
bool createSourceFromConfig(const PString &inputFile, const PString &libraryName, const PVecArchLib &vecArchLib, const PString &libDir, const PString &outputDir)
Create the source from configuration file.
Definition main.cpp:83

References createSourceFromConfig().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: