Skip to content

Commit

Permalink
Change docs: installation, cheatsheet and library.
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmetyusufoglu authored and psychocoderHPC committed Jun 6, 2024
1 parent 5f3b91c commit e4fe80f
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 7 deletions.
2 changes: 2 additions & 0 deletions docs/source/basic/cheatsheet.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ Create a CPU device for memory allocation on the host side

Allocate a buffer in host memory
.. code-block:: c++

// Use alpaka vector as a static array for the extents
alpaka::Vec<Dim, Idx> extent = value;
// Allocate memory for the alpaka buffer, which is a dynamic array
Expand Down Expand Up @@ -161,6 +162,7 @@ Allocate a buffer in device memory
Enqueue a memory copy from host to device
.. code-block:: c++

// arguments can be also alpaka::View instances instead of alpaka::Buf
memcpy(queue, bufDevice, bufHost, extent);

Enqueue a memory copy from device to host
Expand Down
70 changes: 64 additions & 6 deletions docs/source/basic/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,61 @@
Installation
============

**Installing dependencies**

alpaka requires **Boost** and a modern C++ compiler (g++, clang++, Visual C++, …). In order to install **Boost**:

On Linux:

.. code-block::
# Clone alpaka from github.com
git clone --branch 0.9.0 https://github.com/alpaka-group/alpaka.git
cd alpaka
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/install/ ..
cmake --install .
# RPM
sudo dnf install boost-devel
# DEB
sudo apt install libboost-all-dev
On macOS:

.. code-block::
# Using Homebrew, https://brew.sh
brew install boost
# Using MacPorts, https://macports.org
sudo port install boost
On Windows:

.. code-block::
# Using vcpkg, https://github.com/microsoft/vcpkg
vcpkg install boost
**CMake** is the preferred system for configuration the build tree, building and installing. In order to install **CMake**:

On Linux:

.. code-block::
# RPM
sudo dnf install cmake
# DEB
sudo apt install cmake
On macOS or Windows:

Download the installer from https://cmake.org/download/

**Dependencies to use specific backends**: Depending on your target platform you may need additional packages to compile and run alpaka.

- NVIDIA GPUs: CUDA Toolkit (https://developer.nvidia.com/cuda-toolkit)
- AMD GPUs: ROCm / HIP (https://rocmdocs.amd.com/en/latest/index.html)
- Intel GPUs: OneAPI Toolkit (https://www.intel.com/content/www/us/en/developer/tools/oneapi/base-toolkit.html#gs.9x3lnh)

Tests and Examples
++++++++++++++++++

The examples and tests can be compiled without installing alpaka. They will use alpaka headers from the source directory.

**Build and run examples:**

.. code-block::
Expand Down Expand Up @@ -56,3 +99,18 @@ In the overview of :doc:`cmake arguments </advanced/cmake>` you will find all CM
.. hint::

When the test or examples are activated, the alpaka build system automatically activates the ``serial backend``, as it is needed for many tests. Therefore, the tests are run with the ``serial backend`` by default. If you want to test another backend, you have to activate it at CMake configuration time, for example the ``HIP`` backend: ``cmake .. -DBUILD_TESTING=ON -Dalpaka_ACC_GPU_HIP_ENABLE=ON``. Some alpaka tests use a selector algorithm to choose a specific accelerator for the test cases. The selector works with accelerator priorities. Therefore, it is recommended to enable only one accelerator for a build to make sure that the right one is used.


**Installing alpaka**

If user is going to create her/his own project/example outside the source tree alpaka should be installed. Since alpaka is a header only library compilation is not needed before installation.

.. code-block::
# Clone alpaka from github.com
git clone --branch 1.1.0 https://github.com/alpaka-group/alpaka.git
cd alpaka
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/install/ ..
cmake --install .
4 changes: 3 additions & 1 deletion docs/source/basic/library.rst
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ The memory allocation function of the *alpaka* library (``alpaka::allocBuf<TElem
It does not return raw pointers but reference counted memory buffer objects that remove the necessity for manual freeing and the possibility of memory leaks.
Additionally, the memory buffer objects know their extents, their pitches as well as the device they reside on.
Due to padding, the allocated number of bytes may be more than the required storage; the pitch value gives the correct stride for each dimension for row-major access.
This allows buffers that possibly reside on different devices with different pitches to be copied only by providing the buffer objects as well as the extents of the region to copy (``alpaka::memcpy(bufDevA, bufDevB, copyExtents``).
This allows buffers that possibly reside on different devices with different pitches to be copied by providing the buffer objects as well as the extents of the region to copy (``alpaka::memcpy(queue, bufDevA, bufDevB, copyExtents``).

If the data is already in a contiguous STL container on the host; the container can be converted to a View to be used in ``alpaka::memcpy`` function. The data structure ``alpaka::View`` knows the the extent and the device of the data; therefore can be used in memcpy. (``alpaka::memcpy(queue, bufDevA, viewDevB, copyExtents``).

Kernel Execution
````````````````
Expand Down

0 comments on commit e4fe80f

Please sign in to comment.