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
1,584 changes: 72 additions & 1,512 deletions .basedpyright/baseline.json

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions contrib/c-integer-semantics.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

import ctypes
from os import system

Expand Down
2 changes: 1 addition & 1 deletion contrib/mem-pattern-explorer/pattern_vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def nsubgroups(self):
return div_ceil(product(self.lsize), self.subgroup_size)

def animate(self, f, interval=200):
import matplotlib.animation as animation
import matplotlib.pyplot as plt
from matplotlib import animation

fig = plt.figure()

Expand Down
2 changes: 1 addition & 1 deletion examples/fortran/matmul-driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pyopencl as cl
import pyopencl.array as cla
import pyopencl.clrandom as clrandom
from pyopencl import clrandom

import loopy as lp

Expand Down
1 change: 0 additions & 1 deletion examples/python/call-external.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def emit_call_insn(self, insn, target, expression_to_code_mapper):
def generate_preambles(self, target):
assert isinstance(target, CTarget)
yield ("99_cblas", "#include <cblas.h>")
return

# }}}

Expand Down
7 changes: 2 additions & 5 deletions examples/python/ispc-stream-harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ def transform(knl, vars, stream_dtype):

knl = lp.add_and_infer_dtypes(knl, dict.fromkeys(vars, stream_dtype))

knl = lp.set_argument_order(knl, [*vars, "n"])

return knl
return lp.set_argument_order(knl, [*vars, "n"])


def gen_code(knl):
Expand Down Expand Up @@ -67,8 +65,7 @@ def make_knl(name, insn, vars):
target=lp.ISPCTarget(), index_dtype=INDEX_DTYPE,
name="stream_"+name+"_tasks")

knl = transform(knl, vars, STREAM_DTYPE)
return knl
return transform(knl, vars, STREAM_DTYPE)

init_knl = make_knl("init", """
a[i] = 1
Expand Down
6 changes: 3 additions & 3 deletions loopy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ def main():
if args.occa_defines:
with open(args.occa_defines) as defines_fd:
occa_define_code = defines_to_python_code(defines_fd.read())
exec(compile(occa_define_code, args.occa_defines, "exec"), data_dic)
exec(compile(occa_define_code, args.occa_defines, "exec"), data_dic) # noqa: S102

with open(args.infile) as infile_fd:
exec(compile(infile_content, args.infile, "exec"), data_dic)
exec(compile(infile_content, args.infile, "exec"), data_dic) # noqa: S102

if args.transform:
with open(args.transform) as xform_fd:
exec(compile(xform_fd.read(),
exec(compile(xform_fd.read(), # noqa: S102
args.transform, "exec"), data_dic)

try:
Expand Down
16 changes: 12 additions & 4 deletions loopy/codegen/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@


if TYPE_CHECKING:
from collections.abc import Callable, Collection, Hashable, Sequence, Set
from collections.abc import (
Callable,
Collection,
Hashable,
Sequence,
Set as AbstractSet,
)

from pymbolic import Expression

Expand Down Expand Up @@ -288,9 +294,9 @@ def build_loop_nest(
@dataclass(frozen=True)
class ScheduleIndexInfo:
schedule_indices: Sequence[int]
admissible_cond_inames: Set[InameStr]
admissible_cond_inames: AbstractSet[InameStr]
required_predicates: frozenset[Expression]
used_inames_within: Set[InameStr]
used_inames_within: AbstractSet[InameStr]

from loopy.codegen.bounds import get_usable_inames_for_conditional
from loopy.schedule import find_used_inames_within
Expand Down Expand Up @@ -388,7 +394,9 @@ def build_insn_group(
bounds_check_cache = BoundsCheckCache(
kernel, codegen_state.implemented_domain)

found_hoists: list[tuple[int, Sequence[isl.Constraint], Set[Expression]]] = []
found_hoists: list[
tuple[int, Sequence[isl.Constraint], AbstractSet[Expression]]
] = []

candidate_group_length = 1
while candidate_group_length <= len(sched_index_info_entries):
Expand Down
4 changes: 2 additions & 2 deletions loopy/codegen/instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@


if TYPE_CHECKING:
from collections.abc import Collection, Set
from collections.abc import Collection, Set as AbstractSet

from pymbolic import Expression

Expand Down Expand Up @@ -75,7 +75,7 @@ def to_codegen_result(
insn_id: InsnId,
domain: isl.BasicSet,
check_inames: Collection[str],
required_preds: Set[Expression],
required_preds: AbstractSet[Expression],
ast: ASTType
) -> CodeGenerationResult[ASTType] | None:
chk_domain = isl.Set.from_basic_set(domain)
Expand Down
1 change: 0 additions & 1 deletion loopy/diagnostic.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ class ExpressionNotAffineError(LoopyError):
`ISL manual <http://isl.gforge.inria.fr//user.html#Primitive-Functions>`_
for then definition of a quasi-affine expression.
"""
pass


class ExpressionToAffineConversionError(LoopyError):
Expand Down
8 changes: 3 additions & 5 deletions loopy/frontend/fortran/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ def c_preprocess(source, defines=None, filename=None, include_paths=None):
:return: a string
"""
try:
import ply.cpp as cpp
import ply.lex as lex
from ply import cpp, lex
except ImportError as err:
raise LoopyError(
"Using the C preprocessor requires PLY to be installed") from err
Expand Down Expand Up @@ -226,11 +225,11 @@ def parse_transformed_fortran(source, free_form=True, strict=True,

if pre_transform_code is not None:
proc_dict["_MODULE_SOURCE_CODE"] = pre_transform_code
exec(compile(pre_transform_code,
exec(compile(pre_transform_code, # noqa: S102
"<loopy pre-transform code>", "exec"), proc_dict)

proc_dict["_MODULE_SOURCE_CODE"] = transform_code
exec(compile(transform_code, filename, "exec"), proc_dict)
exec(compile(transform_code, filename, "exec"), proc_dict) # noqa: S102

finally:
sys.path = prev_sys_path
Expand Down Expand Up @@ -291,7 +290,6 @@ def _add_assignees_to_calls(knl, all_kernels):
insn.expression.function.name)(*new_params)))
else:
new_insns.append(insn)
pass
elif isinstance(insn, (Assignment, CInstruction,
_DataObliviousInstruction)):
new_insns.append(insn)
Expand Down
22 changes: 11 additions & 11 deletions loopy/frontend/fortran/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ def tuple_to_complex_literal(expr):

class FortranExpressionParser(ExpressionParserBase):
lex_table: ClassVar[LexTable] = [
(_less_than, pytools.lex.RE(r"\.lt\.", re.I)),
(_greater_than, pytools.lex.RE(r"\.gt\.", re.I)),
(_less_equal, pytools.lex.RE(r"\.le\.", re.I)),
(_greater_equal, pytools.lex.RE(r"\.ge\.", re.I)),
(_equal, pytools.lex.RE(r"\.eq\.", re.I)),
(_not_equal, pytools.lex.RE(r"\.ne\.", re.I)),

(_not, pytools.lex.RE(r"\.not\.", re.I)),
(_and, pytools.lex.RE(r"\.and\.", re.I)),
(_or, pytools.lex.RE(r"\.or\.", re.I)),
(_less_than, pytools.lex.RE(r"\.lt\.", re.IGNORECASE)),
(_greater_than, pytools.lex.RE(r"\.gt\.", re.IGNORECASE)),
(_less_equal, pytools.lex.RE(r"\.le\.", re.IGNORECASE)),
(_greater_equal, pytools.lex.RE(r"\.ge\.", re.IGNORECASE)),
(_equal, pytools.lex.RE(r"\.eq\.", re.IGNORECASE)),
(_not_equal, pytools.lex.RE(r"\.ne\.", re.IGNORECASE)),

(_not, pytools.lex.RE(r"\.not\.", re.IGNORECASE)),
(_and, pytools.lex.RE(r"\.and\.", re.IGNORECASE)),
(_or, pytools.lex.RE(r"\.or\.", re.IGNORECASE)),
*ExpressionParserBase.lex_table,
]

Expand Down Expand Up @@ -153,7 +153,7 @@ def parse_terminal(self, pstate):
}

def parse_prefix(self, pstate, min_precedence=0):
import pymbolic.primitives as primitives
from pymbolic import primitives
from pymbolic.parser import _PREC_UNARY

pstate.expect_not_end()
Expand Down
4 changes: 1 addition & 3 deletions loopy/frontend/fortran/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,7 @@ def process_expression_for_loopy(self, expr):
expr = submap(expr)

subshift = SubscriptIndexAdjuster(self)
expr = subshift(expr)

return expr
return subshift(expr)

def written_vars(self):
return frozenset().union(*(insn.write_dependency_names()
Expand Down
Loading
Loading