diff --git a/src/tools/pmreorder/opscontext.py b/src/tools/pmreorder/opscontext.py index e360d7dde98..42b58da180f 100644 --- a/src/tools/pmreorder/opscontext.py +++ b/src/tools/pmreorder/opscontext.py @@ -1,5 +1,5 @@ # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2018-2021, Intel Corporation +# Copyright 2018-2022, Intel Corporation from operationfactory import OperationFactory from binaryoutputhandler import BinaryOutputHandler @@ -56,15 +56,20 @@ def extract_operations(self): :return: list of subclasses of :class:`memoryoperations.BaseOperation` """ + enumerated_ops = list(enumerate(self._operations)) + markers = list(filter(lambda e: e[1].endswith(".BEGIN") + or e[1].endswith(".END"), enumerated_ops)) + operation_ids = list(enumerated_ops) + stop_index = start_index = 0 - for i, elem in enumerate(self._operations): + for i, elem in enumerated_ops: if "START" in elem: start_index = i elif "STOP" in elem: stop_index = i - return list( + operations = list( map( OperationFactory.create_operation, self._operations[start_index + 1: stop_index], @@ -72,3 +77,5 @@ def extract_operations(self): repeat(self.stack_engines), ) ) + + return (operations, operation_ids, markers) diff --git a/src/tools/pmreorder/pmreorder.py b/src/tools/pmreorder/pmreorder.py index 2b8777fb3e5..76a71425262 100644 --- a/src/tools/pmreorder/pmreorder.py +++ b/src/tools/pmreorder/pmreorder.py @@ -103,7 +103,8 @@ def main(): # init and run the state machine a = statemachine.StateMachine(statemachine.InitState(context)) - if a.run_all(context.extract_operations()) is False: + operations, operation_ids, markers = context.extract_operations() + if a.run_all(operations, operation_ids, markers) is False: sys.exit(1) diff --git a/src/tools/pmreorder/statemachine.py b/src/tools/pmreorder/statemachine.py index fbe7f45fa7f..bd264af342a 100644 --- a/src/tools/pmreorder/statemachine.py +++ b/src/tools/pmreorder/statemachine.py @@ -1,10 +1,11 @@ # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2018-2021, Intel Corporation +# Copyright 2018-2022, Intel Corporation import memoryoperations as memops import reorderengines from reorderexceptions import InconsistentFileException from reorderexceptions import NotSupportedOperationException +import os class State: @@ -371,7 +372,7 @@ def __init__(self, init_state): """ self._curr_state = init_state - def run_all(self, operations): + def run_all(self, operations, operation_ids, markers): """ Starts the state machine. @@ -381,8 +382,11 @@ def run_all(self, operations): :return: None """ all_consistent = True - for ops in operations: + for ops, ops_id in zip(operations, operation_ids): + print(ops_id[0]) self._curr_state._context.logger.info(ops) + markers_to_pass = [m[1] for m in markers if m[0] < ops_id[0]] + os.environ["PMREORDER_MARKERS"] = "|".join(markers_to_pass) self._curr_state = self._curr_state.next(ops) check = self._curr_state.run(ops) if check is False: