Skip to content

Commit c2d41a0

Browse files
updated doc
1 parent e8eaa60 commit c2d41a0

File tree

1 file changed

+39
-147
lines changed

1 file changed

+39
-147
lines changed

_docs_v7/Tracy-Integration.md

Lines changed: 39 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@ title: Integrating Tracy Profiler with SU2
33
permalink: /docs_v7/Tracy-Integration/
44
---
55

6-
---
7-
86
- [Introduction](#introduction)
9-
- [Prerequisites](#prerequisites)
10-
- [Integrating Tracy with SU2](#integrating-tracy-with-su2)
11-
- [Setting Up the Tracy Server](#setting-up-the-tracy-server)
7+
- [Compiling SU2 with Tracy](#compiling-su2-with-tracy)
128
- [Instrumenting SU2 Code](#instrumenting-su2-code)
13-
- [Using Tracy for Profiling](#using-tracy-for-profiling)
9+
- [Running the Profiler and Visualizing Data](#running-the-profiler-and-visualizing-data)
1410
- [Conclusion](#conclusion)
1511

1612
---
@@ -19,191 +15,87 @@ permalink: /docs_v7/Tracy-Integration/
1915

2016
Tracy is a high-performance, real-time profiler designed for C++ applications, offering nanosecond-resolution timing with minimal overhead. It is an excellent tool for profiling computationally intensive software like SU2, where traditional profilers such as Valgrind may introduce significant slowdowns. This guide provides step-by-step instructions for integrating Tracy with SU2, enabling users to analyze and optimize the performance of their CFD simulations effectively.
2117

22-
## Prerequisites
23-
24-
Before integrating Tracy with SU2, ensure the following software is installed:
25-
26-
- **SU2 Source Code**: Version 8.2.0 or later.
27-
- **Meson Build System**: Version 0.61.1 or later.
28-
- **Git**: For retrieving the Tracy repository.
29-
- **C++ Compiler**: Such as GCC.
30-
- **CMake**: Required for building the Tracy profiler.
31-
32-
For Ubuntu users, install additional dependencies required for the Tracy server with:
33-
34-
```bash
35-
sudo apt install libfreetype6-dev libcapstone-dev libdbus-1-dev \
36-
libxkbcommon-dev libwayland-dev wayland-protocols \
37-
libegl1-mesa-dev libglvnd-dev libgtk-3-dev
38-
```
39-
40-
## Integrating Tracy with SU2
41-
42-
To embed the Tracy client into SU2, you need to modify the Meson build configuration. The client collects profiling data during runtime. Follow these steps:
43-
44-
1. **Create a Wrap File for Tracy:**
45-
46-
- Navigate to the SU2 source directory: `cd <SU2_SOURCE_DIR>`.
47-
- Create a file named `subprojects/tracy.wrap` with the following content:
48-
49-
```ini
50-
[wrap-git]
51-
url = https://github.com/wolfpld/tracy.git
52-
revision = master
53-
depth = 1
54-
```
55-
56-
2. **Update Meson Options:**
57-
58-
- Edit `meson_options.txt` (or `meson.options`) in `<SU2_SOURCE_DIR>` to include:
59-
60-
```meson
61-
option('tracy_enable',
62-
type: 'boolean',
63-
value: false,
64-
description: 'Enable Tracy profiling support')
65-
```
18+
## Compiling SU2 with Tracy
6619

67-
3. **Modify the Main Meson Build File:**
68-
69-
- Open `meson.build` in `<SU2_SOURCE_DIR>` and add Tracy as a dependency when enabled:
70-
71-
```meson
72-
if get_option('tracy_enable')
73-
tracy_dep = dependency('tracy', static: true)
74-
su2_deps += tracy_dep
75-
su2_cpp_args += '-DTRACY_ENABLE'
76-
77-
if get_option('buildtype') != 'debugoptimized'
78-
warning('For optimal Tracy profiling, use --buildtype=debugoptimized')
79-
endif
80-
endif
81-
```
82-
83-
- Update the `default_options` at the top of `meson.build`:
84-
85-
```meson
86-
default_options: ['buildtype=release',
87-
'warning_level=0',
88-
'c_std=c99',
89-
'cpp_std=c++11',
90-
'tracy_enable=false']
91-
```
92-
93-
- Update the Build Summary to display Tracy status by inserting `get_option('tracy_enable')` into the summary format string (adjust the index accordingly, e.g., `@14@`):
94-
95-
```meson
96-
Tracy Profiler: @14@
97-
```
98-
99-
And update the install instruction line:
100-
101-
```meson
102-
Use './ninja -C @15@ install' to compile and install SU2
103-
```
104-
105-
4. **Build SU2 with Tracy:**
106-
107-
- Ensure Meson is updated:
20+
To compile SU2 with Tracy support, follow these steps:
10821

22+
1. **Install Required Tools:**
23+
- Tracy requires Meson version >=1.3.0, which is newer than the version provided by SU2. Install it manually:
10924
```bash
11025
pip install --user --upgrade meson
11126
```
27+
- Install Ninja manually, as it is required for the build process:
28+
```bash
29+
sudo apt install ninja-build
30+
```
11231

113-
- Run the preconfigure script:
114-
32+
2. **Run the Preconfigure Script:**
33+
- Since the provided `meson.py` script is not used, run the preconfigure script to set up the build environment:
11534
```bash
11635
./preconfigure.py
11736
```
11837

119-
- Configure and build SU2:
120-
38+
3. **Configure and Build SU2:**
39+
- Configure the build with Tracy enabled using Meson:
12140
```bash
122-
meson build_tracy -Dwith-mpi=disabled -Denable-pywrapper=true -Denable-mlpcpp=true --buildtype=debugoptimized -Dtracy_enable=true --prefix=<SU2_INSTALL_PATH>
123-
ninja -C build_tracy install
41+
meson setup build_tracy -Dwith-mpi=disabled -Denable-mlpcpp=true --buildtype=debugoptimized -Dtracy_enable=true --prefix=<SU2_INSTALL_PATH>
12442
```
125-
126-
- Replace `<SU2_SOURCE_DIR>` with the path to your SU2 source code and `<SU2_INSTALL_PATH>` with your desired installation directory.
127-
128-
This process integrates the Tracy client into SU2, enabling profiling capabilities.
129-
130-
## Setting Up the Tracy Server
131-
132-
The Tracy server is the graphical application that visualizes profiling data collected by the client. To set it up:
133-
134-
1. **Build the Tracy Profiler:**
135-
136-
- Navigate to the Tracy directory: `cd <SU2_SOURCE_DIR>/subprojects/tracy`.
137-
- Use CMake to build the profiler:
138-
43+
- Build and install SU2:
13944
```bash
140-
cmake -B profiler/build -S profiler -DCMAKE_BUILD_TYPE=Release -DLEGACY=ON
141-
cmake --build profiler/build --config Release --parallel
45+
ninja -C build_tracy install
14246
```
47+
- Replace `<SU2_INSTALL_PATH>` with your desired installation directory.
14348

144-
- The `-DLEGACY=ON` flag enables X11 support, which may be necessary for some systems. Omit this flag if Wayland is preferred and supported.
145-
146-
The Tracy server is now ready to display profiling data.
49+
This embeds the Tracy client into SU2 for profiling.
14750

14851
## Instrumenting SU2 Code
14952

150-
To collect meaningful profiling data, instrument the SU2 source code with Tracy macros. For example, to profile a specific function:
53+
To profile a function in SU2, add Tracy macros to the source code. Here’s an example:
15154

15255
1. **Include the Tracy Header:**
153-
154-
- Add the following at the top of the source file:
155-
56+
- Add this at the top of the source file:
15657
```c++
15758
#include <tracy/Tracy.hpp>
15859
```
15960

160-
2. **Add Profiling Macros:**
161-
162-
- Instrument the function with `ZoneScopedN`:
163-
61+
2. **Instrument the Function:**
62+
- Use `ZoneScopedN` to mark the function for profiling:
16463
```c++
16564
void MyFunction() {
16665
ZoneScopedN("MyFunction");
16766
// Function implementation
16867
}
16968
```
69+
- The `"MyFunction"` label identifies this section in the Tracy GUI.
17070

171-
- The `ZoneScopedN("name")` macro defines a profiling zone, labeled for identification in the Tracy GUI.
172-
173-
Repeat this process for any functions or code sections you wish to profile.
174-
175-
## Using Tracy for Profiling
176-
177-
With the client integrated, the server built, and the code instrumented, you can profile SU2 simulations:
178-
179-
1. **Launch the Tracy Profiler:**
71+
## Running the Profiler and Visualizing Data
18072

181-
- Navigate to the profiler build directory:
73+
After compiling and instrumenting SU2, profile and visualize the data as follows:
18274

75+
1. **Build the Tracy Server:**
76+
- Navigate to the Tracy directory: `cd <SU2_SOURCE_DIR>/subprojects/tracy`.
77+
- Build the profiler using CMake:
18378
```bash
184-
cd <SU2_SOURCE_DIR>/subprojects/tracy/profiler/build
79+
cmake -B profiler/build -S profiler -DCMAKE_BUILD_TYPE=Release
80+
cmake --build profiler/build --config Release --parallel
18581
```
18682

83+
2. **Launch the Tracy Profiler:**
18784
- Run the profiler:
188-
18985
```bash
190-
./tracy-profiler
86+
./profiler/build/tracy-profiler
19187
```
88+
- Click "Connect" in the GUI to wait for SU2.
19289

193-
- In the GUI, click "Connect" to wait for a connection from SU2.
194-
195-
2. **Execute the Instrumented SU2 Simulation:**
196-
197-
- In a separate terminal, navigate to your simulation directory and run:
198-
90+
3. **Run the SU2 Simulation:**
91+
- In a separate terminal, execute your simulation:
19992
```bash
20093
<SU2_INSTALL_PATH>/bin/SU2_CFD <your_config_file>.cfg
20194
```
95+
- Replace `<SU2_INSTALL_PATH>` and `<your_config_file>` with your installation path and configuration file.
20296

203-
- Replace `<SU2_INSTALL_PATH>` with your installation path and `<your_config_file>` with your configuration file.
204-
205-
As the simulation runs, Tracy will display real-time profiling data, allowing you to analyze performance metrics and identify bottlenecks.
97+
The Tracy GUI will display real-time profiling data during the simulation.
20698

20799
## Conclusion
208100

209-
Integrating Tracy with SU2 equips users with a powerful, low-overhead tool for profiling and optimizing CFD simulations. Its real-time visualization and precise timing capabilities make it ideal for performance analysis. For advanced features, troubleshooting, or additional details, consult the [Tracy documentation](https://github.com/wolfpld/tracy/releases/latest/download/tracy.pdf).
101+
Integrating Tracy with SU2 equips users with a powerful, low-overhead tool for profiling and optimizing CFD simulations. Its real-time visualization and precise timing capabilities make it ideal for performance analysis. For advanced features, troubleshooting, or additional details, consult the [Tracy documentation](https://github.com/wolfpld/tracy/releases/latest/download/tracy.pdf).

0 commit comments

Comments
 (0)