Skip to content
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
14 changes: 11 additions & 3 deletions loopy/target/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,18 @@
from pytools.persistent_dict import WriteOncePersistentDict

from loopy.kernel import KernelState, LoopKernel
from loopy.kernel.data import ArrayArg, _ArraySeparationInfo, auto
from loopy.tools import LoopyKeyBuilder, caches
from loopy.types import LoopyType, NumpyType
from loopy.typing import Expression, integer_expr_or_err
from loopy.typing import auto, integer_expr_or_err
from loopy.version import DATA_MODEL_VERSION


if TYPE_CHECKING:
from collections.abc import Callable, Mapping, Sequence
from collections.abc import Callable, Mapping, Sequence, Set

from pymbolic.typing import Expression

from loopy.kernel.data import ArrayArg, _ArraySeparationInfo
from loopy.schedule.tools import KernelArgInfo
from loopy.translation_unit import TranslationUnit

Expand Down Expand Up @@ -306,7 +308,7 @@
except Exception as e:
# went wrong? oh well
from warnings import warn
warn("Unable to generate code to automatically "

Check warning on line 311 in loopy/target/execution.py

View workflow job for this annotation

GitHub Actions / Conda Pytest (macos-latest)

Unable to generate code to automatically find 'im_h' from 'img':

Check warning on line 311 in loopy/target/execution.py

View workflow job for this annotation

GitHub Actions / Conda Pytest (macos-latest)

Unable to generate code to automatically find 'im_h' from 'img':

Check warning on line 311 in loopy/target/execution.py

View workflow job for this annotation

GitHub Actions / Conda Pytest Twice (for cache behavior)

Unable to generate code to automatically find 'im_h' from 'img':
f"find '{unknown_name}' "
f"from '{', '.join(eqn.based_on_names)}':\n"
f"{e}", ParameterFinderWarning, stacklevel=1)
Expand Down Expand Up @@ -766,7 +768,13 @@

.. automethod:: __call__
"""
t_unit: TranslationUnit
packing_controller: SeparateArrayPackingController | None
entrypoint: str
input_array_names: Set[str]
has_runtime_typed_args: bool
separated_entry_knl: LoopKernel
sep_info: dict[str, _ArraySeparationInfo]

def __init__(self, t_unit: TranslationUnit, entrypoint: str):
self.t_unit = t_unit
Expand Down
2 changes: 1 addition & 1 deletion test/test_c_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def test_scalar_global_args():
"res = sum(i, i)",
target=lp.ExecutableCTarget())(n=n)

assert out == (n*(n-1)/2)
assert out == (n*(n-1)/2) # noqa: RUF069
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of suppressing RUF069, consider clarifying the division intent. If integer division is intended, use // operator (n*(n-1)//2). If float division is intended, consider using a float literal (n*(n-1)/2.0) to make the intent explicit.

Suggested change
assert out == (n*(n-1)/2) # noqa: RUF069
assert out == (n*(n-1)//2)

Copilot uses AI. Check for mistakes.


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions test/test_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ def test_all_counters_parallel_matmul():
sync_map = lp.get_synchronization_map(knl)
assert len(sync_map) == 2
assert sync_map.filter_by(kind="kernel_launch").eval_and_sum(params) == 1
assert sync_map.filter_by(kind="barrier_local").eval_and_sum(params) == 2*m/bsize
assert sync_map.filter_by(kind="barrier_local").eval_and_sum(params) == 2*m/bsize # noqa: RUF069
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of suppressing RUF069, consider clarifying the division intent. If integer division is intended, use // operator (2*m//bsize). If float division is intended, consider using a float literal (2.0*m/bsize) to make the intent explicit.

Suggested change
assert sync_map.filter_by(kind="barrier_local").eval_and_sum(params) == 2*m/bsize # noqa: RUF069
assert sync_map.filter_by(kind="barrier_local").eval_and_sum(params) == 2*m//bsize

Copilot uses AI. Check for mistakes.

op_map = lp.get_op_map(knl, subgroup_size=SGS, count_redundant_work=True)
f32mul = op_map[
Expand Down Expand Up @@ -1164,7 +1164,7 @@ def test_all_counters_parallel_matmul():
).eval_and_sum(params)

# (count-per-sub-group)*n_subgroups
assert local_mem_s == m*2/bsize*n_subgroups
assert local_mem_s == m*2/bsize*n_subgroups # noqa: RUF069
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of suppressing RUF069, consider clarifying the division intent. If integer division is intended, use // operator (m*2//bsize*n_subgroups). If float division is intended, consider using a float literal (m*2.0/bsize*n_subgroups) to make the intent explicit.

Suggested change
assert local_mem_s == m*2/bsize*n_subgroups # noqa: RUF069
assert local_mem_s == m*2//bsize*n_subgroups

Copilot uses AI. Check for mistakes.


def test_floor_div_coefficient_collector():
Expand Down
8 changes: 4 additions & 4 deletions test/test_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def test_tuple(ctx_factory: cl.CtxFactory):
_evt, (a, b) = knl(queue)

assert a.get() == 1
assert b.get() == 2.
assert b.get() == 2. # noqa: RUF069
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of suppressing RUF069, consider fixing the float literal. Replace 2. with 2.0 for better readability and clarity. The RUF069 rule exists to ensure float literals are written in a clear, consistent style.

Copilot uses AI. Check for mistakes.


def test_clamp(ctx_factory: cl.CtxFactory):
Expand Down Expand Up @@ -334,7 +334,7 @@ def test_pyopencl_execution_numpy_handling(ctx_factory: cl.CtxFactory):
x = np.array([4.])
_evt, out = knl(queue, y=y, x=x)
assert out[0] is x
assert x[0] == 7.
assert x[0] == 7. # noqa: RUF069
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of suppressing RUF069, consider fixing the float literal. Replace 7. with 7.0 for better readability and clarity. The RUF069 rule exists to ensure float literals are written in a clear, consistent style.

Copilot uses AI. Check for mistakes.

# test numpy input for x is written to and returned, even when a pyopencl array
# is passed for y
Expand All @@ -343,7 +343,7 @@ def test_pyopencl_execution_numpy_handling(ctx_factory: cl.CtxFactory):
x = np.array([4.])
_evt, out = knl(queue, y=y, x=x)
assert out[0] is x
assert x[0] == 7.
assert x[0] == 7. # noqa: RUF069
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of suppressing RUF069, consider fixing the float literal. Replace 7. with 7.0 for better readability and clarity. The RUF069 rule exists to ensure float literals are written in a clear, consistent style.

Copilot uses AI. Check for mistakes.

# test numpy input for x is written to and returned, even when output-only
knl = lp.make_kernel("{:}", ["x[0] = y[0] + 2"])
Expand All @@ -352,7 +352,7 @@ def test_pyopencl_execution_numpy_handling(ctx_factory: cl.CtxFactory):
x = np.array([4.])
_evt, out = knl(queue, y=y, x=x)
assert out[0] is x
assert x[0] == 5.
assert x[0] == 5. # noqa: RUF069
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of suppressing RUF069, consider fixing the float literal. Replace 5. with 5.0 for better readability and clarity. The RUF069 rule exists to ensure float literals are written in a clear, consistent style.

Copilot uses AI. Check for mistakes.


def test_opencl_support_for_bool(ctx_factory: cl.CtxFactory):
Expand Down
Loading