Skip to content

Docs - Reductions - added contribute() details #288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion docs/reductions-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,21 @@ A reduction is a distributed and scalable operation that reduces data
distributed across chares into a smaller set of data.
A reduction involves the chares in a collection (Group, Array or Section). They are
started by the elements calling their ``Chare.reduce()`` or ``Chare.allreduce()``
methods (see :ref:`Chare <chare-api-label>`).
methods (see :ref:`Chare <chare-api-label>`).

The reduction calls accumulate objects from a chare collection to a single desired
collection/object. ``Chare.reduce(<callback>, <data>, <Reducer>)`` is the general format.
This returns a single collection/object to the callback function after applying the Reducer
function on all individual chare data.

Alternatively, one can use the ``Chare.contribute()`` to achieve the same. The signature of the
contribute function is ``Chare.contribute(<data>, <Reducer>, <callback>)``

* ``data``: scalar/vector data. Can be a collection/primitive/object. Each chare contributes some compatible data to the reducer.

* ``Reducer``: charm4py.Reducer - :ref:`reducer-api-label`

* ``callback``: any method - either belonging to a Chare or global or a different class. The reducer sends each reduced data to the callback.

.. important::

Expand Down
Loading