Commit 2bf01d5e authored by one's avatar one
Browse files

Format python code on branch dtk

parent 47d4a79d
......@@ -10,7 +10,6 @@
import re
_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+)?$')
......@@ -95,7 +94,6 @@ def _hpcg_sort_key(metric_name):
def sort_metrics(metrics):
"""Sort metrics with benchmark-specific sorters and a stable default fallback."""
def sort_key(metric_name):
for sorter in _SORTERS:
key = sorter(metric_name)
......
......@@ -14,11 +14,24 @@
class GpuHpcgBenchmark(MicroBenchmarkWithInvoke):
"""The GPU HPCG benchmark base class."""
_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',
'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'}
_operation_metric_map = {
'DDOT': 'ddot',
'WAXPBY': 'waxpby',
'SpMV': 'spmv',
'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)')
_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')
......
......@@ -114,14 +114,18 @@ def _parse_csv_phase_rows(self, raw_output):
if phase_name in self._phase_metric_map:
metric_tag = self._phase_metric_map[phase_name]
array_size = int(row['n_elements'])
phase_rows.append({
'metric_name': self._get_phase_bw_metric_name(metric_tag, array_size),
'value': self._mbps_to_gbps(row['max_mbytes_per_sec']),
})
phase_rows.append({
'metric_name': self._get_phase_time_metric_name(metric_tag, array_size),
'value': float(row['runtime']),
})
phase_rows.append(
{
'metric_name': self._get_phase_bw_metric_name(metric_tag, array_size),
'value': self._mbps_to_gbps(row['max_mbytes_per_sec']),
}
)
phase_rows.append(
{
'metric_name': self._get_phase_time_metric_name(metric_tag, array_size),
'value': float(row['runtime']),
}
)
if not phase_rows:
raise ValueError('No valid phase rows found in CSV output.')
......@@ -145,22 +149,30 @@ def _parse_csv_function_rows(self, raw_output):
if function_name in self._function_metric_map:
metric_tag = self._function_metric_map[function_name]
array_size = int(row['n_elements'])
function_rows.append({
'metric_name': self._get_function_bw_metric_name(metric_tag, array_size),
'value': self._mbps_to_gbps(row['max_mbytes_per_sec']),
})
function_rows.append({
'metric_name': self._get_function_time_metric_name(metric_tag, array_size, 'min'),
'value': float(row['min_runtime']),
})
function_rows.append({
'metric_name': self._get_function_time_metric_name(metric_tag, array_size, 'max'),
'value': float(row['max_runtime']),
})
function_rows.append({
'metric_name': self._get_function_time_metric_name(metric_tag, array_size, 'avg'),
'value': float(row['avg_runtime']),
})
function_rows.append(
{
'metric_name': self._get_function_bw_metric_name(metric_tag, array_size),
'value': self._mbps_to_gbps(row['max_mbytes_per_sec']),
}
)
function_rows.append(
{
'metric_name': self._get_function_time_metric_name(metric_tag, array_size, 'min'),
'value': float(row['min_runtime']),
}
)
function_rows.append(
{
'metric_name': self._get_function_time_metric_name(metric_tag, array_size, 'max'),
'value': float(row['max_runtime']),
}
)
function_rows.append(
{
'metric_name': self._get_function_time_metric_name(metric_tag, array_size, 'avg'),
'value': float(row['avg_runtime']),
}
)
if not function_rows:
raise ValueError('No valid function rows found in CSV output.')
......@@ -188,7 +200,9 @@ def _format_device_output(self, device_name, metrics):
metric_width = max(len(metric['metric_name']) for metric in metrics)
output_lines = ['Device: {}'.format(device_name)]
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
def _get_text_output_header(self):
......
......@@ -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)
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():
match = pattern.match(line.strip())
if match:
......@@ -92,8 +94,9 @@ def _process_raw_result(self, cmd_idx, raw_output):
if set(result.keys()) != set(self._metric_names):
logger.error(
'Cannot extract kernel launch benchmark metrics - round: {}, benchmark: {}, raw data: {}.'
.format(self._curr_run_index, self._name, raw_output)
'Cannot extract kernel launch benchmark metrics - round: {}, benchmark: {}, raw data: {}.'.format(
self._curr_run_index, self._name, raw_output
)
)
return False
......
......@@ -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(
'container_name',
options_list=('--container-name',),
options_list=('--container-name', ),
type=str,
help='Docker container name. Defaults to sb-workspace.'
)
......
......@@ -546,18 +546,20 @@ def fake_get_shell_config(cmd):
return {'module_args': cmd, 'cmdline': '', 'host_pattern': 'localhost', 'module': 'shell'}
self.runner._ansible_client.get_shell_config = fake_get_shell_config
mode = OmegaConf.create({
'name': 'mpi',
'proc_num': 4,
'node_num': 1,
'bind_to': 'numa',
'mca': {},
'env': {
'NCCL_BUFFSIZE': 4194304,
'NCCL_RINGS': '0 1 2 3|0 3 2 1',
'PATH': None,
},
})
mode = OmegaConf.create(
{
'name': 'mpi',
'proc_num': 4,
'node_num': 1,
'bind_to': 'numa',
'mca': {},
'env': {
'NCCL_BUFFSIZE': 4194304,
'NCCL_RINGS': '0 1 2 3|0 3 2 1',
'PATH': None,
},
}
)
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