Skip to content

Commit 07d4168

Browse files
committed
GPU: Improve settings handling and make GPUDisplayControl a qconfig GPUSettings struct
1 parent be26f4c commit 07d4168

15 files changed

Lines changed: 89 additions & 56 deletions

‎GPU/GPUTracking/Base/GPUParam.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "GPUCommonDef.h"
1919
#include "GPUCommonMath.h"
2020
#include "GPUDef.h"
21+
#define GPUSETTINGS_PARAM
2122
#include "GPUSettings.h"
2223
#include "GPUTPCGMPolynomialField.h"
2324
#include "DataFormatsTPC/Constants.h"

‎GPU/GPUTracking/Base/GPUParamRTC.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#define GPUPARAMRTC_H
1717

1818
#include "GPUParam.h"
19+
#define GPUSETTINGS_ALL
20+
#include "GPUSettings.h"
1921
#include <string>
2022

2123
namespace o2::gpu

‎GPU/GPUTracking/DataTypes/GPUConfigDump.cxx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "GPUConfigDump.h"
1616
#include "GPUDataTypesIO.h"
17+
#define GPUSETTINGS_ALL
1718
#include "GPUSettings.h"
1819

1920
#include <functional>

‎GPU/GPUTracking/DataTypes/GPUSettings.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
#define GPUSETTINGS_H
1717

1818
#include "GPUCommonDef.h"
19-
#include "GPUSettingsTypes.h"
2019

20+
#endif // GPUSETTINGS_H
21+
22+
// Outside of header guard, since might run it multiple times for different config structs
2123
#ifdef GPUCA_GPUCODE_DEVICE
2224
#define QCONFIG_GPU
2325
#endif
2426
// See GPUSettingsList.h for a list of all available settings of GPU Reconstruction
2527
#ifndef GPUCA_GPUCODE_GENRTC
2628
#include "utils/qconfig.h"
2729
#endif
28-
29-
#endif // GPUSETTINGS_H

‎GPU/GPUTracking/DataTypes/GPUSettingsParam.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
// clang-format off
1616

17+
// No include guard: included multiple times by qconfig with different macro definitions
18+
1719
// Derrived parameters used in GPUParam
1820
BeginHiddenConfig(GPUSettingsParam, param)
1921
AddVariableRTC(continuousTracking, int8_t, 0) // Continuous tracking, estimate bz and errors for abs(z) = 125cm during seeding

‎GPU/GPUTracking/Definitions/GPUSettingsList.h‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919
// Create plain-C struct for GPU code.
2020
// Create static constexpr with default values for GPU run time compilation
2121

22-
#ifdef BeginConfig // File should not be included without defining the macros, but rootcling will do for dictionary generation
22+
#include "GPUSettingsTypes.h"
23+
24+
#if (!defined(__CLING__) && !defined(G__DICTIONARY)) || defined(BeginSubConfig) // File should not be included without defining the macros, but rootcling will do for dictionary generation
2325

2426
// clang-format off
27+
BeginNamespace(o2::gpu)
2528

2629
// Settings concerning the reconstruction, stored as parameters in GPU constant memory
2730
// There must be no bool in here, use int8_t, as sizeof(bool) is compiler dependent and fails on GPUs!!!!!!
@@ -709,4 +712,6 @@ EndConfig()
709712
#endif // !GPUCA_STANDALONE
710713
#endif // !GPUCA_GPUCODE_DEVICE
711714

712-
#endif // #ifndef __CLING__
715+
EndNamespace() // o2::gpu
716+
717+
#endif // (!defined(__CLING__) && !defined(G__DICTIONARY)) || defined(BeginSubConfig)

‎GPU/GPUTracking/display/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ set(SRCS_NO_H helpers/GPUDisplayLoader.cxx
132132
frontend/GPUDisplayHelp.cxx
133133
frontend/GPUDisplayFrontendConfig.cxx)
134134

135-
set(HDRS_INSTALL helpers/GPUDisplayMagneticFieldConstants.h frontend/GPUDisplayFrontendKeys.h frontend/GPUDisplayControl.h)
135+
set(HDRS_INSTALL helpers/GPUDisplayMagneticFieldConstants.h frontend/GPUDisplayFrontendKeys.h GPUDisplayControl.h GPUDisplayTypes.h)
136136

137137
if(GPUCA_EVENT_DISPLAY_VULKAN)
138138
set(SRCS ${SRCS} backend/GPUDisplayBackendVulkan.cxx)

‎GPU/GPUTracking/display/GPUDisplay.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
#ifndef GPUDISPLAY_H
1616
#define GPUDISPLAY_H
1717

18+
#define GPUSETTINGS_DISPLAYCONTROL
19+
#include "GPUSettings.h"
1820
#include "frontend/GPUDisplayFrontend.h"
19-
#include "frontend/GPUDisplayControl.h"
2021
#include "backend/GPUDisplayBackend.h"
2122
#include "GPUDisplayInterface.h"
22-
#include "GPUSettings.h"
2323
#include "DataFormatsTPC/Constants.h"
2424

2525
#include <atomic>

‎GPU/GPUTracking/display/GPUDisplayControl.h‎

Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,34 @@
1212
/// \file GPUDisplayControl.h
1313
/// \author David Rohr
1414

15-
#ifndef GPUDISPLAYCONTROL_H
16-
#define GPUDISPLAYCONTROL_H
15+
// No include guard: included multiple times by qconfig with different macro definitions
1716

1817
#include <atomic>
1918
#include <cstdint>
2019
#include <string>
20+
#include "GPUDisplayTypes.h"
2121

22-
namespace o2::gpu
23-
{
24-
template <class T>
25-
struct GPUDisplayCopyableAtomic : std::atomic<T> { // std::atomic deletes the copy, here it copies the value
26-
using std::atomic<T>::atomic;
27-
GPUDisplayCopyableAtomic(const GPUDisplayCopyableAtomic& o) : std::atomic<T>(o.load()) {}
28-
GPUDisplayCopyableAtomic& operator=(const GPUDisplayCopyableAtomic& o)
29-
{
30-
this->store(o.load());
31-
return *this;
32-
}
33-
};
34-
35-
struct GPUDisplayControl { // Settings of the display without RTTI, copied to the Qt GUI
36-
GPUDisplayCopyableAtomic<int32_t> mDisplayControl = 0; // Control for next event (=1) or quit (=2)
37-
GPUDisplayCopyableAtomic<bool> mResetScene = false;
38-
int32_t mPrintInfoText = 1;
39-
bool mPrintInfoTextAlways = false;
40-
bool mRequestScreenshot = false;
41-
int32_t mAnimateScreenshot = 0;
42-
bool mAnimationChangeConfig = true;
43-
float mAnimationDelay = 2.f;
44-
bool mPrintInfoTextGUI = true; // Send the status and info text to the Qt GUI, shown at its bottom
45-
bool mGuiPrintInfo = false; // Show the info of options changed with Qt GUI elements (not for key presses in the GUI)
46-
bool mRotateModel = false; // Rotate the model instead of the camera, like holding RCTRL (set in the Qt GUI)
47-
bool mRotateAroundZ = false; // Rotate the TPC around the beamline, like holding RALT (set in the Qt GUI)
48-
std::string mFilterMacroCustom; // Code of the custom track filter ROOT macro (trackFilter = filterMacros.size() + 1), set in the Qt GUI
49-
std::string mScreenShotname = "screenshot"; // Name of screenshot and animation frame files, followed by numbers
50-
std::string mGLPosFile = "glpos.tmp"; // File for saving / loading the camera position
51-
std::string mGLAnimationFile = "glanimation.tmp"; // File for saving / loading the animation path
52-
int8_t mGuiDarkMode = -1; // Dark mode of the Qt GUI, -1 = not yet set: the GUI reports the system scheme when it starts
53-
float mGuiScale = 1.f; // Scale factor of text and elements of the Qt GUI (on top of the system scaling), Ctrl + mouse wheel / Ctrl + 0 in the GUI
54-
bool dummy = false; // dummy value to reference for keys that do not change variables
55-
};
56-
} // namespace o2::gpu
57-
58-
#endif
22+
// clang-format off
23+
BeginNamespace(o2::gpu)
24+
BeginHiddenConfig(GPUDisplayControl, control)
25+
AddVariable(mDisplayControl, GPUDisplayCopyableAtomic<int32_t>, 0) // Control for next event (=1) or quit (=2)
26+
AddVariable(mResetScene, GPUDisplayCopyableAtomic<bool>, false)
27+
AddVariable(mPrintInfoText, int32_t, 1)
28+
AddVariable(mPrintInfoTextAlways, bool, false)
29+
AddVariable(mRequestScreenshot, bool, false)
30+
AddVariable(mAnimateScreenshot, int32_t, 0)
31+
AddVariable(mAnimationChangeConfig, bool, true)
32+
AddVariable(mAnimationDelay, float, 2.f)
33+
AddVariable(mPrintInfoTextGUI, bool, true) // Send the status and info text to the Qt GUI, shown at its bottom
34+
AddVariable(mGuiPrintInfo, bool, false) // Show the info of options changed with Qt GUI elements (not for key presses in the GUI)
35+
AddVariable(mRotateModel, bool, false) // Rotate the model instead of the camera, like holding RCTRL (set in the Qt GUI)
36+
AddVariable(mRotateAroundZ, bool, false) // Rotate the TPC around the beamline, like holding RALT (set in the Qt GUI)
37+
AddVariable(mFilterMacroCustom, std::string, "") // Code of the custom track filter ROOT macro (trackFilter = filterMacros.size() + 1), set in the Qt GUI
38+
AddVariable(mScreenShotname, std::string, "screenshot") // Name of screenshot and animation frame files, followed by numbers
39+
AddVariable(mGLPosFile, std::string, "glpos.tmp") // File for saving / loading the camera position
40+
AddVariable(mGLAnimationFile, std::string, "glanimation.tmp") // File for saving / loading the animation path
41+
AddVariable(mGuiDarkMode, int8_t, -1) // Dark mode of the Qt GUI, -1 = not yet set: the GUI reports the system scheme when it starts
42+
AddVariable(mGuiScale, float, 1.f) // Scale factor of text and elements of the Qt GUI (on top of the system scaling), Ctrl + mouse wheel / Ctrl + 0 in the GUI
43+
AddVariable(dummy, bool, false) // dummy value to reference for keys that do not change variables
44+
EndConfig()
45+
EndNamespace() // o2::gpu
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2019-2026 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/// \file GPUDisplayTypes.h
13+
/// \author David Rohr
14+
15+
#ifndef GPUDISPLAYTYPES_H
16+
#define GPUDISPLAYTYPES_H
17+
18+
namespace o2::gpu
19+
{
20+
template <class T>
21+
struct GPUDisplayCopyableAtomic : std::atomic<T> { // std::atomic deletes the copy, here it copies the value
22+
using std::atomic<T>::atomic;
23+
GPUDisplayCopyableAtomic(const GPUDisplayCopyableAtomic& o) : std::atomic<T>(o.load()) {}
24+
GPUDisplayCopyableAtomic& operator=(const GPUDisplayCopyableAtomic& o)
25+
{
26+
this->store(o.load());
27+
return *this;
28+
}
29+
};
30+
} // namespace o2::gpu
31+
32+
#endif

0 commit comments

Comments
 (0)