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

Add transform-arg-to-image.

parent 5eedbe24
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,16 @@ To-do
- Make tests run on GPUs
- Streamline arg
- Fix timer / call code
- variant_prefetch_fields in test_dg
- make sure simple side effects in global work
- syntax for linear array access
Fixes:
- Group instructions by dependency/inames for scheduling, to
......@@ -62,6 +72,8 @@ Fixes:
Future ideas
^^^^^^^^^^^^
- Put all OpenCL functions into mangler
- Fuse: store/fetch elimination?
- Expose iname-duplicate-and-rename as a primitive.
......
......@@ -168,8 +168,8 @@ Dealing with Substitution Rules
.. autofunction:: expand_subst
Precomputation and Prefetching
------------------------------
Caching, Precomputation and Prefetching
---------------------------------------
.. autofunction:: precompute
......@@ -177,6 +177,8 @@ Precomputation and Prefetching
Uses :func:`extract_subst` and :func:`precompute`.
.. autofunction:: change_arg_to_image
Padding
-------
......
......@@ -609,6 +609,22 @@ def add_dependency(kernel, insn_match, dependency):
# }}}
# {{{ change variable kinds
def change_arg_to_image(knl, name):
new_args = []
for arg in knl.args:
if arg.name == name:
assert arg.offset == 0
assert arg.shape is not None
new_args.append(ImageArg(arg.name, dtype=arg.dtype, shape=arg.shape))
else:
new_args.append(arg)
return knl.copy(args=new_args)
# }}}
......
......@@ -198,30 +198,33 @@ class ConstantArg(_ShapedArg):
return "<ConstantArg '%s' of type %s and shape (%s)>" % (
self.name, self.dtype, ",".join(str(i) for i in self.shape))
class ImageArg(object):
class ImageArg(Record):
def __init__(self, name, dtype, dimensions=None, shape=None):
self.name = name
self.dtype = np.dtype(dtype)
dtype = np.dtype(dtype)
if shape is not None:
if dimensions is not None:
raise RuntimeError("cannot specify both shape and dimensions "
"in ImageArg")
self.dimensions = len(shape)
self.shape = shape
if dimensions is not None and dimensions != len(shape):
raise RuntimeError("cannot specify both shape and "
"disagreeing dimensions in ImageArg")
dimensions = len(shape)
else:
if not isinstance(dimensions, int):
raise RuntimeError("ImageArg: dimensions must be an integer")
self.dimensions = dimensions
Record.__init__(self,
dimensions=dimensions,
shape=shape,
dtype=dtype,
name=name)
def __repr__(self):
return "<ImageArg '%s' of type %s>" % (self.name, self.dtype)
class ValueArg(object):
class ValueArg(Record):
def __init__(self, name, dtype, approximately=None):
self.name = name
self.dtype = np.dtype(dtype)
self.approximately = approximately
Record.__init__(self, name=name, dtype=np.dtype(dtype),
approximately=approximately)
def __repr__(self):
return "<ValueArg '%s' of type %s>" % (self.name, self.dtype)
......
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