-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathspbench
executable file
·1043 lines (903 loc) · 36.1 KB
/
spbench
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
##
##############################################################################
# File : spbench.py
#
# Title : SPBench command-line interface
#
# Author: Adriano Marques Garcia <[email protected]>
#
# Date : July 06, 2021
#
# Copyright (C) 2021 Adriano M. Garcia
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
##############################################################################
##
import argparse
import sys
import os
from argparse import RawTextHelpFormatter
from sys import version_info
python_3 = version_info[0]
from src.new_bench_option import new_bench_func
from src.new_op_option import new_op_func
from src.new_app_option import new_app_func
from src.delete_option import delete_reg_func
from src.exec_option import execute_func
from src.compile_option import compile_func
from src.clean_option import clean_func
from src.update_option import update_func
from src.list_benchmarks_option import list_benchmarks_func
from src.install_option import install_func
from src.configure_option import configure_func
from src.global_config_option import global_config_func
from src.edit_option import edit_source_func
from src.edit_op_option import edit_op_source_func
from src.list_inputs_option import list_inputs_func
from src.list_op_option import list_op_func
from src.new_input_option import new_input_func
from src.delete_input_option import del_input_func
from src.download_inputs_option import download_inputs_func
from src.rename_bench_option import rename_bench_func
from src.reset_option import reset_operators_func
from src.delete_app_option import delete_app_func
from src.list_apps_option import list_apps_func
from src.errors import *
from src.utils.utils import *
from argparse import ArgumentParser,SUPPRESS
spbench_version="v0.4.3-alpha"
spbench_path = os.path.dirname(os.path.realpath(__file__))#os.path.dirname(sys.argv[0])
def new(args):
new_bench_func(spbench_path, args)
def new_op(args):
new_op_func(spbench_path, args)
def new_app(args):
new_app_func(spbench_path, args)
def delete_reg(args):
delete_reg_func(spbench_path, args)
def list_reg(args):
list_benchmarks_func(spbench_path, args)
def configure(args):
configure_func(spbench_path, args)
def global_config(args):
global_config_func(spbench_path, args)
def edit_source(args):
edit_source_func(spbench_path, args)
def edit_op_source(args):
edit_op_source_func(spbench_path, args)
def execute(args):
try:
execute_func(spbench_path, args)
except ArgumentTypeError as e:
print("\n ", e, "\n")
sys.exit()
def compile(args):
compile_func(spbench_path, args)
def clean(args):
clean_func(spbench_path, args)
def update(args):
update_func(spbench_path, args)
def register_inputs(args):
new_input_func(spbench_path, args)
def download_inputs(args):
download_inputs_func(spbench_path, args)
def list_reg_inputs(args):
list_inputs_func(spbench_path, args)
def list_operators(args):
list_op_func(spbench_path, args)
def list_apps(args):
list_apps_func(spbench_path)
def delete_input(args):
del_input_func(spbench_path, args)
def delete_app(args):
delete_app_func(spbench_path, args)
def install(args):
install_func(spbench_path, args)
def rename_bench(args):
rename_bench_func(spbench_path, args)
def reset_operators(args):
reset_operators_func(spbench_path, args)
def spb_version(args):
print("\n SPBench " + spbench_version + "\n")
if len(sys.argv) < 2:
print(" Error: No SPBench command given.\n Run \'./spbench --help\' for more information.")
sys.exit()
class SmartFormatter(argparse.HelpFormatter):
def _split_lines(self, text, width):
if text.startswith(''):
return text[2:].splitlines()
# this is the RawTextHelpFormatter._split_lines
return argparse.HelpFormatter._split_lines(self, text, width)
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench [command] [subcommands]""",
description="""
Run \'./spbench --help\' for more information.
Or run ./spbench [command] --help to see more details for each command.
""",
epilog="""
Available commands:\n
-------------------------------------------------------------
COMMAND | DESCRIPTION
-------------------------------------------------------------
install - Download and install the required libraries for the supported applications
new - Create a new benchmark
edit - Open a benchmark to edit the main source code
configure - Open a JSON configuration file for adding compiling dependencies
global-config - Open a JSON configuration file for adding global compiling dependencies
update - Update makefiles with the information provided in the JSON configuration file
compile - Compile a given benchmark (similar to make)
clean - Clean a benchmark (similar to make clean)
exec - Execute a given benchmark
list - List all available benchmarks
delete - Delete a given benchmark
rename - Rename a given benchmark
list-op - List all available operators for a given benchmark
edit-op - Open an operator's source code of a given benchmark to edit it
reset-op - Reset to default the source code of all operators for a given benchmark
list-inputs - List all available inputs for running the benchmarks
new-input - Add a new input custom input for the benchmarks
delete-input - Delete a given input
download-inputs - Download all available inputs provided by SPBench
new-app - Add a new empty application to the SPBench suite
delete-app - Delete an application from SPBench
list-apps - List the information of all available applications
version - Print the current SPBench version
-------------------------------------------------------------
""")
#if(python_3 == 3):
# subparsers = parser.add_subparsers(required=True)
#else:
subparsers = parser.add_subparsers(dest=argparse.SUPPRESS, metavar=argparse.SUPPRESS, help=argparse.SUPPRESS)
#subparser for 'install' option
parser_inst = subparsers.add_parser('install',
formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench install [subcommands]""",
description=""" Description: Download and install the required libraries for the supported applications.""")
#subparser for 'new' option
parser_new = subparsers.add_parser('new',
formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench new [subcommands]""",
description=""" Description: Create a new benchmark.""")
#subparser for 'new-op' option
#parser_new_op = subparsers.add_parser('new-op',
# formatter_class=argparse.RawDescriptionHelpFormatter,
# usage="""./spbench new-op [subcommands]""",
# description=""" Description: Create a new operator for a given benchmark.""")
#subparser for 'edit' option
parser_edit = subparsers.add_parser('edit',
formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench edit [subcommands]""",
description=""" Description: Open a benchmark to edit the main source code.""")
#subparser for 'edit' option
parser_edit_op = subparsers.add_parser('edit-op',
formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench edit-op [subcommands]""",
description=""" Description: Open an operator of a given benchmark to edit its source code.""")
#subparser for 'configure' option
parser_config = subparsers.add_parser('configure',
formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench configure [subcommands]""",
description=""" Description: Open a JSON configuration file for adding compiling dependencies.""")
#subparser for 'global-config' option
parser_global_config = subparsers.add_parser('global-config',
formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench global-config [subcommands]""",
description=""" Description: Open a JSON configuration file for adding global compiling dependencies.\n The information added to keys in the global configuration file will override the info present in the individual config. files when generating makefiles.\n The \'EXTRA\' keys do not override the original information, but append it instead. """)
#subpraser for 'update' option
parser_update = subparsers.add_parser('update',
formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench update [subcommands]""",
description=""" Description: Generate a new makefile based on the information provided in the JSON configuration file.""")
#subparser for 'compile' option
parser_cmp = subparsers.add_parser('compile',
formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench compile [subcommands]""",
description=""" Description: Compile a given benchmark.""")
#subparser for 'clean' option
parser_clean = subparsers.add_parser('clean',
formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench clean [subcommands]""",
description=""" Description: Clean a benchmark (similar to make clean)""")
#subparser for 'exec' option
parser_exec = subparsers.add_parser('exec',
formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench exec [subcommands]""",
description=""" Description: Execute a given benchmark.""")
#subparser for 'list' option
parser_list = subparsers.add_parser('list',
formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench list [subcommands]""",
description=""" Description: List all available benchmarks.""")
#subparser for delete benchmark option
parser_del = subparsers.add_parser('delete',
formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench delete [subcommands]""",
description=""" Description: Delete a given benchmark""")
#subparser for reset operators option
parser_reset_op = subparsers.add_parser('reset-op',
formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench reset-op [subcommands]""",
description=""" Description: Reset to default the source code of all operators for a given benchmark (it still keeps the old operators as backup until this command is executed again).""")
#subparser for list registered inputs
parser_list_inputs = subparsers.add_parser('list-inputs',
formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench list-inputs [subcommands]""",
description=""" Description: List all available inputs for running the benchmarks.""")
#subparser for list operators inputs
parser_list_op = subparsers.add_parser('list-op',
formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench list-op [subcommands]""",
description=""" Description: List all available operators for a given benchmark.""")
#subparser for register input
parser_reg_inputs = subparsers.add_parser('new-input',
formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench new-input [subcommands]""",
description=""" Description: Add a new input custom input for the benchmarks.""")
#subparser for delete input
parser_del_input = subparsers.add_parser('delete-input',
formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench delete-input [subcommands]""",
description=""" Description: Delete a given input.""")
#subparser for download inputs
parser_get_inputs = subparsers.add_parser('download-inputs',
formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench download-inputs [subcommands]""",
description=""" Description: Download all available inputs provided by SPBench.""")
#subparser for rename benchmark
parser_rename_bench = subparsers.add_parser('rename',
formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench rename [subcommands]""",
description=""" Description: Rename a given benchmark.""")
#subparser for adding a new application
parser_new_app = subparsers.add_parser('new-app',
formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench new-app [subcommands]""",
description=""" Description: Create a simple application in SPBench. This toy application can be used as template to guide the additioning of new applications to SPBench.""")
# subparser for deleting an application
parser_del_app = subparsers.add_parser('delete-app',
formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench delete-app [subcommands]""",
description=""" Description: Delete an application from SPBench.""")
# subparser for listing all applications
parser_list_apps = subparsers.add_parser('list-apps',
formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench list-apps""",
description=""" Description: List the information of all available applications.""")
#subparser for 'version' option
parser_version = subparsers.add_parser('version',
formatter_class=argparse.RawDescriptionHelpFormatter,
usage="""./spbench version""",
description=""" Print the current SPBench version.""")
parser_version.set_defaults(func=spb_version)
##
# Install applications
##
parser_inst.add_argument('-app',
action='store',
type=str,
dest='app_id',
required=False,
default='all',
choices=getAppsList(spbench_path),
help='You can choose a specific application to install or you can use \'all\' to install all applications.')
parser_inst.set_defaults(func=install)
##
# Add new benchmark
##
parser_new.add_argument('-benchmark',
action='store',
type=str,
dest='benchmark_id',
required=True,
help='Set a name for your new benchmark')# (it must be the same name of the directory you created)')
parser_new.add_argument('-app',
action='store',
type=str,
dest='app_id',
required=True,
choices=getAppsList(spbench_path),
help="You must choose one from the following applications:\n " + str(getAppsList(spbench_path)) + " (mandatory)")
parser_new.add_argument('-ppi',
action='store',
type=str,
dest='ppi_id',
required=False,
default='sequential',
help="You should insert here a name for the PPI you will use \n(e.g., fastflow, spar, tbb, ...). You can choose \'sequential\' or any name, as well. (Optional. Default: sequential)")
parser_new.add_argument('-from',
action='store',
type=str,
dest='copy_from',
required=False,
default='',
help="Use this option to create your new benchmark as a copy of an existent benchmark. Insert the name of the benchmark you want to copy from (Optional. Default: sequential)")
parser_new.add_argument('-nsources',
action='store_true',
default=False,
dest='nsources',
required=False,
help='Use this option to create a new benchmark with support for multiple sources (optional)')
parser_new.set_defaults(func=new)
##
# Edit benchmark
##
parser_edit.add_argument('-benchmark',
action='store',
type=str,
dest='benchmark_id',
required=True,
help='Enter the name of an application benchmark to edit (mandatory)')
parser_edit.add_argument('-editor',
action='store',
type=str,
dest='user_editor',
required=False,
default='',
help='Enter the name of a text editor available in your machine, e.g. "vim", "nano", etc. (Default: nano, vim, or vi)')
parser_edit.set_defaults(func=edit_source)
##
# Edit benchmark's operator
##
parser_edit_op.add_argument('-benchmark',
action='store',
type=str,
dest='benchmark_id',
required=True,
help='Enter the name of an application benchmark to edit (mandatory)')
parser_edit_op.add_argument('-operator',
action='store',
type=str,
dest='operator_id',
required=True,
help='Enter the name of the benchmark\'s operator to edit (mandatory)')
parser_edit_op.add_argument('-editor',
action='store',
type=str,
dest='user_editor',
required=False,
default='',
help='Enter the name of a text editor available in your machine, e.g. "vim", "nano", etc. (default: nano, vim, or vi)')
parser_edit_op.set_defaults(func=edit_op_source)
##
# Configure benchmark
##
parser_config.add_argument('-benchmark',
action='store',
type=str,
dest='benchmark_id',
required=True,
help='Enter the name of an application benchmark to configure (mandatory)')
parser_config.add_argument('-editor',
action='store',
type=str,
dest='user_editor',
required=False,
default='',
help='Enter the name of a text editor available in your machine, e.g. "vim", "nano", etc. (default: nano, vim, or vi)')
parser_config.set_defaults(func=configure)
##
# Global-config
##
parser_global_config.add_argument('-editor',
action='store',
type=str,
dest='user_editor',
required=False,
default='',
help='Enter the name of a text editor available in your machine, e.g. "vim", "nano", etc. (default: nano, vim, or vi)')
parser_global_config.set_defaults(func=global_config)
##
# Update benchmark
##
parser_update.add_argument('-benchmark',
action='store',
type=str,
dest='benchmark_id',
required=False,
default='all',
help='Insert the name of a benchmark to update it (optional). Default: All')
parser_update.add_argument('-app',
action='store',
type=str,
dest='app_id',
required=False,
choices=getAppsListAll(spbench_path),
help="Update all benchmarks for a specific application: \n " + str(getAppsListAll(spbench_path)) + " (optional)")
parser_update.add_argument('-ppi',
action='store',
type=str,
dest='ppi_id',
required=False,
help="Update all benchmarks for a specific PPI (optional)\n")
parser_update.set_defaults(func=update)
##
# Compile benchmark
##
parser_cmp.add_argument('-benchmark',
action='store',
type=str,
dest='benchmark_id',
required=False,
help='Insert the name of a benchmark to compile (optional). You can use \'all\' to compile all benchmarks.')
parser_cmp.add_argument('-app',
action='store',
type=str,
dest='app_id',
required=False,
choices=getAppsList(spbench_path),
help="Compile all benchmarks based on a specific application: \n " + str(getAppsList(spbench_path)) + " (optional)")
parser_cmp.add_argument('-ppi',
action='store',
type=str,
dest='ppi_id',
required=False,
help="Compile all benchmarks implemented with a specific PPI (optional)\n")
parser_cmp.add_argument('-clean',
action='store_true',
default=False,
dest='clean',
required=False,
help='If used, it will run \'make clean\' and then \'make\' (optional)')
parser_cmp.set_defaults(func=compile)
##
# Clean benchmark
##
parser_clean.add_argument('-benchmark',
action='store',
type=str,
dest='benchmark_id',
required=False,
help='Insert the name of a benchmark to clean (make clean) (optional). You can use \'all\' to clean all benchmarks.')
parser_clean.add_argument('-app',
action='store',
type=str,
dest='app_id',
required=False,
choices=getAppsList(spbench_path),
help="Clean all benchmarks based on a specific application:\n " + str(getAppsList(spbench_path)) + " (optional)")
parser_clean.add_argument('-ppi',
action='store',
type=str,
dest='ppi_id',
required=False,
help="Clean all benchmarks implemented with a specific PPI (optional)\n")
parser_clean.add_argument('-logs',
action='store_true',
default=False,
dest='clean_logs',
required=False,
help='Clean all execution logs of SPBench (optional)')
parser_clean.add_argument('-outputs',
action='store_true',
default=False,
dest='clean_outputs',
required=False,
help='Clean all the outputs generated by the benchmarks (optional)')
parser_clean.set_defaults(func=clean)
##
# Execute benchmark
##
parser_exec.add_argument('-benchmark',
action='store',
type=str,
dest='benchmark_id',
required=False,
help='Name of the benchmark to execute. You can use \'-bench all\' to execute all benchmarks.')
parser_exec.add_argument('-app',
action='store',
type=str,
dest='app_id',
required=False,
choices=getAppsList(spbench_path),
help="Run all benchmarks based on a specific application: \n " + str(getAppsList(spbench_path)) + " (optional)")
parser_exec.add_argument('-ppi',
action='store',
type=str,
dest='ppi_id',
required=False,
help="Run all benchmarks implemented with a specific PPI (optional)\n")
parser_exec.add_argument('-input',
action='append',
nargs='+',
type=str,
dest='input_id',
required=True,
help='Input file (mandatory) - You can select more than one for multiple sources apps')
parser_exec.add_argument('-nthreads',
action='store',
type=str,
dest='nthreads',
required=False,
default='',
help='Number of threads. It can be used inside the benchmarks as a global variable. You can insert a single number or a range using the \':\' character (e.g. -nthreads 1:10). You can also define iteration step of the range (e.g. -nthreads 4:4:16 would run the benchmarks with 4, 8, 12, and 16 threads). Default value: 1. (Optional)')
parser_exec.add_argument('-debug',
action='store_true',
default=False,
dest='debug',
required=False,
help='By default, SPBench captures the benchmark output while it is running and prints all the output at once at the end of the execution. If you want it to print the output on-the-fly (e.g. to print debug info added by you), you must use the -debug argument in the execution command. Notice that, if this option is enabled, some advanced SPBench features may not work properly. It will not show the standard deviation of the metrics or store the result in the general log file, for instance. (optional)')
parser_exec.add_argument('-batch',
action='store',
type=str,
dest='batch_size',
required=False,
default='',
help='Batch size. It can be used to set a batch size. Default value: 1. (Optional)')
parser_exec.add_argument('-batch-interval',
action='store',
type=str,
dest='batch_interval',
required=False,
default='',
help='Batch interval in seconds. It can be used to set a batch size based on a time window. Default value: 0 (0 = disabled). (Optional)')
parser_exec.add_argument('-monitor',
action='store',
type=str,
dest='time_interval',
required=False,
default='',
help='Monitor latency, throughput, CPU and memory usage. You must indicate the monitoring time interval in milliseconds (e.g. 250. Optional).')
parser_exec.add_argument('-monitor-thread',
action='store',
type=str,
dest='time_interval_thr',
required=False,
default='',
help='It does the same as \'-monitor\', but here the monitoring computation runs as an individual thread. You must indicate the monitoring time interval in milliseconds (e.g. 250. Optional).')
parser_exec.add_argument('-frequency',
action='store',
type=str,
dest='items_frequency',
required=False,
default='',
help='The applications will try to read items in a constant frequency. You must indicate how many items per second the application should target, e.g. 100. The minimum frequency you can set must be higher than zero. There is no limit for maximum frequency, the maximum possible frequency will vary according to data and application characteristics and also by the memory access speed (it automatically runs the application in-memory for reaching high frequencies). (Optional).')
parser_exec.add_argument('-freq-pattern',
action='store',
type=str,
dest='frequency_pattern',
required=False,
default='',
help='(Optional) Usage example: [-freq-pattern wave,10,5,80] (pattern,period,min,max). This argument overwrites the -frequency command and sets a varying frequency for the input stream. You can select and set a frequency variation pattern. For this argument you need to supply a tuple string: <pattern,period,max,min>, where pattern can be "wave", "spike", "binary", "increasing" or "decreasing". Period is the duration in seconds of one cycle of the pattern. And min is the minimum frequency and max the maximum frequency, defined in items per second. For the spike pattern you can also set the duration of the spikes as percentage of the period (0-100) (e.g. <pattern,period,max,min,spike>). The default spike duration is 10 percent of the period.')
parser_exec.add_argument('-in-memory',
action='append_const',
const="-I",
dest='exec_arguments',
required=False,
help='Run the application in-memory (Optional)')
parser_exec.add_argument('-latency',
action='append_const',
const="-l",
dest='exec_arguments',
required=False,
help='Print average latency and throughput results (Optional)')
parser_exec.add_argument('-throughput',
action='append_const',
const="-T",
dest='exec_arguments',
required=False,
help='Print average throughput results (Optional)')
# parser_exec.add_argument('-f',
# action='store',
# type=argparse.FileType('w'),
# dest='latency_file',
# required=False,
# help='Insert a file name to store latency results (Optional)')
parser_exec.add_argument('-latency-monitor',
action='append_const',
const="-L",
dest='exec_arguments',
required=False,
help='Monitors latency per stage and per item and generates a log file (Optional)')
parser_exec.add_argument('-resource-usage',
action='append_const',
const='-r',
dest='exec_arguments',
required=False,
help='Print the global memory and CPU usage for this application (Optional). To use it is required to run the benchmark as root or adjust paranoid value.')
parser_exec.add_argument('-user-arg',
action='append',
nargs='+',
type=str,
dest='user_args',
required=False,
help='User custom argument (optional). Allow users to pass one or more arguments. Single argument: [-user-arg single_argument] or [-user-arg "single argument"]. Multiple arguments: [-user-arg two arguments] or [-user-arg two -user-args arguments]')
parser_exec.add_argument('-repeat',
action='store',
type=str,
dest='repetitions',
required=False,
default='1',
help='You can use this argument to repeat this execution n times (Optional). It will compute and show a summary of the selected metrics at the end.')
parser_exec.add_argument('-test-result',
action='store_true',
default=False,
dest='test_result',
required=False,
help='This option enables correctness test (optional)')
parser_exec.add_argument('-executor',
action='store',
type=str,
dest='executor',
required=False,
default='',
help='(Optional) You can use this argument to change the way the benchmarks are executed. Usage example: [./spbench exec -executor \"-my_executor my_executor_parameters\" -bench ...]')
parser_exec.add_argument('-print',
action='store_true',
default=False,
dest='print_exec_line',
required=False,
help='(Optional) When this parameter is added, the exec command will only print on the screen the execution command it would use to run the benchmark. You may use it to manually change some aspect of the execution.')
parser_exec.add_argument('-quiet',
action='store_true',
default=False,
dest='quiet',
required=False,
help='Run it in quiet mode. Results can be retrieved from the \'log/general_log.csv\' file (optional)')
parser_exec.add_argument('-d',
action='append_const',
const='-d',
dest='exec_arguments',
required=False,
help='Decompress mode (Use only for Bzip2. Optional)')
parser_exec.set_defaults(func=execute)
##
# List benchmarks
##
parser_list.add_argument('-app',
action='store',
type=str,
dest='app_id',
required=False,
choices=getAppsList(spbench_path),
help="You can filter by application:\n" + str(getAppsList(spbench_path)) + " (optional)")
parser_list.add_argument('-ppi',
action='store',
type=str,
dest='ppi_id',
required=False,
help="Shows all the benchmarks for a specific PPI (optional)")
parser_list.set_defaults(func=list_reg)
##
# List operators
##
parser_list_op.add_argument('-benchmark',
action='store',
type=str,
dest='benchmark_id',
required=True,
help="You must give the name of the respective benchmark you want to see the operators list.")
parser_list_op.set_defaults(func=list_operators)
##
# Delete benchmark
##
parser_del.add_argument('-benchmark',
action='store',
type=str,
dest='benchmark_id',
required=True,
help='Insert the name of the benchmark to delete')
parser_del.set_defaults(func=delete_reg)
##
# Reset operators
##
parser_reset_op.add_argument('-benchmark',
action='store',
type=str,
dest='benchmark_id',
required=False,
help='Insert the name of a benchmark to reset its operators. Caution: It will remove any current modifications on the operators.')
parser_reset_op.add_argument('-app',
action='store',
type=str,
dest='app_id',
required=False,
choices=getAppsList(spbench_path),
help="Reset operators for all benchmarks for a specific application: \n[bzip2] [lane_detection] [ferret] [person_recognition](optional)")
parser_reset_op.add_argument('-ppi',
action='store',
type=str,
dest='ppi_id',
required=False,
help="Reset operators for all benchmarks for a specific PPI (optional)\n")
#parser_reset.add_argument('-nsources',
# action='store_true',
# default=False,
# dest='nsources',
# required=False,
# help='Use this option together with \'-app\' or \'-ppi\' to filter multi-source benchmarks (optional). Default: single source')
parser_reset_op.set_defaults(func=reset_operators)
##
# register inputs
##
parser_reg_inputs.add_argument('-id',
action='store',
type=str,
dest='input_id',
required=True,
help='Set a name for your new input (existent entries will be replaced)')
parser_reg_inputs.add_argument('-app',
action='store',
type=str,
dest='app_id',
required=True,
choices=getAppsList(spbench_path),
help="You must choose one from the following applications:\n " + str(getAppsList(spbench_path)) + " (mandatory)")
parser_reg_inputs.add_argument('-input-string',
action='store',
type=str,
dest='input',
required=True,
#default='sequential',
help="You must insert the input string \n(e.g., \"/home/user/my_input_file ...\")")
parser_reg_inputs.add_argument('-md5',
action='store',
type=str,
dest='md5_hash',
required=False,
default="",
help="SPBench uses the associated md5 hash to check the correctness of the result for this input (Optional).\n ATTENTION: do not insert the input file resulting md5 hash here. You must insert the md5 hash regarding the output file. See the respective documentation for more details (LINK)(FORTHCOMING)")
parser_reg_inputs.set_defaults(func=register_inputs)
##
# Delete inputs
##
parser_del_input.add_argument('-id',
action='store',
type=str,
dest='input_id',
default='all',
required=False,
help='Insert the ID of the input you want to remove from registry. The default value is \'all\', it will delete all registered inputs from the application provided in the -app argument.')
parser_del_input.add_argument('-app',
action='store',
type=str,
dest='app_id',
required=True,
help="Name of the application (mandatory).")
parser_del_input.set_defaults(func=delete_input)
##
# Download inputs
##
parser_get_inputs.add_argument('-app',
action='store',
type=str,
dest='app_id',
required=False,
default="all",
choices=getAppsListAll(spbench_path),
help="You can choose from the applications list or \n\n leave it empty to download all inputs.")
parser_get_inputs.add_argument('-class',
action='store',
type=str,
dest='class_id',
required=False,
default="all",
choices=['all', 'test', 'small', 'medium', 'large', 'huge'],
help='You can insert the input class\nyou want to download or leave it empty to download all classes. Default: \'all\'')
parser_get_inputs.add_argument('-force',
action='store_true',
default=False,
dest='force',
required=False,
help='Use this option to overwrite any existing input file and download it again (optional).')
parser_get_inputs.set_defaults(func=download_inputs)
##
# rename benchmark
##
parser_rename_bench.add_argument('-old-name',
action='store',
type=str,
dest='old_bench_id',
required=True,
help="Insert the old benchmark id you want to rename.")
parser_rename_bench.add_argument('-new-name',
action='store',
type=str,
dest='new_bench_id',
required=True,
help='Insert the new benchmark id.')
parser_rename_bench.set_defaults(func=rename_bench)
##
# List inputs
##
parser_list_inputs.add_argument('-app',
action='store',
type=str,
dest='app_id',
required=False,
choices=getAppsList(spbench_path),
help="You can filter by application:\n" + str(getAppsList(spbench_path)) + " (optional)")
parser_list_inputs.set_defaults(func=list_reg_inputs)
##
# New application
##
parser_new_app.add_argument('-app',
action='store',
type=str,
dest='app_id',
required=True,
help="The ID of the new application (mandatory). The ID should not contain empty spaces. Example of acceptable names are: \"bzip2\", \"lane_detect\", \"face-recognizer\", ...")
parser_new_app.add_argument('-name',
action='store',
type=str,
dest='app_name',
default='',
required=False,
help="The name of the new application (optional) (limited to 50 characters). Example: \"Bzip2\", \"Lane Detection\", \"Face Recognizer\". Default name: same as the ID.")
parser_new_app.add_argument('-operators',
nargs='+',
action='store',
type=str,
dest='operators_list',
required=True,
help='Add a list of middle operators to this new application (mandatory, at least one must be provided). Usage: [ -operators <op1_name> <op2_name> ... ]. Source and sink operators are already included.')
parser_new_app.add_argument('-description',
action='store',
type=str,
dest='description',
required=False,
default='This is a user-defined application.',
help="A brief description of the application (optional).")
parser_new_app.add_argument('-notes',
action='store',
type=str,
dest='notes',
required=False,
default='The original code of this application is a toy example. Edit it to create your own application.',
help="Notes about the application (optional).")
parser_new_app.set_defaults(func=new_app)
##
# Delete application
##
parser_del_app.add_argument('-app',
action='store',
type=str,
dest='app_id',
required=True,
help="The name of the application to delete (mandatory).")
parser_del_app.set_defaults(func=delete_app)