Updated documentation

This commit is contained in:
Alejandro Saucedo 2020-10-14 08:42:42 +01:00
parent e4a4f2cb5d
commit 2f7fc45b2b
12 changed files with 115 additions and 25 deletions

View file

@ -18,11 +18,11 @@
# -- Project information -----------------------------------------------------
project = 'Vulkan Kompute'
copyright = '2020, Alejandro Saucedo'
copyright = '2020, The Institute for Ethical AI & Machine Learning'
author = 'Alejandro Saucedo'
# The full version, including alpha/beta/rc tags
release = '0.1.0'
release = '0.3.2'
# -- General configuration ---------------------------------------------------

View file

@ -11,7 +11,10 @@ Index
:maxdepth: 2
:titlesonly:
Advanced Examples <overview/advanced-examples.rst>
Advanced Examples <overview/advanced-examples>
Mobile App Intergration (Android) <overview/mobile-android>
Game Engine Integration (Godot Engine) <overview/game-engine-godot>
Converting GLSL/HLSL Shaders to C++ Headers <overview/shaders-to-headers>
Class Reference <overview/reference>
Memory management principles <overview/memory-management>
Code Index <genindex>

View file

@ -2,8 +2,15 @@
Advanced Examples
==================
The power of Kompute comes in when the interface is used for complex computations. In this section we cover a set of advanced examples including machine learning and data processing applications that showcase the more advanced capabilities of Kompute.
The power of Kompute comes in when the interface is used for complex computations. This section contains an outline of the advanced / end-to-end examples available.
Currently the advanced examples available include:
* `Machine Learning Logistic Regression Implementation <https://towardsdatascience.com/machine-learning-and-data-processing-in-the-gpu-with-vulkan-kompute-c9350e5e5d3a`_
* `Android NDK Mobile Kompute ML Application <https://towardsdatascience.com/gpu-accelerated-machine-learning-in-your-mobile-applications-using-the-android-ndk-vulkan-kompute-1e9da37b7617`_
* `Game Development Kompute ML in Godot Engine <https://towardsdatascience.com/supercharging-game-development-with-gpu-accelerated-ml-using-vulkan-kompute-the-godot-game-engine-4e75a84ea9f0`_
Below there is also a simple implementation of the logistic regression algorithm using Vulkan Kompute.
Logistic Regression Example
------------------

View file

@ -0,0 +1,7 @@
.. mdinclude:: ../../examples/godot_logistic_regression/README.md
.. mdinclude:: ../../examples/godot_logistic_regression/custom_module/README.md
.. mdinclude:: ../../examples/godot_logistic_regression/gdnative_shared/README.md

View file

@ -3,12 +3,25 @@ Memory Management Principles
=====================
The principle in Vulkan Kompute on memory management is summarised as follows:
* Explicit is better than implicit for specifying memory management
* Interfaces for memory management are constant until freed
* Memory management responsibilities are acyclic from static object references
* Memory management by Kompute is optional and only in place if resource is created by Kompute
Vulkan Kompute is responsible for managing both the CPU and GPU memory allocations and resources, and is important that they are able to explicitly define when these objects are released or destroyed. Similarly, it's important that the memory resources created by the application are released safely.
Vulkan Kompute is built with the BYOV principle in mind (Bring your own Vulkan). This means that even though the top level resources are managing the memory to its owned resources, they themselves may not have full ownership of the GPU / Vulkan components themselves.
The memory ownership is hierarchically outlined in the component architecture - in this diagram, the arrows provide an intuition on the memory management ownership relationships (in this case you can ignore the arrow from the Algorithm, as this is the only one that as of today doesn't manage the memory of the Tensors).
.. image:: ../images/kompute-architecture.jpg
:width: 100%
Optional Memory Management
-------------
As outlined above, resource memory is only managed by Kompute if the resources are created by Kompute. Each of the Kompute components can also be initialised with externally managed resources. The kp::Manager for example can be initialized with an external Vulkan Device. The first principle ensures that all memory ownership is explicitly defined when managing and creating Kompute resources.

View file

@ -0,0 +1,3 @@
.. mdinclude:: ../../examples/android/android-simple/README.md

View file

@ -0,0 +1,47 @@
Converting Shaders to C++ Headers
=====================
Kompute allows for shaders to be loaded directly through the kp::OpAlgoBase as either raw strings (through shaderc) or compiled SPIRV bytes. For this latter, the traditional method of including the SPIRV bytes is by loading the SPIRV file directly and passing the contents.
The Kompute codebase has a utility that allows you to convert shader files into C++ header files containing the SPIRV header data. This is useful as it enables developers to compile the SPIRV shaders into the final binary, which avoids the need for multiple files being required.
The utility can be found under `scripts/convert_shaders.py <https://github.com/EthicalML/vulkan-kompute/blob/master/scripts/convert_shaders.py>`_ and consists primarily of a Python CLI that can be called to pass arguments.
In order to use this Python utility, you will have to first install the dependencies outlined by the `scripts/requirements.txt` file. You will need to have python 3 and pip3 installed.
.. code-block:: bash
:linenos:
python3 -m pip install -r scripts/requirements.txt
Once the dependencies can be installed, you can run the Python script directly through the file as `python3 scripts/convert_shaders.py`.
You can run `python3 scripts/convert_shaders.py --help` to see all the options available - namely:
.. code-block:: bash
:linenos:
> python3 scripts/convert_shaders.py --help
Usage: convert_shaders.py [OPTIONS]
CLI function for shader generation
Options:
-p, --shader-path TEXT The path for the directory to build and convert
shaders [required]
-s, --shader-binary TEXT The path for the directory to build and convert
shaders [required]
-c, --header-path TEXT The (optional) output file for the cpp header
files
-v, --verbose Enable versbosity if flag is provided
--help Show this message and exit.
You can see the command that converts the shaders `in the makefile <https://github.com/EthicalML/vulkan-kompute/blob/45ddfe524b9ed63c5fe1fc33773c8f93a18e2fac/Makefile#L143>`_ to get an idea of how you would be able to use this utility.