Allow to easily experiment with 32 bit "max version" type
Some checks failed
Tests / Clang total: 1038, passed: 1038
Clang |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |0|0|0|0|:clap:
Tests / SIMD fallback total: 1038, passed: 1038
Tests / Release [gcc] total: 1038, passed: 1038
GNU C Compiler (gcc) |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |0|0|0|0|:clap:
Tests / Release [gcc,aarch64] total: 775, passed: 775
Tests / Coverage total: 779, passed: 779
weaselab/conflict-set/pipeline/head There was a failure building this commit

This commit is contained in:
2024-06-28 13:54:12 -07:00
parent efb0e52a0a
commit 0e96177f5c

View File

@@ -242,6 +242,8 @@ constexpr int kNodeCopySize =
// children's parent pointers. The caller must then insert the new node into the
// tree.
using MaxVersionT = int64_t;
struct Node0 : Node {
constexpr static auto kType = Type_Node0;
uint8_t *partialKey() { return (uint8_t *)(this + 1); }
@@ -258,7 +260,7 @@ struct Node3 : Node {
// Sorted
uint8_t index[kMaxNodes];
Node *children[kMaxNodes];
int64_t childMaxVersion[kMaxNodes];
MaxVersionT childMaxVersion[kMaxNodes];
uint8_t *partialKey() { return (uint8_t *)(this + 1); }
void copyChildrenAndKeyFrom(const Node0 &other);
@@ -274,7 +276,7 @@ struct Node16 : Node {
// Sorted
uint8_t index[kMaxNodes];
Node *children[kMaxNodes];
int64_t childMaxVersion[kMaxNodes];
MaxVersionT childMaxVersion[kMaxNodes];
uint8_t *partialKey() { return (uint8_t *)(this + 1); }
void copyChildrenAndKeyFrom(const Node3 &other);
@@ -291,13 +293,13 @@ struct Node48 : Node {
int8_t nextFree;
int8_t index[256];
Node *children[kMaxNodes];
int64_t childMaxVersion[kMaxNodes];
MaxVersionT childMaxVersion[kMaxNodes];
uint8_t reverseIndex[kMaxNodes];
constexpr static int kMaxOfMaxPageSize = 16;
constexpr static int kMaxOfMaxShift =
std::countr_zero(uint32_t(kMaxOfMaxPageSize));
constexpr static int kMaxOfMaxTotalPages = kMaxNodes / kMaxOfMaxPageSize;
int64_t maxOfMax[kMaxOfMaxTotalPages];
MaxVersionT maxOfMax[kMaxOfMaxTotalPages];
uint8_t *partialKey() { return (uint8_t *)(this + 1); }
@@ -312,12 +314,12 @@ struct Node256 : Node {
constexpr static auto kType = Type_Node256;
BitSet bitSet;
Node *children[256];
int64_t childMaxVersion[256];
MaxVersionT childMaxVersion[256];
constexpr static int kMaxOfMaxPageSize = 16;
constexpr static int kMaxOfMaxShift =
std::countr_zero(uint32_t(kMaxOfMaxPageSize));
constexpr static int kMaxOfMaxTotalPages = 256 / kMaxOfMaxPageSize;
int64_t maxOfMax[kMaxOfMaxTotalPages];
MaxVersionT maxOfMax[kMaxOfMaxTotalPages];
uint8_t *partialKey() { return (uint8_t *)(this + 1); }
void copyChildrenAndKeyFrom(const Node48 &other);
void copyChildrenAndKeyFrom(const Node256 &other);
@@ -1710,7 +1712,7 @@ downLeftSpine:
}
// Returns true if all in-bounds vs are <= readVersion
bool scan16(const int64_t *vs, const uint8_t *is, int begin, int end,
bool scan16(const MaxVersionT *vs, const uint8_t *is, int begin, int end,
int64_t readVersion) {
assert(end - begin < 256);
@@ -2798,16 +2800,16 @@ void setMaxVersion(Node *n, ConflictSet::Impl *impl, int64_t newMax) {
assert(n48->bitSet.test(index));
int i = n48->index[index];
n48->childMaxVersion[i] = newMax;
n48->maxOfMax[i >> Node48::kMaxOfMaxShift] =
std::max(n48->maxOfMax[i >> Node48::kMaxOfMaxShift], newMax);
n48->maxOfMax[i >> Node48::kMaxOfMaxShift] = std::max<MaxVersionT>(
n48->maxOfMax[i >> Node48::kMaxOfMaxShift], newMax);
return;
}
case Type_Node256: {
auto *n256 = static_cast<Node256 *>(n);
assert(n256->bitSet.test(index));
n256->childMaxVersion[index] = newMax;
n256->maxOfMax[index >> Node256::kMaxOfMaxShift] =
std::max(n256->maxOfMax[index >> Node256::kMaxOfMaxShift], newMax);
n256->maxOfMax[index >> Node256::kMaxOfMaxShift] = std::max<MaxVersionT>(
n256->maxOfMax[index >> Node256::kMaxOfMaxShift], newMax);
return;
}
default: // GCOVR_EXCL_LINE