Skip to content

Commit

Permalink
remove pointer type
Browse files Browse the repository at this point in the history
  • Loading branch information
yushangdi committed Oct 11, 2023
1 parent 32fb4d5 commit 806e846
Showing 1 changed file with 0 additions and 69 deletions.
69 changes: 0 additions & 69 deletions benchmarks/Connectivity/SimpleUnionAsync/Connectivity.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,75 +29,6 @@
namespace gbbs {
namespace simple_union_find {

template <class IntT>
inline IntT find_compress(IntT i, IntT* parents) {
IntT j = i;
if (parents[j] == j) return j;
do {
j = parents[j];
} while (parents[j] != j);
IntT tmp;
while ((tmp = parents[i]) > j) {
parents[i] = j;
i = tmp;
}
return j;
}

template <class IntT>
inline bool unite_impl(IntT u_orig, IntT v_orig, IntT* parents) {
IntT u = u_orig;
IntT v = v_orig;
while (u != v) {
u = find_compress(u, parents);
v = find_compress(v, parents);
if (u > v && parents[u] == u &&
gbbs::atomic_compare_and_swap(&parents[u], u, v)) {
return true;
} else if (v > u && parents[v] == v &&
gbbs::atomic_compare_and_swap(&parents[v], v, u)) {
return true;
}
}
return false;
}

template <class IntT>
inline IntT find_compress_atomic(IntT i, IntT* parents) {
IntT j = i;
if (gbbs::atomic_load(&parents[j]) == j) return j;
do {
j = gbbs::atomic_load(&parents[j]);
} while (gbbs::atomic_load(&parents[j]) != j);
IntT tmp;
while ((tmp = gbbs::atomic_load(&parents[i])) > j) {
if (!gbbs::atomic_compare_and_swap(&parents[i], tmp, j)) {
return j;
}
i = tmp;
}
return j;
}

template <class IntT>
inline bool unite_impl_atomic(IntT u_orig, IntT v_orig,
IntT* parents) {
IntT u = u_orig;
IntT v = v_orig;
while (u != v) {
u = find_compress_atomic(u, parents);
v = find_compress_atomic(v, parents);
if (u > v && parents[u] == u &&
gbbs::atomic_compare_and_swap(&parents[u], u, v)) {
return true;
} else if (v > u && parents[v] == v &&
gbbs::atomic_compare_and_swap(&parents[v], v, u)) {
return true;
}
}
return false;
}

template <class IntT, class Range>
inline IntT find_compress(IntT i, Range parents) {
IntT j = i;
Expand Down

0 comments on commit 806e846

Please sign in to comment.