@@ -63,8 +63,9 @@ struct ClusterNative {
6363 static constexpr int scalePadPacked = 64 ; // < ~60 is needed for 0.1mm precision, but power of two avoids rounding
6464 static constexpr int scaleSigmaTimePacked = 32 ; // 1/32nd of pad/timebin precision for cluster size
6565 static constexpr int scaleSigmaPadPacked = 32 ;
66- static constexpr int scaleSaturatedQTot = 4 ;
67- static constexpr int maxSaturatedQTot = USHRT_MAX * scaleSaturatedQTot;
66+ static constexpr int scaleSaturatedQtot = 8 ;
67+ static constexpr int maxRegularQtot = 25 * 1024 ;
68+ static constexpr int maxSaturatedQtot = (USHRT_MAX - maxRegularQtot) * scaleSaturatedQtot;
6869
6970 uint32_t timeFlagsPacked; // < Contains the time in the lower 24 bits in a packed format, contains the flags in the
7071 // upper 8 bits
@@ -89,9 +90,8 @@ struct ClusterNative {
8990 GPUd () uint16_t getQtot () const
9091 {
9192 if (isSaturated ()) [[unlikely]] {
92- // Check for overflow, so return type can stay uint16
93- auto sqtot = getSaturatedQtot ();
94- return sqtot <= USHRT_MAX ? sqtot : USHRT_MAX;
93+ auto sQtot = getSaturatedQtot ();
94+ return sQtot < USHRT_MAX ? sQtot : USHRT_MAX;
9595 }
9696 return qTot;
9797 }
@@ -155,19 +155,19 @@ struct ClusterNative {
155155 sigmaPadPacked = tmp;
156156 }
157157
158- GPUd () bool isSaturated () const { return qMax >= 1023 ; }
158+ GPUd () bool isSaturated () const { return qTot > maxRegularQtot ; }
159159
160160 GPUd () void setSaturatedQtot (uint32_t qtot)
161161 {
162- if (qtot > maxSaturatedQTot) {
163- qtot = maxSaturatedQTot;
162+ this ->qTot = USHRT_MAX;
163+ if (qtot < maxSaturatedQtot) {
164+ this ->qTot = ((qtot + scaleSaturatedQtot / 2 ) / scaleSaturatedQtot) + maxRegularQtot;
164165 }
165- this ->qTot = (qtot + scaleSaturatedQTot / 2 ) / scaleSaturatedQTot;
166166 }
167167
168168 GPUd () uint32_t getSaturatedQtot () const
169169 {
170- return uint32_t (qTot) * scaleSaturatedQTot ;
170+ return uint32_t (qTot - maxRegularQtot ) * scaleSaturatedQtot ;
171171 }
172172
173173 GPUd () void setSaturatedTailLength (uint32_t tail)
0 commit comments