Skip to content

Commit 3b622f4

Browse files
avoid using multiple workers when strategy is not parallel
1 parent 58d07d5 commit 3b622f4

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

kernel_tuner/interface.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"adaptive_tabu_greywolf": "kernel_tuner.strategies.gen_adaptive_tabu_greywolf",
7777
}
7878

79+
_STRATEGY_PARALLEL = ["brute_force", "random_sample", "diff_evo", "genetic_algorithm", "pso", "firefly_algorithm"]
7980

8081
def _strategy_import_error(strategy_name, module_path, err):
8182
base_msg = (
@@ -704,6 +705,9 @@ def tune_kernel(
704705
from kernel_tuner.runners.simulation import SimulationRunner
705706
runner = SimulationRunner(kernelsource, kernel_options, device_options, iterations, observers)
706707
elif parallel:
708+
# Avoid using multiple workers on strategies not supporting parallelism
709+
if strategy not in _STRATEGY_PARALLEL:
710+
parallel = 1
707711
from kernel_tuner.runners.parallel import ParallelRunner
708712
num_workers = None if parallel is True else parallel
709713
runner = ParallelRunner(kernelsource, kernel_options, device_options, tuning_options, iterations, observers, num_workers=num_workers)

0 commit comments

Comments
 (0)