| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*************************************** | ||
| 2 | Auteur : Pierre Aubert | ||
| 3 | Mail : pierre.aubert@lapp.in2p3.fr | ||
| 4 | Licence : CeCILL-C | ||
| 5 | ****************************************/ | ||
| 6 | |||
| 7 | #include "convertToString.h" | ||
| 8 | |||
| 9 | #include "OptionParser.h" | ||
| 10 | |||
| 11 | #include "FrontEnd/HeaderParser.h" | ||
| 12 | #include "BackEnd/backend.h" | ||
| 13 | #include "BackEnd/backend_proxy_loader.h" | ||
| 14 | |||
| 15 | ///Create the OptionParser of this program | ||
| 16 | /** @return OptionParser of this program | ||
| 17 | */ | ||
| 18 | 3 | OptionParser createOptionParser(){ | |
| 19 |
2/2✓ Branch 0 (2→3) taken 3 times.
✓ Branch 2 (3→4) taken 3 times.
|
3 | OptionParser parser(true, __PROGRAM_VERSION__); |
| 20 |
2/2✓ Branch 0 (5→6) taken 3 times.
✓ Branch 2 (6→7) taken 3 times.
|
3 | parser.setExampleLongOption("phoenix_hpc_proxy --input=file.ph5 --output=output/dir/"); |
| 21 |
2/2✓ Branch 0 (8→9) taken 3 times.
✓ Branch 2 (9→10) taken 3 times.
|
3 | parser.setExampleShortOption("phoenix_hpc_proxy -i file1.ph5 file1.ph5 fileN.ph5 -o output/dir/"); |
| 22 | |||
| 23 |
4/4✓ Branch 0 (11→12) taken 3 times.
✓ Branch 2 (12→13) taken 3 times.
✓ Branch 4 (13→14) taken 3 times.
✓ Branch 6 (14→15) taken 3 times.
|
3 | parser.addOption("header", "i", OptionType::FILENAME, true, "list of input headers to be used to describe the main library"); |
| 24 |
1/1✓ Branch 0 (20→21) taken 3 times.
|
3 | std::string libName("lib_shadok"); |
| 25 |
5/5✓ Branch 0 (22→23) taken 3 times.
✓ Branch 2 (23→24) taken 3 times.
✓ Branch 4 (24→25) taken 3 times.
✓ Branch 6 (25→26) taken 3 times.
✓ Branch 8 (26→27) taken 3 times.
|
3 | parser.addOption("library", "l", libName, "name of the library to be created"); |
| 26 | |||
| 27 |
4/4✓ Branch 0 (31→32) taken 3 times.
✓ Branch 2 (32→33) taken 3 times.
✓ Branch 4 (33→34) taken 3 times.
✓ Branch 6 (34→35) taken 3 times.
|
3 | parser.addOption("libdir", "d", OptionType::DIRECTORY, false, "directory where the sub libraries are installed"); |
| 28 | |||
| 29 |
4/4✓ Branch 0 (38→39) taken 3 times.
✓ Branch 2 (39→40) taken 3 times.
✓ Branch 4 (40→41) taken 3 times.
✓ Branch 6 (41→42) taken 3 times.
|
3 | 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 |
4/4✓ Branch 0 (45→46) taken 3 times.
✓ Branch 2 (46→47) taken 3 times.
✓ Branch 4 (47→48) taken 3 times.
✓ Branch 6 (48→49) taken 3 times.
|
3 | parser.addOption("sse", "", OptionType::FILENAME, false, "file name of the library to be used for sse architecture"); |
| 31 |
4/4✓ Branch 0 (52→53) taken 3 times.
✓ Branch 2 (53→54) taken 3 times.
✓ Branch 4 (54→55) taken 3 times.
✓ Branch 6 (55→56) taken 3 times.
|
3 | parser.addOption("sse2", "", OptionType::FILENAME, false, "file name of the library to be used for sse2 architecture"); |
| 32 |
4/4✓ Branch 0 (59→60) taken 3 times.
✓ Branch 2 (60→61) taken 3 times.
✓ Branch 4 (61→62) taken 3 times.
✓ Branch 6 (62→63) taken 3 times.
|
3 | parser.addOption("ssse3", "", OptionType::FILENAME, false, "file name of the library to be used for ssse3 architecture"); |
| 33 |
4/4✓ Branch 0 (66→67) taken 3 times.
✓ Branch 2 (67→68) taken 3 times.
✓ Branch 4 (68→69) taken 3 times.
✓ Branch 6 (69→70) taken 3 times.
|
3 | parser.addOption("sse4.1", "", OptionType::FILENAME, false, "file name of the library to be used for sse4.1 architecture"); |
| 34 |
4/4✓ Branch 0 (73→74) taken 3 times.
✓ Branch 2 (74→75) taken 3 times.
✓ Branch 4 (75→76) taken 3 times.
✓ Branch 6 (76→77) taken 3 times.
|
3 | parser.addOption("sse4.2", "", OptionType::FILENAME, false, "file name of the library to be used for sse4.2 architecture"); |
| 35 |
4/4✓ Branch 0 (80→81) taken 3 times.
✓ Branch 2 (81→82) taken 3 times.
✓ Branch 4 (82→83) taken 3 times.
✓ Branch 6 (83→84) taken 3 times.
|
3 | parser.addOption("avx", "", OptionType::FILENAME, false, "file name of the library to be used for avx architecture"); |
| 36 |
4/4✓ Branch 0 (87→88) taken 3 times.
✓ Branch 2 (88→89) taken 3 times.
✓ Branch 4 (89→90) taken 3 times.
✓ Branch 6 (90→91) taken 3 times.
|
3 | parser.addOption("avx2", "", OptionType::FILENAME, false, "file name of the library to be used for avx2 architecture"); |
| 37 |
4/4✓ Branch 0 (94→95) taken 3 times.
✓ Branch 2 (95→96) taken 3 times.
✓ Branch 4 (96→97) taken 3 times.
✓ Branch 6 (97→98) taken 3 times.
|
3 | parser.addOption("avx512f", "", OptionType::FILENAME, false, "file name of the library to be used for avx512f architecture"); |
| 38 |
4/4✓ Branch 0 (101→102) taken 3 times.
✓ Branch 2 (102→103) taken 3 times.
✓ Branch 4 (103→104) taken 3 times.
✓ Branch 6 (104→105) taken 3 times.
|
3 | parser.addOption("avx512bw", "", OptionType::FILENAME, false, "file name of the library to be used for avx512wb architecture"); |
| 39 | |||
| 40 |
1/1✓ Branch 0 (110→111) taken 3 times.
|
3 | std::string defaultOutputDir("."); |
| 41 |
5/5✓ Branch 0 (112→113) taken 3 times.
✓ Branch 2 (113→114) taken 3 times.
✓ Branch 4 (114→115) taken 3 times.
✓ Branch 6 (115→116) taken 3 times.
✓ Branch 8 (116→117) taken 3 times.
|
3 | parser.addOption("output", "o", defaultOutputDir, "Output directory"); |
| 42 | |||
| 43 | 3 | return parser; | |
| 44 | 3 | } | |
| 45 | |||
| 46 | ///Parse the vector of library architecture | ||
| 47 | /** @param[out] vecArchLib : vector of libraries architecture | ||
| 48 | * @param defaultMode : arguments passed to the program | ||
| 49 | */ | ||
| 50 | 3 | void parseVecArchLib(PVecArchLib & vecArchLib, const OptionMode & defaultMode){ | |
| 51 |
10/10✓ Branch 0 (4→5) taken 3 times.
✓ Branch 2 (8→9) taken 3 times.
✓ Branch 4 (12→13) taken 3 times.
✓ Branch 6 (16→17) taken 3 times.
✓ Branch 8 (20→21) taken 3 times.
✓ Branch 10 (24→25) taken 3 times.
✓ Branch 12 (28→29) taken 3 times.
✓ Branch 14 (32→33) taken 3 times.
✓ Branch 16 (36→37) taken 3 times.
✓ Branch 18 (40→41) taken 3 times.
|
57 | std::string libAnyArch(""), libSse(""), libSse2(""), libSsse3(""), libSse41(""), libSse42(""), libAvx(""), libAvx2(""), libAvx512f(""), libAvx512wb(""); |
| 52 |
2/2✓ Branch 0 (42→43) taken 3 times.
✓ Branch 2 (43→44) taken 3 times.
|
3 | defaultMode.getValue(libAnyArch, "anyarch"); |
| 53 |
2/2✓ Branch 0 (45→46) taken 3 times.
✓ Branch 2 (46→47) taken 3 times.
|
3 | defaultMode.getValue(libSse, "sse"); |
| 54 |
2/2✓ Branch 0 (48→49) taken 3 times.
✓ Branch 2 (49→50) taken 3 times.
|
3 | defaultMode.getValue(libSse2, "sse2"); |
| 55 |
2/2✓ Branch 0 (51→52) taken 3 times.
✓ Branch 2 (52→53) taken 3 times.
|
3 | defaultMode.getValue(libSsse3, "ssse3"); |
| 56 |
2/2✓ Branch 0 (54→55) taken 3 times.
✓ Branch 2 (55→56) taken 3 times.
|
3 | defaultMode.getValue(libSse41, "sse4.1"); |
| 57 |
2/2✓ Branch 0 (57→58) taken 3 times.
✓ Branch 2 (58→59) taken 3 times.
|
3 | defaultMode.getValue(libSse42, "sse4.2"); |
| 58 |
2/2✓ Branch 0 (60→61) taken 3 times.
✓ Branch 2 (61→62) taken 3 times.
|
3 | defaultMode.getValue(libAvx, "avx"); |
| 59 |
2/2✓ Branch 0 (63→64) taken 3 times.
✓ Branch 2 (64→65) taken 3 times.
|
3 | defaultMode.getValue(libAvx2, "avx2"); |
| 60 |
2/2✓ Branch 0 (66→67) taken 3 times.
✓ Branch 2 (67→68) taken 3 times.
|
3 | defaultMode.getValue(libAvx512f, "avx512f"); |
| 61 |
2/2✓ Branch 0 (69→70) taken 3 times.
✓ Branch 2 (70→71) taken 3 times.
|
3 | defaultMode.getValue(libAvx512wb, "avx512wb"); |
| 62 | |||
| 63 |
3/3✓ Branch 0 (72→73) taken 3 times.
✓ Branch 2 (73→74) taken 3 times.
✓ Branch 4 (74→75) taken 3 times.
|
3 | addArch(vecArchLib, "anyarch", libAnyArch); |
| 64 |
3/3✓ Branch 0 (77→78) taken 3 times.
✓ Branch 2 (78→79) taken 3 times.
✓ Branch 4 (79→80) taken 3 times.
|
3 | addArch(vecArchLib, "sse", libSse); |
| 65 |
3/3✓ Branch 0 (82→83) taken 3 times.
✓ Branch 2 (83→84) taken 3 times.
✓ Branch 4 (84→85) taken 3 times.
|
3 | addArch(vecArchLib, "sse2", libSse2); |
| 66 |
3/3✓ Branch 0 (87→88) taken 3 times.
✓ Branch 2 (88→89) taken 3 times.
✓ Branch 4 (89→90) taken 3 times.
|
3 | addArch(vecArchLib, "ssse3", libSsse3); |
| 67 |
3/3✓ Branch 0 (92→93) taken 3 times.
✓ Branch 2 (93→94) taken 3 times.
✓ Branch 4 (94→95) taken 3 times.
|
3 | addArch(vecArchLib, "sse4.1", libSse41); |
| 68 |
3/3✓ Branch 0 (97→98) taken 3 times.
✓ Branch 2 (98→99) taken 3 times.
✓ Branch 4 (99→100) taken 3 times.
|
3 | addArch(vecArchLib, "sse4.2", libSse42); |
| 69 |
3/3✓ Branch 0 (102→103) taken 3 times.
✓ Branch 2 (103→104) taken 3 times.
✓ Branch 4 (104→105) taken 3 times.
|
3 | addArch(vecArchLib, "avx", libAvx); |
| 70 |
3/3✓ Branch 0 (107→108) taken 3 times.
✓ Branch 2 (108→109) taken 3 times.
✓ Branch 4 (109→110) taken 3 times.
|
3 | addArch(vecArchLib, "avx2", libAvx2); |
| 71 |
3/3✓ Branch 0 (112→113) taken 3 times.
✓ Branch 2 (113→114) taken 3 times.
✓ Branch 4 (114→115) taken 3 times.
|
3 | addArch(vecArchLib, "avx512f", libAvx512f); |
| 72 |
3/3✓ Branch 0 (117→118) taken 3 times.
✓ Branch 2 (118→119) taken 3 times.
✓ Branch 4 (119→120) taken 3 times.
|
3 | addArch(vecArchLib, "avx512wb", libAvx512wb); |
| 73 | 3 | } | |
| 74 | |||
| 75 | ///Create the source from configuration file | ||
| 76 | /** @param inputFile : name of the input file to be used | ||
| 77 | * @param libraryName : name of the library to be created | ||
| 78 | * @param vecArchLib : vector of library architecture to be used | ||
| 79 | * @param libDir : directory where the sub libraries are installed | ||
| 80 | * @param outputDir : output directory to be used | ||
| 81 | * @return true on success, false otherwise | ||
| 82 | */ | ||
| 83 | 3 | bool createSourceFromConfig(const PString & inputFile, const PString & libraryName, const PVecArchLib & vecArchLib, | |
| 84 | const PString & libDir, const PString & outputDir) | ||
| 85 | { | ||
| 86 |
1/1✓ Branch 0 (2→3) taken 3 times.
|
3 | HeaderParser parser; |
| 87 |
3/4✓ Branch 0 (3→4) taken 3 times.
✓ Branch 2 (4→5) taken 3 times.
✗ Branch 4 (6→7) not taken.
✓ Branch 5 (6→12) taken 3 times.
|
3 | if(!parser.load(inputFile)){ |
| 88 | ✗ | std::cerr << "createSourceFromConfig : cannot parse the input file '"<<inputFile<<"'" << std::endl; | |
| 89 | ✗ | return false; | |
| 90 | } | ||
| 91 |
1/1✓ Branch 0 (12→13) taken 3 times.
|
3 | std::string libName(getLibraryFile(vecArchLib)); |
| 92 |
2/2✓ Branch 0 (15→16) taken 3 times.
✓ Branch 2 (16→17) taken 3 times.
|
3 | PVecSource vecSource = parser.getVecSource(); |
| 93 |
1/2✗ Branch 0 (18→19) not taken.
✓ Branch 1 (18→22) taken 3 times.
|
3 | if(vecSource.size() == 0lu){ |
| 94 | ✗ | std::cerr << "createSourceFromConfig : no source to be created" << std::endl; | |
| 95 | ✗ | return false; | |
| 96 | } | ||
| 97 |
3/3✓ Branch 0 (22→23) taken 3 times.
✓ Branch 2 (23→24) taken 3 times.
✓ Branch 4 (24→25) taken 3 times.
|
3 | bool b(cpp_backend(vecSource, libName, outputDir)); |
| 98 |
1/2✗ Branch 0 (27→28) not taken.
✓ Branch 1 (27→33) taken 3 times.
|
3 | if(!b){ |
| 99 | ✗ | std::cerr << "createSourceFromConfig : cannot save source/header from input file '"<<inputFile<<"'" << std::endl; | |
| 100 | ✗ | return b; | |
| 101 | } | ||
| 102 |
3/3✓ Branch 0 (33→34) taken 3 times.
✓ Branch 2 (34→35) taken 3 times.
✓ Branch 4 (35→36) taken 3 times.
|
3 | b &= cpp_backend_proxy(vecSource, libraryName, vecArchLib, libDir, outputDir); |
| 103 |
1/2✗ Branch 0 (38→39) not taken.
✓ Branch 1 (38→42) taken 3 times.
|
3 | if(!b){ |
| 104 | ✗ | std::cerr << "createSourceFromConfig : cannot save source/header ProxyLoader class" << std::endl; | |
| 105 | ✗ | return b; | |
| 106 | } | ||
| 107 | 3 | return b; | |
| 108 | 3 | } | |
| 109 | |||
| 110 | ///Process all the input files | ||
| 111 | /** @param listInputFile : list of the input files | ||
| 112 | * @param libName : name of the library to be created | ||
| 113 | * @param vecArchLib : vector of library architecture to be used | ||
| 114 | * @param libDir : directory where the sub libraries are installed | ||
| 115 | * @param outputDir : output directory to be used | ||
| 116 | * @return 0 on success, -1 otherwise | ||
| 117 | */ | ||
| 118 | 3 | int processFiles(const PVecPath & listInputFile, const PString & libName, const PVecArchLib & vecArchLib, | |
| 119 | const PPath & libDir, const PPath & outputDir) | ||
| 120 | { | ||
| 121 | 3 | bool b(true); | |
| 122 |
2/2✓ Branch 0 (16→3) taken 3 times.
✓ Branch 1 (16→17) taken 3 times.
|
12 | for(PVecPath::const_iterator it(listInputFile.begin()); it != listInputFile.end(); ++it){ |
| 123 |
1/1✓ Branch 0 (5→6) taken 3 times.
|
6 | b &= createSourceFromConfig(*it, libName, vecArchLib, libDir, outputDir); |
| 124 | } | ||
| 125 | 3 | return b - 1; | |
| 126 | } | ||
| 127 | |||
| 128 | 3 | int main(int argc, char** argv){ | |
| 129 |
1/1✓ Branch 0 (2→3) taken 3 times.
|
3 | OptionParser parser = createOptionParser(); |
| 130 |
1/1✓ Branch 0 (3→4) taken 3 times.
|
3 | parser.parseArgument(argc, argv); |
| 131 | |||
| 132 |
1/1✓ Branch 0 (4→5) taken 3 times.
|
3 | const OptionMode & defaultMode = parser.getDefaultMode(); |
| 133 | 3 | PVecPath listInputFile; | |
| 134 |
2/2✓ Branch 0 (6→7) taken 3 times.
✓ Branch 2 (7→8) taken 3 times.
|
3 | defaultMode.getValue(listInputFile, "header"); |
| 135 | |||
| 136 |
4/4✓ Branch 0 (9→10) taken 3 times.
✓ Branch 2 (10→11) taken 3 times.
✓ Branch 4 (12→13) taken 3 times.
✓ Branch 6 (13→14) taken 3 times.
|
3 | PPath outputDir("."), libDir(""); |
| 137 |
1/1✓ Branch 0 (15→16) taken 3 times.
|
3 | PString libName(""); |
| 138 |
2/2✓ Branch 0 (16→17) taken 3 times.
✓ Branch 2 (17→18) taken 3 times.
|
3 | defaultMode.getValue(outputDir, "output"); |
| 139 |
2/2✓ Branch 0 (19→20) taken 3 times.
✓ Branch 2 (20→21) taken 3 times.
|
3 | defaultMode.getValue(libName, "library"); |
| 140 |
2/2✓ Branch 0 (22→23) taken 3 times.
✓ Branch 2 (23→24) taken 3 times.
|
3 | defaultMode.getValue(libDir, "libdir"); |
| 141 | |||
| 142 | 3 | PVecArchLib vecArchLib; | |
| 143 |
1/1✓ Branch 0 (26→27) taken 3 times.
|
3 | parseVecArchLib(vecArchLib, defaultMode); |
| 144 | |||
| 145 |
1/1✓ Branch 0 (27→28) taken 3 times.
|
3 | return processFiles(listInputFile, libName, vecArchLib, libDir, outputDir); |
| 146 | 3 | } | |
| 147 | |||
| 148 | |||
| 149 |