Commit 504af2c4 authored by Pierre Aubert's avatar Pierre Aubert
Browse files

Add options to set libraries for specific architectures

parent 141ed1e4
......@@ -14,3 +14,26 @@ bool repr_isFunction(const PFunction & fct){
return fct.getOtherCode() == "";
}
///Set a PArchLib
/** @param arch : name of the architecture
* @param libName : name of the library for the corresponding architecture
* @return corresponding PArchLib
*/
PArchLib createArchLib(const std::string & arch, const std::string & libName){
PArchLib archLib;
archLib.setArchitecture(arch);
archLib.setName(libName);
return archLib;
}
///Add a PArchLib in the vector of Architecture if the libName is not empty
/** @param[out] vecArch : vector of architecture to be updated
* @param arch : name of the architecture
* @param libName : name of the library
*/
void addArch(PVecArchLib & vecArch, const std::string & arch, const std::string & libName){
if(libName != ""){
vecArch.push_back(createArchLib("anyarch", libName));
}
}
......@@ -18,4 +18,7 @@ typedef std::vector<PArchLib> PVecArchLib;
bool repr_isFunction(const PFunction & fct);
PArchLib createArchLib(const std::string & arch, const std::string & libName);
void addArch(PVecArchLib & vecArch, const std::string & arch, const std::string & libName);
#endif
......@@ -23,23 +23,65 @@ OptionParser createOptionParser(){
parser.setExampleLongOption("phoenix_hpc_proxy --input=file.ph5 --output=output/dir/");
parser.setExampleShortOption("phoenix_hpc_proxy -i file1.ph5 file1.ph5 fileN.ph5 -o output/dir/");
parser.addOption("input", "i", OptionType::FILENAME, true, "list of input files to be treated");
parser.addOption("header", "i", OptionType::FILENAME, true, "list of input headers to be used to describe the main library");
std::string libName("lib_shadok");
parser.addOption("library", "l", libName, "name of the library to be created");
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)");
parser.addOption("sse", "", OptionType::FILENAME, false, "file name of the library to be used for sse architecture");
parser.addOption("sse2", "", OptionType::FILENAME, false, "file name of the library to be used for sse2 architecture");
parser.addOption("ssse3", "", OptionType::FILENAME, false, "file name of the library to be used for ssse3 architecture");
parser.addOption("sse4.1", "", OptionType::FILENAME, false, "file name of the library to be used for sse4.1 architecture");
parser.addOption("sse4.2", "", OptionType::FILENAME, false, "file name of the library to be used for sse4.2 architecture");
parser.addOption("avx", "", OptionType::FILENAME, false, "file name of the library to be used for avx architecture");
parser.addOption("avx2", "", OptionType::FILENAME, false, "file name of the library to be used for avx2 architecture");
parser.addOption("avx512f", "", OptionType::FILENAME, false, "file name of the library to be used for avx512f architecture");
parser.addOption("avx512wb", "", OptionType::FILENAME, false, "file name of the library to be used for avx512wb architecture");
std::string defaultOutputDir(".");
parser.addOption("output", "o", defaultOutputDir, "Output directory");
return parser;
}
///Parse the vector of library architecture
/** @param[out] vecArchLib : vector of libraries architecture
* @param defaultMode : arguments passed to the program
*/
void parseVecArchLib(PVecArchLib & vecArchLib, const OptionMode & defaultMode){
std::string libAnyArch(""), libSse(""), libSse2(""), libSsse3(""), libSse41(""), libSse42(""), libAvx(""), libAvx2(""), libAvx512f(""), libAvx512wb("");
defaultMode.getValue(libAnyArch, "anyarch");
defaultMode.getValue(libSse, "sse");
defaultMode.getValue(libSse2, "sse2");
defaultMode.getValue(libSsse3, "ssse3");
defaultMode.getValue(libSse41, "sse4.1");
defaultMode.getValue(libSse42, "sse4.2");
defaultMode.getValue(libAvx, "avx");
defaultMode.getValue(libAvx2, "avx2");
defaultMode.getValue(libAvx512f, "avx512f");
defaultMode.getValue(libAvx512wb, "avx512wb");
addArch(vecArchLib, "anyarch", libAnyArch);
addArch(vecArchLib, "sse", libSse);
addArch(vecArchLib, "sse2", libSse2);
addArch(vecArchLib, "ssse3", libSsse3);
addArch(vecArchLib, "sse4.1", libSse41);
addArch(vecArchLib, "sse4.2", libSse42);
addArch(vecArchLib, "avx", libAvx);
addArch(vecArchLib, "avx2", libAvx2);
addArch(vecArchLib, "avx512f", libAvx512f);
addArch(vecArchLib, "avx512wb", libAvx512wb);
}
///Create the source from configuration file
/** @param inputFile : name of the input file to be used
* @param libraryName : name of the library to be created
* @param vecArchLib : vector of library architecture to be used
* @param outputDir : output directory to be used
* @return true on success, false otherwise
*/
bool createSourceFromConfig(const std::string & inputFile, const std::string & libraryName, const std::string & outputDir){
bool createSourceFromConfig(const std::string & inputFile, const std::string & libraryName, const PVecArchLib & vecArchLib, const std::string & outputDir){
HeaderParser parser;
if(!parser.load(inputFile)){
std::cerr << "createSourceFromConfig : cannot parse the input file '"<<inputFile<<"'" << std::endl;
......@@ -47,7 +89,6 @@ bool createSourceFromConfig(const std::string & inputFile, const std::string & l
}
PVecSource vecSource = parser.getVecSource();
bool b(cpp_backend(vecSource, outputDir));
PVecArchLib vecArchLib;
if(!b){
std::cerr << "createSourceFromConfig : cannot save source/header from input file '"<<inputFile<<"'" << std::endl;
return b;
......@@ -63,13 +104,14 @@ bool createSourceFromConfig(const std::string & inputFile, const std::string & l
///Process all the input files
/** @param listInputFile : list of the input files
* @param libraryName : name of the library to be created
* @param vecArchLib : vector of library architecture to be used
* @param outputDir : output directory to be used
* @return 0 on success, -1 otherwise
*/
int processFiles(const std::list<std::string> & listInputFile, const std::string & libName, const std::string & outputDir){
int processFiles(const std::list<std::string> & listInputFile, const std::string & libName, const PVecArchLib & vecArchLib, const std::string & outputDir){
bool b(true);
for(std::list<std::string>::const_iterator it(listInputFile.begin()); it != listInputFile.end(); ++it){
b &= createSourceFromConfig(*it, libName, outputDir);
b &= createSourceFromConfig(*it, libName, vecArchLib, outputDir);
}
return b - 1;
}
......@@ -86,7 +128,10 @@ int main(int argc, char** argv){
defaultMode.getValue(outputDir, "output");
defaultMode.getValue(libName, "library");
return processFiles(listInputFile, libName, outputDir);
PVecArchLib vecArchLib;
parseVecArchLib(vecArchLib, defaultMode);
return processFiles(listInputFile, libName, vecArchLib, outputDir);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment