Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup(optimizer): verbose: show warnings for missing overhead models #485

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion discopop_library/discopop_optimizer/Variables/Experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from discopop_library.MemoryRegions.utils import get_sizes_of_memory_regions
from discopop_library.PathManagement.PathManagement import load_file_mapping
from discopop_library.discopop_optimizer.CostModels.CostModel import CostModel
from discopop_library.discopop_optimizer.OptimizerArguments import OptimizerArguments
from discopop_library.discopop_optimizer.classes.context.ContextObject import ContextObject
from discopop_library.discopop_optimizer.classes.enums.Distributions import FreeSymbolDistribution
from discopop_library.discopop_optimizer.classes.nodes.FunctionRoot import FunctionRoot
Expand Down Expand Up @@ -60,6 +61,8 @@ class Experiment(object):

file_mapping: Dict[int, Path] # file-mapping

arguments: OptimizerArguments

detection_result: DetectionResult

function_models: Dict[FunctionRoot, List[Tuple[CostModel, ContextObject, str]]]
Expand All @@ -70,10 +73,16 @@ class Experiment(object):
suggestion_to_node_ids_dict: Dict[int, List[int]]

def __init__(
self, file_mapping: Dict[int, Path], system: System, detection_result: DetectionResult, profiler_dir: str
self,
file_mapping: Dict[int, Path],
system: System,
detection_result: DetectionResult,
profiler_dir: str,
arguments: OptimizerArguments,
):
self.__system = system
self.detection_result = detection_result
self.arguments = arguments

self.__memory_region_sizes = get_sizes_of_memory_regions(
set(),
Expand Down
20 changes: 12 additions & 8 deletions discopop_library/discopop_optimizer/classes/system/System.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,27 @@ def __build_GPU(self, device_configuration: Dict[str, Any]):
)
self.add_device(gpu, device_configuration["device_id"])

def set_device_doall_overhead_model(self, device: Device, model: Expr):
print("System: Set DOALL overhead model: ", model)
def set_device_doall_overhead_model(self, device: Device, model: Expr, arguments: OptimizerArguments):
if arguments.verbose:
print("System: Set DOALL overhead model: ", model)
self.__device_do_all_overhead_models[device] = model

def set_reduction_overhead_model(self, device: Device, model: Expr):
print("System: Set REDUCTION overhead model: ", model)
def set_reduction_overhead_model(self, device: Device, model: Expr, arguments: OptimizerArguments):
if arguments.verbose:
print("System: Set REDUCTION overhead model: ", model)
self.__device_reduction_overhead_models[device] = model

def get_device_doall_overhead_model(self, device: Device) -> Expr:
def get_device_doall_overhead_model(self, device: Device, arguments: OptimizerArguments) -> Expr:
if device not in self.__device_do_all_overhead_models:
warnings.warn("No DOALL overhead model, assuming 0 for device: " + str(device))
if arguments.verbose:
warnings.warn("No DOALL overhead model, assuming 0 for device: " + str(device))
return Expr(Integer(0))
return self.__device_do_all_overhead_models[device]

def get_device_reduction_overhead_model(self, device: Device) -> Expr:
def get_device_reduction_overhead_model(self, device: Device, arguments: OptimizerArguments) -> Expr:
if device not in self.__device_reduction_overhead_models:
warnings.warn("No REDUCTION overhead model, assuming 0 for device: " + str(device))
if arguments.verbose:
warnings.warn("No REDUCTION overhead model, assuming 0 for device: " + str(device))
return Expr(Integer(0))
return self.__device_reduction_overhead_models[device]

Expand Down
4 changes: 3 additions & 1 deletion discopop_library/discopop_optimizer/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def run(arguments: OptimizerArguments):
system.set_device_doall_overhead_model(
system.get_device(system.get_host_device_id()),
ExtrapInterpolatedMicrobench(arguments.doall_microbench_file).getFunctionSympy(),
arguments,
)
if arguments.reduction_microbench_file != "None":
# construct and set overhead model for reduction suggestions
Expand All @@ -130,10 +131,11 @@ def run(arguments: OptimizerArguments):
ExtrapInterpolatedMicrobench(arguments.reduction_microbench_file).getFunctionSympy(
benchType=MicrobenchType.FOR
),
arguments,
)

# define Experiment
experiment = Experiment(file_mapping, system, detection_result, profiler_dir)
experiment = Experiment(file_mapping, system, detection_result, profiler_dir, arguments)

# build optimization graph
if arguments.verbose:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def get_overhead_term(node_data: Loop, environment: Experiment, device_id: int)
unit of the overhead term are micro seconds."""
# retrieve DoAll overhead model
overhead_model = environment.get_system().get_device_doall_overhead_model(
environment.get_system().get_device(device_id)
environment.get_system().get_device(device_id), environment.arguments
)
# substitute workload, iterations and threads
thread_count = environment.get_system().get_device(device_id).get_thread_count()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def get_overhead_term(node_data: Loop, environment: Experiment, device_id: int)

# retrieve Reduction overhead model
overhead_model = environment.get_system().get_device_reduction_overhead_model(
environment.get_system().get_device(device_id)
environment.get_system().get_device(device_id), environment.arguments
)
# substitute workload, iterations and threads
thread_count = environment.get_system().get_device(device_id).get_thread_count()
Expand Down