Skip to content
Snippets Groups Projects
Commit 0a7c4263 authored by Kaushik Kulkarni's avatar Kaushik Kulkarni
Browse files

Checked that the functions are scoped.

parent 47a73915
No related branches found
No related tags found
2 merge requests!426Discussion: kernel_callables_v3-edit2,!246WIP: Kernel Callables
......@@ -37,6 +37,8 @@ from loopy.version import DATA_MODEL_VERSION
from loopy.kernel.data import make_assignment
# for the benefit of loopy.statistics, for now
from loopy.type_inference import infer_unknown_types
from pymbolic.primitives import Variable
from pymbolic.mapper import Collector
import logging
logger = logging.getLogger(__name__)
......@@ -2097,6 +2099,29 @@ def check_atomic_loads(kernel):
# }}}
# {{{ check for unscoped calls
class UnScopedCallCollector(Collector):
def map_call(self, expr):
if isinstance(expr.function, Variable):
return set([expr.function.name])
else:
return set()
def check_function_are_scoped(kernel):
""" Checks if all the calls in the instruction expression have been scoped,
otherwise indicate to what all calls we await signature.
"""
for insn in kernel.instructions:
unscoped_calls = UnScopedCallCollector()(insn.expression)
if unscoped_calls:
raise LoopyError("Unknown function obtained %s -- register a function"
" or a kernel corresponding to it." % unscoped_calls[0])
# }}}
preprocess_cache = WriteOncePersistentDict(
"loopy-preprocess-cache-v2-"+DATA_MODEL_VERSION,
key_builder=LoopyKeyBuilder())
......@@ -2146,6 +2171,10 @@ def preprocess_kernel(kernel, device=None):
from loopy.transform.subst import expand_subst
kernel = expand_subst(kernel)
# Checking if all the functions being used in the kernel and scoped to a
# finite namespace
check_function_are_scoped(kernel)
# Ordering restriction:
# Type inference and reduction iname uniqueness don't handle substitutions.
# Get them out of the way.
......
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