[Optimization] Replaced std::unordered_map by phmap::flat_hash_map (#1662)

Co-authored-by: Da Zheng <zhengda1936@gmail.com>
This commit is contained in:
IzabelaMazur
2020-06-21 19:27:29 +02:00
committed by GitHub
parent 3d47693b1f
commit 8a20b6c19c
3 changed files with 7 additions and 2 deletions

3
.gitmodules vendored
View File

@@ -13,3 +13,6 @@
[submodule "third_party/METIS"]
path = third_party/METIS
url = https://github.com/KarypisLab/METIS.git
[submodule "third_party/phmap"]
path = third_party/phmap
url = https://github.com/greg7mdp/parallel-hashmap.git

View File

@@ -11,6 +11,7 @@
#include <unordered_map>
#include <utility>
#include "../../c_api_common.h"
#include "../third_party/phmap/parallel_hashmap/phmap.h"
namespace dgl {
namespace aten {
@@ -51,7 +52,7 @@ class IdHashMap {
const int64_t len = ids->shape[0];
for (int64_t i = 0; i < len; ++i) {
const IdType id = ids_data[i];
// std::unorderd_map::insert assures that an insertion will not happen if the
// phmap::flat_hash_map::insert assures that an insertion will not happen if the
// key already exists.
oldv2newv_.insert({id, oldv2newv_.size()});
filter_[id & kFilterMask] = true;
@@ -105,7 +106,7 @@ class IdHashMap {
// Hashtable is very slow. Using bloom filter can significantly speed up lookups.
std::vector<bool> filter_;
// The hashmap from old vid to new vid
std::unordered_map<IdType, IdType> oldv2newv_;
phmap::flat_hash_map<IdType, IdType> oldv2newv_;
};
/*

1
third_party/phmap vendored Submodule

Submodule third_party/phmap added at 25293cefd8