Skip to content

Commit 12c8d48

Browse files
authored
debuggers and performance analysis tools (#46)
1 parent 1aa18ee commit 12c8d48

File tree

11 files changed

+377
-300
lines changed

11 files changed

+377
-300
lines changed

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ The Alps Research infrastructure hosts multiple platforms and clusters targeting
6868
[](){#ref-get-in-touch}
6969
## Get in Touch
7070

71-
If you can't find the information that you need in the documentation, help is available.
71+
If you cannot find the information that you need in the documentation, help is available.
7272

7373
<div class="grid cards" markdown>
7474

docs/services/index.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
* slurm
77
* uenv
88
* container engine
9-
* debuggers and profilers
109

11-
We document the tools and their interfaces here, but we don't put all the documentation for a tool here.
10+
We document the tools and their interfaces here, but we do not put all the documentation for a tool here.
1211

1312
* e.g Documentation on how to build software using uenv, is in another section.
1413
* e.g Documentation on how to use Podman to build containers, is in another section.

docs/software/devtools/index.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[](){#ref-software-devtools}
2+
# Debugging and Performance Analysis tools
3+
4+
Debugging and Performance Analysis tools can assist users in developing and optimizing scientific parallel applications, especially in a high-performance computing (HPC) environment.
5+
Efficient tools can significantly improve workflows and save valuable computational resources.
6+
7+
CSCS provides debuggers and performance analysis tools on Alps Clusters.
8+
9+
!!! note "get in touch"
10+
If you have issues or questions about debugging or performance analysis tools, please do not hesitate to [contact us][ref-get-in-touch].
11+
12+
[](){#ref-devtools-debug}
13+
## Debugging
14+
15+
Parallel debugging tools designed for parallel and distributed applications can help you diagnose issues and verify the correctness of your code - whether you are using MPI, OpenMP, or accelerated programming models.
16+
17+
Learning to debug a code effectively will not only help you quickly resolve issues but also build a deeper understanding of how your code interacts with the underlying hardware.
18+
In this section we introduce the various debugging tools available at CSCS.
19+
20+
* [Linaro Forge DDT][ref-devtools-ddt]
21+
22+
[](){#ref-devtools-perf}
23+
## Performance Analysis
24+
25+
Performance analysis tools are essential to gain insight into how an application leverages a distributed system with CPUs and GPUs and should be integrated to the development and optimization workflow of the application.
26+
This ensures that computational resources are utilized to their fullest potential.
27+
28+
Learning to analyze the performance of an applications effectively is crucial to build a deeper understanding of how your code interacts with the underlying hardware.
29+
In this section we introduce the various performance analysis solutions available at CSCS.
30+
If you have issues or questions about performance analysis tools, please do not hesitate to [contact us][ref-get-in-touch].
31+
32+
* [Linaro Forge MAP][ref-devtools-map]
33+
* [NVIDIA Nsight Developer Tools][ref-devtools-nsight]
34+
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
[](){#ref-devtools-ddt}
2+
# Linaro DDT
3+
4+
DDT allows source-level debugging of Fortran, C, C++ and Python codes.
5+
It can be used for debugging serial, multi-threaded (OpenMP), multi-process (MPI) and accelerated (CUDA, OpenACC) programs running on research and production systems, including the CSCS Alps system.
6+
DDT can be executed either with its graphical user interface or from the command-line.
7+
8+
!!! note
9+
Linaro DDT is provided in the `linaro-forge` uenv.
10+
Before using DDT, please read the [`linaro-forge` documentation][ref-uenv-linaro], which explains how to download and set up the latest version and set it up.
11+
12+
## User guide
13+
14+
The following guid will walk through the steps required to build and debug an application using DDT.
15+
16+
### Set up the user environment and build the executable
17+
18+
Once the uenv is loaded and activated, the program to debug must be compiled with the `-g` (for CPU) and `-G` (for GPU) debugging flags.
19+
For example, we can build a CUDA test with a user environment:
20+
21+
```terminal
22+
uenv start prgenv-gnu:24.11:v1 --view=default
23+
nvcc -c -arch=sm_90 -g -G test_gpu.cu
24+
mpicxx -g test_cpu.cpp test_gpu.o -o myexe
25+
```
26+
27+
### Launch Linaro DDT
28+
29+
To use the DDT client with uenv, it must be launched in `Manual Launch` mode
30+
(assuming that it is connected to Alps via `Remote Launch`):
31+
32+
=== "on local machine"
33+
34+
Start DDT, and connect to the target cluster using the drop down menu for `Remote Launch`.
35+
36+
Click on `Manual launch`, set the number of processes to listen to, then wait for the slurm job to start (see the "on Alps" tab).
37+
38+
<img src="https://raw.githubusercontent.com/jgphpc/cornerstone-octree/ddt/scripts/img/ddt/0.png" width="600" />
39+
40+
=== "on Alps"
41+
42+
Log into the system and launch with the `srun` command:
43+
44+
```terminal
45+
# start a session with both the PE used to build your application
46+
# and the linaro-forge uenv mounted
47+
> uenv start prgenv-gnu/24.11:v1,linaro-forge/24.1.1:v1 --view=prgenv-gnu:default
48+
> source /user-tools/activate
49+
50+
> srun -N1 -n4 -t15 -pdebug ./cuda_visible_devices.sh ddt-client ./myexe
51+
```
52+
53+
### Start debugging
54+
55+
By default, DDT will pause execution on the call to `MPI_Init`:
56+
<img src="https://raw.githubusercontent.com/jgphpc/cornerstone-octree/ddt/scripts/img/ddt/1.png" width="600" />
57+
58+
There are two mechanisms for controlling program execution:
59+
60+
=== "Breakpoint"
61+
62+
Breakpoint(s) can be set by clicking in the margin to the left of the line number:
63+
64+
<img src="https://raw.githubusercontent.com/jgphpc/cornerstone-octree/ddt/scripts/img/ddt/3.png" width="600" />
65+
66+
=== "Stop at"
67+
68+
Execution can be paused in every CUDA kernel launch by activating the default breakpoints from the Control menu:
69+
70+
<img src="https://raw.githubusercontent.com/jgphpc/cornerstone-octree/ddt/scripts/img/ddt/4.png" width="400" />
71+
72+
73+
This screenshot shows a debugging session on 128 gpus:
74+
75+
![DDTgpus](https://raw.githubusercontent.com/jgphpc/cornerstone-octree/ddt/scripts/img/ddt/5.png)
76+
77+
More informations regarding how to use Linaro DDT are provided in the Forge [User Guide](https://docs.linaroforge.com/latest/html/forge/index.html).
78+
79+
## Troubleshooting
80+
81+
See the troubleshooting guide for the [`linaro-forge` uenv][ref-uenv-linaro-troubleshooting].
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
[](){#ref-uenv-linaro}
2+
# Linaro Forge
3+
4+
[Linaro Forge](https://docs.linaroforge.com/latest/html/forge/index.html) is a suite of profiling and debugging tools, that includes the DDT debugger and the MAP profiler.
5+
6+
!!! note
7+
We have separate user guides for the tools provided by the `linaro-forge` uenv.
8+
The documentation here shows how to download the uenv, and how to set up your environment.
9+
10+
Once you are set up, follow the specific guides:
11+
12+
* the [DDT debugger][ref-devtools-ddt]
13+
* the [MAP profiler][ref-devtools-map].
14+
15+
## Quickstart guide
16+
17+
The Linaro uenv is named `linaro-forge`, and the available versions can be determined using the `uenv image find` command:
18+
19+
!!! example "finding available linaro-forge versions"
20+
21+
```
22+
> uenv image find linaro-forge
23+
uenv arch system id size(MB) date
24+
linaro-forge/24.1.1:v1 gh200 daint e0e79f5c3e6a8ee0 365 2025-02-12
25+
26+
> uenv image pull linaro-forge/24.1.1:v1
27+
pulling e0e79f5c3e6a8ee0 100.00% --- 365/365 (0.00 MB/s)
28+
```
29+
30+
This uenv is configured to be mounted in the `/user-tools` path so that they can be used alongside application and development uenv mounted at `/user-environment`.
31+
32+
When using alongside another uenv, start a uenv session with both uenv.
33+
In the following example, the `prgenv-gnu` and `linaro-forge` uenv will be mounted at `/user-environment` and `/user-tools` respectively:
34+
35+
```bash
36+
> uenv start prgenv-gnu/24.11,linaro-forge/24.1.1 \
37+
--view=prgenv-gnu:default,forge
38+
39+
# test that everything has been mounted correctly
40+
# (will give warnings if there are problems)
41+
> uenv status
42+
43+
# check that ddt is in the path
44+
> ddt --version
45+
Linaro DDT Part of Linaro Forge.
46+
Copyright (c) 2023-2024 Linaro Limited. All rights reserved.
47+
Version: 24.1.1
48+
```
49+
50+
!!! note
51+
The `linaro-forge` uenv is always mounted at the `/user-tools` mount point, and a script `/user-tools/activate` is provided to load both ddt and map into your environment, without needing to use a view.
52+
53+
```bash
54+
> uenv start linaro-forge/14.1.1
55+
> source /user-tools/activate
56+
> ddt --version
57+
Linaro DDT Part of Linaro Forge.
58+
Copyright (c) 2023-2024 Linaro Limited. All rights reserved.
59+
Version: 24.1.1
60+
```
61+
62+
### Install and configure the Linaro client on your local machine
63+
64+
We recommend installing the [desktop client](https://www.linaroforge.com/downloadForge) on your local workstation/laptop.
65+
It can be downloaded for a selection of operating systems.
66+
The client can be configured to connect with the debug jobs running on Alps, offering a better user experience compared to running with X11 forwarding.
67+
Once installed, the client needs to be configured to connect to the vCluster on which you are working.
68+
69+
First, start the client on your laptop:
70+
71+
=== "Linux"
72+
73+
The path will change if you have installed a different version, or if it has been installed in a non-standard installation location.
74+
75+
```bash
76+
$HOME/linaro/forge/24.1.1/bin/ddt
77+
```
78+
79+
=== "MacOS"
80+
81+
The path will change if you have installed a different version, or if it has been installed in a non-standard installation location.
82+
83+
```bash
84+
open /Applications/Linaro\ Forge\ Client\ 24.1.1.app/
85+
```
86+
87+
Next, configure a connection to the target system.
88+
Open the *Remote Launch* menu and click on *configure* then *Add*.
89+
Examples of the settings are below.
90+
91+
=== "Daint"
92+
93+
| Field | Value |
94+
| ----------- | --------------------------------------- |
95+
| Connection | `daint` |
96+
97+
| Remote Installation Directory | `uenv run linaro-forge/24.1.1:/user-tools -- /user-tools/env/forge/` |
98+
99+
=== "Santis"
100+
101+
| Field | Value |
102+
| ----------- | --------------------------------------- |
103+
| Connection | `santis` |
104+
105+
| Remote Installation Directory | `uenv run linaro-forge/24.1.1:/user-tools -- /user-tools/env/forge/` |
106+
107+
=== "Clariden"
108+
109+
| Field | Value |
110+
| ----------- | --------------------------------------- |
111+
| Connection | `clariden` |
112+
113+
| Remote Installation Directory | `uenv run linaro-forge/24.1.1:/user-tools -- /user-tools/env/forge/` |
114+
115+
=== "Eiger"
116+
117+
| Field | Value |
118+
| ----------- | --------------------------------------- |
119+
| Connection | `eiger` |
120+
121+
| Remote Installation Directory | `uenv run linaro-forge/24.1.1:/user-tools -- /user-tools/env/forge/` |
122+
123+
!!! tip
124+
125+
It is recommended to log into Alps using `ela.cscs.ch` as a ssh Jump host, as explained [here][ref-ssh-config].
126+
In that case, you can remove `[email protected]` from the Linaro client configuration above.
127+
128+
Some notes on the examples above:
129+
130+
* SSH forwarding via `ela.cscs.ch` is used to access the cluster;
131+
* replace the username `cscsusername` with your CSCS user name that you would normally use to open an SSH connection to CSCS;
132+
* `Remote Installation Path` is pointing to the install directory of ddt inside the image;
133+
* private keys should be the ones generated for CSCS MFA, and this field does not need to be set if you have added the key to your [SSH agent][ref-ssh-agent].
134+
135+
Once configured, test and save the configuration:
136+
137+
1. check whether the configuration is correct, click `Test Remote Launch`.
138+
2. Click on `ok` and `close` to save the configuration.
139+
3. You can now connect by going to `Remote Launch` and choose the `Alps` entry.
140+
If the client fails to connect, look at the error message, check your SSH
141+
configuration and make sure you can ssh without the client.
142+
143+
[](){#ref-uenv-linaro-troubleshooting}
144+
## Troubleshooting
145+
146+
Notes about known issues.
147+
148+
!!! warning "The proxy type is invalid for this operation"
149+
150+
If the tool fails to launch with the following error message:
151+
152+
Error communicating with Licence Server velan.cscs.ch:
153+
The proxy type is invalid for this operation
154+
Attempting again while ignoring proxies.
155+
156+
Proxy environment variables need to be set to let the tool connect to the license server, as explained in [Compute node proxy configuration][ref-guides-internet-access].
157+
158+
!!! note "AMD GPU support"
159+
160+
CSCS does not currently have a Linaro license for AMD gpus.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
[](){#ref-devtools-map}
2+
# Linaro Forge MAP and Performance Reports
3+
4+
MAP can be used for profiling serial, multi-threaded (OpenMP), multi-process (MPI) and accelerated (Cuda, OpenACC) programs running on research and production systems, including the CSCS Alps system.
5+
MAP can be executed either with its graphical user interface or from the command-line.
6+
7+
Linaro MAP can be used to profile an application either by the GUI or by the CLI.
8+
In the first case the user can set the profiling configuration using the GUI and then see the results.
9+
In the latter (recommended) case, the user can use the MAP executable to launch the application they want to profile which will generate a report file that can then be opened from the locally installed [client](https://docs.linaroforge.com/latest/html/forge/forge/installing/mac_install.html).
10+
11+
!!! note
12+
Linaro Map is provided in the `linaro-forge` uenv.
13+
Before using Map, please read the [`linaro-forge` documentation][ref-uenv-linaro], which explains how to download and set up the latest version and set it up.
14+
15+
## Linaro Forge MAP
16+
17+
We will focus here on the profiling using MAP from the CLI but the same configuration applies in the other case as well.
18+
To debug an MPI application on Alps the following script is necessary:
19+
20+
```bash
21+
> map -n <num_of_procs> --mpi=slurm --mpiargs="<slurm_arguments>" \
22+
--profile <executable> <executable_arguments>
23+
```
24+
25+
This will generate a profile report in a binary file with suffix `.map`.
26+
27+
To open this file we can open the Linaro Forge Client on our local machine, navigate to the `Linaro MAP` tab, connect to the corresponding `Remote` and then select `LOAD PROFILE DATA FILE` to locate the file.
28+
29+
After loading the report file we will be in the home of Linaro MAP.
30+
31+
<img src="https://raw.githubusercontent.com/iomaganaris/alps-uenv/refs/heads/linaro_map_docs_archive/docs/images/map-home.png" width="800" />
32+
33+
## Linaro Forge Performance Reports
34+
35+
Linaro MAP also allows the generation of a high level Performance Report in HTML format that shows key metrics of the profiled application.
36+
To see this we can click in the toolbar `Reports > View HTML Performance Report in browser`.
37+
38+
This will look like the following:
39+
40+
<center>
41+
<img src="https://raw.githubusercontent.com/iomaganaris/alps-uenv/refs/heads/linaro_map_docs_archive/docs/images/perf-report.png" width="300">
42+
</center>
43+
44+
More informations regarding how to use Linaro MAP and Performance Reports are provided in the Forge [User Guide](https://docs.linaroforge.com/latest/html/forge/index.html).
45+
46+
## Troubleshooting
47+
48+
See the troubleshooting guide for the [`linaro-forge` uenv][ref-uenv-linaro-troubleshooting].
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[](){#ref-devtools-nsight}
2+
# NVIDIA Nsight
3+
4+
## NVIDIA Nsight Systems
5+
6+
[NVIDIA Nsight Systems](https://developer.nvidia.com/nsight-systems) is a system-wide performance analysis tool that enables developers to gain a deep understanding of how their applications utilize computing resources, such as CPUs, GPUs, memory, and I/O.
7+
The tool provides a unified view of application performance across the entire system, capturing detailed trace information that allows users to analyze how different components interact and where performance issues might arise.
8+
9+
A key advantage of Nsight Systems is its ability to provide detailed traces of GPU activity, offering deeper insights into GPU utilization.
10+
It features a timeline-based visualization, enabling developers to inspect the execution flow, pinpoint latencies, and correlate events across different system components.
11+
As a sampling profiler, it can be easily used to profile applications written in C, C++, Python, Fortran, or Julia by wrapping the application with the Nsight Systems profiler executable.
12+
13+
!!! note
14+
NVIDIA Nsight Systems is available with any [uenv][ref-uenv] that comes with a CUDA compiler, for instance [`prgenv-gnu`][ref-uenv-prgenv-gnu].
15+
16+
## NVIDIA Nsight Compute
17+
18+
[NVIDIA Nsight Compute](https://developer.nvidia.com/nsight-compute) is a performance analysis tool specifically designed for optimizing GPU-accelerated applications.
19+
It focuses on providing detailed metrics and insights into the performance of CUDA kernels, helping developers identify performance bottlenecks and improve the efficiency of their GPU code.
20+
Nsight Compute offers a kernel-level profiler with customizable reports, enabling in-depth analysis of memory usage, compute utilization, and instruction throughput.
21+
As a sampling profiler, it can be easily used to profile applications written in C, C++, Python, Fortran, or Julia by wrapping the application with the Nsight Compute profiler executable.
22+
23+
!!! note
24+
NVIDIA Nsight Systems is available with any [uenv][ref-uenv] that comes with a CUDA compiler, for instance [`prgenv-gnu`][ref-uenv-prgenv-gnu].
25+
26+
### Known Issues and Common Problems
27+
28+
??? warning "CrashReporter: Qt initialization failed, Failed to load Qt platform plugin: xcb"
29+
While we recommend using `ncu` instead of `ncu-ui`, it is possible to use X11 to launch ncu-ui.
30+
However, this will fail with the following error message: `Failed to load Qt platform plugin: "xcb"`.
31+
32+
To workaround this issue, you can follow these instructions:
33+
34+
```bash
35+
ssh -Y -J <user>@ela.cscs.ch <user>@daint.alps.cscs.ch
36+
# the -Y ssh flag enables trusted X11 forwarding.
37+
wget https://jfrog.svc.cscs.ch/artifactory/cscs-reframe-tests/nvidia/ncu_deps.tar.gz
38+
tar xf ncu_deps.tar.gz
39+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/usr/lib64
40+
ncu-ui &
41+
```
42+

docs/software/tools/index.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)