mirror of
https://github.com/RRZE-HPC/OSACA.git
synced 2026-01-06 19:20:07 +01:00
added --lines option
This commit is contained in:
@@ -94,6 +94,13 @@ def create_parser(parser=None):
|
|||||||
help='Run the throughput analysis with fixed probabilities for all suitable ports per '
|
help='Run the throughput analysis with fixed probabilities for all suitable ports per '
|
||||||
'instruction. Otherwise, OSACA will print the optimal port utilization for the kernel.',
|
'instruction. Otherwise, OSACA will print the optimal port utilization for the kernel.',
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--lines',
|
||||||
|
type=str,
|
||||||
|
help='Define lines that should be included in the analysis. This option overwrites any'
|
||||||
|
' range defined by markers in the assembly. Add either single lines or ranges defined by'
|
||||||
|
' "-" or ":", each entry separated by commas, e.g.: --lines 1,2,8-18,20:24',
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--db-check',
|
'--db-check',
|
||||||
dest='check_db',
|
dest='check_db',
|
||||||
@@ -272,8 +279,12 @@ def inspect(args, output_file=sys.stdout):
|
|||||||
traceback.print_exc(file=sys.stderr)
|
traceback.print_exc(file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Reduce to marked kernel and add semantics
|
# Reduce to marked kernel or chosen section and add semantics
|
||||||
kernel = reduce_to_section(parsed_code, isa)
|
if args.lines:
|
||||||
|
line_range = get_line_range(args.lines)
|
||||||
|
kernel = [line for line in parsed_code if line['line_number'] in line_range]
|
||||||
|
else:
|
||||||
|
kernel = reduce_to_section(parsed_code, isa)
|
||||||
machine_model = MachineModel(arch=arch)
|
machine_model = MachineModel(arch=arch)
|
||||||
semantics = ArchSemantics(machine_model)
|
semantics = ArchSemantics(machine_model)
|
||||||
semantics.add_semantics(kernel)
|
semantics.add_semantics(kernel)
|
||||||
@@ -346,6 +357,19 @@ def get_unmatched_instruction_ratio(kernel):
|
|||||||
unmatched_counter += 1
|
unmatched_counter += 1
|
||||||
return unmatched_counter / len(kernel)
|
return unmatched_counter / len(kernel)
|
||||||
|
|
||||||
|
def get_line_range(line_str):
|
||||||
|
line_str = line_str.replace(':', '-')
|
||||||
|
lines = line_str.split(',')
|
||||||
|
lines_int = []
|
||||||
|
for l in lines:
|
||||||
|
if '-' in l:
|
||||||
|
start = int(l.split('-')[0])
|
||||||
|
end = int(l.split('-')[1])
|
||||||
|
rnge = list(range(start, end+1))
|
||||||
|
lines_int += rnge
|
||||||
|
else:
|
||||||
|
lines_int.append(int(l))
|
||||||
|
return lines_int
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Initialize and run command line interface."""
|
"""Initialize and run command line interface."""
|
||||||
|
|||||||
@@ -166,6 +166,31 @@ class TestCLI(unittest.TestCase):
|
|||||||
args = parser.parse_args([self._find_test_file(kernel_aarch64)])
|
args = parser.parse_args([self._find_test_file(kernel_aarch64)])
|
||||||
osaca.run(args, output_file=output)
|
osaca.run(args, output_file=output)
|
||||||
|
|
||||||
|
def test_lines_arg(self):
|
||||||
|
# Run tests with --lines option
|
||||||
|
parser = osaca.create_parser()
|
||||||
|
kernel_x86 = 'triad_x86_iaca.s'
|
||||||
|
args_base = parser.parse_args(
|
||||||
|
['--arch', 'csx', self._find_test_file(kernel_x86)]
|
||||||
|
)
|
||||||
|
output_base = StringIO()
|
||||||
|
osaca.run(args_base, output_file=output_base)
|
||||||
|
output_base = output_base.getvalue().split('\n')[8:]
|
||||||
|
args = []
|
||||||
|
args.append(parser.parse_args(
|
||||||
|
['--lines', '146-154', '--arch', 'csx', self._find_test_file(kernel_x86)]
|
||||||
|
))
|
||||||
|
args.append(parser.parse_args(
|
||||||
|
['--lines', '146:154', '--arch', 'csx', self._find_test_file(kernel_x86)]
|
||||||
|
))
|
||||||
|
args.append(parser.parse_args(
|
||||||
|
['--lines', '146,147:148,149-154', '--arch', 'csx', self._find_test_file(kernel_x86)]
|
||||||
|
))
|
||||||
|
for a in args:
|
||||||
|
with self.subTest(params=a):
|
||||||
|
output = StringIO()
|
||||||
|
osaca.run(a, output_file=output)
|
||||||
|
self.assertEqual(output.getvalue().split('\n')[8:], output_base)
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# Helper functions
|
# Helper functions
|
||||||
|
|||||||
Reference in New Issue
Block a user