Skip to content
Snippets Groups Projects
Commit 91be1b94 authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

Improve code generation for constants, 'f' vs no trailing 'f', integer vs non-integer.

parent 76de8414
No related branches found
No related tags found
No related merge requests found
......@@ -65,7 +65,6 @@ To-do
- Scalar insn priority
- What to do about constants in codegen? (...f suffix, complex types)
- If finding a maximum proves troublesome, move parameters into the domain
......@@ -123,6 +122,9 @@ Future ideas
Dealt with
^^^^^^^^^^
- What to do about constants in codegen? (...f suffix, complex types)
-> dealt with by type contexts
- relating to Multi-Domain
- Make sure that variables that enter into loop bounds are only written
exactly once. [DONE]
......
......@@ -173,7 +173,7 @@ def wrap_in_for_from_constraints(ccm, iname, constraint_bset, stmt):
from pymbolic import var
rhs += iname_coeff*var(iname)
end_conds.append("%s >= 0" %
ccm(cfm(rhs)))
ccm(cfm(rhs), 'i'))
else: # iname_coeff > 0
kind, bound = solve_constraint_for_bound(cns, iname)
assert kind == ">="
......@@ -205,7 +205,7 @@ def wrap_in_for_from_constraints(ccm, iname, constraint_bset, stmt):
from cgen import For
from loopy.codegen import wrap_in
return wrap_in(For,
"int %s = %s" % (iname, ccm(start_expr)),
"int %s = %s" % (iname, ccm(start_expr, 'i')),
" && ".join(end_conds),
"++%s" % iname,
stmt)
......
This diff is collapsed.
......@@ -12,11 +12,18 @@ def generate_instruction_code(kernel, insn, codegen_state):
expr = insn.expression
from loopy.codegen.expression import perform_cast
expr = perform_cast(ccm, expr, expr_dtype=ccm.infer_type(expr),
target_dtype=kernel.get_var_descriptor(insn.get_assignee_var_name()).dtype)
target_dtype = kernel.get_var_descriptor(insn.get_assignee_var_name()).dtype
expr_dtype = ccm.infer_type(expr)
expr = perform_cast(ccm, expr,
expr_dtype=expr_dtype,
target_dtype=target_dtype)
from cgen import Assign
insn_code = Assign(ccm(insn.assignee), ccm(expr))
from loopy.codegen.expression import dtype_to_type_context
insn_code = Assign(
ccm(insn.assignee, prec=None, type_context=None),
ccm(expr, prec=None, type_context=dtype_to_type_context(target_dtype)))
from loopy.codegen.bounds import wrap_in_bounds_checks
insn_inames = kernel.insn_inames(insn)
insn_code, impl_domain = wrap_in_bounds_checks(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment