Skip to content

Commit 68161aa

Browse files
updated the doc with instructions for Tracy wrapper
1 parent 6586c4c commit 68161aa

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

_docs_v7/Tracy-Integration.md

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,31 @@ This embeds the Tracy client into SU2 for profiling.
5050

5151
## Instrumenting SU2 Code
5252

53-
To profile a function in SU2, add Tracy macros to the source code. Here’s an example:
54-
55-
1. **Include the Tracy Header:**
56-
- Add this at the top of the source file:
57-
```c++
58-
#include <tracy/Tracy.hpp>
59-
```
60-
61-
2. **Instrument the Function:**
62-
- Use `ZoneScopedN` to mark the function for profiling:
63-
```c++
64-
void MyFunction() {
65-
ZoneScopedN("MyFunction");
66-
// Function implementation
67-
}
68-
```
69-
- The `"MyFunction"` label identifies this section in the Tracy GUI.
53+
To profile a function in SU2, you must use the project's centralized wrapper macros. This approach ensures that profiling can be cleanly enabled or disabled at compile time without modifying the core logic.
54+
55+
1. **Include the SU2 Tracy Wrapper Header:**
56+
- Add an include directive for `tracy_structure.hpp` at the top of your C++ source file. The relative path will depend on the file's location. For example, for a file in `SU2_CFD/src/fluid/`:
57+
```cpp
58+
#include "../../../Common/include/tracy_structure.hpp"
59+
```
60+
- **Important:** Do not include `<tracy/Tracy.hpp>` directly. The wrapper header manages the actual Tracy library.
61+
62+
2. **Instrument the Function with SU2 Macros:**
63+
- Use `SU2_ZONE_SCOPED_N("MyLabel")` to mark a function or scope with a custom name. This is the recommended macro for clarity.
64+
```cpp
65+
void MyFunction() {
66+
SU2_ZONE_SCOPED_N("MyFunction");
67+
// Function implementation
68+
}
69+
```
70+
- The label you provide (e.g., `"MyFunction"`) is what will appear in the Tracy profiler's timeline.
71+
- Alternatively, for a quick annotation, you can use `SU2_ZONE_SCOPED;`. This macro automatically uses the compiler-provided function name for the label.
72+
```cpp
73+
void MyFunction() {
74+
SU2_ZONE_SCOPED;
75+
// Function implementation
76+
}
77+
```
7078
7179
## Running the Profiler and Visualizing Data
7280

0 commit comments

Comments
 (0)