[Performance] Remove phmap dependency. (#7658)

This commit is contained in:
Muhammed Fatih BALIN
2024-08-05 11:29:40 -04:00
committed by GitHub
parent 55cf23f9fb
commit cb4604aca2
7 changed files with 26 additions and 26 deletions

3
.gitmodules vendored
View File

@@ -10,9 +10,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
[submodule "third_party/nanoflann"]
path = third_party/nanoflann
url = https://github.com/jlblancoc/nanoflann

View File

@@ -340,15 +340,9 @@ else(EXTERNAL_DMLC_PATH)
set(GOOGLE_TEST 0) # Turn off dmlc-core test
endif(EXTERNAL_DMLC_PATH)
if(EXTERNAL_PHMAP_PATH)
include_directories(SYSTEM ${EXTERNAL_PHMAP_PATH})
else(EXTERNAL_PHMAP_PATH)
target_include_directories(dgl PRIVATE "third_party/phmap")
endif(EXTERNAL_PHMAP_PATH)
target_include_directories(dgl PRIVATE "tensoradapter/include")
target_include_directories(dgl PRIVATE "third_party/pcg/include")
target_include_directories(dgl PRIVATE "third_party/tsl_robin_map/include")
if(EXTERNAL_NANOFLANN_PATH)
include_directories(SYSTEM ${EXTERNAL_NANOFLANN_PATH})
@@ -473,7 +467,7 @@ if(BUILD_CPP_TEST)
include_directories("include")
include_directories("third_party/dlpack/include")
include_directories("third_party/dmlc-core/include")
include_directories("third_party/phmap")
include_directories("third_party/tsl_robin_map/include")
include_directories("third_party/libxsmm/include")
include_directories("third_party/pcg/include")
file(GLOB_RECURSE TEST_SRC_FILES ${PROJECT_SOURCE_DIR}/tests/cpp/*.cc)

View File

@@ -7,7 +7,7 @@
#define DGL_ARRAY_CPU_ARRAY_UTILS_H_
#include <dgl/aten/types.h>
#include <parallel_hashmap/phmap.h>
#include <tsl/robin_map.h>
#include <unordered_map>
#include <utility>
@@ -53,8 +53,7 @@ class IdHashMap {
const int64_t len = ids->shape[0];
for (int64_t i = 0; i < len; ++i) {
const IdType id = ids_data[i];
// phmap::flat_hash_map::insert assures that an insertion will not happen
// if the key already exists.
// Insertion will not happen if the key already exists.
oldv2newv_.insert({id, oldv2newv_.size()});
filter_[id & kFilterMask] = true;
}
@@ -106,7 +105,7 @@ class IdHashMap {
// lookups.
std::vector<bool> filter_;
// The hashmap from old vid to new vid
phmap::flat_hash_map<IdType, IdType> oldv2newv_;
tsl::robin_map<IdType, IdType> oldv2newv_;
};
/**

View File

@@ -6,7 +6,8 @@
#include <dgl/array.h>
#include <dgl/runtime/parallel_for.h>
#include <parallel_hashmap/phmap.h>
#include <tsl/robin_map.h>
#include <tsl/robin_set.h>
#include <vector>
@@ -28,7 +29,7 @@ void CountNNZPerRow(
const IdType* B_indices, IdType* C_indptr_data, int64_t M) {
parallel_for(0, M, [=](size_t b, size_t e) {
for (auto i = b; i < e; ++i) {
phmap::flat_hash_set<IdType> set;
tsl::robin_set<IdType> set;
for (IdType u = A_indptr[i]; u < A_indptr[i + 1]; ++u) {
IdType w = A_indices[u];
for (IdType v = B_indptr[w]; v < B_indptr[w + 1]; ++v)
@@ -60,7 +61,7 @@ void ComputeIndicesAndData(
IdType* C_indices_data, DType* C_weights_data, int64_t M) {
parallel_for(0, M, [=](size_t b, size_t e) {
for (auto i = b; i < e; ++i) {
phmap::flat_hash_map<IdType, DType> map;
tsl::robin_map<IdType, DType> map;
for (IdType u = A_indptr[i]; u < A_indptr[i + 1]; ++u) {
IdType w = A_indices[u];
DType vA = A_data[A_eids ? A_eids[u] : u];

View File

@@ -6,7 +6,8 @@
#include <dgl/array.h>
#include <dgl/runtime/parallel_for.h>
#include <parallel_hashmap/phmap.h>
#include <tsl/robin_map.h>
#include <tsl/robin_set.h>
#include <vector>
@@ -30,7 +31,7 @@ void CountNNZPerRow(
runtime::parallel_for(0, M, [=](size_t b, size_t e) {
for (size_t i = b; i < e; ++i) {
phmap::flat_hash_set<IdType> set;
tsl::robin_set<IdType> set;
for (int64_t k = 0; k < n; ++k) {
for (IdType u = A_indptr[k][i]; u < A_indptr[k][i + 1]; ++u)
set.insert(A_indices[k][u]);
@@ -63,7 +64,7 @@ void ComputeIndicesAndData(
int64_t n = A_indptr.size();
runtime::parallel_for(0, M, [=](size_t b, size_t e) {
for (auto i = b; i < e; ++i) {
phmap::flat_hash_map<IdType, DType> map;
tsl::robin_map<IdType, DType> map;
for (int64_t k = 0; k < n; ++k) {
for (IdType u = A_indptr[k][i]; u < A_indptr[k][i + 1]; ++u) {
IdType kA = A_indices[k][u];

View File

@@ -26,7 +26,7 @@
#include <dgl/random.h>
#include <dgl/runtime/parallel_for.h>
#include <dmlc/omp.h>
#include <parallel_hashmap/phmap.h>
#include <tsl/robin_map.h>
#include <algorithm>
#include <cmath>
@@ -45,6 +45,13 @@ namespace impl {
using dgl::random::continuous_seed;
template <typename K, typename V>
using map_t = tsl::robin_map<K, V>;
template <typename iterator>
auto& mutable_value_ref(iterator it) {
return it.value();
}
constexpr double eps = 0.0001;
template <typename IdxType, typename FloatType>
@@ -61,7 +68,7 @@ auto compute_importance_sampling_probabilities(
double prev_ex_nodes = max_degree * num_rows;
phmap::flat_hash_map<IdxType, FloatType> hop_map, hop_map2;
map_t<IdxType, FloatType> hop_map, hop_map2;
for (int iters = 0; iters < importance_sampling || importance_sampling < 0;
iters++) {
// NOTE(mfbalin) When the graph is unweighted, the first c values in
@@ -83,7 +90,9 @@ auto compute_importance_sampling_probabilities(
for (auto j = indptr[rid]; j < indptr[rid + 1]; j++) {
const auto ct = c * (weighted && iters == 1 ? A[j] : 1);
auto itb = hop_map2.emplace(indices[j], ct);
if (!itb.second) itb.first->second = std::max(ct, itb.first->second);
if (!itb.second) {
mutable_value_ref(itb.first) = std::max(ct, itb.first->second);
}
}
}
if (hop_map.empty())
@@ -203,7 +212,7 @@ std::pair<COOMatrix, FloatArray> CSRLaborPick(
hop_size += act_degree;
}
phmap::flat_hash_map<IdxType, FloatType> hop_map;
map_t<IdxType, FloatType> hop_map;
if (importance_sampling)
hop_map = compute_importance_sampling_probabilities<IdxType, FloatType>(

1
third_party/phmap vendored

Submodule third_party/phmap deleted from 65775fa09f