7#include "convertToString.h"
9#include "OptionParser.h"
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/");
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");
27 parser.addOption(
"libdir",
"d", OptionType::DIRECTORY,
false,
"directory where the sub libraries are installed");
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");
40 std::string defaultOutputDir(
".");
41 parser.addOption(
"output",
"o", defaultOutputDir,
"Output directory");
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");
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);
84 const PString & libDir,
const PString & outputDir)
87 if(!parser.load(inputFile)){
88 std::cerr <<
"createSourceFromConfig : cannot parse the input file '"<<inputFile<<
"'" << std::endl;
93 if(vecSource.size() == 0lu){
94 std::cerr <<
"createSourceFromConfig : no source to be created" << std::endl;
99 std::cerr <<
"createSourceFromConfig : cannot save source/header from input file '"<<inputFile<<
"'" << std::endl;
104 std::cerr <<
"createSourceFromConfig : cannot save source/header ProxyLoader class" << std::endl;
119 const PPath & libDir,
const PPath & outputDir)
122 for(PVecPath::const_iterator it(listInputFile.begin()); it != listInputFile.end(); ++it){
128int main(
int argc,
char** argv){
130 parser.parseArgument(argc, argv);
132 const OptionMode & defaultMode = parser.getDefaultMode();
133 PVecPath listInputFile;
134 defaultMode.getValue(listInputFile,
"header");
136 PPath outputDir(
"."), libDir(
"");
138 defaultMode.getValue(outputDir,
"output");
139 defaultMode.getValue(libName,
"library");
140 defaultMode.getValue(libDir,
"libdir");
145 return processFiles(listInputFile, libName, vecArchLib, libDir, outputDir);
bool cpp_backend(PSource &source, const PString &libName, const PPath &outputDir)
Save a vector of PSource in the output directory.
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.
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.
bool createSourceFromConfig(const PString &inputFile, const PString &libraryName, const PVecArchLib &vecArchLib, const PString &libDir, const PString &outputDir)
Create the source from configuration file.
OptionParser createOptionParser()
Create the OptionParser of this program.
PPath getLibraryFile(const PVecArchLib &vecArch)
Get the first non empty library file name.
void addArch(PVecArchLib &vecArch, const PString &arch, const PString &libName)
Add a PArchLib in the vector of Architecture if the libName is not empty.
std::vector< PSource > PVecSource
std::vector< PArchLib > PVecArchLib