4 Commits

Author SHA1 Message Date
5378a06c39 Vectorize all bounds checks for Node256 scan
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
2024-06-27 17:40:23 -07:00
12c6ed2568 Reorganize to prepare for better vectorized first/last page 2024-06-27 17:21:41 -07:00
a2bf839b19 Update corpus 2024-06-27 17:15:35 -07:00
c065b185ae Vectorize inner page check for Node256 2024-06-27 17:09:45 -07:00
391 changed files with 54 additions and 22 deletions

View File

@@ -313,7 +313,7 @@ struct Node256 : Node {
BitSet bitSet;
Node *children[256];
int64_t childMaxVersion[256];
constexpr static int kMaxOfMaxPageSize = 8;
constexpr static int kMaxOfMaxPageSize = 16;
constexpr static int kMaxOfMaxShift =
std::countr_zero(uint32_t(kMaxOfMaxPageSize));
constexpr static int kMaxOfMaxTotalPages = 256 / kMaxOfMaxPageSize;
@@ -1779,6 +1779,7 @@ bool checkMaxBetweenExclusive(Node *n, int begin, int end,
}
// [begin, end) is now the half-open interval of children we're interested in.
assert(begin < end);
const unsigned shiftUpperBound = end - begin;
const unsigned shiftAmount = begin;
@@ -1820,36 +1821,67 @@ bool checkMaxBetweenExclusive(Node *n, int begin, int end,
}
case Type_Node256: {
auto *self = static_cast<Node256 *>(n);
// Check the first page
if (self->maxOfMax[begin >> Node256::kMaxOfMaxShift] > readVersion) {
bool result = true;
for (int i = 0; i < Node256::kMaxOfMaxPageSize; ++i) {
int j = (begin & ~(Node256::kMaxOfMaxPageSize - 1)) + i;
result &= !((self->childMaxVersion[j] > readVersion) & inBounds(j));
if (end <= 0) {
return true;
}
const int firstPage = begin >> Node256::kMaxOfMaxShift;
const int lastPage = (end - 1) >> Node256::kMaxOfMaxShift;
if (firstPage == lastPage) {
if (self->maxOfMax[firstPage] <= readVersion) {
return true;
}
if (!result) {
return result;
uint64_t conflict = 0;
// Check all in page
for (int i = 0; i < Node256::kMaxOfMaxPageSize; ++i) {
conflict |=
(self->childMaxVersion[(firstPage << Node256::kMaxOfMaxShift) + i] >
readVersion)
<< i;
}
// Mask away out of bounds
const int intraPageBegin = begin & (Node256::kMaxOfMaxPageSize - 1);
const int intraPageEnd = end - (lastPage << Node256::kMaxOfMaxShift);
conflict &= (1 << intraPageEnd) - 1;
conflict >>= intraPageBegin;
return !conflict;
}
// Check the first page
if (self->maxOfMax[firstPage] > readVersion) {
uint64_t conflict = 0;
for (int i = 0; i < Node256::kMaxOfMaxPageSize; ++i) {
int j = (firstPage << Node256::kMaxOfMaxShift) + i;
conflict |= (self->childMaxVersion[j] > readVersion) << i;
}
const int intraPageBegin = begin & (Node256::kMaxOfMaxPageSize - 1);
conflict >>= intraPageBegin;
if (conflict) {
return false;
}
}
// Check the last page
if (end >= 1 &&
self->maxOfMax[(end - 1) >> Node256::kMaxOfMaxShift] > readVersion) {
bool result = true;
if (self->maxOfMax[lastPage] > readVersion) {
uint64_t conflict = 0;
for (int i = 0; i < Node256::kMaxOfMaxPageSize; ++i) {
int j = ((end - 1) & ~(Node256::kMaxOfMaxPageSize - 1)) + i;
result &= !((self->childMaxVersion[j] > readVersion) & inBounds(j));
int j = (lastPage << Node256::kMaxOfMaxShift) + i;
conflict |= (self->childMaxVersion[j] > readVersion) << i;
}
if (!result) {
return result;
const int intraPageEnd = end - (lastPage << Node256::kMaxOfMaxShift);
conflict &= (1 << intraPageEnd) - 1;
if (conflict) {
return false;
}
}
// Check inner pages
bool result = true;
for (int i = (begin >> Node256::kMaxOfMaxShift) + 1;
i < ((end - 1) >> Node256::kMaxOfMaxShift); ++i) {
result &= self->maxOfMax[i] <= readVersion;
uint64_t conflict = 0;
// Check all possible inner pages
for (int i = 1; i < Node256::kMaxOfMaxTotalPages - 1; ++i) {
conflict |= (self->maxOfMax[i] > readVersion) << i;
}
return result;
// Only keep inner pages
const int innerPageBegin = (begin >> Node256::kMaxOfMaxShift) + 1;
const int innerPageEnd = (end - 1) >> Node256::kMaxOfMaxShift;
conflict &= (1 << innerPageEnd) - 1;
conflict >>= innerPageBegin;
return !conflict;
}
default: // GCOVR_EXCL_LINE
__builtin_unreachable(); // GCOVR_EXCL_LINE

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 B

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More