Skip to content

Commit 573f2c8

Browse files
authored
Pointer map (#123)
* Abseil LTS is default btree map * Use phmap::btree as alternative * Remove deprecated btree alternative
1 parent 794ac1c commit 573f2c8

File tree

8 files changed

+51
-45
lines changed

8 files changed

+51
-45
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,12 @@ $> cmake --build build --target install --parallel
333333

334334
<!--- @formatter:off --->
335335

336-
| Option | Default | Description |
337-
| --- | :---: | --- |
338-
| `TYPEART_ABSEIL` | `ON` | Enable usage of btree-backed map of the [Abseil project](https://abseil.io/) instead of `std::map` |
339-
| `TYPEART_BTREE` | `OFF` | *Deprecated*. Enable usage of a [btree-backed map](https://github.com/ahueck/cpp-btree) (alternative to Abseil) instead of `std::map` |
340-
| `TYPEART_SOFTCOUNTERS` | `OFF` | Enable runtime tracking of #tracked addrs. / #distinct checks / etc. |
341-
| `TYPEART_LOG_LEVEL_RT` | `0` | Granularity of runtime logger. 3 is most verbose, 0 is least |
336+
| Option | Default | Description |
337+
|------------------------|:-------:|---------------------------------------------------------------------------------------------------------------------------------------|
338+
| `TYPEART_PHMAP` | `ON` | Enable usage of a [btree-backed map](https://github.com/greg7mdp/parallel-hashmap) instead of `std::map` for storing allocation data. |
339+
| `TYPEART_ABSEIL` | `OFF` | Enable usage of btree-backed map of the [Abseil project](https://abseil.io/) (alternative to TYPEART_PHMAP). |
340+
| `TYPEART_SOFTCOUNTERS` | `OFF` | Enable runtime tracking of #tracked addrs. / #distinct checks / etc. |
341+
| `TYPEART_LOG_LEVEL_RT` | `0` | Granularity of runtime logger. 3 is most verbose, 0 is least. |
342342

343343
<!--- @formatter:on --->
344344

cmake/typeartToolchainOptions.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ add_feature_info(UBSAN TYPEART_UBSAN "Build with sanitizer \"ubsan=undefined\"."
7474
option(TYPEART_MPI_WRAPPER "Generate mpicc and mpic++ wrapper for TypeART" ON)
7575
add_feature_info(MPI_WRAPPER TYPEART_MPI_WRAPPER "Generate TypeART compiler wrapper for mpicc and mpic++.")
7676

77-
option(TYPEART_ABSEIL "Enable usage of abseil's btree-backed map instead of std::map for the runtime." ON)
77+
option(TYPEART_ABSEIL "Enable usage of Abseil's btree-backed map instead of std::map for the runtime." ON)
7878
add_feature_info(ABSEIL TYPEART_ABSEIL "External library \"Abseil\" replaces runtime std::map with btree-backed map.")
7979

80-
cmake_dependent_option(TYPEART_BTREE "Enable usage of btree-backed map instead of std::map for the runtime." ON
80+
cmake_dependent_option(TYPEART_PHMAP "Enable usage of project \"phmap\" btree-backed map for the runtime." ON
8181
"NOT TYPEART_ABSEIL" OFF
8282
)
83-
add_feature_info(BTREE TYPEART_BTREE "*Deprecated* External library replaces runtime std::map with btree-backed map.")
83+
add_feature_info(PHMAP TYPEART_PHMAP "External library \"parallel-hashmap\" replaces runtime std::map with btree-backed map.")
8484

8585
option(TYPEART_INSTALL_UTIL_SCRIPTS "Install single file build and run scripts" OFF)
8686
mark_as_advanced(TYPEART_INSTALL_UTIL_SCRIPTS)

externals/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ mark_as_advanced(
88
FETCHCONTENT_UPDATES_DISCONNECTED
99
)
1010

11-
if(TYPEART_BTREE)
12-
add_subdirectory(btree)
11+
if(TYPEART_PHMAP)
12+
#set(CMAKE_POLICY_DEFAULT_CMP0076 NEW)
13+
add_subdirectory(phmap)
1314
endif()
1415

1516
if(TYPEART_ABSEIL)

externals/abseil/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set(ABSL_PROPAGATE_CXX_STD ON)
33
FetchContent_Declare(
44
cpp-abseil
55
GIT_REPOSITORY https://github.com/abseil/abseil-cpp.git
6+
GIT_TAG 215105818dfde3174fe799600bb0f3cae233d0bf # LTS Nov. 2021
67
GIT_SHALLOW 1
78
)
89

externals/btree/CMakeLists.txt

Lines changed: 0 additions & 21 deletions
This file was deleted.

externals/phmap/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FetchContent_Declare(
2+
phmap_phmap
3+
GIT_REPOSITORY https://github.com/greg7mdp/parallel-hashmap.git
4+
GIT_SHALLOW 1
5+
GIT_TAG 48e86db1f4ebc85145d384ba061c4f615cb3106f
6+
)
7+
8+
FetchContent_GetProperties(phmap_phmap)
9+
10+
if(NOT phmap_phmap_POPULATED)
11+
FetchContent_Populate(phmap_phmap)
12+
13+
add_library(phmap_phmap INTERFACE IMPORTED GLOBAL)
14+
target_include_directories(phmap_phmap SYSTEM INTERFACE ${phmap_phmap_SOURCE_DIR})
15+
add_library(phpmap::phpmap ALIAS phmap_phmap)
16+
endif()
17+
18+
mark_as_advanced(
19+
FETCHCONTENT_SOURCE_DIR_PHMAP_PHMAP
20+
FETCHCONTENT_UPDATES_DISCONNECTED_PHMAP_PHMAP
21+
)

lib/runtime/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ target_link_libraries(
4646
LLVMCore
4747
LLVMSupport
4848
$<$<BOOL:${TYPEART_MPI_LOGGER}>:MPI::MPI_CXX>
49-
$<$<BOOL:${TYPEART_BTREE}>:google::btree>
49+
$<$<BOOL:${TYPEART_PHMAP}>:phpmap::phpmap>
5050
$<$<BOOL:${TYPEART_ABSEIL}>:absl::btree>
5151
$<$<BOOL:${TYPEART_SAFEPTR}>:sf::pointer>
5252
$<$<NOT:$<BOOL:${TYPEART_DISABLE_THREAD_SAFETY}>>:Threads::Threads>
@@ -68,7 +68,7 @@ target_compile_definitions(
6868
PRIVATE TYPEART_LOG_LEVEL=${TYPEART_LOG_LEVEL_RT}
6969
$<$<BOOL:${TYPEART_MPI_LOGGER}>:TYPEART_MPI_LOGGER=1>
7070
$<$<BOOL:${TYPEART_SOFTCOUNTERS}>:ENABLE_SOFTCOUNTER=1>
71-
$<$<BOOL:${TYPEART_BTREE}>:TYPEART_BTREE>
71+
$<$<BOOL:${TYPEART_PHMAP}>:TYPEART_PHMAP>
7272
$<$<BOOL:${TYPEART_ABSEIL}>:TYPEART_ABSEIL>
7373
$<$<BOOL:${TYPEART_SAFEPTR}>:USE_SAFEPTR>
7474
$<$<BOOL:${TYPEART_DISABLE_THREAD_SAFETY}>:TYPEART_DISABLE_THREAD_SAFETY>

lib/runtime/RuntimeData.h

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,27 @@
1414
#define TYPEART_RUNTIMEDATA_H
1515

1616
#ifdef TYPEART_BTREE
17-
#ifdef TYPEART_ABSEIL
18-
#error TypeART-RT: Set BTREE and ABSL, mutually exclusive.
19-
#endif
20-
#include "btree_map.h"
17+
#error TypeART-RT: TYPART_BTREE is deprecated.
2118
#endif
2219

2320
#ifdef TYPEART_ABSEIL
24-
#ifdef TYPEART_BTREE
25-
#error TypeART-RT: Set ABSL and BTREE, mutually exclusive.
21+
#ifdef TYPEART_PHMAP
22+
#error TypeART-RT: Set ABSL and PHMAP, mutually exclusive.
2623
#endif
2724
#pragma GCC diagnostic push
2825
#pragma GCC diagnostic ignored "-Wpedantic"
2926
#include "absl/container/btree_map.h"
3027
#pragma GCC diagnostic pop
3128
#endif
3229

33-
#if !defined(TYPEART_BTREE) && !defined(TYPEART_ABSEIL)
30+
#ifdef TYPEART_PHMAP
31+
#ifdef TYPEART_ABSEIL
32+
#error TypeART-RT: Set ABSL and PHMAP, mutually exclusive.
33+
#endif
34+
#include "parallel_hashmap/btree.h"
35+
#endif
36+
37+
#if !defined(TYPEART_PHMAP) && !defined(TYPEART_ABSEIL)
3438
#include <map>
3539
#endif
3640

@@ -58,15 +62,15 @@ struct RuntimeT {
5862
using Stack = std::vector<MemAddr>;
5963
static constexpr auto StackReserve{512U};
6064
static constexpr char StackName[] = "std::vector";
61-
#ifdef TYPEART_BTREE
62-
using PointerMapBaseT = btree::btree_map<MemAddr, PointerInfo>;
63-
static constexpr char MapName[] = "btree::btree_map";
65+
#ifdef TYPEART_PHMAP
66+
using PointerMapBaseT = phmap::btree_map<MemAddr, PointerInfo>;
67+
static constexpr char MapName[] = "phmap::btree_map";
6468
#endif
6569
#ifdef TYPEART_ABSEIL
6670
using PointerMapBaseT = absl::btree_map<MemAddr, PointerInfo>;
6771
static constexpr char MapName[] = "absl::btree_map";
6872
#endif
69-
#if !defined(TYPEART_BTREE) && !defined(TYPEART_ABSEIL)
73+
#if !defined(TYPEART_PHMAP) && !defined(TYPEART_ABSEIL)
7074
using PointerMapBaseT = std::map<MemAddr, PointerInfo>;
7175
static constexpr char MapName[] = "std::map";
7276
#endif

0 commit comments

Comments
 (0)