Skip to content

Commit

Permalink
core(graph): adding documentation for Kokkos::Experimental::Graph
Browse files Browse the repository at this point in the history
  • Loading branch information
romintomasetti committed Aug 21, 2024
1 parent b30fe1a commit ff3854e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/source/API/core-index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ API: Core
- Utility functionality part of Kokkos Core.
* - `Detection Idiom <core/Detection-Idiom.html>`__
- Used to recognize, in an SFINAE-friendly way, the validity of any C++ expression.
* - `Graph and related <core/Graph.html>`_
- Kokkos Graph abstraction.
* - `Macros <core/Macros.html>`__
- Global macros defined by Kokkos, used for architectures, general settings, etc.

Expand All @@ -60,4 +62,5 @@ API: Core
./core/Utilities
./core/Detection-Idiom
./core/Macros
./core/Graph
./core/Profiling
46 changes: 46 additions & 0 deletions docs/source/API/core/Graph.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Graph and related
=================

Usage
-----

:code:`Kokkos::Graph` is an abstraction that can be used to define a group of asynchronous workloads that are organised as a direct acyclic graph.

:code:`Kokkos::Graph` is a powerful way of describing workload dependencies.

For small workloads that need to be sumitted several times, it might save you some overhead [reference to some presentation / paper].

:code:`Kokkos::Graph` is specialized for some backends:

* :code:`Cuda`: [ref to vendor doc]
* :code:`HIP`: [ref to vendor doc]
* :code:`SYCL`: [ref to vendor doc]

For other backends, Kokkos provides a defaulted implementation [ref to file].

Basic example
-------------

This example showcases how three workloads can be organised as a :code:`Kokkos::Graph`.

Workloads A and B are independent, but workload C needs the completion of A and B.

.. code-block:: cpp
int main()
{
auto graph = Kokkos::Experimental::create_graph<Exec>([&](auto root) {
const auto node_A = root.then_parallel_for(...label..., ...policy..., ...body...);
const auto node_B = root.then_parallel_for(...label..., ...policy..., ...body...);
const auto ready = Kokkos::Experimental::when_all(node_A, node_B);
const auto node_C = ready.then_parallel_for(...label..., ...policy..., ...body...);
});
for(int irep = 0; irep < nrep; ++irep)
graph.submit();
}
Advanced example
----------------

To be done soon.

0 comments on commit ff3854e

Please sign in to comment.