Skip to content

Commit 1d61b75

Browse files
authored
Merge pull request #2536 from divyaprakash-iitd/feature_tracy
Tracy profiler integration
2 parents 0b6e0ad + b91452c commit 1d61b75

File tree

4 files changed

+63
-2
lines changed

4 files changed

+63
-2
lines changed

Common/include/tracy_structure.hpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*!
2+
* \file tracy_structure.hpp
3+
* \brief Tracy profiler interface header.
4+
* Provides compatibility macros if the code is built without
5+
* tracy support. Profiling macros are defined here so that
6+
* they can be completely "disabled" when compiling without tracy.
7+
* \note Do not include tracy headers explicitly anywhere, use this header instead.
8+
* \note To enable tracy, define the TRACY_ENABLE macro during compilation.
9+
* \author Divyaprakash
10+
* \version 8.2.0 "Harrier"
11+
*
12+
* SU2 Project Website: https://su2code.github.io
13+
*
14+
* The SU2 Project is maintained by the SU2 Foundation
15+
* (http://su2foundation.org)
16+
*
17+
* Copyright 2012-2025, SU2 Contributors (cf. AUTHORS.md)
18+
*
19+
* SU2 is free software; you can redistribute it and/or
20+
* modify it under the terms of the GNU Lesser General Public
21+
* License as published by the Free Software Foundation; either
22+
* version 2.1 of the License, or (at your option) any later version.
23+
*
24+
* SU2 is distributed in the hope that it will be useful,
25+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
26+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27+
* Lesser General Public License for more details.
28+
*
29+
* You should have received a copy of the GNU Lesser General Public
30+
* License along with SU2. If not, see <http://www.gnu.org/licenses/>.
31+
*/
32+
33+
#pragma once
34+
35+
#ifdef HAVE_TRACY
36+
#include "tracy/Tracy.hpp"
37+
#define SU2_ZONE_SCOPED ZoneScoped
38+
#define SU2_ZONE_SCOPED_N(name) ZoneScopedN(name)
39+
#else
40+
#define SU2_ZONE_SCOPED
41+
#define SU2_ZONE_SCOPED_N(name)
42+
#endif

meson.build

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,19 @@ if get_option('enable-autodiff') and not omp
120120
endif
121121
endif
122122

123+
# Add Tracy dependency if enabled
124+
if get_option('enable-tracy')
125+
tracy_dep = dependency('tracy', static: true)
126+
su2_deps += tracy_dep
127+
su2_cpp_args += '-DHAVE_TRACY'
128+
129+
# Add build type check
130+
if get_option('buildtype') != 'debugoptimized'
131+
warning('For optimal Tracy profiling, use --buildtype=debugoptimized')
132+
endif
133+
endif
134+
135+
123136
# add cgns library
124137
if get_option('enable-cgns')
125138
subdir('externals/cgns')
@@ -364,6 +377,7 @@ message('''---------------------------------------------------------------------
364377
libROM: @11@
365378
CoolProp: @12@
366379
MLPCpp: @13@
380+
Tracy Profiler: @14@
367381
368382
Please be sure to add the $SU2_HOME and $SU2_RUN environment variables,
369383
and update your $PATH (and $PYTHONPATH if applicable) with $SU2_RUN
@@ -375,11 +389,11 @@ message('''---------------------------------------------------------------------
375389
export PATH=$PATH:$SU2_RUN
376390
export PYTHONPATH=$PYTHONPATH:$SU2_RUN
377391
378-
Use './ninja -C @14@ install' to compile and install SU2
392+
Use './ninja -C @15@ install' to compile and install SU2
379393
'''.format(get_option('prefix')+'/bin', meson.project_source_root(), get_option('enable-tecio'), get_option('enable-cgns'),
380394
get_option('enable-autodiff'), get_option('enable-directdiff'), get_option('enable-pywrapper'), get_option('enable-mkl'),
381395
get_option('enable-openblas'), get_option('enable-pastix'), get_option('enable-mixedprec'), get_option('enable-librom'), get_option('enable-coolprop'),
382-
get_option('enable-mlpcpp'), meson.project_build_root().startswith(meson.project_source_root()) ? meson.project_build_root().split('/')[-1] : meson.project_build_root()))
396+
get_option('enable-mlpcpp'), get_option('enable-tracy'), meson.project_build_root().startswith(meson.project_source_root()) ? meson.project_build_root().split('/')[-1] : meson.project_build_root()))
383397

384398
if get_option('enable-mpp')
385399
if get_option('install-mpp')

meson_options.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ option('opdi-shared-read-opt', type : 'boolean', value : true, description : 'Op
2929
option('librom_root', type : 'string', value : '', description: 'libROM base directory')
3030
option('enable-librom', type : 'boolean', value : false, description: 'enable LLNL libROM support')
3131
option('static-cgns-deps', type : 'boolean', value : false, description: 'prefer static or dynamic (default) libraries for CGNS dependencies')
32+
option('enable-tracy', type: 'boolean', value: false, description: 'Enable Tracy profiling support')

subprojects/tracy.wrap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[wrap-git]
2+
url = https://github.com/wolfpld/tracy.git
3+
revision = master
4+
depth = 1

0 commit comments

Comments
 (0)