Skip to content

Commit

Permalink
Ensure we're not losing variance in paired info improver.
Browse files Browse the repository at this point in the history
Use better unordered data structures
  • Loading branch information
asl committed Dec 20, 2024
1 parent f3db51b commit 4f34cc0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/common/paired_info/concurrent_pair_info_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ class ConcurrentPairedBuffer : public PairedBufferBase<ConcurrentPairedBuffer<G,
template<class Graph>
using ConcurrentPairedInfoBuffer = ConcurrentPairedBuffer<Graph, RawPointTraits, btree_map>;

template<class Graph>
using ConcurrentClusteredPairedInfoBuffer = ConcurrentPairedBuffer<Graph, PointTraits, btree_map>;

template<class Graph>
using ConcurrentUnorderedClusteredPairedInfoBuffer = ConcurrentPairedBuffer<Graph, PointTraits, phmap_map>;

} // namespace de

} // namespace omnigraph
10 changes: 5 additions & 5 deletions src/common/paired_info/pair_info_improver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class PairInfoImprover {
typedef std::vector<omnigraph::de::PairInfo<EdgeId> > PairInfos;
typedef std::pair<EdgeId, EdgeId> EdgePair;
typedef omnigraph::de::PairedInfoIndexT<Graph> Index;
typedef omnigraph::de::ConcurrentPairedInfoBuffer<Graph> Buffer;
typedef omnigraph::de::ConcurrentUnorderedClusteredPairedInfoBuffer<Graph> Buffer;

public:
PairInfoImprover(const Graph& g,
Expand Down Expand Up @@ -123,7 +123,7 @@ class PairInfoImprover {
}

size_t RemoveContradictional(unsigned nthreads) {
omnigraph::de::ConcurrentPairedInfoBuffer<Graph> buf(graph_);
Buffer buf(graph_);

omnigraph::IterationHelper<Graph, EdgeId> edges(graph_);
auto ranges = edges.Ranges(nthreads * 16);
Expand All @@ -142,7 +142,7 @@ class PairInfoImprover {
DEBUG("Merging maps");
// FIXME: This is a bit crazy, but we do not have a sane way to iterate
// over buffer. In any case, this is better than it used to be before
omnigraph::de::UnclusteredPairedInfoIndexT<Graph> to_remove(graph_);
omnigraph::de::UnorderedPairedInfoIndexT<Graph> to_remove(graph_);
to_remove.MoveAssign(buf);

DEBUG("Resulting size " << to_remove.size());
Expand All @@ -161,7 +161,7 @@ class PairInfoImprover {

size_t FillMissing(unsigned nthreads) {
DEBUG("Fill missing: Creating indexes");
omnigraph::de::ConcurrentPairedInfoBuffer<Graph> buf(graph_);
Buffer buf(graph_);

SplitPathConstructor<Graph> spc(graph_);

Expand Down Expand Up @@ -189,7 +189,7 @@ class PairInfoImprover {
DEBUG("Merging maps");
// FIXME: This is a bit crazy, but we do not have a sane way to iterate
// over buffer. In any case, this is better than it used to be before
omnigraph::de::UnclusteredPairedInfoIndexT<Graph> to_add(graph_);
omnigraph::de::UnorderedPairedInfoIndexT<Graph> to_add(graph_);
to_add.MoveAssign(buf);

DEBUG("Resulting size " << to_add.size());
Expand Down
6 changes: 6 additions & 0 deletions src/common/paired_info/paired_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,12 @@ using const_btree_map = NoLockingConstAdapter<phmap::btree_map<K, V>>; //Two-par
template<typename Graph>
using PairedInfoIndexT = PairedIndex<Graph, PointTraits, const_btree_map>;

template<typename K, typename V>
using phmap_map = NoLockingAdapter<phmap::parallel_flat_hash_map<K, V>>; //Two-parameters wrapper

template<typename Graph>
using UnorderedPairedInfoIndexT = PairedIndex<Graph, PointTraits, phmap_map>;

template<typename K, typename V>
using btree_map = NoLockingAdapter<phmap::btree_map<K, V>>; //Two-parameters wrapper

Expand Down

0 comments on commit 4f34cc0

Please sign in to comment.