Skip to content

Commit 20f7937

Browse files
committed
Have a base class for runners.
1 parent a8beb0c commit 20f7937

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

kernel_tuner/runners/runner.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""This module contains the interface for runners."""
2+
from __future__ import print_function
3+
4+
from abc import ABC, abstractmethod
5+
6+
class Runner(ABC):
7+
"""Base class for kernel_tuner runners"""
8+
@abstractmethod
9+
def __init__(self, kernel_source, kernel_options, device_options, iterations, observers):
10+
pass
11+
12+
@abstractmethod
13+
def get_environment(self):
14+
pass
15+
16+
@abstractmethod
17+
def run(self, parameter_space, tuning_options):
18+
pass

kernel_tuner/runners/sequential.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
from kernel_tuner.core import DeviceInterface
88
from kernel_tuner.util import (ErrorConfig, print_config_output,
99
process_metrics, store_cache)
10+
from kernel_tuner.runners.runner import Runner
1011

1112

12-
class SequentialRunner:
13+
class SequentialRunner(Runner):
1314
""" SequentialRunner is used for tuning with a single process/thread """
1415

1516
def __init__(self, kernel_source, kernel_options, device_options, iterations, observers):

kernel_tuner/runners/simulation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from time import perf_counter
55

66
from kernel_tuner import util
7+
from kernel_tuner.runners.runner import Runner
78

89
_SimulationDevice = namedtuple("_SimulationDevice", ["max_threads", "env", "quiet"])
910

@@ -25,7 +26,7 @@ def get_environment(self):
2526
return self.env
2627

2728

28-
class SimulationRunner:
29+
class SimulationRunner(Runner):
2930
""" SimulationRunner is used for tuning with a single process/thread """
3031

3132
def __init__(self, kernel_source, kernel_options, device_options, iterations, observers):

0 commit comments

Comments
 (0)