Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vector comparisons #2119

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Vector comparisons #2119

wants to merge 8 commits into from

Conversation

willdealtry
Copy link
Collaborator

Implement some portable vectorized comparisons

@willdealtry willdealtry changed the title Vector min max Vector comparisons Jan 14, 2025
Copy link

github-actions bot commented Mar 4, 2025

Label error. Requires exactly 1 of: patch, minor, major. Found:

@willdealtry willdealtry marked this pull request as ready for review March 4, 2025 16:16
list(APPEND arcticdb_core_libraries ${KERBEROS_LIBRARY})
list(APPEND arcticdb_core_includes ${KERBEROS_INCLUDE_DIR})
#list(APPEND arcticdb_core_libraries ${KERBEROS_LIBRARY})
#list(APPEND arcticdb_core_includes ${KERBEROS_INCLUDE_DIR})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uncomment

@@ -1097,7 +1105,7 @@ if(${TEST})
util/test/rapidcheck_string_pool.cpp
util/test/rapidcheck_main.cpp
util/test/rapidcheck_lru_cache.cpp
version/test/rapidcheck_version_map.cpp)
version/test/rapidcheck_version_map.cpp util/test/test_min_max_integer.cpp)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed here, although this code is a good candidate for rapidcheck testing

static_assert(HeaderSize == Align);
uint8_t data_[MinSize];
static const size_t DataAlignment = 64;
static const size_t PadSize = (DataAlignment - (HeaderDataSize % DataAlignment)) % DataAlignment;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mod operator is a no-op, (DataAlignment - (HeaderDataSize % DataAlignment)) < DataAlignment, so (DataAlignment - (HeaderDataSize % DataAlignment)) % DataAlignment == (DataAlignment - (HeaderDataSize % DataAlignment))

@@ -68,7 +68,7 @@ std::vector<ChunkedBufferImpl<BlockSize>> split(const ChunkedBufferImpl<BlockSiz
}

template std::vector<ChunkedBufferImpl<64>> split(const ChunkedBufferImpl<64>& input, size_t nbytes);
template std::vector<ChunkedBufferImpl<3968>> split(const ChunkedBufferImpl<3968>& input, size_t nbytes);
template std::vector<ChunkedBufferImpl<4032ul>> split(const ChunkedBufferImpl<4032ul>& input, size_t nbytes);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this just too small in error before?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's any data that has been written into storage in 3968 byte blocks, will they still be readable without further modifications?

@@ -19,8 +19,7 @@ class ColumnDataRandomAccessorTest : public testing::Test {
input_data.resize(n);
std::iota(input_data.begin(), input_data.end(), 42);
}
// 3968 bytes == 496 int64s per block, so 3 blocks here
size_t n{1000};
size_t n{1100};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment is useful, it's now 504 int64s per block

constexpr size_t lane_count = sizeof(VectorType) / sizeof(T);

T init_min = std::numeric_limits<T>::max();
T init_max = std::numeric_limits<T>::min();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It smells a bit that there are max related variables when only min is being computed and vice versa, but I can't see a way to refactor that removes them without a lot of code duplication


VectorType vector_min, vector_max;
if constexpr (ComputeMin) {
T* lanes = reinterpret_cast<T*>(&vector_min);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed, vector_min[i] should do the obvious thing
https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html


#ifdef HAS_VECTOR_EXTENSIONS

class MinMaxStressTest : public ::testing::Test {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could move to a benchmark

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of duplication in here, could we parametrize across supported types, and then move the random tests to rapidcheck?

return FloatExtremumFinder<T, FloatMaxComparator<T>>::find(data, n);
}

#else
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments below the #else as for min_max_integer.hpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants