Skip to content

Commit 5863589

Browse files
committed
ITS: prepare to make further changes to the config
Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
1 parent b897656 commit 5863589

17 files changed

Lines changed: 228 additions & 170 deletions

File tree

Common/Utils/include/CommonUtils/EnumFlags.h

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <string>
2525
#include <sstream>
2626
#include <limits>
27+
#include <bit>
2728
#include <bitset>
2829
#include <initializer_list>
2930
#include <cstdint>
@@ -34,7 +35,15 @@
3435
#include <iostream>
3536
#include <iomanip>
3637

38+
#if !defined(__CUDACC__) && !defined(__HIPCC__)
39+
#define O2_ENUMFLAGS_ENABLE_REFLECTION 1
40+
#else
41+
#define O2_ENUMFLAGS_ENABLE_REFLECTION 0
42+
#endif
43+
44+
#if O2_ENUMFLAGS_ENABLE_REFLECTION
3745
#include "CommonUtils/StringUtils.h"
46+
#endif
3847

3948
namespace o2::utils
4049
{
@@ -55,6 +64,7 @@ concept EnumFlagHelper = requires {
5564
// This is very much inspired by much more extensive libraries like magic_enum.
5665
// Inspiration by its c++20 version (https://github.com/fix8mt/conjure_enum).
5766
// NOTE: Cannot detect if bit values past the underlying type are defined.
67+
#if O2_ENUMFLAGS_ENABLE_REFLECTION
5868
template <EnumFlagHelper E>
5969
struct FlagsHelper final {
6070
using U = std::underlying_type_t<E>;
@@ -317,10 +327,12 @@ struct FlagsHelper final {
317327
return false;
318328
}
319329
};
330+
#endif
320331

321332
} // namespace details::enum_flags
322333

323334
// Require an enum to fullfil what one would except from a bitset.
335+
#if O2_ENUMFLAGS_ENABLE_REFLECTION
324336
template <typename E>
325337
concept EnumFlag = requires {
326338
// range checks
@@ -332,6 +344,10 @@ concept EnumFlag = requires {
332344
requires !details::enum_flags::FlagsHelper<E>::hasNone(); // added automatically
333345
requires !details::enum_flags::FlagsHelper<E>::hasAll(); // added automatically
334346
};
347+
#else
348+
template <typename E>
349+
concept EnumFlag = details::enum_flags::EnumFlagHelper<E>;
350+
#endif
335351

336352
/**
337353
* \brief Class to aggregate and manage enum-based on-off flags.
@@ -358,7 +374,9 @@ template <EnumFlag E>
358374
class EnumFlags
359375
{
360376
static constexpr int DefaultBase{2};
377+
#if O2_ENUMFLAGS_ENABLE_REFLECTION
361378
using H = details::enum_flags::FlagsHelper<E>;
379+
#endif
362380
using U = std::underlying_type_t<E>;
363381
U mBits{0};
364382

@@ -388,18 +406,21 @@ class EnumFlags
388406
// Initialize with a list of flags.
389407
constexpr EnumFlags(std::initializer_list<E> flags) noexcept
390408
{
391-
std::for_each(flags.begin(), flags.end(), [this](const E f) noexcept { mBits |= to_bit(f); });
409+
for (const E f : flags) {
410+
mBits |= to_bit(f);
411+
}
392412
}
413+
#if O2_ENUMFLAGS_ENABLE_REFLECTION
393414
// Init from a string.
394415
//
395416
explicit EnumFlags(const std::string& str, int base = DefaultBase)
396417
{
397418
set(str, base);
398419
}
399-
// Destructor.
400-
constexpr ~EnumFlags() = default;
420+
#endif
401421

402-
static constexpr U None{0}; // Represents no flags set.
422+
static constexpr U None{0}; // Represents no flags set.
423+
#if O2_ENUMFLAGS_ENABLE_REFLECTION
403424
static constexpr U All{H::MaxRep}; // Represents all flags set.
404425

405426
// Return list of all enum values
@@ -432,6 +453,7 @@ class EnumFlags
432453
throw;
433454
}
434455
}
456+
#endif
435457
// Returns the raw bitset value.
436458
[[nodiscard]] constexpr auto value() const noexcept
437459
{
@@ -493,6 +515,7 @@ class EnumFlags
493515
}
494516

495517
// Checks if all flags are set.
518+
#if O2_ENUMFLAGS_ENABLE_REFLECTION
496519
[[nodiscard]] constexpr bool all() const noexcept
497520
{
498521
return mBits == All;
@@ -537,6 +560,7 @@ class EnumFlags
537560
}
538561
return oss.str();
539562
}
563+
#endif
540564

541565
// Checks if any flag is set (Boolean context).
542566
[[nodiscard]] constexpr explicit operator bool() const noexcept
@@ -645,6 +669,7 @@ class EnumFlags
645669
}
646670

647671
// Serializes the flag set to a string.
672+
#if O2_ENUMFLAGS_ENABLE_REFLECTION
648673
[[nodiscard]] std::string serialize() const
649674
{
650675
return std::to_string(mBits);
@@ -659,6 +684,7 @@ class EnumFlags
659684
}
660685
mBits = static_cast<U>(v);
661686
}
687+
#endif
662688

663689
// Counts the number of set bits (active flags).
664690
[[nodiscard]] constexpr size_t count() const noexcept
@@ -686,6 +712,7 @@ class EnumFlags
686712

687713
private:
688714
// Set implementation, bits was zeroed before.
715+
#if O2_ENUMFLAGS_ENABLE_REFLECTION
689716
void setImpl(const std::string& s, int base = 2)
690717
{
691718
// Helper to check if character is valid for given base
@@ -782,15 +809,20 @@ class EnumFlags
782809
throw std::invalid_argument("Cannot parse string!");
783810
}
784811
}
812+
#endif
785813
};
786814

815+
#if O2_ENUMFLAGS_ENABLE_REFLECTION
787816
template <EnumFlag E>
788817
std::ostream& operator<<(std::ostream& os, const EnumFlags<E>& f)
789818
{
790819
os << f.pstring(true);
791820
return os;
792821
}
822+
#endif
793823

794824
} // namespace o2::utils
795825

826+
#undef O2_ENUMFLAGS_ENABLE_REFLECTION
827+
796828
#endif

Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/TimeFrameGPU.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,30 @@ class TimeFrameGPU final : public TimeFrame<NLayers>
4242
void popMemoryStack(const int);
4343
void registerHostMemory(const int);
4444
void unregisterHostMemory(const int);
45-
void initialise(const int, const TrackingParameters&, const int);
46-
void loadIndexTableUtils(const int);
47-
void loadTrackingFrameInfoDevice(const int, const int);
48-
void createTrackingFrameInfoDeviceArray(const int);
49-
void loadUnsortedClustersDevice(const int, const int);
50-
void createUnsortedClustersDeviceArray(const int, const int = NLayers);
51-
void loadClustersDevice(const int, const int);
52-
void createClustersDeviceArray(const int, const int = NLayers);
53-
void loadClustersIndexTables(const int, const int);
54-
void createClustersIndexTablesArray(const int);
55-
void createUsedClustersDevice(const int, const int);
56-
void createUsedClustersDeviceArray(const int, const int = NLayers);
45+
void initialise(const TrackingParameters&, int maxLayers);
46+
void loadIndexTableUtils();
47+
void loadTrackingFrameInfoDevice(const int);
48+
void createTrackingFrameInfoDeviceArray();
49+
void loadUnsortedClustersDevice(const int);
50+
void createUnsortedClustersDeviceArray(const int = NLayers);
51+
void loadClustersDevice(const int);
52+
void createClustersDeviceArray(const int = NLayers);
53+
void loadClustersIndexTables(const int);
54+
void createClustersIndexTablesArray();
55+
void createUsedClustersDevice(const int);
56+
void createUsedClustersDeviceArray(const int = NLayers);
5757
void loadUsedClustersDevice();
58-
void loadROFrameClustersDevice(const int, const int);
59-
void createROFrameClustersDeviceArray(const int);
58+
void loadROFrameClustersDevice(const int);
59+
void createROFrameClustersDeviceArray();
6060
void loadROFCutMask(const int);
61-
void loadVertices(const int);
62-
void loadROFOverlapTable(const int);
63-
void loadROFVertexLookupTable(const int);
64-
void updateROFVertexLookupTable(const int);
61+
void loadVertices();
62+
void loadROFOverlapTable();
63+
void loadROFVertexLookupTable();
64+
void updateROFVertexLookupTable();
6565

6666
///
67-
void createTrackletsLUTDevice(const int, const int);
68-
void createTrackletsLUTDeviceArray(const int);
67+
void createTrackletsLUTDevice(bool, const int);
68+
void createTrackletsLUTDeviceArray();
6969
void loadTrackletsDevice();
7070
void loadTrackletsLUTDevice();
7171
void loadCellsDevice();
@@ -74,12 +74,12 @@ class TimeFrameGPU final : public TimeFrame<NLayers>
7474
void loadTrackSeedsChi2Device();
7575
void loadTrackSeedsDevice(bounded_vector<TrackSeedN>&);
7676
void createTrackletsBuffers(const int);
77-
void createTrackletsBuffersArray(const int);
77+
void createTrackletsBuffersArray();
7878
void createCellsBuffers(const int);
79-
void createCellsBuffersArray(const int);
79+
void createCellsBuffersArray();
8080
void createCellsDevice();
8181
void createCellsLUTDevice(const int);
82-
void createCellsLUTDeviceArray(const int);
82+
void createCellsLUTDeviceArray();
8383
void createNeighboursIndexTablesDevice(const int);
8484
void createNeighboursDevice(const unsigned int layer);
8585
void createNeighboursLUTDevice(const int, const unsigned int);

Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/TrackingKernels.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void countTrackletsInROFsHandler(const IndexTableUtils<NLayers>* utils,
5151
const int** clustersIndexTables,
5252
int** trackletsLUTs,
5353
gsl::span<int*> trackletsLUTsHost,
54-
const int iteration,
54+
const bool selectUPCVertices,
5555
const float NSigmaCut,
5656
bounded_vector<float>& phiCuts,
5757
const float resolutionPV,
@@ -82,7 +82,7 @@ void computeTrackletsInROFsHandler(const IndexTableUtils<NLayers>* utils,
8282
gsl::span<int> nTracklets,
8383
int** trackletsLUTs,
8484
gsl::span<int*> trackletsLUTsHost,
85-
const int iteration,
85+
const bool selectUPCVertices,
8686
const float NSigmaCut,
8787
bounded_vector<float>& phiCuts,
8888
const float resolutionPV,

0 commit comments

Comments
 (0)