Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unification with HIP #8

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 41 additions & 8 deletions content/2.01_DeviceQuery.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,19 @@ First, we want to ask API how many CUDA+capable devices are available, which is

.. signature:: |cudaGetDeviceCount|

.. code-block:: CUDA

__host__ ​__device__​ cudaError_t cudaGetDeviceCount(int* numDevices)
.. tabs::

.. tab:: CUDA

.. code-block:: c++

__host__ __device__ cudaError_t cudaGetDeviceCount(int* numDevices)

.. tab:: HIP

.. code-block:: c++

__host__ __device__ cudaError_t cudaGetDeviceCount(int* numDevices)

The function calls the API and returns the number of the available devices in the address provided as a first argument.
There are a couple of things to notice here.
Expand All @@ -36,19 +46,42 @@ To populate the |cudaDeviceProp| structure, CUDA has |cudaGetDeviceProperties| f

.. signature:: |cudaGetDeviceProperties|

.. code-block:: c++
.. tabs::

.. tab:: CUDA

.. code-block:: c++

__host__ cudaError_t cudaGetDeviceProperties(cudaDeviceProp* prop, int deviceId)

.. tab:: HIP

.. code-block:: c++

__host__ cudaError_t cudaGetDeviceProperties(cudaDeviceProp* prop, int deviceId)

__host__​ cudaError_t cudaGetDeviceProperties(cudaDeviceProp* prop, int deviceId)

The function has a |__host__| specifier, which means that one can not call it from the device code.
It also returns |cudaError_t| structure, which can be |cudaErrorInvalidDevice| in case we are trying to get properties of a non-existing device (e.g. when ``deviceId`` is larger than ``numDevices`` above).
The function takes a pointer to the |cudaDeviceProp| structure, to which the data is saved and an integer index of the device to get the information about.
The following code should get you an information on the first device in the system (one with ``deviceId = 0``).

.. code-block:: c++

cudaGetDeviceProp prop;
cudaGetDeviceProperties(&prop, 0);
.. tabs::

.. tab:: CUDA

.. code-block:: c++

cudaGetDeviceProp prop;
cudaGetDeviceProperties(&prop, 0);

.. tab:: HIP

.. code-block:: c++

cudaGetDeviceProp prop;
cudaGetDeviceProperties(&prop, 0);

Exercise
--------
Expand Down
12 changes: 12 additions & 0 deletions content/4.01_FromCUDAToHIP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.. _cuda_to_hip:

From CUDA to HIP
================

1. Performance and performance portability
------------------------------------------

2. Tools for HIPification
-------------------------


2 changes: 1 addition & 1 deletion content/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# -- Project information -----------------------------------------------------

project = "CUDA training materials"
project = "Heterogeneous programming with CUDA/HIP"
copyright = "2021, Artem Zhmurov and individual contributors."
author = "Artem Zhmurov and individual contributors."
github_user = "ENCCS"
Expand Down
5 changes: 3 additions & 2 deletions content/index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CUDA training
=============
Heterogeneous programming with CUDA/HIP
=======================================


Intro
Expand All @@ -22,6 +22,7 @@ Intro
2.04_HeatEquation
3.01_ParallelReduction
3.02_TaskParallelism
4.01_FromCUDAToHIP


.. toctree::
Expand Down