Skip to content

Commit

Permalink
Removed deprecated command
Browse files Browse the repository at this point in the history
Changed from alapka enqueue to alpaka exec
Added entries to get
- pitches
- mdspan
- kernelFunctionAttributes
- NDIndex
  • Loading branch information
ikbuibui authored and psychocoderHPC committed Sep 18, 2024
1 parent 6f759e3 commit 3d043fe
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions docs/source/basic/cheatsheet.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@ Allocate a buffer in host memory
using BufHost = alpaka::Buf<DevHost, DataType, Dim, Idx>;
BufHost bufHost = allocBuf<DataType, Idx>(devHost, extent);

(Optional, affects CPU – GPU memory copies) Prepare it for asynchronous memory copies
.. code-block:: c++

prepareForAsyncCopy(bufHost);

Create a view to host memory represented by a pointer
.. code-block:: c++

Expand Down Expand Up @@ -154,6 +149,18 @@ Get a raw pointer to a buffer or view initialization, etc.
DataType* raw = view::getPtrNative(bufHost);
DataType* rawViewPtr = view::getPtrNative(hostView);

Get the pitches (memory in bytes to the next element in the buffer along the pitch dimension) of a buffer
.. code-block:: c++

auto pitchBufAcc = alpaka::getPitchesInBytes(bufAcc)
auto pitchViewAcc = alpaka::getPitchesInBytes(viewAcc)

Get a mdspan to a buffer or view initialization, etc.
.. code-block:: c++

auto bufMdSpan = alpaka::experimental::getMdSpan(bufAcc)
auto viewMdSpan = alpaka::experimental::getMdSpan(viewAcc)

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

Expand Down Expand Up @@ -216,18 +223,23 @@ Manually set a kernel launch configuration
threadsPerBlock,
elementsPerThread};

Instantiate a kernel and create a task that will run it (does not launch it yet)
Instantiate a kernel (does not launch it yet)
.. code-block:: c++

Kernel kernel{argumentsForConstructor};
auto taskRunKernel = createTaskKernel<Acc>(workDiv, kernel, parameters);

acc parameter of the kernel is provided automatically, does not need to be specified here

Get information about the kernel from the device (size, maxThreadsPerBlock, sharedMemSize, registers, etc.)
.. code-block:: c++

auto kernelFunctionAttributes = alpaka::getFunctionAttributes<Acc>(devAcc, kernel, parameters...);


Put the kernel for execution
.. code-block:: c++

enqueue(queue, taskRunKernel);
exec(queue, workDiv, kernel, parameters...);

Kernel Implementation
---------------------
Expand Down Expand Up @@ -259,7 +271,12 @@ Access components of and destructure multi-dimensional indices and extents
Linearize multi-dimensional vectors
.. code-block:: c++

auto linearIdx = mapIdx<1u>(idx, extent);
auto linearIdx = mapIdx<1u>(idxND, extentND);

More generally, index multi-dimensional vectors with a different dimensionality
.. code-block:: c++

auto idxND = alpaka::mapIdx<N>(idxMD, extentMD);

.. raw:: pdf
Expand Down

0 comments on commit 3d043fe

Please sign in to comment.