Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pyopencl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Klöckner
pyopencl
Commits
a3435606
Commit
a3435606
authored
14 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
Document reductions.
parent
7d5f9365
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
doc/source/array.rst
+79
-7
79 additions, 7 deletions
doc/source/array.rst
doc/source/misc.rst
+5
-2
5 additions, 2 deletions
doc/source/misc.rst
pyopencl/reduction.py
+1
-1
1 addition, 1 deletion
pyopencl/reduction.py
with
85 additions
and
10 deletions
doc/source/array.rst
+
79
−
7
View file @
a3435606
...
...
@@ -161,8 +161,41 @@ Conditionals
Return the elementwise minimum of *a* and *b*. (added in 0.94)
.. _reductions:
Reductions
^^^^^^^^^^
.. function:: sum(a, dtype=None, stream=None)
.. versionadded: 2011.1
.. function:: dot(a, b, dtype=None, stream=None)
.. versionadded: 2011.1
.. function:: subset_dot(subset, a, b, dtype=None, stream=None)
.. versionadded: 2011.1
.. function:: max(a, stream=None)
.. versionadded: 2011.1
.. function:: min(a, stream=None)
.. versionadded: 2011.1
.. function:: subset_max(subset, a, stream=None)
.. versionadded: 2011.1
.. function:: subset_min(subset, a, stream=None)
.. versionadded: 2011.1
Elementwise Functions on :class:`Arrray` Instances
--------------------------------------------------
---
--------------------------------------------------
.. module:: pyopencl.clmath
...
...
@@ -284,12 +317,6 @@ Generating Arrays of Random Numbers
Single-pass Custom Expression Evaluation
----------------------------------------
.. warning::
The following functionality is included in this documentation in the
hope that it may be useful, but its interface may change in future
revisions. Feedback is welcome.
.. module:: pyopencl.elementwise
Evaluating involved expressions on :class:`pyopencl.array.Array` instances can be
...
...
@@ -351,6 +378,51 @@ Here's a usage example::
(You can find this example as :file:`examples/demo_elementwise.py` in the PyOpenCL
distribution.)
Custom Reductions
-----------------
.. module:: pycuda.reduction
.. class:: ReductionKernel(ctx, dtype_out, neutral, reduce_expr, map_expr=None, arguments=None, name="reduce_kernel", options="", preamble="")
Generate a kernel that takes a number of scalar or vector *arguments*
(at least one vector argument), performs the *map_expr* on each entry of
the vector argument and then the *reduce_expr* on the outcome of that.
*neutral* serves as an initial value. *preamble* offers the possibility
to add preprocessor directives and other code (such as helper functions)
to be added before the actual reduction kernel code.
Vectors in *map_expr* should be indexed by the variable *i*. *reduce_expr*
uses the formal values "a" and "b" to indicate two operands of a binary
reduction operation. If you do not specify a *map_expr*, "in[i]" -- and
therefore the presence of only one input argument -- is automatically
assumed.
*dtype_out* specifies the :class:`numpy.dtype` in which the reduction is
performed and in which the result is returned. *neutral* is
specified as float or integer formatted as string. *reduce_expr* and
*map_expr* are specified as string formatted operations and *arguments*
is specified as a string formatted as a C argument list. *name* specifies
the name as which the kernel is compiled, *keep* and *options* are passed
unmodified to :class:`pycuda.compiler.SourceModule`. *preamble* is specified
as a string of code.
.. method __call__(*args, queue=None)
.. versionadded: 2011.1
Here's a usage example::
a = pyopencl.array.arange(400, dtype=numpy.float32)
b = pyopencl.array.arange(400, dtype=numpy.float32)
krnl = ReductionKernel(ctx, numpy.float32, neutral="0",
reduce_expr="a+b", map_expr="a[i]*b[i]",
arguments="__global float *a, __global float *b")
my_dot_prod = krnl(a, b).get()
Fast Fourier Transforms
-----------------------
...
...
This diff is collapsed.
Click to expand it.
doc/source/misc.rst
+
5
−
2
View file @
a3435606
...
...
@@ -65,14 +65,17 @@ C interface to Python:
User-visible Changes
====================
Version
0.93
------------
Version
2011.1
------------
--
.. note::
This version is currently under development. You can get snapshots from
PyOpenCL's git version control.
* Add :mod:`pycuda.reduction`.
* Add :ref:`reductions`.
Version 0.92
------------
...
...
This diff is collapsed.
Click to expand it.
pyopencl/reduction.py
+
1
−
1
View file @
a3435606
...
...
@@ -247,7 +247,7 @@ def get_reduction_kernel(
class
ReductionKernel
:
def
__init__
(
self
,
ctx
,
dtype_out
,
neutral
,
reduce_expr
,
map_expr
=
None
,
arguments
=
None
,
name
=
"
reduce_kernel
"
,
options
=
[]
,
preamble
=
""
):
name
=
"
reduce_kernel
"
,
options
=
""
,
preamble
=
""
):
self
.
dtype_out
=
dtype_out
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment