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 ...@@ -49,6 +49,16 @@ To-do
- Make tests run on GPUs - 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: Fixes:
- Group instructions by dependency/inames for scheduling, to - Group instructions by dependency/inames for scheduling, to
...@@ -62,6 +72,8 @@ Fixes: ...@@ -62,6 +72,8 @@ Fixes:
Future ideas Future ideas
^^^^^^^^^^^^ ^^^^^^^^^^^^
- Put all OpenCL functions into mangler
- Fuse: store/fetch elimination? - Fuse: store/fetch elimination?
- Expose iname-duplicate-and-rename as a primitive. - Expose iname-duplicate-and-rename as a primitive.
......
...@@ -168,8 +168,8 @@ Dealing with Substitution Rules ...@@ -168,8 +168,8 @@ Dealing with Substitution Rules
.. autofunction:: expand_subst .. autofunction:: expand_subst
Precomputation and Prefetching Caching, Precomputation and Prefetching
------------------------------ ---------------------------------------
.. autofunction:: precompute .. autofunction:: precompute
...@@ -177,6 +177,8 @@ Precomputation and Prefetching ...@@ -177,6 +177,8 @@ Precomputation and Prefetching
Uses :func:`extract_subst` and :func:`precompute`. Uses :func:`extract_subst` and :func:`precompute`.
.. autofunction:: change_arg_to_image
Padding Padding
------- -------
......
...@@ -609,6 +609,22 @@ def add_dependency(kernel, insn_match, dependency): ...@@ -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): ...@@ -198,30 +198,33 @@ class ConstantArg(_ShapedArg):
return "<ConstantArg '%s' of type %s and shape (%s)>" % ( return "<ConstantArg '%s' of type %s and shape (%s)>" % (
self.name, self.dtype, ",".join(str(i) for i in self.shape)) 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): def __init__(self, name, dtype, dimensions=None, shape=None):
self.name = name dtype = np.dtype(dtype)
self.dtype = np.dtype(dtype)
if shape is not None: if shape is not None:
if dimensions is not None: if dimensions is not None and dimensions != len(shape):
raise RuntimeError("cannot specify both shape and dimensions " raise RuntimeError("cannot specify both shape and "
"in ImageArg") "disagreeing dimensions in ImageArg")
self.dimensions = len(shape) dimensions = len(shape)
self.shape = shape
else: else:
if not isinstance(dimensions, int): if not isinstance(dimensions, int):
raise RuntimeError("ImageArg: dimensions must be an integer") 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): def __repr__(self):
return "<ImageArg '%s' of type %s>" % (self.name, self.dtype) return "<ImageArg '%s' of type %s>" % (self.name, self.dtype)
class ValueArg(object): class ValueArg(Record):
def __init__(self, name, dtype, approximately=None): def __init__(self, name, dtype, approximately=None):
self.name = name Record.__init__(self, name=name, dtype=np.dtype(dtype),
self.dtype = np.dtype(dtype) approximately=approximately)
self.approximately = approximately
def __repr__(self): def __repr__(self):
return "<ValueArg '%s' of type %s>" % (self.name, self.dtype) 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