Project
Loading...
Searching...
No Matches
GPUCommonBitSet.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
14
15#ifndef GPUCOMMONBITSET_H
16#define GPUCOMMONBITSET_H
17
18// Limited reimplementation of std::bitset for the GPU.
19// Fixed to 32 bits for now.
20// In contrast to the GPUCommonArray, we cannot just use std::bitset on the host.
21// The layout may be implementation defined, so it is not guarantueed that we
22// get correct data after copying it into a gpustd::bitset on the GPU.
23
24#include "GPUCommonDef.h"
25#include "GPUCommonRtypes.h"
26#include "GPUCommonMath.h"
27#ifndef GPUCA_GPUCODE_DEVICE
28#include <string>
29#endif
30
32{
33template <uint32_t N>
34class bitset
35{
36 static_assert(N <= 32, "> 32 bits not supported");
37
38 public:
39 GPUdDefault() constexpr bitset() = default;
40#ifndef __METAL__
41 // MSL will not use a user-declared copy constructor to build an object in the
42 // constant address space, where GPUconstexpr() arrays of bitset live. Leaving
43 // it implicit is what makes those arrays constructible.
44 GPUdDefault() constexpr bitset(const bitset&) = default;
45#endif
46#ifdef __OPENCL__
47 GPUdDefault() constexpr bitset(const __constant bitset&) = default;
48#endif // __OPENCL__
49 GPUd() constexpr bitset(uint32_t vv) : v(vv) {};
50#ifdef __METAL__
51 GPUd() constexpr bitset(uint32_t vv) constant : v(vv) {};
52#endif
53 static GPUglobalconstexpr() uint32_t full_set = ((1ul << N) - 1ul);
54
55 GPUd() constexpr bool all() const { return (v & full_set) == full_set; }
56 GPUd() constexpr bool any() const { return v & full_set; }
57 GPUd() constexpr bool none() const { return !any(); }
58
59 GPUd() constexpr void set() { v = full_set; }
60 GPUd() constexpr void set(uint32_t i) { v |= (1u << i) & full_set; }
61 GPUd() constexpr void reset() { v = 0; }
62 GPUd() constexpr void reset(uint32_t i) { v &= ~(1u << i); }
63 GPUd() constexpr void flip() { v = (~v) & full_set; }
64
65 GPUdDefault() constexpr bitset& operator=(const bitset&) = default;
66 GPUd() constexpr bitset operator|(const bitset b) const { return v | b.v; }
67 GPUd() constexpr bitset& operator|=(const bitset b)
68 {
69 v |= b.v;
70 return *this;
71 }
72 GPUd() constexpr bitset operator&(const bitset b) const { return v & b.v; }
73 GPUd() constexpr bitset& operator&=(const bitset b)
74 {
75 v &= b.v;
76 return *this;
77 }
78 GPUd() constexpr bitset operator^(const bitset b) const { return v ^ b.v; }
79 GPUd() constexpr bitset& operator^=(const bitset b)
80 {
81 v ^= b.v;
82 return *this;
83 }
84 GPUd() constexpr bitset operator~() const { return (~v) & full_set; }
85 GPUd() constexpr bool operator==(const bitset b) const { return v == b.v; }
86 GPUd() constexpr bool operator!=(const bitset b) const { return v != b.v; }
87
88 GPUd() constexpr bool operator[](uint32_t i) const { return (v >> i) & 1u; }
89
90 GPUd() constexpr uint32_t to_ulong() const { return v; }
91
92 GPUd() constexpr uint32_t count() const
93 {
94 // count number of non-0 bits in 32bit word
95 return GPUCommonMath::Popcount(v);
96 }
97
98#ifndef GPUCA_GPUCODE_DEVICE
99 std::string to_string() const;
100#endif
101
102 private:
103 uint32_t v = 0;
104
105 ClassDefNV(bitset, 1);
106};
107
108#ifndef GPUCA_GPUCODE_DEVICE
109template <uint32_t N>
110inline std::string bitset<N>::to_string() const
111{
112 std::string retVal;
113 for (uint32_t i = N; i--;) {
114 retVal += std::to_string((int32_t)((*this)[i]));
115 }
116 return retVal;
117}
118template <class CharT, class Traits, uint32_t N>
119std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, const bitset<N>& x)
120{
121 os << x.to_string();
122 return os;
123}
124
125#endif
126} // namespace o2::gpu::gpustd
127
128#endif
unsigned int uint32_t
int32_t i
int32_t retVal
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder int32_t
GPUd() const expr void reset()
GPUd() const expr void reset(uint32_t i)
GPUd() const expr void flip()
GPUdDefault() const expr bitset &operator
GPUd() const expr bitset(uint32_t vv)
static GPUglobalconstexpr() uint32_t full_set
GPUd() const expr void set()
GPUd() const expr bool none() const
GPUd() const expr bool any() const
GPUdDefault() const expr bitset()=default
GPUd() const expr bitset &operator|
GPUdDefault() const expr bitset(const bitset &)=default
GPUd() const expr void set(uint32_t i)
GLint GLenum GLint x
Definition glcorearb.h:403
GLint GLsizei count
Definition glcorearb.h:399
const GLdouble * v
Definition glcorearb.h:832
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &os, const bitset< N > &x)
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52