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

Merge branch 'master' of tuck.ath.cx:src/pyopencl

Conflicts:
	doc/source/misc.rst
parents 3cccc6c0 0755d8a4
No related branches found
No related tags found
No related merge requests found
...@@ -604,6 +604,19 @@ Here's a usage example:: ...@@ -604,6 +604,19 @@ Here's a usage example::
assert (dev_data.get() == np.cumsum(host_data, axis=0)).all() assert (dev_data.get() == np.cumsum(host_data, axis=0)).all()
Custom data types in Reduction and Scan
---------------------------------------
If you would like to use your own (struct/union/whatever) data types in
scan and reduction, define those types in the *preamble* and let PyOpenCL
know about them using this function:
.. function:: pyopencl.tools.register_dtype(dtype, name)
*dtype* is a :func:`numpy.dtype`.
.. versionadded: 2011.2
Fast Fourier Transforms Fast Fourier Transforms
----------------------- -----------------------
......
...@@ -90,6 +90,7 @@ Version 2011.2 ...@@ -90,6 +90,7 @@ Version 2011.2
* Add :class:`pyopencl.NannyEvent` objects. * Add :class:`pyopencl.NannyEvent` objects.
* Add :mod:`pyopencl.characterize`. * Add :mod:`pyopencl.characterize`.
* Ensure compatibility with OS X Lion. * Ensure compatibility with OS X Lion.
* Add :func:`pyopencl.tools.register_dtype` to enable scan/reduction on struct types.
.. * Beta support for OpenCL 1.2. .. * Beta support for OpenCL 1.2.
......
...@@ -225,7 +225,11 @@ def get_reduction_kernel(stage, ...@@ -225,7 +225,11 @@ def get_reduction_kernel(stage,
map_expr = "in[i]" map_expr = "in[i]"
if stage == 2: if stage == 2:
arguments = "__global const %s *in" % out_type in_arg = "__global const %s *in" % out_type
if arguments:
arguments = in_arg + ", " + arguments
else:
arguments = in_arg
inf = get_reduction_source( inf = get_reduction_source(
ctx, out_type, out_type_size, ctx, out_type, out_type_size,
...@@ -311,6 +315,8 @@ class ReductionKernel: ...@@ -311,6 +315,8 @@ class ReductionKernel:
if kwargs: if kwargs:
raise TypeError("invalid keyword argument to reduction kernel") raise TypeError("invalid keyword argument to reduction kernel")
stage1_args = args
while True: while True:
invocation_args = [] invocation_args = []
vectors = [] vectors = []
...@@ -363,7 +369,7 @@ class ReductionKernel: ...@@ -363,7 +369,7 @@ class ReductionKernel:
return result return result
else: else:
stage_inf = self.stage_2_inf stage_inf = self.stage_2_inf
args = [result] args = (result,) + stage1_args
......
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