Project
Loading...
Searching...
No Matches
RangeReference.h
Go to the documentation of this file.
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
15
16#ifndef ALICEO2_RANGEREFERENCE_H
17#define ALICEO2_RANGEREFERENCE_H
18
19#include "GPUCommonRtypes.h"
20#include "GPUCommonDef.h"
21
22namespace o2
23{
24namespace dataformats
25{
26// Composed range reference
27
28template <typename FirstEntry = int, typename NElem = int>
30{
31 public:
32 GPUd() RangeReference(FirstEntry ent, NElem n) { set(ent, n); }
33 GPUdDefault() RangeReference(const RangeReference<FirstEntry, NElem>& src) = default;
36 GPUd() void set(FirstEntry ent, NElem n)
37 {
38 mFirstEntry = ent;
40 }
41 GPUd() void clear() { set(0, 0); }
42 GPUd() FirstEntry getFirstEntry() const { return mFirstEntry; }
43 GPUd() FirstEntry getEntriesBound() const { return mFirstEntry + mEntries; }
44 GPUd() NElem getEntries() const { return mEntries; }
45 GPUd() void setFirstEntry(FirstEntry ent) { mFirstEntry = ent; }
46 GPUd() void setEntries(NElem n) { mEntries = n; }
47 GPUd() void changeEntriesBy(NElem inc) { mEntries += inc; }
48 GPUd() bool operator==(const RangeReference& other) const
49 {
50 return mFirstEntry == other.mFirstEntry && mEntries == other.mEntries;
51 }
52
53 private:
54 FirstEntry mFirstEntry;
55 NElem mEntries = 0;
56
58};
59
60// Compact (32bit long) range reference
61template <int NBitsN>
63{
64 using Base = unsigned int;
65
66 private:
67 static constexpr int NBitsTotal = sizeof(Base) * 8;
68 static constexpr Base MaskN = ((0x1 << NBitsN) - 1);
69 static constexpr Base MaskR = (~Base(0)) & (~MaskN);
70 Base mData = 0;
71 GPUd() void sanityCheck()
72 {
73 static_assert(NBitsN < NBitsTotal, "NBitsN too large");
74 }
75
76 public:
77 GPUd() RangeRefComp(int ent, int n) { set(ent, n); }
80 GPUhd() void set(int ent, int n)
81 {
82 mData = (Base(ent) << NBitsN) + (Base(n) & MaskN);
83 }
84 GPUd() static constexpr Base getMaxFirstEntry() { return MaskR >> NBitsN; }
85 GPUd() static constexpr Base getMaxEntries() { return MaskN; }
86 GPUhd() int getFirstEntry() const { return mData >> NBitsN; }
87 GPUhd() int getEntries() const { return mData & ((0x1 << NBitsN) - 1); }
88 GPUhd() int getEntriesBound() const { return getFirstEntry() + getEntries(); }
89 GPUhd() void setFirstEntry(int ent) { mData = (Base(ent) << NBitsN) | (mData & MaskN); }
90 GPUhd() void setEntries(int n) { mData = (mData & MaskR) | (Base(n) & MaskN); }
91 GPUhd() void changeEntriesBy(int inc) { setEntries(getEntries() + inc); }
92 GPUhd() bool operator==(const RangeRefComp& other) const
93 {
94 return mData == other.mData;
95 }
96
97 ClassDefNV(RangeRefComp, 1);
98};
99
100} // namespace dataformats
101} // namespace o2
102
103#endif
GPUhd() void changeEntriesBy(int inc)
GPUd() static const expr Base getMaxEntries()
GPUhd() void setEntries(int n)
GPUhd() int getFirstEntry() const
GPUhd() int getEntriesBound() const
GPUhd() void set(int ent
GPUd() static const expr Base getMaxFirstEntry()
GPUd() RangeRefComp(int ent
GPUhd() int getEntries() const
GPUhd() void setFirstEntry(int ent)
GPUdDefault() RangeRefComp()=default
GPUd() void changeEntriesBy(NElem inc)
GPUd() RangeReference(FirstEntry ent
GPUd() void setFirstEntry(FirstEntry ent)
GPUd() FirstEntry getEntriesBound() const
GPUd() NElem getEntries() const
GPUd() void setEntries(NElem n)
GPUd() bool operator
1st entry of the group
GPUdDefault() RangeReference(const RangeReference< FirstEntry
GPUd() FirstEntry getFirstEntry() const
ClassDefNV(RangeReference, 1)
GLdouble n
Definition glcorearb.h:1982
GLenum src
Definition glcorearb.h:1767
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
VectorOfTObjectPtrs other
vec clear()