diff --git a/discopop_explorer/PEGraphX.py b/discopop_explorer/PEGraphX.py index 65b9b8475..206a3b7b9 100644 --- a/discopop_explorer/PEGraphX.py +++ b/discopop_explorer/PEGraphX.py @@ -160,9 +160,9 @@ class Node: end_line: int type: NodeType name: str - parent_function_id: Optional[ - NodeID - ] = None # metadata to speedup some calculations (TODO FunctionNodes have themselves as parent) + parent_function_id: Optional[NodeID] = ( + None # metadata to speedup some calculations (TODO FunctionNodes have themselves as parent) + ) workload: Optional[int] = None # properties of CU Nodes @@ -959,12 +959,10 @@ def node_at(self, node_id: NodeID) -> Node: NodeT = TypeVar("NodeT", bound=Node) @overload - def all_nodes(self) -> List[Node]: - ... + def all_nodes(self) -> List[Node]: ... @overload - def all_nodes(self, type: Union[Type[NodeT], Tuple[Type[NodeT], ...]]) -> List[NodeT]: - ... + def all_nodes(self, type: Union[Type[NodeT], Tuple[Type[NodeT], ...]]) -> List[NodeT]: ... def all_nodes(self, type=Node): """List of all nodes of specified type @@ -1007,12 +1005,10 @@ def in_edges( return [t for t in self.g.in_edges(node_id, data="data") if t[2].etype == etype] @overload - def subtree_of_type(self, root: Node) -> List[Node]: - ... + def subtree_of_type(self, root: Node) -> List[Node]: ... @overload - def subtree_of_type(self, root: Node, type: Union[Type[NodeT], Tuple[Type[NodeT], ...]]) -> List[NodeT]: - ... + def subtree_of_type(self, root: Node, type: Union[Type[NodeT], Tuple[Type[NodeT], ...]]) -> List[NodeT]: ... def subtree_of_type(self, root, type=Node): """Gets all nodes in subtree of specified type including root @@ -1024,14 +1020,12 @@ def subtree_of_type(self, root, type=Node): return self.subtree_of_type_rec(root, set(), type) @overload - def subtree_of_type_rec(self, root: Node, visited: Set[Node]) -> List[Node]: - ... + def subtree_of_type_rec(self, root: Node, visited: Set[Node]) -> List[Node]: ... @overload def subtree_of_type_rec( self, root: Node, visited: Set[Node], type: Union[Type[NodeT], Tuple[Type[NodeT], ...]] - ) -> List[NodeT]: - ... + ) -> List[NodeT]: ... def subtree_of_type_rec(self, root, visited, type=Node): """recursive helper function for subtree_of_type""" diff --git a/discopop_explorer/pattern_detectors/combined_gpu_patterns/CombinedGPURegions.py b/discopop_explorer/pattern_detectors/combined_gpu_patterns/CombinedGPURegions.py index 8dec7e53c..8d97fdd6b 100644 --- a/discopop_explorer/pattern_detectors/combined_gpu_patterns/CombinedGPURegions.py +++ b/discopop_explorer/pattern_detectors/combined_gpu_patterns/CombinedGPURegions.py @@ -123,9 +123,9 @@ def __init__(self, pet: PEGraphX, contained_regions: List[GPURegionInfo], projec ) = get_written_and_read_memory_regions_by_cu(self.contained_regions, pet) # get memory region and variable associations for each CU - cu_and_variable_to_memory_regions: Dict[ - NodeID, Dict[VarName, Set[MemoryRegion]] - ] = get_cu_and_varname_to_memory_regions(self.contained_regions, pet, written_memory_regions_by_cu) + cu_and_variable_to_memory_regions: Dict[NodeID, Dict[VarName, Set[MemoryRegion]]] = ( + get_cu_and_varname_to_memory_regions(self.contained_regions, pet, written_memory_regions_by_cu) + ) print("WRITTEN MEMORY REGIONS BY CU: ", file=sys.stderr) print(written_memory_regions_by_cu, file=sys.stderr) @@ -136,9 +136,9 @@ def __init__(self, pet: PEGraphX, contained_regions: List[GPURegionInfo], projec print(file=sys.stderr) # get memory regions to cus and variables names - memory_regions_to_cus_and_variables: Dict[ - MemoryRegion, Dict[NodeID, Set[VarName]] - ] = get_memory_region_to_cu_and_variables_dict(cu_and_variable_to_memory_regions) + memory_regions_to_cus_and_variables: Dict[MemoryRegion, Dict[NodeID, Set[VarName]]] = ( + get_memory_region_to_cu_and_variables_dict(cu_and_variable_to_memory_regions) + ) print("MEMORY REGIONS TO CUS AND VARIABLES:", file=sys.stderr) print(memory_regions_to_cus_and_variables, file=sys.stderr) print(file=sys.stderr) @@ -150,9 +150,9 @@ def __init__(self, pet: PEGraphX, contained_regions: List[GPURegionInfo], projec print(file=sys.stderr) # extend device liveness with memory regions - device_liveness_plus_memory_regions: Dict[ - VarName, List[Tuple[NodeID, Set[MemoryRegion]]] - ] = add_memory_regions_to_device_liveness(live_device_variables, cu_and_variable_to_memory_regions) + device_liveness_plus_memory_regions: Dict[VarName, List[Tuple[NodeID, Set[MemoryRegion]]]] = ( + add_memory_regions_to_device_liveness(live_device_variables, cu_and_variable_to_memory_regions) + ) # ### STEP 2.2: CALCULATE LIVE DATA BY PROPAGATING MEMORY REGIONS AND EXTENDING LIFESPAN @@ -252,9 +252,9 @@ def __init__(self, pet: PEGraphX, contained_regions: List[GPURegionInfo], projec # ### STEP 5: CONVERT MEMORY REGIONS IN UPDATES TO VARIABLE NAMES # propagate memory region to variable name associations within function body - memory_regions_to_functions_and_variables: Dict[ - MemoryRegion, Dict[NodeID, Set[VarName]] - ] = propagate_variable_name_associations(pet, memory_regions_to_cus_and_variables) + memory_regions_to_functions_and_variables: Dict[MemoryRegion, Dict[NodeID, Set[VarName]]] = ( + propagate_variable_name_associations(pet, memory_regions_to_cus_and_variables) + ) print("MEMORY REGIONS TO FUNCTIONS AND VARIABLES:", file=sys.stderr) print(memory_regions_to_functions_and_variables, file=sys.stderr) print(file=sys.stderr) diff --git a/discopop_explorer/pattern_detectors/combined_gpu_patterns/prepare_metadata.py b/discopop_explorer/pattern_detectors/combined_gpu_patterns/prepare_metadata.py index 8a3976e05..3783bf676 100644 --- a/discopop_explorer/pattern_detectors/combined_gpu_patterns/prepare_metadata.py +++ b/discopop_explorer/pattern_detectors/combined_gpu_patterns/prepare_metadata.py @@ -13,9 +13,10 @@ from discopop_explorer.pattern_detectors.combined_gpu_patterns.classes.Dependency import Dependency -def get_dependencies_as_metadata( - pet: PEGraphX, all_dependencies: Set[Dependency] -) -> Tuple[List[Tuple[VarName, NodeID, str]], List[Tuple[VarName, NodeID, str]],]: +def get_dependencies_as_metadata(pet: PEGraphX, all_dependencies: Set[Dependency]) -> Tuple[ + List[Tuple[VarName, NodeID, str]], + List[Tuple[VarName, NodeID, str]], +]: in_deps_metadata: Set[Tuple[VarName, NodeID, str]] = set() out_deps_metadata: Set[Tuple[VarName, NodeID, str]] = set() diff --git a/discopop_explorer/utils.py b/discopop_explorer/utils.py index 303070f94..d3887b749 100644 --- a/discopop_explorer/utils.py +++ b/discopop_explorer/utils.py @@ -731,7 +731,15 @@ def classify_task_vars( in_deps: List[Tuple[NodeID, NodeID, Dependency]], out_deps: List[Tuple[NodeID, NodeID, Dependency]], used_in_task_parallelism_detection=False, -) -> Tuple[List[Variable], List[Variable], List[Variable], List[Variable], List[Variable], List[Variable], List[str],]: +) -> Tuple[ + List[Variable], + List[Variable], + List[Variable], + List[Variable], + List[Variable], + List[Variable], + List[str], +]: """Classify task variables :param pet: CU graph diff --git a/discopop_library/discopop_optimizer/Microbench/Microbench.py b/discopop_library/discopop_optimizer/Microbench/Microbench.py index b2f2567d0..b25360e9b 100644 --- a/discopop_library/discopop_optimizer/Microbench/Microbench.py +++ b/discopop_library/discopop_optimizer/Microbench/Microbench.py @@ -49,7 +49,10 @@ class Microbench(ABC): @abstractmethod def getMeasurements( self, - ) -> Dict[MicrobenchType, Dict[MicrobenchDimension, Dict[MicrobenchCoordinate, List[float]]],]: + ) -> Dict[ + MicrobenchType, + Dict[MicrobenchDimension, Dict[MicrobenchCoordinate, List[float]]], + ]: raise TypeError("Pure virtual method called") @abstractmethod diff --git a/discopop_library/discopop_optimizer/Microbench/MixedMicrobench.py b/discopop_library/discopop_optimizer/Microbench/MixedMicrobench.py index bf64b6113..960a4648e 100644 --- a/discopop_library/discopop_optimizer/Microbench/MixedMicrobench.py +++ b/discopop_library/discopop_optimizer/Microbench/MixedMicrobench.py @@ -26,19 +26,28 @@ def __init__(self, inner: Microbench, outer: Microbench, threshold: MicrobenchCo def getMeasurements( self, - ) -> Dict[MicrobenchType, Dict[MicrobenchDimension, Dict[MicrobenchCoordinate, List[float]]],]: + ) -> Dict[ + MicrobenchType, + Dict[MicrobenchDimension, Dict[MicrobenchCoordinate, List[float]]], + ]: raise TypeError( "This MixedMicrobench might be based on two different sets of measurements. Use getInnerMeasurements() or getOuterMeasurements() instead." ) def getInnerMeasurements( self, - ) -> Dict[MicrobenchType, Dict[MicrobenchDimension, Dict[MicrobenchCoordinate, List[float]]],]: + ) -> Dict[ + MicrobenchType, + Dict[MicrobenchDimension, Dict[MicrobenchCoordinate, List[float]]], + ]: return self.inner.getMeasurements() def getOuterMeasurements( self, - ) -> Dict[MicrobenchType, Dict[MicrobenchDimension, Dict[MicrobenchCoordinate, List[float]]],]: + ) -> Dict[ + MicrobenchType, + Dict[MicrobenchDimension, Dict[MicrobenchCoordinate, List[float]]], + ]: return self.outer.getMeasurements() def toJSON(self) -> str: diff --git a/discopop_library/discopop_optimizer/Microbench/PureDataMicrobench.py b/discopop_library/discopop_optimizer/Microbench/PureDataMicrobench.py index bf0cb1f86..545e49f78 100644 --- a/discopop_library/discopop_optimizer/Microbench/PureDataMicrobench.py +++ b/discopop_library/discopop_optimizer/Microbench/PureDataMicrobench.py @@ -52,16 +52,17 @@ class PureDataMicrobench(Microbench): ] @overload - def __getitem__(self, key: MicrobenchType) -> Dict[MicrobenchDimension, Dict[MicrobenchCoordinate, List[float]]]: - ... + def __getitem__( + self, key: MicrobenchType + ) -> Dict[MicrobenchDimension, Dict[MicrobenchCoordinate, List[float]]]: ... @overload - def __getitem__(self, key: Tuple[MicrobenchType, MicrobenchDimension]) -> Dict[MicrobenchCoordinate, List[float]]: - ... + def __getitem__( + self, key: Tuple[MicrobenchType, MicrobenchDimension] + ) -> Dict[MicrobenchCoordinate, List[float]]: ... @overload - def __getitem__(self, key: Tuple[MicrobenchType, MicrobenchDimension, MicrobenchCoordinate]) -> List[float]: - ... + def __getitem__(self, key: Tuple[MicrobenchType, MicrobenchDimension, MicrobenchCoordinate]) -> List[float]: ... # allow to use this class like a dictionary def __getitem__(self, key): @@ -181,7 +182,10 @@ def mergeAll(self, others: List[PureDataMicrobench]): # inherited from Microbench def getMeasurements( self, - ) -> Dict[MicrobenchType, Dict[MicrobenchDimension, Dict[MicrobenchCoordinate, List[float]]],]: + ) -> Dict[ + MicrobenchType, + Dict[MicrobenchDimension, Dict[MicrobenchCoordinate, List[float]]], + ]: return self.measurements # inherited from Microbench diff --git a/discopop_library/discopop_optimizer/OptimizationGraph.py b/discopop_library/discopop_optimizer/OptimizationGraph.py index bc324aec8..2764e2683 100644 --- a/discopop_library/discopop_optimizer/OptimizationGraph.py +++ b/discopop_library/discopop_optimizer/OptimizationGraph.py @@ -125,9 +125,9 @@ def __init__( experiment.substitutions[cast(Symbol, function.sequential_costs)] = experiment.selected_paths_per_function[ function ][0].sequential_costs - experiment.substitutions[ - cast(Symbol, function.parallelizable_costs) - ] = experiment.selected_paths_per_function[function][0].parallelizable_costs + experiment.substitutions[cast(Symbol, function.parallelizable_costs)] = ( + experiment.selected_paths_per_function[function][0].parallelizable_costs + ) # TODO END OF DUMMY diff --git a/discopop_library/discopop_optimizer/gui/presentation/OptionTable.py b/discopop_library/discopop_optimizer/gui/presentation/OptionTable.py index 7724e1d3b..19a7887df 100644 --- a/discopop_library/discopop_optimizer/gui/presentation/OptionTable.py +++ b/discopop_library/discopop_optimizer/gui/presentation/OptionTable.py @@ -212,12 +212,12 @@ def show_options( def __update_selection(cm, ctx): experiment.selected_paths_per_function[function_root] = (cm, ctx) - experiment.substitutions[ - cast(Symbol, function_root.sequential_costs) - ] = experiment.selected_paths_per_function[function_root][0].sequential_costs - experiment.substitutions[ - cast(Symbol, function_root.parallelizable_costs) - ] = experiment.selected_paths_per_function[function_root][0].parallelizable_costs + experiment.substitutions[cast(Symbol, function_root.sequential_costs)] = ( + experiment.selected_paths_per_function[function_root][0].sequential_costs + ) + experiment.substitutions[cast(Symbol, function_root.parallelizable_costs)] = ( + experiment.selected_paths_per_function[function_root][0].parallelizable_costs + ) # update displayed value label2.configure(state=NORMAL) label2.delete(0, END) diff --git a/discopop_library/discopop_optimizer/suggestions/optimizers/loop_collapse.py b/discopop_library/discopop_optimizer/suggestions/optimizers/loop_collapse.py index 5e4314fff..0fd76d53f 100644 --- a/discopop_library/discopop_optimizer/suggestions/optimizers/loop_collapse.py +++ b/discopop_library/discopop_optimizer/suggestions/optimizers/loop_collapse.py @@ -130,9 +130,11 @@ def __collapse_loops_in_function(function_node_id): inner_queue += [ ( p, - tmp_dist - if isinstance(data_at(global_graph, p), ContextNode) - else tmp_dist + 1, + ( + tmp_dist + if isinstance(data_at(global_graph, p), ContextNode) + else tmp_dist + 1 + ), ) for p in preds ]