github.com/eth-easl/loader@v0.0.0-20230908084258-8a37e1d94279/tools/trace_synthesizer/__main__.py (about) 1 """Console script.""" 2 # MIT License 3 # 4 # Copyright (c) 2023 EASL and the vHive community 5 # 6 # Permission is hereby granted, free of charge, to any person obtaining a copy 7 # of this software and associated documentation files (the "Software"), to deal 8 # in the Software without restriction, including without limitation the rights 9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 # copies of the Software, and to permit persons to whom the Software is 11 # furnished to do so, subject to the following conditions: 12 # 13 # The above copyright notice and this permission notice shall be included in all 14 # copies or substantial portions of the Software. 15 # 16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 # SOFTWARE. 23 24 import argparse 25 import os 26 import sys 27 28 from synthesizer import generate 29 30 31 def run(args): 32 if not os.path.exists(args.output): 33 try: 34 os.makedirs(args.output) 35 except OSError as e: 36 raise RuntimeError(f"Failed to create the output folder: {e}") 37 38 if args.cmd == 'generate': 39 inv_df, mem_df, run_df = generate(args) 40 41 return 42 43 44 def main(): 45 parser = argparse.ArgumentParser() 46 subparser = parser.add_subparsers(dest="cmd") 47 48 gen_parser = subparser.add_parser('generate') 49 50 gen_parser.add_argument( 51 '-f', 52 '--functions', 53 required=False, 54 type=int, 55 default=1, 56 metavar='integer', 57 help='Number of functions in the trace' 58 ) 59 60 gen_parser.add_argument( 61 '-b', 62 '--beginning', 63 required=True, 64 type=int, 65 metavar='integer', 66 help='Starting RPS value' 67 ) 68 69 gen_parser.add_argument( 70 '-t', 71 '--target', 72 required=True, 73 type=int, 74 metavar='integer', 75 help='Maximum' 76 ) 77 78 gen_parser.add_argument( 79 '-s', 80 '--step', 81 required=True, 82 type=int, 83 metavar='integer', 84 help='Step size' 85 ) 86 87 gen_parser.add_argument( 88 '-dur', 89 '--duration', 90 required=True, 91 type=int, 92 metavar='integer', 93 help='Duration of each RPS slot in minutes' 94 ) 95 96 gen_parser.add_argument( 97 '-e', 98 '--execution', 99 required=False, 100 type=int, 101 default=1000, 102 metavar='integer', 103 help='Execution time of the functions in ms' 104 ) 105 106 gen_parser.add_argument( 107 '-mem', 108 '--memory', 109 required=False, 110 type=int, 111 default=120, 112 metavar='integer', 113 help='Memory usage of the functions in MB' 114 ) 115 116 gen_parser.add_argument( 117 '-o', 118 '--output', 119 required=True, 120 metavar='path', 121 help='Output path for the resulting trace' 122 ) 123 124 gen_parser.add_argument( 125 '-m', 126 '--mode', 127 required=True, 128 metavar='integer', 129 help='Normal [0]; RPS sweep [1]; Burst [2]' 130 ) 131 132 args = parser.parse_args() 133 134 return run(args) 135 136 137 if __name__ == "__main__": 138 sys.exit(main()) # pragma: no cover