"googlemock/git@developer.sourcefind.cn:yangql/googletest.git" did not exist on "0adeadd2830211f827fd2908e4621f6a4afa810c"
Commit 2bf01d5e authored by one's avatar one
Browse files

Format python code on branch dtk

parent 47d4a79d
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
import re import re
_RCCL_PATTERN = re.compile(r'^(?P<bench>rccl-bw(?::[^/]+)?)/(?P<op>[^_]+)_(?P<size>\d+)_(?P<suffix>.+?)(?::\d+)?$') _RCCL_PATTERN = re.compile(r'^(?P<bench>rccl-bw(?::[^/]+)?)/(?P<op>[^_]+)_(?P<size>\d+)_(?P<suffix>.+?)(?::\d+)?$')
_HPCG_PATTERN = re.compile(r'^(?P<bench>gpu-hpcg(?::[^/]+)?)/(?P<metric>.+?)(?::\d+)?$') _HPCG_PATTERN = re.compile(r'^(?P<bench>gpu-hpcg(?::[^/]+)?)/(?P<metric>.+?)(?::\d+)?$')
...@@ -95,7 +94,6 @@ def _hpcg_sort_key(metric_name): ...@@ -95,7 +94,6 @@ def _hpcg_sort_key(metric_name):
def sort_metrics(metrics): def sort_metrics(metrics):
"""Sort metrics with benchmark-specific sorters and a stable default fallback.""" """Sort metrics with benchmark-specific sorters and a stable default fallback."""
def sort_key(metric_name): def sort_key(metric_name):
for sorter in _SORTERS: for sorter in _SORTERS:
key = sorter(metric_name) key = sorter(metric_name)
......
...@@ -14,11 +14,24 @@ ...@@ -14,11 +14,24 @@
class GpuHpcgBenchmark(MicroBenchmarkWithInvoke): class GpuHpcgBenchmark(MicroBenchmarkWithInvoke):
"""The GPU HPCG benchmark base class.""" """The GPU HPCG benchmark base class."""
_mpi_output_prefix_pattern = re.compile(r'^\[\d+,\d+\]<(?:stdout|stderr)>:\s*') _mpi_output_prefix_pattern = re.compile(r'^\[\d+,\d+\]<(?:stdout|stderr)>:\s*')
_operation_metric_map = {'DDOT': 'ddot', 'WAXPBY': 'waxpby', 'SpMV': 'spmv', 'MG': 'mg', 'Total': 'total', _operation_metric_map = {
'Final': 'final'} 'DDOT': 'ddot',
_time_metric_map = {'Total Time': 'total_time', 'Setup Time': 'setup_time', 'Optimization Time': 'optimization_time'} 'WAXPBY': 'waxpby',
_domain_metric_map = {'Local domain': 'local_domain', 'Global domain': 'global_domain', 'SpMV': 'spmv',
'Process domain': 'process_domain'} 'MG': 'mg',
'Total': 'total',
'Final': 'final'
}
_time_metric_map = {
'Total Time': 'total_time',
'Setup Time': 'setup_time',
'Optimization Time': 'optimization_time'
}
_domain_metric_map = {
'Local domain': 'local_domain',
'Global domain': 'global_domain',
'Process domain': 'process_domain'
}
_float_pattern = re.compile(r'([0-9]+(?:\.[0-9]+)?)\s+(GFlop/s|GB/s)') _float_pattern = re.compile(r'([0-9]+(?:\.[0-9]+)?)\s+(GFlop/s|GB/s)')
_dimension_pattern = re.compile(r'([0-9]+)\s*x\s*([0-9]+)\s*x\s*([0-9]+)') _dimension_pattern = re.compile(r'([0-9]+)\s*x\s*([0-9]+)\s*x\s*([0-9]+)')
_time_value_pattern = re.compile(r'([0-9]+(?:\.[0-9]+)?)\s+sec') _time_value_pattern = re.compile(r'([0-9]+(?:\.[0-9]+)?)\s+sec')
......
...@@ -114,14 +114,18 @@ def _parse_csv_phase_rows(self, raw_output): ...@@ -114,14 +114,18 @@ def _parse_csv_phase_rows(self, raw_output):
if phase_name in self._phase_metric_map: if phase_name in self._phase_metric_map:
metric_tag = self._phase_metric_map[phase_name] metric_tag = self._phase_metric_map[phase_name]
array_size = int(row['n_elements']) array_size = int(row['n_elements'])
phase_rows.append({ phase_rows.append(
{
'metric_name': self._get_phase_bw_metric_name(metric_tag, array_size), 'metric_name': self._get_phase_bw_metric_name(metric_tag, array_size),
'value': self._mbps_to_gbps(row['max_mbytes_per_sec']), 'value': self._mbps_to_gbps(row['max_mbytes_per_sec']),
}) }
phase_rows.append({ )
phase_rows.append(
{
'metric_name': self._get_phase_time_metric_name(metric_tag, array_size), 'metric_name': self._get_phase_time_metric_name(metric_tag, array_size),
'value': float(row['runtime']), 'value': float(row['runtime']),
}) }
)
if not phase_rows: if not phase_rows:
raise ValueError('No valid phase rows found in CSV output.') raise ValueError('No valid phase rows found in CSV output.')
...@@ -145,22 +149,30 @@ def _parse_csv_function_rows(self, raw_output): ...@@ -145,22 +149,30 @@ def _parse_csv_function_rows(self, raw_output):
if function_name in self._function_metric_map: if function_name in self._function_metric_map:
metric_tag = self._function_metric_map[function_name] metric_tag = self._function_metric_map[function_name]
array_size = int(row['n_elements']) array_size = int(row['n_elements'])
function_rows.append({ function_rows.append(
{
'metric_name': self._get_function_bw_metric_name(metric_tag, array_size), 'metric_name': self._get_function_bw_metric_name(metric_tag, array_size),
'value': self._mbps_to_gbps(row['max_mbytes_per_sec']), 'value': self._mbps_to_gbps(row['max_mbytes_per_sec']),
}) }
function_rows.append({ )
function_rows.append(
{
'metric_name': self._get_function_time_metric_name(metric_tag, array_size, 'min'), 'metric_name': self._get_function_time_metric_name(metric_tag, array_size, 'min'),
'value': float(row['min_runtime']), 'value': float(row['min_runtime']),
}) }
function_rows.append({ )
function_rows.append(
{
'metric_name': self._get_function_time_metric_name(metric_tag, array_size, 'max'), 'metric_name': self._get_function_time_metric_name(metric_tag, array_size, 'max'),
'value': float(row['max_runtime']), 'value': float(row['max_runtime']),
}) }
function_rows.append({ )
function_rows.append(
{
'metric_name': self._get_function_time_metric_name(metric_tag, array_size, 'avg'), 'metric_name': self._get_function_time_metric_name(metric_tag, array_size, 'avg'),
'value': float(row['avg_runtime']), 'value': float(row['avg_runtime']),
}) }
)
if not function_rows: if not function_rows:
raise ValueError('No valid function rows found in CSV output.') raise ValueError('No valid function rows found in CSV output.')
...@@ -188,7 +200,9 @@ def _format_device_output(self, device_name, metrics): ...@@ -188,7 +200,9 @@ def _format_device_output(self, device_name, metrics):
metric_width = max(len(metric['metric_name']) for metric in metrics) metric_width = max(len(metric['metric_name']) for metric in metrics)
output_lines = ['Device: {}'.format(device_name)] output_lines = ['Device: {}'.format(device_name)]
for metric in metrics: for metric in metrics:
output_lines.append('{:<{width}} {:.6f}'.format(metric['metric_name'], metric['value'], width=metric_width)) output_lines.append(
'{:<{width}} {:.6f}'.format(metric['metric_name'], metric['value'], width=metric_width)
)
return output_lines return output_lines
def _get_text_output_header(self): def _get_text_output_header(self):
......
...@@ -84,7 +84,9 @@ def _process_raw_result(self, cmd_idx, raw_output): ...@@ -84,7 +84,9 @@ def _process_raw_result(self, cmd_idx, raw_output):
self._result.add_raw_data('raw_output_' + str(cmd_idx), raw_output, self._args.log_raw_data) self._result.add_raw_data('raw_output_' + str(cmd_idx), raw_output, self._args.log_raw_data)
result = {} result = {}
pattern = re.compile(r'^(e2e_latency_us|host_dispatch_us|launch_throughput_mkps|device_launch_us):\s*(-?\d+(?:\.\d+)?)$') pattern = re.compile(
r'^(e2e_latency_us|host_dispatch_us|launch_throughput_mkps|device_launch_us):\s*(-?\d+(?:\.\d+)?)$'
)
for line in raw_output.splitlines(): for line in raw_output.splitlines():
match = pattern.match(line.strip()) match = pattern.match(line.strip())
if match: if match:
...@@ -92,8 +94,9 @@ def _process_raw_result(self, cmd_idx, raw_output): ...@@ -92,8 +94,9 @@ def _process_raw_result(self, cmd_idx, raw_output):
if set(result.keys()) != set(self._metric_names): if set(result.keys()) != set(self._metric_names):
logger.error( logger.error(
'Cannot extract kernel launch benchmark metrics - round: {}, benchmark: {}, raw data: {}.' 'Cannot extract kernel launch benchmark metrics - round: {}, benchmark: {}, raw data: {}.'.format(
.format(self._curr_run_index, self._name, raw_output) self._curr_run_index, self._name, raw_output
)
) )
return False return False
......
...@@ -44,7 +44,7 @@ def load_arguments(self, command): ...@@ -44,7 +44,7 @@ def load_arguments(self, command):
ac.argument('docker_image', options_list=('--docker-image', '-i'), type=str, help='Docker image URI.') ac.argument('docker_image', options_list=('--docker-image', '-i'), type=str, help='Docker image URI.')
ac.argument( ac.argument(
'container_name', 'container_name',
options_list=('--container-name',), options_list=('--container-name', ),
type=str, type=str,
help='Docker container name. Defaults to sb-workspace.' help='Docker container name. Defaults to sb-workspace.'
) )
......
...@@ -546,7 +546,8 @@ def fake_get_shell_config(cmd): ...@@ -546,7 +546,8 @@ def fake_get_shell_config(cmd):
return {'module_args': cmd, 'cmdline': '', 'host_pattern': 'localhost', 'module': 'shell'} return {'module_args': cmd, 'cmdline': '', 'host_pattern': 'localhost', 'module': 'shell'}
self.runner._ansible_client.get_shell_config = fake_get_shell_config self.runner._ansible_client.get_shell_config = fake_get_shell_config
mode = OmegaConf.create({ mode = OmegaConf.create(
{
'name': 'mpi', 'name': 'mpi',
'proc_num': 4, 'proc_num': 4,
'node_num': 1, 'node_num': 1,
...@@ -557,7 +558,8 @@ def fake_get_shell_config(cmd): ...@@ -557,7 +558,8 @@ def fake_get_shell_config(cmd):
'NCCL_RINGS': '0 1 2 3|0 3 2 1', 'NCCL_RINGS': '0 1 2 3|0 3 2 1',
'PATH': None, 'PATH': None,
}, },
}) }
)
self.runner._run_proc('foo', mode, {'proc_rank': 0}) self.runner._run_proc('foo', mode, {'proc_rank': 0})
......
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