Skip to content
Open
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased
- Fixed `run_kernel` with Julia kernels when `grid_div_x/y/z` are passed as Julia vectors.
- `block_size_names` can be passed as a tuple, and the list passed in is no longer modified.

## [1.6.0] - 2026-11-13
- Extended Julia functionality:
Expand Down
7 changes: 5 additions & 2 deletions kernel_tuner/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ def tune_kernel(
block_size_names = util.check_block_size_params_names_list(block_size_names, tune_params)

# ensure there is always at least three names
util.append_default_block_size_names(block_size_names)
block_size_names = util.append_default_block_size_names(block_size_names)

# if Julia, infer the Julia backend from the kernelsource
if kernelsource.lang.upper() == "JULIA":
Expand Down Expand Up @@ -976,9 +976,12 @@ def run_kernel(
params = util.julia_list_of_pairs_to_dict(params)
# convert scalars without explicit types to numpy scalars
arguments = [numpy.array(a)[()] if numpy.isscalar(a) else a for a in arguments]
grid_div_x = util.possible_julia_vector_to_list(grid_div_x)
grid_div_y = util.possible_julia_vector_to_list(grid_div_y)
grid_div_z = util.possible_julia_vector_to_list(grid_div_z)
block_size_names = util.possible_julia_vector_to_list(block_size_names)
# ensure there is always at least three names
util.append_default_block_size_names(block_size_names)
block_size_names = util.append_default_block_size_names(block_size_names)

_check_user_input(kernel_name, kernelsource, arguments, block_size_names)

Expand Down
13 changes: 8 additions & 5 deletions kernel_tuner/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def check_tune_params_list(tune_params, observers, simulation_mode=False):
def check_block_size_names(block_size_names):
if block_size_names is not None:
# do some type checks for the user input
if not isinstance(block_size_names, list):
if not isinstance(block_size_names, (list, tuple)):
raise ValueError("block_size_names should be a list of strings!", block_size_names, type(block_size_names))
if len(block_size_names) > 3:
raise ValueError("block_size_names should not contain more than 3 names!", block_size_names)
Expand All @@ -421,11 +421,14 @@ def check_block_size_names(block_size_names):


def append_default_block_size_names(block_size_names):
"""Returns the block size names as a new list, padded with the default names to at least three names.

Any sequence is accepted (e.g. a tuple, or a Julia vector), and the one passed in is not modified.
"""
if block_size_names is None:
return
for i, name in enumerate(default_block_size_names):
if len(block_size_names) < i + 1:
block_size_names.append(name)
return None
block_size_names = list(block_size_names)
return block_size_names + default_block_size_names[len(block_size_names) :]


def check_block_size_params_names_list(block_size_names, tune_params):
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
[project]
name = "kernel_tuner"
description = "An easy to use CUDA/OpenCL kernel tuner in Python"
version = "1.6.0" # adhere to PEP440 versioning: https://packaging.python.org/en/latest/guides/distributing-packages-using-setuptools/#id55
version = "1.6.1" # adhere to PEP440 versioning: https://packaging.python.org/en/latest/guides/distributing-packages-using-setuptools/#id55
readme = "README.md"
license = "Apache-2.0"
authors = [
Expand Down Expand Up @@ -162,4 +162,4 @@ select = [
"D", # pydocstyle,
]
[tool.ruff.lint.pydocstyle]
convention = "google"
convention = "google"
12 changes: 12 additions & 0 deletions test/test_util_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,18 @@ def test_check_tune_params_list3():
check_tune_params_list(tune_params, [])


def test_append_default_block_size_names():
assert append_default_block_size_names(None) is None
assert append_default_block_size_names([]) == ["block_size_x", "block_size_y", "block_size_z"]
# a tuple is accepted as well, and the names passed in are not modified
names = ("bx",)
assert append_default_block_size_names(names) == ["bx", "block_size_y", "block_size_z"]
names = ["bx", "by"]
assert append_default_block_size_names(names) == ["bx", "by", "block_size_z"]
assert names == ["bx", "by"]
assert append_default_block_size_names(["bx", "by", "bz", "bw"]) == ["bx", "by", "bz", "bw"]


def test_check_block_size_params_names_list():
def test_warnings(function, args, number, warning_type):
with warnings.catch_warnings(record=True) as w:
Expand Down
Loading