Skip to content

Commit

Permalink
implemented prefetching in ordered trees for smart pointer keys
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffplaisance committed Oct 13, 2023
1 parent 5cad5d9 commit b383f37
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions include/bpptree/detail/ordered_detail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@

namespace bpptree::detail {

template <typename T, typename = void>
struct IsPtrOrSmartPtr : std::false_type {};

template <typename T>
struct IsPtrOrSmartPtr<T, std::enable_if_t<std::is_pointer_v<decltype(&*std::declval<T const&>())>>> : std::true_type {};

template <typename T, typename = void>
struct HasDataPtr : std::false_type {};

Expand All @@ -38,9 +44,9 @@ struct OrderedDetail {

template <typename Comp>
IndexType find_key_index(Key const& search_val, Comp const& comp) const {
if constexpr (std::is_pointer_v<Key>) {
if constexpr (IsPtrOrSmartPtr<Key>::value) {
for (IndexType i = 0; i < this->length; ++i) {
__builtin_prefetch(extractor.get_key(this->values[i]), 0, 3);
__builtin_prefetch(&*extractor.get_key(this->values[i]), 0, 3);
}
}
if constexpr (HasDataPtr<Key>::value) {
Expand Down Expand Up @@ -254,9 +260,9 @@ struct OrderedDetail {

template <typename Comp>
IndexType find_key_index(Key const& search_val, Comp const& comp) const {
if constexpr (std::is_pointer_v<Key>) {
if constexpr (IsPtrOrSmartPtr<Key>::value) {
for (IndexType i = 0; i < this->length; ++i) {
__builtin_prefetch(keys[i], 0, 3);
__builtin_prefetch(&*keys[i], 0, 3);
}
}
if constexpr (HasDataPtr<Key>::value) {
Expand Down

0 comments on commit b383f37

Please sign in to comment.