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

@ -25,13 +25,13 @@
<h4>Blazing fast, lightweight, mobile-enabled, and optimized for advanced GPU processing usecases.</h4>
🔋 [Documentation](https://ethicalml.github.io/vulkan-kompute/) 💻 [Blog Post](https://medium.com/@AxSaucedo/machine-learning-and-data-processing-in-the-gpu-with-vulkan-kompute-c9350e5e5d3a) ⌨ [Examples](https://github.com/EthicalML/vulkan-kompute#your-first-kompute) 💾
🔋 [Documentation](https://kompute.cc) 💻 [Blog Post](https://medium.com/@AxSaucedo/machine-learning-and-data-processing-in-the-gpu-with-vulkan-kompute-c9350e5e5d3a) ⌨ [Examples](#more-examples) 💾
## Principles & Features
* [Single header](single_include/kompute/Kompute.hpp) library for simple import to your project
* [Documentation](https://ethicalml.github.io/vulkan-kompute/) leveraging doxygen and sphinx
* [Documentation](https://kompute.cc) leveraging doxygen and sphinx
* BYOV: Bring-your-own-Vulkan design to play nice with existing Vulkan applications
* Non-Vulkan core naming conventions to disambiguate Vulkan vs Kompute components
* Fast development cycles with shader tooling, but robust static shader binary bundles for prod
@ -51,7 +51,7 @@ This project is built using cmake, providing a simple way to integrate as static
#### Your First Kompute
Pass compute shader data in glsl/hlsl text or compiled SPIR-V format (or as path to the file) - [view more examples](#more-examples).
Pass compute shader data in glsl/hlsl text or compiled SPIR-V format (or as path to the file). View [more examples](#simple-examples).
```c++
int main() {
@ -103,7 +103,7 @@ This project started after seeing that a lot of new and renowned ML & DL project
The Vulkan SDK offers a great low level interface that enables for highly specialized optimizations - however it comes at a cost of highly verbose code which requires 500-2000 lines of code to even begin writing application code. This has resulted in each of these projects having to implement the same baseline to abstract the non-compute related features of Vulkan, although it's not always the case, this can result in slower development cycles, and opportunities for bugs to be introduced.
We are currently developing Vulkan Kompute not to hide the Vulkan SDK interface (as it's incredibly well designed) but to augment it with a direct focus on Vulkan's GPU computing capabilities. [This article](https://medium.com/swlh/machine-learning-and-data-processing-in-the-gpu-with-vulkan-kompute-c9350e5e5d3a) provides a high level overview of the motivations of Kompute, together with a set of hands on examples that introduce both GPU computing as well as the core Vulkan Kompute architecture.
We are currently developing Vulkan Kompute not to hide the Vulkan SDK interface (as it's incredibly well designed) but to augment it with a direct focus on Vulkan's GPU computing capabilities. [This article](https://towardsdatascience.com/machine-learning-and-data-processing-in-the-gpu-with-vulkan-kompute-c9350e5e5d3a) provides a high level overview of the motivations of Kompute, together with a set of hands on examples that introduce both GPU computing as well as the core Vulkan Kompute architecture.
## More examples
@ -111,7 +111,7 @@ We are currently developing Vulkan Kompute not to hide the Vulkan SDK interface
* [Pass shader as raw string](#your-first-kompute)
* [Create your custom Kompute Operations](#your-custom-kompute-operation)
* [Record batch commands with a Kompute Sequence](#record-batch-commands-with-a-kompute-sequence)
* [Record batch commands with a Kompute Sequence](#record-batch-commands)
### End-to-end examples
@ -121,7 +121,7 @@ We are currently developing Vulkan Kompute not to hide the Vulkan SDK interface
### Your Custom Kompute Operation
Build your own pre-compiled operations for domain specific workflows.
Build your own pre-compiled operations for domain specific workflows. Back to [more examples](#simple-examples)
We also provide tools that allow you to [convert shaders into C++ headers](https://github.com/EthicalML/vulkan-kompute/blob/master/scripts/convert_shaders.py#L40).
@ -164,9 +164,9 @@ int main() {
}
```
#### Record batch commands with a Kompute Sequence
#### Record batch commands
Record commands in a single submit by using a Sequence to send in batch to GPU.
Record commands in a single submit by using a Sequence to send in batch to GPU. Back to [more examples](#simple-examples)
```c++
int main() {
@ -214,13 +214,6 @@ int main() {
}
```
## Advanced Examples
We cover more advanced examples and applications of Vulkan Kompute, such as machine learning algorithms built on top of Kompute.
You can find these in the end to end examples [section](#end-to-end-examples).
## Components & Architecture
The core architecture of Kompute include the following:

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.

View file

@ -1,10 +1,12 @@
# Kompute Mobile App Integration (Android)
This is the accompanying code for the Blog post ["Supercharging your Mobile Apps with On-Device GPU Accelerated Machine Learning using the Android NDK & Vulkan Kompute"](https://towardsdatascience.com/gpu-accelerated-machine-learning-in-your-mobile-applications-using-the-android-ndk-vulkan-kompute-1e9da37b7617).
<table>
<tr>
<td width="70%">
<h1>Vulkan Kompute Android</h1>
<h3>Example Running Logistic Regression with Vulkan Kompute in Android Phones</h3>
<p>
@ -14,6 +16,9 @@ The example uses the Kompute build in the relative folder to build the respectiv
The build structure provides a range of options to build in different Android hardware. This example was tested in various emulators including Pixel 2, and a physical Samsung S7 phone.
</p>
<br>
<img src="https://raw.githubusercontent.com/EthicalML/vulkan-kompute/android-example/docs/images/android-editor.jpg">
</td>

View file

@ -1,4 +1,5 @@
# Godot Kompute ML Example
# Kompute Game Engine Integration (Godot)
![](https://github.com/EthicalML/vulkan-kompute/raw/master/docs/images/komputer-godot-4.gif)

View file

@ -1,4 +1,9 @@
# Vulkan Kompute Godot Example
## Godot Engine Integration: Godot Engine Source Module
This is the accompanying code for the Blog post ["Supercharging Game Development with GPU Accelerated Machine Learning"](https://medium.com/@AxSaucedo/supercharging-game-development-with-gpu-accelerated-ml-using-vulkan-kompute-the-godot-game-engine-4e75a84ea9f0).
This section contains the implementation of the Kompute module as a statically compile module built with the Godot engine source code. This approach requires re-compiling the Godot engine source code.
![](https://github.com/EthicalML/vulkan-kompute/raw/master/docs/images/komputer-godot-4.gif)

View file

@ -1,8 +1,14 @@
# Vulkan Kompute Godot Example
## Godot Engine Integration: GdNative Library
This is the accompanying code for the Blog post ["Supercharging Game Development with GPU Accelerated Machine Learning"](https://medium.com/@AxSaucedo/supercharging-game-development-with-gpu-accelerated-ml-using-vulkan-kompute-the-godot-game-engine-4e75a84ea9f0).
This section contains the implementation of the Kompute module as a shared GdNative Library that can be loaded dynamically through the Godot engine. This approach does not require re-compiling the Godot engine source code.
![](https://github.com/EthicalML/vulkan-kompute/raw/master/docs/images/komputer-godot-4.gif)
## Set Up Dependencies
### Set Up Dependencies
We can get all the required dependencies from godot by running