Skip to content

Commit e9d0cf2

Browse files
committed
GPU: clean up and split qconfig header
1 parent dc10792 commit e9d0cf2

10 files changed

Lines changed: 464 additions & 384 deletions

File tree

‎GPU/GPUTracking/Base/GPUParam.cxx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ using namespace o2::gpu;
2828
#include <cstring>
2929
#include <tuple>
3030

31-
#include "utils/qconfigrtc.h"
31+
#include "utils/qconfig_rtc.h"
3232

3333
void GPUParam::SetDefaults(float solenoidBz, bool assumeConstantBz)
3434
{

‎GPU/GPUTracking/DataTypes/GPUConfigDump.cxx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace
2929
GPUSettingsStandalone configStandalone;
3030
std::vector<std::function<void()>> qprint_global;
3131
#define QCONFIG_PRINT
32-
#include "utils/qconfig.h"
32+
#include "utils/qconfig_internal.h"
3333
#undef QCONFIG_PRINT
3434
} // namespace
3535

‎GPU/GPUTracking/Standalone/Benchmark/standalone.cxx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ std::vector<GPUChainTracking::InOutMemory> ioMemEvents;
9292

9393
int32_t ReadConfiguration(int argc, char** argv)
9494
{
95-
int32_t qcRet = qConfigParse(argc, (const char**)argv);
95+
int32_t qcRet = qConfig::qConfigParse(argc, (const char**)argv);
9696
if (qcRet) {
9797
if (qcRet != qConfig::qcrHelp) {
9898
printf("Error parsing command line parameters\n");
@@ -107,7 +107,7 @@ int32_t ReadConfiguration(int argc, char** argv)
107107
}
108108
if (configStandalone.printSettings > 1) {
109109
printf("Config Dump before ReadConfiguration\n");
110-
qConfigPrint();
110+
qConfig::qConfigPrint();
111111
}
112112
if (configStandalone.proc.debugLevel == -1) {
113113
configStandalone.proc.debugLevel = 0;
@@ -295,7 +295,7 @@ int32_t ReadConfiguration(int argc, char** argv)
295295
}
296296
if (configStandalone.printSettings > 1) {
297297
printf("Config Dump after ReadConfiguration\n");
298-
qConfigPrint();
298+
qConfig::qConfigPrint();
299299
}
300300

301301
return (0);

‎GPU/GPUTracking/utils/qconfig.cxx‎

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,16 @@
2222
#include <tuple>
2323
#include "qconfig.h"
2424
#include "qconfig_helpers.h"
25+
#include "qconfig_internal_helpers.h"
2526

2627
// Create config instances
2728
#define QCONFIG_PARSER_CXX
2829
#define QCONFIG_INSTANCE
29-
#include "qconfig.h"
30+
#include "qconfig_internal.h"
3031
#undef QCONFIG_INSTANCE
3132

3233
namespace qConfig
3334
{
34-
#define QCONFIG_SETTING(name, type) \
35-
struct qon_mxcat3(q, name, _t) { \
36-
type v; \
37-
constexpr qon_mxcat3(q, name, _t)(type s) : v(s) {} \
38-
}; \
39-
constexpr qon_mxcat3(q, name, _t) name(type v) { return (qon_mxcat3(q, name, _t)(v)); }
40-
41-
#define QCONFIG_SETTING_TEMPLATE(name) \
42-
template <typename T> \
43-
struct qon_mxcat3(q, name, _t) { \
44-
T v; \
45-
constexpr qon_mxcat3(q, name, _t)(const T& s) : v(s) {} \
46-
}; \
47-
template <typename T> \
48-
constexpr qon_mxcat3(q, name, _t)<T> name(T v) \
49-
{ \
50-
return (qon_mxcat3(q, name, _t) < T > (v)); \
51-
}
52-
53-
QCONFIG_SETTING(message, const char*)
54-
QCONFIG_SETTING_TEMPLATE(min)
55-
QCONFIG_SETTING_TEMPLATE(max)
56-
QCONFIG_SETTING_TEMPLATE(set)
57-
QCONFIG_SETTING_TEMPLATE(def)
5835

5936
static inline const char* getOptName(const char** argv, int32_t i)
6037
{
@@ -477,22 +454,22 @@ static inline void qConfigHelp(const char* subConfig = nullptr, int32_t followSu
477454
printf("Usage Info:");
478455
}
479456
#define QCONFIG_HELP
480-
#include "qconfig.h"
457+
#include "qconfig_internal.h"
481458
#undef QCONFIG_HELP
482459
if (followSub < 2) {
483460
printf("\n");
484461
}
485462
}
486463

487464
// Create parser for configuration
488-
static inline int32_t qConfigParse(int argc, const char** argv, const char* /*filename*/)
465+
int32_t qConfigParse(int argc, const char** argv, const char* /*filename*/)
489466
{
490467
for (int32_t i = 1; i < argc; i++) {
491468
const char* thisoption = argv[i];
492469
repeat:
493470
bool found = false;
494471
#define QCONFIG_PARSE
495-
#include "qconfig.h"
472+
#include "qconfig_internal.h"
496473
#undef QCONFIG_PARSE
497474
if (found == false) {
498475
printf("Invalid argument: %s\n", argv[i]);
@@ -505,16 +482,13 @@ static inline int32_t qConfigParse(int argc, const char** argv, const char* /*fi
505482

506483
std::vector<std::function<void()>> qprint_global;
507484
#define QCONFIG_PRINT
508-
#include "qconfig.h"
485+
#include "qconfig_internal.h"
509486
#undef QCONFIG_PRINT
510-
} // end namespace qConfig
511-
512-
// Main parse function called from outside
513-
int32_t qConfigParse(int argc, const char** argv, const char* filename) { return (qConfig::qConfigParse(argc, argv, filename)); }
514487

515488
void qConfigPrint()
516489
{
517-
for (auto& f : qConfig::qprint_global) {
490+
for (auto& f : qprint_global) {
518491
f();
519492
}
520493
}
494+
} // end namespace qConfig

‎GPU/GPUTracking/utils/qconfig.h‎

Lines changed: 5 additions & 339 deletions
Large diffs are not rendered by default.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright 2019-2020 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 qconfig_general.h
13+
/// \author David Rohr
14+
15+
#ifndef QCONFIG_H_GENERAL
16+
#define QCONFIG_H_GENERAL
17+
#ifndef GPUCA_GPUCODE_DEVICE
18+
#include <cstdint>
19+
#include <string>
20+
#endif
21+
22+
namespace qConfig
23+
{
24+
#ifndef GPUCA_GPUCODE_DEVICE
25+
int32_t qConfigParse(int argc, const char** argv, const char* filename = nullptr);
26+
void qConfigPrint(); // Print all settings
27+
template <class T>
28+
void qConfigPrint(const T& qconfig_tmp_object, const std::string& blockName = ""); // Print one sub config, specializations created in qconfig.cxx
29+
#endif
30+
enum qConfigRetVal { qcrOK = 0,
31+
qcrError = 1,
32+
qcrMinFailure = 2,
33+
qcrMaxFailure = 3,
34+
qcrHelp = 4,
35+
qcrCmd = 5,
36+
qcrArgMissing = 6,
37+
qcrArgIncomplete = 7,
38+
qcrArrayOverflow = 8 };
39+
} // namespace qConfig
40+
#endif // QCONFIG_H_GENERAL

0 commit comments

Comments
 (0)