Skip to content

Commit

Permalink
fix(label-propagation): share all structs on the heap between impleme…
Browse files Browse the repository at this point in the history
…ntations
  • Loading branch information
dsalwasser committed Apr 23, 2024
1 parent 214c996 commit e6f601b
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions kaminpar-shm/label_propagation.h
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,16 @@ class InOrderLabelPropagation : public LabelPropagation<Derived, Config, Graph>
using Base::_rating_map_ets;
};

template <typename NodeID> struct AbstractChunk {
NodeID start;
NodeID end;
};

struct Bucket {
std::size_t start;
std::size_t end;
};

/*!
* Parallel label propagation template that iterates over nodes in chunk random
* order.
Expand Down Expand Up @@ -1308,14 +1318,18 @@ class ChunkRandomLabelPropagation : public LabelPropagation<Derived, Config, Gra

using Permutations =
RandomPermutations<NodeID, Config::kPermutationSize, Config::kNumberOfNodePermutations>;
using Chunk = AbstractChunk<NodeID>;

public:
//! The data strucutres that are stored on the heap and used by label propagation.
using DataStructures = std::tuple<
tbb::enumerable_thread_specific<RatingMap>,
StaticArray<uint8_t>,
StaticArray<uint8_t>,
StaticArray<ClusterID>,
tbb::concurrent_vector<NodeID>,
std::vector<Chunk>,
std::vector<Bucket>,
ConcurrentFastResetArray<EdgeWeight, ClusterID>>;

/*!
Expand All @@ -1325,12 +1339,22 @@ class ChunkRandomLabelPropagation : public LabelPropagation<Derived, Config, Gra
* @param structs The data structures to use.
*/
void setup(DataStructures structs) {
auto [rating_map_ets, active, favored_clusters, second_phase_nodes, concurrent_rating_map] =
std::move(structs);
auto
[rating_map_ets,
active,
moved,
favored_clusters,
second_phase_nodes,
chunks,
buckets,
concurrent_rating_map] = std::move(structs);
Base::_rating_map_ets = std::move(rating_map_ets);
Base::_active = std::move(active);
Base::_moved = std::move(moved);
Base::_favored_clusters = std::move(favored_clusters);
Base::_second_phase_nodes = std::move(second_phase_nodes);
_chunks = std::move(chunks);
_buckets = std::move(buckets);
_concurrent_rating_map = std::move(concurrent_rating_map);
}

Expand All @@ -1343,8 +1367,11 @@ class ChunkRandomLabelPropagation : public LabelPropagation<Derived, Config, Gra
return std::make_tuple(
std::move(Base::_rating_map_ets),
std::move(Base::_active),
std::move(Base::_moved),
std::move(Base::_favored_clusters),
std::move(Base::_second_phase_nodes),
std::move(_chunks),
std::move(_buckets),
std::move(_concurrent_rating_map)
);
}
Expand Down Expand Up @@ -1436,16 +1463,6 @@ class ChunkRandomLabelPropagation : public LabelPropagation<Derived, Config, Gra
}

private:
struct Chunk {
NodeID start;
NodeID end;
};

struct Bucket {
std::size_t start;
std::size_t end;
};

void init_chunks(const NodeID from, NodeID to) {
_chunks.clear();
_buckets.clear();
Expand Down

0 comments on commit e6f601b

Please sign in to comment.