mirror of
https://github.com/dmlc/dgl.git
synced 2026-06-04 19:44:23 +08:00
[Optimization] Replaced std::unordered_map by phmap::flat_hash_map (#1662)
Co-authored-by: Da Zheng <zhengda1936@gmail.com>
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -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
|
||||
|
||||
@@ -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
1
third_party/phmap
vendored
Submodule
Submodule third_party/phmap added at 25293cefd8
Reference in New Issue
Block a user