Skip to content

Commit

Permalink
update phmap
Browse files Browse the repository at this point in the history
  • Loading branch information
fcharlie committed Apr 19, 2024
1 parent bec4b4a commit 789d130
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# bela sources
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.27)

project(bela CXX C ASM)

Expand All @@ -21,11 +21,11 @@ option(BELA_ENABLE_ASSEMBLY_FILES "bela enable assembly files" OFF)
message(STATUS "CMAKE_ASM_COMPILER_ID ${CMAKE_ASM_COMPILER_ID}")

if(NOT (DEFINED CMAKE_CXX_STANDARD))
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 23)
endif()

if(CMAKE_CXX_STANDARD LESS 20 OR CMAKE_CXX_STANDARD STREQUAL "98")
message(FATAL_ERROR "Bela requires C++20 or later")
if(CMAKE_CXX_STANDARD LESS 23 OR CMAKE_CXX_STANDARD STREQUAL "98")
message(FATAL_ERROR "Bela requires C++23 or later")
endif()

set(CMAKE_CXX_STANDARD_REQUIRED YES)
Expand Down
2 changes: 1 addition & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![license badge](https://img.shields.io/github/license/fcharlie/bela.svg)](LICENSE)
[![Master Branch Status](https://github.com/fcharlie/bela/workflows/BelaCI/badge.svg)](https://github.com/fcharlie/bela/actions)

Modern C++20 library collection, better development experience on Windows (10,11)
Modern C++23 library collection, better development experience on Windows (10,11)

A lot of the code supports wchar_t based on Abseil modifications, some of which come from Visual C++ STL.

Expand Down
2 changes: 1 addition & 1 deletion include/bela/__phmap/VERSION
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
https://github.com/greg7mdp/parallel-hashmap.git
65775fa09fecaa65d0b0022ab6bf091c0e509445
10368163ab1f4367d2f0685b5928b1c973ebd1ec
29 changes: 12 additions & 17 deletions include/bela/__phmap/phmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,19 +206,23 @@ constexpr bool IsNoThrowSwappable(std::false_type /* is_swappable */) {
// --------------------------------------------------------------------------
template <typename T>
uint32_t TrailingZeros(T x) {
uint32_t res;
PHMAP_IF_CONSTEXPR(sizeof(T) == 8)
return base_internal::CountTrailingZerosNonZero64(static_cast<uint64_t>(x));
res = base_internal::CountTrailingZerosNonZero64(static_cast<uint64_t>(x));
else
return base_internal::CountTrailingZerosNonZero32(static_cast<uint32_t>(x));
res = base_internal::CountTrailingZerosNonZero32(static_cast<uint32_t>(x));
return res;
}

// --------------------------------------------------------------------------
template <typename T>
uint32_t LeadingZeros(T x) {
uint32_t res;
PHMAP_IF_CONSTEXPR(sizeof(T) == 8)
return base_internal::CountLeadingZeros64(static_cast<uint64_t>(x));
res = base_internal::CountLeadingZeros64(static_cast<uint64_t>(x));
else
return base_internal::CountLeadingZeros32(static_cast<uint32_t>(x));
res = base_internal::CountLeadingZeros32(static_cast<uint32_t>(x));
return res;
}

// --------------------------------------------------------------------------
Expand Down Expand Up @@ -424,28 +428,21 @@ struct GroupSse2Impl
#endif
}

#ifdef __INTEL_COMPILER
#pragma warning push
#pragma warning disable 68
#endif
// Returns a bitmask representing the positions of empty or deleted slots.
// -----------------------------------------------------------------------
BitMask<uint32_t, kWidth> MatchEmptyOrDeleted() const {
auto special = _mm_set1_epi8(static_cast<uint8_t>(kSentinel));
auto special = _mm_set1_epi8(static_cast<char>(kSentinel));
return BitMask<uint32_t, kWidth>(
static_cast<uint32_t>(_mm_movemask_epi8(_mm_cmpgt_epi8_fixed(special, ctrl))));
}

// Returns the number of trailing empty or deleted elements in the group.
// ----------------------------------------------------------------------
uint32_t CountLeadingEmptyOrDeleted() const {
auto special = _mm_set1_epi8(static_cast<uint8_t>(kSentinel));
auto special = _mm_set1_epi8(static_cast<char>(kSentinel));
return TrailingZeros(
static_cast<uint32_t>(_mm_movemask_epi8(_mm_cmpgt_epi8_fixed(special, ctrl)) + 1));
}
#ifdef __INTEL_COMPILER
#pragma warning pop
#endif

// ----------------------------------------------------------------------
void ConvertSpecialToEmptyAndFullToDeleted(ctrl_t* dst) const {
Expand Down Expand Up @@ -581,8 +578,7 @@ inline size_t CapacityToGrowth(size_t capacity)
assert(IsValidCapacity(capacity));
// `capacity*7/8`
PHMAP_IF_CONSTEXPR (Group::kWidth == 8) {
if (capacity == 7)
{
if (capacity == 7) {
// x-x/8 does not work when x==7.
return 6;
}
Expand All @@ -598,8 +594,7 @@ inline size_t GrowthToLowerboundCapacity(size_t growth)
{
// `growth*8/7`
PHMAP_IF_CONSTEXPR (Group::kWidth == 8) {
if (growth == 7)
{
if (growth == 7) {
// x+(x-1)/7 does not work when x==7.
return 8;
}
Expand Down
9 changes: 9 additions & 0 deletions include/bela/__phmap/phmap_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,15 @@
#define PHMAP_IF_CONSTEXPR(expr) if ((expr))
#endif

// ----------------------------------------------------------------------
// builtin unreachable
// ----------------------------------------------------------------------
#if PHMAP_HAVE_BUILTIN(__builtin_unreachable)
#define PHMAP_BUILTIN_UNREACHABLE() __builtin_unreachable()
#else
#define PHMAP_BUILTIN_UNREACHABLE() (void)0
#endif

// ----------------------------------------------------------------------
// base/macros.h
// ----------------------------------------------------------------------
Expand Down

0 comments on commit 789d130

Please sign in to comment.