ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
CountLess.h File Reference

The count of the items of a short array smaller than a key, the search in a node of the B-trees in main memory [see BTreeMap.h and StaticSearch.h]: on a sorted array of \( N \) items it is the place of the key, found with no branch. More...

#include <bit>
#include <cstddef>
#include <cstdint>
#include <type_traits>
#include "ADS/SimdInline.h"

Go to the source code of this file.

Namespaces

namespace  ADS

Detailed description

The count of the items of a short array smaller than a key, the search in a node of the B-trees in main memory [see BTreeMap.h and StaticSearch.h]: on a sorted array of \( N \) items it is the place of the key, found with no branch.

countLess< N >( a , x ) and countLess< N , true >( a , x ), the items not larger than \( x \), read all the \( N \) items, which must be there (the unused places of a node are padded with the largest value). greaterBits< N >( a , x ) gives the items larger than \( x \) as the bits of a word, \( N \le 64 \) [see WordRangeMinimum.h].

On the integers of 32 and 64 bits and on the floating types, with ADS_WITH_HIGHWAY, they are a few comparisons of the vectors of Highway inlined at the instructions of the compiler [see SimdInline.h], each giving a mask whose lanes a count of the lanes sums (16 items of 32 bits at once on AVX-512, 8 on AVX2, 4 on SSE2 and NEON); without it, and on the other types, the loop of the comparisons, which the compiler may vectorize or not (GCC 13 does not: it chains the carries of the comparisons, one item per cycle and a dependence from each to the next). An item that is a NaN counts as in the loop, as not smaller.

Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa