-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLI - Add command sb benchmark [list,list-parameters] (#279)
__Description__ Add command `sb benchmark list` and `sb benchmark list-parameters` to support listing all optional parameters for benchmarks. <details> <summary>Examples</summary> <pre> $ sb benchmark list -n [a-z]+-bw -o table Result -------- mem-bw nccl-bw rccl-bw </pre> <pre> $ sb benchmark list-parameters -n mem-bw === mem-bw === optional arguments: --bin_dir str Specify the directory of the benchmark binary. --duration int The elapsed time of benchmark in seconds. --mem_type str [str ...] Memory types to benchmark. E.g. htod dtoh dtod. --memory str Memory argument for bandwidthtest. E.g. pinned unpinned. --run_count int The run count of benchmark. --shmoo_mode Enable shmoo mode for bandwidthtest. default values: {'bin_dir': None, 'duration': 0, 'mem_type': ['htod', 'dtoh'], 'memory': 'pinned', 'run_count': 1} </pre> </details> __Major Revisions__ * Add `sb benchmark list` to list benchmarks matching given name. * Add `sb benchmark list-parameters` to list parameters for benchmarks which match given name. __Minor Revisions__ * Sort format help text for argparse.
- Loading branch information
Showing
8 changed files
with
228 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
"""SuperBench CLI benchmark subgroup command handler.""" | ||
|
||
import re | ||
from pprint import pformat | ||
|
||
from knack.util import CLIError | ||
|
||
from superbench.benchmarks import Platform, BenchmarkRegistry | ||
|
||
|
||
def benchmark_list_command_handler(name=None): | ||
"""List benchmarks which match the regular expression. | ||
Args: | ||
name (str, optional): Benchmark name or regular expression. Defaults to None. | ||
Raises: | ||
CLIError: If cannot find the matching benchmark. | ||
Returns: | ||
list: Benchmark list. | ||
""" | ||
benchmark_list = list(BenchmarkRegistry.get_all_benchmark_predefine_settings().keys()) | ||
if name is None: | ||
return benchmark_list | ||
filter_list = list(filter(re.compile(name).match, benchmark_list)) | ||
if not filter_list: | ||
raise CLIError('Benchmark {} does not exist.'.format(name)) | ||
return filter_list | ||
|
||
|
||
def benchmark_list_params_command_handler(name=None): | ||
"""List parameters for benchmarks which match the regular expression. | ||
Args: | ||
name (str, optional): Benchmark name or regular expression. Defaults to None. | ||
Raises: | ||
CLIError: If cannot find the matching benchmark. | ||
""" | ||
for benchmark_name in benchmark_list_command_handler(name): | ||
format_help = '' | ||
for platform in Platform: | ||
if platform in BenchmarkRegistry.benchmarks[benchmark_name]: | ||
format_help = BenchmarkRegistry.get_benchmark_configurable_settings( | ||
BenchmarkRegistry.create_benchmark_context(benchmark_name, platform=platform) | ||
) | ||
break | ||
print( | ||
( | ||
f'=== {benchmark_name} ===\n\n' | ||
f'{format_help}\n\n' | ||
f'default values:\n' | ||
f'{pformat(BenchmarkRegistry.benchmarks[benchmark_name]["predefine_param"])}\n' | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters