Skip to content

Instantly share code, notes, and snippets.

View amirphl's full-sized avatar
🎯
Focusing

Amir M Pirhosseinloo amirphl

🎯
Focusing
View GitHub Profile
template <typename T, typename Comparator>
HOT ssize_t forward_lower_bound(std::span<const T> data, const T elem, const Comparator &comp) noexcept
{
static_assert(std::is_integral<T>::value, "T must be an integral type");
static_assert(std::hardware_constructive_interference_size == 64, "Cache line size must be 64 bytes");
static constexpr uint8_t chunk_size = sizeof(__m512i) / sizeof(T);
const T *begin = data.data();
const size_t size = data.size();
size_t remaining = size;