Skip to content

Commit

Permalink
chore[automatic]: optimized imports
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasrothenberger committed Sep 27, 2023
1 parent 01242c4 commit 2872740
Show file tree
Hide file tree
Showing 89 changed files with 172 additions and 257 deletions.
8 changes: 3 additions & 5 deletions discopop_explorer/PETGraphX.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@
from __future__ import annotations

import copy
import sys
from time import sleep
from typing import Dict, List, Sequence, Tuple, Set, Optional, Type, TypeVar, cast, Union, overload, Any
from enum import IntEnum, Enum
import itertools
from enum import IntEnum, Enum
from typing import Dict, List, Sequence, Tuple, Set, Optional, Type, TypeVar, cast, Union, overload, Any

import jsonpickle # type:ignore
import matplotlib.pyplot as plt # type:ignore
import networkx as nx # type:ignore
from alive_progress import alive_bar # type: ignore
from lxml.objectify import ObjectifiedElement # type:ignore

from .parser import LoopData, readlineToCUIdMap, writelineToCUIdMap, DependenceItem
from .variable import Variable
from alive_progress import alive_bar # type: ignore


# unused
Expand Down
21 changes: 10 additions & 11 deletions discopop_explorer/discopop_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,26 @@
# directory for details.

import cProfile
from dataclasses import dataclass
from pathlib import Path
from pluginbase import PluginBase # type:ignore
from typing import List, Optional

import json
import os
import pstats2 # type:ignore
import sys
import time
from dataclasses import dataclass
from pathlib import Path
from typing import List, Optional

from .json_serializer import PatternInfoSerializer
from .parser import parse_inputs
from .pattern_detection import PatternDetectorX
from .PETGraphX import PETGraphX
import pstats2 # type:ignore
from pluginbase import PluginBase # type:ignore

from discopop_library.PathManagement.PathManagement import get_path
from discopop_library.discopop_optimizer.Microbench.ExtrapInterpolatedMicrobench import (
ExtrapInterpolatedMicrobench,
)
from discopop_library.PathManagement.PathManagement import get_path
from discopop_library.result_classes.DetectionResult import DetectionResult
from .PETGraphX import PETGraphX
from .json_serializer import PatternInfoSerializer
from .parser import parse_inputs
from .pattern_detection import PatternDetectorX


@dataclass
Expand Down
1 change: 0 additions & 1 deletion discopop_explorer/generate_Data_CUInst.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
EdgeType,
)
from .parser import parse_inputs
from discopop_library.PathManagement.PathManagement import get_path


def __collect_children_ids(pet: PETGraphX, parent_id: NodeID, children_ids: List[NodeID]):
Expand Down
4 changes: 2 additions & 2 deletions discopop_explorer/json_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
from json import JSONEncoder
from typing import Dict, Any

from .PETGraphX import Node
from discopop_library.result_classes.DetectionResult import DetectionResult
from .PETGraphX import Node
from .pattern_detectors.PatternInfo import PatternInfo
from .pattern_detectors.pipeline_detector import PipelineStage
from .variable import Variable
from .pattern_detectors.task_parallelism.classes import TPIType
from .variable import Variable


def filter_members(d: Dict[Any, Any]) -> Dict[Any, Any]:
Expand Down
6 changes: 3 additions & 3 deletions discopop_explorer/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
# the 3-Clause BSD License. See the LICENSE file in the package base
# directory for details.

from dataclasses import dataclass
import re
import os
from typing import Any, List, Tuple
import re
import warnings
from collections import defaultdict
from dataclasses import dataclass
from os.path import abspath, dirname
from typing import Any, List, Tuple

from lxml import objectify # type:ignore

Expand Down
13 changes: 6 additions & 7 deletions discopop_explorer/pattern_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
# This software may be modified and distributed under the terms of
# the 3-Clause BSD License. See the LICENSE file in the package base
# directory for details.
import os
import sys
from typing import Dict, Union

from alive_progress import alive_bar # type: ignore

from discopop_explorer.pattern_detectors.task_parallelism.task_parallelism_detector import (
build_preprocessed_graph_and_run_detection as detect_tp,
)
from discopop_library.discopop_optimizer.OptimizationGraph import OptimizationGraph
from discopop_library.discopop_optimizer.Variables.Experiment import Experiment
from discopop_library.discopop_optimizer.classes.system.System import System
Expand All @@ -20,13 +23,9 @@
from .PETGraphX import DummyNode, LoopNode, PETGraphX, EdgeType
from .pattern_detectors.do_all_detector import run_detection as detect_do_all
from .pattern_detectors.geometric_decomposition_detector import run_detection as detect_gd
from .pattern_detectors.simple_gpu_patterns.gpu_pattern_detector import run_detection as detect_gpu
from .pattern_detectors.pipeline_detector import run_detection as detect_pipeline
from .pattern_detectors.reduction_detector import run_detection as detect_reduction
from discopop_explorer.pattern_detectors.task_parallelism.task_parallelism_detector import (
build_preprocessed_graph_and_run_detection as detect_tp,
)
from alive_progress import alive_bar # type: ignore
from .pattern_detectors.simple_gpu_patterns.gpu_pattern_detector import run_detection as detect_gpu


class PatternDetectorX(object):
Expand Down
2 changes: 1 addition & 1 deletion discopop_explorer/pattern_detectors/PatternInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import json
from typing import Optional

from ..utils import calculate_workload, calculate_per_iteration_workload_of_loop
from ..PETGraphX import LoopNode, Node, NodeID, LineID, PETGraphX
from ..utils import calculate_workload, calculate_per_iteration_workload_of_loop


class PatternInfo(object):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
# This software may be modified and distributed under the terms of
# the 3-Clause BSD License. See the LICENSE file in the package base
# directory for details.
import os.path
from typing import List, Tuple, Dict, Set, Type, Optional
import sys
from typing import List, Tuple, Dict, Set

from discopop_explorer.PETGraphX import EdgeType, CUNode, PETGraphX, NodeID, MemoryRegion
from discopop_explorer.pattern_detectors.PatternInfo import PatternInfo
from discopop_explorer.pattern_detectors.combined_gpu_patterns.classes.Aliases import (
VarName,
)
from discopop_explorer.pattern_detectors.combined_gpu_patterns.classes.Dependency import Dependency
from discopop_explorer.pattern_detectors.combined_gpu_patterns.classes.Enums import (
ExitPointPositioning,
Expand All @@ -18,10 +21,6 @@
EntryPointType,
UpdateType,
)
from discopop_explorer.pattern_detectors.combined_gpu_patterns.classes.Aliases import (
VarName,
)
from discopop_explorer.pattern_detectors.combined_gpu_patterns.classes.Update import Update
from discopop_explorer.pattern_detectors.combined_gpu_patterns.prepare_metadata import (
get_dependencies_as_metadata,
)
Expand All @@ -35,21 +34,21 @@
add_memory_regions_to_device_liveness,
propagate_memory_regions,
convert_liveness,
extend_data_lifespan,
calculate_host_liveness,
)
from discopop_explorer.pattern_detectors.combined_gpu_patterns.step_3 import (
initialize_writes,
propagate_writes,
cleanup_writes,
group_writes_by_cu,
)
from discopop_explorer.pattern_detectors.combined_gpu_patterns.step_4 import (
identify_updates,
create_circle_free_function_graphs,
add_accesses_from_called_functions,
identify_updates_in_unrolled_function_graphs,
)
from discopop_explorer.pattern_detectors.combined_gpu_patterns.step_5 import (
propagate_variable_name_associations,
)
from discopop_explorer.pattern_detectors.combined_gpu_patterns.step_6 import (
convert_updates_to_entry_and_exit_points,
identify_end_of_life_points,
Expand All @@ -58,17 +57,8 @@
remove_duplicates,
join_elements,
)
from discopop_explorer.pattern_detectors.combined_gpu_patterns.utilities import (
prepare_liveness_metadata,
)
from discopop_explorer.pattern_detectors.combined_gpu_patterns.step_5 import (
propagate_variable_name_associations,
)

from discopop_explorer.pattern_detectors.simple_gpu_patterns.GPURegions import GPURegionInfo

import sys


class CombinedGPURegion(PatternInfo):
contained_regions: List[GPURegionInfo]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# the 3-Clause BSD License. See the LICENSE file in the package base
# directory for details.
import os.path
import sys
from typing import Set, Tuple, List

from discopop_explorer.PETGraphX import PETGraphX, NodeID, MemoryRegion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@
# the 3-Clause BSD License. See the LICENSE file in the package base
# directory for details.

import sys
from typing import Set, List, Tuple

from discopop_explorer.PETGraphX import PETGraphX, NodeID
from discopop_explorer.pattern_detectors.combined_gpu_patterns.classes.Aliases import VarName
from discopop_explorer.pattern_detectors.combined_gpu_patterns.classes.Dependency import Dependency
from discopop_explorer.pattern_detectors.combined_gpu_patterns.classes.Enums import (
EntryPointPositioning,
ExitPointPositioning,
)


def get_dependencies_as_metadata(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
# the 3-Clause BSD License. See the LICENSE file in the package base
# directory for details.

import sys
from typing import Dict, List, Tuple, Set, Optional, cast
from typing import Dict, List, Tuple, Set, Optional

from discopop_explorer.PETGraphX import PETGraphX, EdgeType, NodeID, CUNode, MemoryRegion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
# directory for details.

import copy
from typing import Dict, Set, Tuple, Optional, List, cast, Any
import sys
from typing import Dict, Set, Tuple, Optional, List, cast

import networkx as nx # type: ignore
from networkx import NetworkXNoCycle, MultiDiGraph
Expand All @@ -22,8 +23,6 @@
Dependency,
FunctionNode,
)
import sys

from discopop_explorer.pattern_detectors.combined_gpu_patterns.classes.Enums import UpdateType
from discopop_explorer.pattern_detectors.combined_gpu_patterns.classes.Update import Update

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# the 3-Clause BSD License. See the LICENSE file in the package base
# directory for details.

from typing import Dict, Set, cast
from typing import Dict, Set

from discopop_explorer.PETGraphX import PETGraphX, NodeID, MemoryRegion
from discopop_explorer.pattern_detectors.combined_gpu_patterns.classes.Aliases import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# directory for details.
import copy
import sys
import typing
from typing import Set, Tuple, Dict, List, cast, Optional, Union

from networkx import MultiDiGraph # type: ignore
Expand All @@ -24,14 +23,11 @@
from discopop_explorer.pattern_detectors.combined_gpu_patterns.classes.Aliases import (
VarName,
)
from discopop_explorer.pattern_detectors.combined_gpu_patterns.classes.Dependency import Dependency
from discopop_explorer.pattern_detectors.combined_gpu_patterns.classes.EntryPoint import EntryPoint
from discopop_explorer.pattern_detectors.combined_gpu_patterns.classes.Enums import (
UpdateType,
EntryPointType,
ExitPointType,
EntryPointPositioning,
ExitPointPositioning,
)
from discopop_explorer.pattern_detectors.combined_gpu_patterns.classes.ExitPoint import ExitPoint
from discopop_explorer.pattern_detectors.combined_gpu_patterns.classes.Update import Update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from typing import List, Set, Dict, Tuple, Optional

from discopop_explorer.PETGraphX import (
CUNode,
PETGraphX,
EdgeType,
NodeID,
Expand Down
6 changes: 4 additions & 2 deletions discopop_explorer/pattern_detectors/do_all_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
# This software may be modified and distributed under the terms of
# the 3-Clause BSD License. See the LICENSE file in the package base
# directory for details.
from multiprocessing import Pool
from typing import List, Dict, Set, Tuple, cast

from alive_progress import alive_bar # type: ignore

from .PatternInfo import PatternInfo
from ..PETGraphX import (
CUNode,
Expand All @@ -19,9 +22,8 @@
MemoryRegion,
DepType,
)
from ..variable import Variable
from ..utils import classify_loop_variables
from multiprocessing import Pool
from ..variable import Variable


class DoAllInfo(PatternInfo):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
import math
from typing import Dict, List, Tuple, Optional

from alive_progress import alive_bar # type: ignore

from .PatternInfo import PatternInfo
from ..PETGraphX import FunctionNode, LoopNode, NodeID, PETGraphX, NodeType, Node, EdgeType
from ..utils import classify_task_vars, get_child_loops, contains
from ..PETGraphX import FunctionNode, LoopNode, NodeID, PETGraphX, Node, EdgeType
from ..utils import classify_task_vars, get_child_loops
from ..variable import Variable
from alive_progress import alive_bar # type: ignore

__loop_iterations: Dict[NodeID, int] = {}

Expand Down
5 changes: 3 additions & 2 deletions discopop_explorer/pattern_detectors/pipeline_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@


from typing import List, Tuple, Dict, Set

from alive_progress import alive_bar # type: ignore

from .PatternInfo import PatternInfo
from ..PETGraphX import (
CUNode,
LineID,
LoopNode,
NodeID,
PETGraphX,
NodeType,
Node,
EdgeType,
DepType,
Dependency,
)
from ..utils import correlation_coefficient, classify_task_vars, contains
from ..utils import correlation_coefficient, classify_task_vars

__pipeline_threshold = 0.9

Expand Down
5 changes: 3 additions & 2 deletions discopop_explorer/pattern_detectors/reduction_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
# directory for details.


from multiprocessing import Pool
from typing import List, cast

from alive_progress import alive_bar # type: ignore

from .PatternInfo import PatternInfo
Expand All @@ -21,9 +23,8 @@
DepType,
EdgeType,
)
from ..utils import is_reduction_var, classify_loop_variables
from ..variable import Variable
from ..utils import is_reduction_var, classify_loop_variables, contains
from multiprocessing import Pool


class ReductionInfo(PatternInfo):
Expand Down
Loading

0 comments on commit 2872740

Please sign in to comment.