From 400616d36f20c34c70857579cbba3500e275ba12 Mon Sep 17 00:00:00 2001 From: Roberto Di Remigio Date: Mon, 14 Feb 2022 13:08:51 +0100 Subject: [PATCH 1/3] Change title to include HIP --- content/conf.py | 2 +- content/index.rst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/content/conf.py b/content/conf.py index 2fe3a21..ff936dc 100644 --- a/content/conf.py +++ b/content/conf.py @@ -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" diff --git a/content/index.rst b/content/index.rst index bfc57b2..b170e1c 100644 --- a/content/index.rst +++ b/content/index.rst @@ -1,5 +1,5 @@ -CUDA training -============= +Heterogeneous programming with CUDA/HIP +======================================= Intro From 8c86a81f8a206deb4680fffc2012f55a97e2add6 Mon Sep 17 00:00:00 2001 From: Roberto Di Remigio Date: Mon, 14 Feb 2022 13:11:04 +0100 Subject: [PATCH 2/3] Add scaffold of hipfication episode --- content/4.01_FromCUDAToHIP.rst | 12 ++++++++++++ content/index.rst | 1 + 2 files changed, 13 insertions(+) create mode 100644 content/4.01_FromCUDAToHIP.rst diff --git a/content/4.01_FromCUDAToHIP.rst b/content/4.01_FromCUDAToHIP.rst new file mode 100644 index 0000000..1ef9343 --- /dev/null +++ b/content/4.01_FromCUDAToHIP.rst @@ -0,0 +1,12 @@ +.. _cuda_to_hip: + +From CUDA to HIP +================ + +1. Performance and performance portability +------------------------------------------ + +2. Tools for HIPification +------------------------- + + diff --git a/content/index.rst b/content/index.rst index b170e1c..e300f9e 100644 --- a/content/index.rst +++ b/content/index.rst @@ -22,6 +22,7 @@ Intro 2.04_HeatEquation 3.01_ParallelReduction 3.02_TaskParallelism + 4.01_FromCUDAToHIP .. toctree:: From 0bb19f50c1491f42b4e391839b47a8bec9a8dc50 Mon Sep 17 00:00:00 2001 From: Roberto Di Remigio Date: Mon, 14 Feb 2022 13:14:37 +0100 Subject: [PATCH 3/3] Add HIP tabs --- content/2.01_DeviceQuery.rst | 49 ++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/content/2.01_DeviceQuery.rst b/content/2.01_DeviceQuery.rst index 6f85647..2f5bdd0 100644 --- a/content/2.01_DeviceQuery.rst +++ b/content/2.01_DeviceQuery.rst @@ -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. @@ -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 --------