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
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/
```
The actual version can be found here:
The actual version can be found here:
```console
[user@p03-amd02.cs]$cat /opt/rocm/.info/version
...
...
@@ -49,9 +49,9 @@ The actual version can be found here:
## 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>
...
...
@@ -90,7 +90,7 @@ int main()
for(long long i = 0;i < count; i++)
printf(" %7.2f", h_y[i]);
printf("\n");
// allocation of memory on the GPU device
float * d_x;
float * d_y;
...
...
@@ -126,10 +126,10 @@ 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
AMD clang version 16.0.0 (https://github.com/RadeonOpenCompute/llvm-project roc-5.5.1 23194 69ef12a7c3cc5b0ccf820bc007bd87e8b3ac3037)
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>
...
...
@@ -205,7 +204,7 @@ The basic code in HIP that uses hipBlas looks like this. This a full code and yo
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.
...
...
@@ -463,11 +462,11 @@ The OpenMP toolchain is automatically installed as part of the standard ROCm ins
-`lib` : Libraries including those required for target offload.
-`lib-debug` : Debug versions of the above libraries.
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>
...
...
@@ -497,7 +496,7 @@ int main(int argc, char ** argv)
for(long long i = 0;i < print_count; i++)
printf("%3lld ", a[i]);
printf("\n");
printf("B: ");
for(long long i = 0;i < print_count; i++)
printf("%3lld ", b[i]);
...
...
@@ -523,19 +522,21 @@ int main(int argc, char ** argv)
These options are required for target offload from an OpenMP program:
-`-target x86_64-pc-linux-gnu`
-`-fopenmp`
-`-fopenmp-targets=amdgcn-amd-amdhsa`
-`-Xopenmp-target=amdgcn-amd-amdhsa`
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`:
-`-target x86_64-pc-linux-gnu`
-`-fopenmp`
-`-fopenmp-targets=amdgcn-amd-amdhsa`
-`-Xopenmp-target=amdgcn-amd-amdhsa`
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`
Note: You also have to include the `O0`, `O2`, `O3` or `O3` flag. Without this flag the execution of the compiled code fails.