"src/git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "b50014067d7d31ef09d6dad62175bc19c2e258bf"
Unverified Commit 8a20b6c1 authored by IzabelaMazur's avatar IzabelaMazur Committed by GitHub
Browse files

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


Co-authored-by: default avatarDa Zheng <zhengda1936@gmail.com>
parent 3d47693b
...@@ -13,3 +13,6 @@ ...@@ -13,3 +13,6 @@
[submodule "third_party/METIS"] [submodule "third_party/METIS"]
path = third_party/METIS path = third_party/METIS
url = https://github.com/KarypisLab/METIS.git 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 @@ ...@@ -11,6 +11,7 @@
#include <unordered_map> #include <unordered_map>
#include <utility> #include <utility>
#include "../../c_api_common.h" #include "../../c_api_common.h"
#include "../third_party/phmap/parallel_hashmap/phmap.h"
namespace dgl { namespace dgl {
namespace aten { namespace aten {
...@@ -51,7 +52,7 @@ class IdHashMap { ...@@ -51,7 +52,7 @@ class IdHashMap {
const int64_t len = ids->shape[0]; const int64_t len = ids->shape[0];
for (int64_t i = 0; i < len; ++i) { for (int64_t i = 0; i < len; ++i) {
const IdType id = ids_data[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. // key already exists.
oldv2newv_.insert({id, oldv2newv_.size()}); oldv2newv_.insert({id, oldv2newv_.size()});
filter_[id & kFilterMask] = true; filter_[id & kFilterMask] = true;
...@@ -105,7 +106,7 @@ class IdHashMap { ...@@ -105,7 +106,7 @@ class IdHashMap {
// Hashtable is very slow. Using bloom filter can significantly speed up lookups. // Hashtable is very slow. Using bloom filter can significantly speed up lookups.
std::vector<bool> filter_; std::vector<bool> filter_;
// The hashmap from old vid to new vid // The hashmap from old vid to new vid
std::unordered_map<IdType, IdType> oldv2newv_; phmap::flat_hash_map<IdType, IdType> oldv2newv_;
}; };
/* /*
......
Subproject commit 25293cefd8b85491b45600c03fe8edf07647553f
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment