p03-amd01 server has hyperthreading enabled therefore htop shows 128 cores.
p03-amd01 server has hyperthreading enabled therefore htop shows 128 cores.
p03-amd02 server has hyperthreading dissabled therefore htop shows 64 cores.
p03-amd02 server has hyperthreading dissabled therefore htop shows 64 cores.
## Using AMD MI100 GPUs
## Using AMD MI100 GPUs
...
@@ -34,23 +33,26 @@ p03-amd02 server has hyperthreading dissabled therefore htop shows 64 cores.
...
@@ -34,23 +33,26 @@ p03-amd02 server has hyperthreading dissabled therefore htop shows 64 cores.
The AMD GPUs can be programmed using the [ROCm open-source platform](https://docs.amd.com/).
The AMD GPUs can be programmed using the [ROCm open-source platform](https://docs.amd.com/).
ROCm and related libraries are installed directly in the system. You can find it here:
ROCm and related libraries are installed directly in the system. You can find it here:
```
```console
/opt/rocm/
/opt/rocm/
```
```
The actual version can be found here:
The actual version can be found here:
```
```console
[user@p03-amd02.cs]$cat /opt/rocm/.info/version
[user@p03-amd02.cs]$cat /opt/rocm/.info/version
5.5.1-74
5.5.1-74
```
```
## Basic HIP code
## Basic HIP Code
The first way how to program AMD GPUs is to use HIP.
The first way how to program AMD GPUs is to use HIP.
The basic vector addition code in HIP looks like this. This a full code and you can copy and paste it into a file. For this example we use `vector_add.hip.cpp` .
The basic vector addition code in HIP looks like this. This a full code and you can copy and paste it into a file. For this example we use `vector_add.hip.cpp` .
```
```console
#include <cstdio>
#include <cstdio>
#include <hip/hip_runtime.h>
#include <hip/hip_runtime.h>
...
@@ -125,7 +127,7 @@ int main()
...
@@ -125,7 +127,7 @@ int main()
To compile the code we use `hipcc` compiler. The compiler information can be found like this:
To compile the code we use `hipcc` compiler. The compiler information can be found like this:
````
```console
[user@p03-amd02.cs ~]$hipcc --version
[user@p03-amd02.cs ~]$hipcc --version
HIP version: 5.5.30202-eaf00c0b
HIP version: 5.5.30202-eaf00c0b
...
@@ -133,16 +135,17 @@ AMD clang version 16.0.0 (https://github.com/RadeonOpenCompute/llvm-project roc-
...
@@ -133,16 +135,17 @@ AMD clang version 16.0.0 (https://github.com/RadeonOpenCompute/llvm-project roc-
More details on HIP programming is in the [HIP Programming Guide](https://docs.amd.com/bundle/HIP-Programming-Guide-v5.5/page/Introduction_to_HIP_Programming_Guide.html)
More details on HIP programming is in the [HIP Programming Guide](https://docs.amd.com/bundle/HIP-Programming-Guide-v5.5/page/Introduction_to_HIP_Programming_Guide.html)
## HIP and ROCm libraries
## HIP and ROCm Libraries
The list of official AMD libraries can be found [here](https://docs.amd.com/category/libraries).
The list of official AMD libraries can be found [here](https://docs.amd.com/category/libraries).
The libraries are installed in the same directory is ROCm
The libraries are installed in the same directory is ROCm
```
```console
/opt/rocm/
/opt/rocm/
```
```
Following libraries are installed:
Following libraries are installed:
```
```console
drwxr-xr-x 4 root root 44 Jun 7 14:09 hipblas
drwxr-xr-x 4 root root 44 Jun 7 14:09 hipblas
drwxr-xr-x 3 root root 17 Jun 7 14:09 hipblas-clients
drwxr-xr-x 3 root root 17 Jun 7 14:09 hipblas-clients
The basic code in HIP that uses hipBlas looks like this. This a full code and you can copy and paste it into a file. For this example we use `hipblas.hip.cpp` .
The basic code in HIP that uses hipBlas looks like this. This a full code and you can copy and paste it into a file. For this example we use `hipblas.hip.cpp` .
```
```console
#include <cstdio>
#include <cstdio>
#include <vector>
#include <vector>
#include <cstdlib>
#include <cstdlib>
...
@@ -306,15 +309,16 @@ int main()
...
@@ -306,15 +309,16 @@ int main()
```
```
The code compilation can be done as follows:
The code compilation can be done as follows:
```
```console
hipcc hipblas.hip.cpp -o hipblas.x -lhipblas
hipcc hipblas.hip.cpp -o hipblas.x -lhipblas
```
```
### Using hipSolver library
## Using HipSolver Library
The basic code in HIP that uses hipSolver looks like this. This a full code and you can copy and paste it into a file. For this example we use `hipsolver.hip.cpp` .
The basic code in HIP that uses hipSolver looks like this. This a full code and you can copy and paste it into a file. For this example we use `hipsolver.hip.cpp` .
The ROCm™ installation includes an LLVM-based implementation that fully supports the OpenMP 4.5 standard and a subset of the OpenMP 5.0 standard. Fortran, C/C++ compilers, and corresponding runtime libraries are included.
The ROCm™ installation includes an LLVM-based implementation that fully supports the OpenMP 4.5 standard and a subset of the OpenMP 5.0 standard. Fortran, C/C++ compilers, and corresponding runtime libraries are included.
...
@@ -459,12 +464,11 @@ The OpenMP toolchain is automatically installed as part of the standard ROCm ins
...
@@ -459,12 +464,11 @@ The OpenMP toolchain is automatically installed as part of the standard ROCm ins
More information can be found in the [AMD OpenMP Support Guide](https://docs.amd.com/bundle/OpenMP-Support-Guide-v5.5/page/Introduction_to_OpenMP_Support_Guide.html).
More information can be found in the [AMD OpenMP Support Guide](https://docs.amd.com/bundle/OpenMP-Support-Guide-v5.5/page/Introduction_to_OpenMP_Support_Guide.html).
## Compilation of OpenMP Code
### Compilation of OpenMP code
Basic example that uses OpenMP offload is here. Again, code is comlete and can be copy and pasted into file. Here we use `vadd.cpp`.
Basic example that uses OpenMP offload is here. Again, code is comlete and can be copy and pasted into file. Here we use `vadd.cpp`.
```
```console
#include <cstdio>
#include <cstdio>
#include <cstdlib>
#include <cstdlib>
...
@@ -520,7 +524,7 @@ int main(int argc, char ** argv)
...
@@ -520,7 +524,7 @@ int main(int argc, char ** argv)
@@ -533,4 +537,4 @@ These options are required for target offload from an OpenMP program:
...
@@ -533,4 +537,4 @@ These options are required for target offload from an OpenMP program:
This flag specifies the GPU architecture of targeted GPU. You need to chage this when moving for instance to LUMI with MI250X GPU. The MI100 GPUs presented in CS have code `gfx908`:
This flag specifies the GPU architecture of targeted GPU. You need to chage this when moving for instance to LUMI with MI250X GPU. The MI100 GPUs presented in CS have code `gfx908`:
-`-march=gfx908`
-`-march=gfx908`
Note: You also have to include the `O0`, `O2`, `O3` or `O3` flag. Without this flag the execution of the compiled code fails.
Note: You also have to include the `O0`, `O2`, `O3` or `O3` flag. Without this flag the execution of the compiled code fails.