From af7f366021359b125fa9f0186abe3c7ffd0c30ce Mon Sep 17 00:00:00 2001 From: Peter Mocary Date: Sun, 21 Jul 2024 15:32:24 +0200 Subject: [PATCH] fixup! fixup! fixup! fixup! add new Tracer engine based on the PIN framework --- perun/collect/trace/pin/engine.py | 9 ++++++--- perun/collect/trace/pin/parse/__init__.py | 8 ++++---- perun/collect/trace/pin/parse/time_parser.py | 4 ++-- perun/collect/trace/run.py | 1 - perun/profile/factory.py | 1 - 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/perun/collect/trace/pin/engine.py b/perun/collect/trace/pin/engine.py index 377892c5a..6d4aeb2b4 100644 --- a/perun/collect/trace/pin/engine.py +++ b/perun/collect/trace/pin/engine.py @@ -154,7 +154,7 @@ def assemble_collect_program(self, **kwargs) -> None: run_safely_external_command(f"make -C {get_tmp_directory()}") msg_to_stdout("[Debug]: The pintool is built.", 3) - def collect(self, config, **kwargs: Dict[str, Any]) -> None: + def collect(self, **kwargs: Dict[str, Any]) -> None: """Collect the raw performance data using the assembled pintool. :param Configuration config: the configuration object @@ -162,6 +162,7 @@ def collect(self, config, **kwargs: Dict[str, Any]) -> None: :raises PinBinaryInstrumentationFailed: execution of pin with generated pintool failed """ msg_to_stdout("[Info]: Collecting the performance data.", 2) + config = kwargs["config"] collection_cmd: str = ( f"{self.__pin_root}/pin " f"-t {get_tmp_directory()}/obj-intel64/pintool.so " @@ -174,7 +175,7 @@ def collect(self, config, **kwargs: Dict[str, Any]) -> None: except subprocess.CalledProcessError: raise PinBinaryInstrumentationFailed - def transform(self, config, **kwargs) -> Generator[Dict[str, Union[str, int]], None, None]: + def transform(self, **kwargs) -> Generator[Dict[str, Union[str, int]], None, None]: """Transform the raw performance data into a resources as used in the profiles. :param Configuration config: the configuration object @@ -182,6 +183,7 @@ def transform(self, config, **kwargs) -> Generator[Dict[str, Union[str, int]], N :return iterable: a generator object that produces the resources """ msg_to_stdout("[Info]: Transforming the collected data to perun profile.", 2) + config = kwargs["config"] # Transform function information from DWARF debug info into a map based on name function_arguments_map = {} @@ -222,12 +224,13 @@ def transform(self, config, **kwargs) -> Generator[Dict[str, Union[str, int]], N return dynamic_parser.parse_dynamic_data_file() - def cleanup(self, config, **kwargs: Dict[str, Any]) -> None: + def cleanup(self, **kwargs: Dict[str, Any]) -> None: """Cleans up all the engine-related resources such as files, processes, locks, etc. :param Configuration config: collection parameters """ msg_to_stdout("[Info]: Cleaning up.", 2) + config = kwargs["config"] if os.path.exists(f"{get_tmp_directory()}/obj-intel64"): msg_to_stdout("[Debug]: Removing the built pintool.", 3) run_safely_external_command(f"make -C {get_tmp_directory()} clean-obj-intel64") diff --git a/perun/collect/trace/pin/parse/__init__.py b/perun/collect/trace/pin/parse/__init__.py index 28b590874..153439376 100644 --- a/perun/collect/trace/pin/parse/__init__.py +++ b/perun/collect/trace/pin/parse/__init__.py @@ -1,4 +1,4 @@ -from .parser import PinStaticOutputParser, PinDynamicOutputParser, ProgramData -from .time_parser import PinTimeOutputParser -from .instructions_parser import PinInstructionOutputParser -from .memory_parser import PinMemoryOutputParser +from .parser import PinStaticOutputParser, PinDynamicOutputParser, ProgramData # noqa: F401 +from .time_parser import PinTimeOutputParser # noqa: F401 +from .instructions_parser import PinInstructionOutputParser # noqa: F401 +from .memory_parser import PinMemoryOutputParser # noqa: F401 diff --git a/perun/collect/trace/pin/parse/time_parser.py b/perun/collect/trace/pin/parse/time_parser.py index 44142a82d..af0e77b6c 100644 --- a/perun/collect/trace/pin/parse/time_parser.py +++ b/perun/collect/trace/pin/parse/time_parser.py @@ -289,8 +289,8 @@ def parse_dynamic_data_file(self) -> Generator[Dict[str, Union[str, int]], None, if self.basic_block_backlog: msg_to_stdout( - f"[DEBUG]: Basic blocks backlog contains " - "{len(self.basic_block_backlog)} unpaired entries.", + "[DEBUG]: Basic blocks backlog contains " + f"{len(self.basic_block_backlog)} unpaired entries.", 3, ) diff --git a/perun/collect/trace/run.py b/perun/collect/trace/run.py index f27a59f76..3cf0b53f1 100644 --- a/perun/collect/trace/run.py +++ b/perun/collect/trace/run.py @@ -24,7 +24,6 @@ import perun.logic.runner as runner import perun.utils.log as stdout import perun.utils.metrics as metrics -import perun.utils as utils from perun.profile.factory import Profile from perun.utils.structs import CollectStatus diff --git a/perun/profile/factory.py b/perun/profile/factory.py index 737899588..44ea29520 100644 --- a/perun/profile/factory.py +++ b/perun/profile/factory.py @@ -17,7 +17,6 @@ # Third-Party Imports import click -import re # Perun Imports from perun.logic import config