Skip to content

Commit d8c4db4

Browse files
committed
assign edges with the same endings to the same machine
1 parent 49a883b commit d8c4db4

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ int main(int argc, char *argv[])
5454
partitioner = new DbhPartitioner(FLAGS_filename);
5555
else
5656
LOG(ERROR) << "unkown method: " << FLAGS_method;
57+
LOG(INFO) << "partition method: " << FLAGS_method;
5758
partitioner->split();
5859
partition_timer.stop();
5960
LOG(INFO) << "partition time: " << partition_timer.get_time();

src/random_partitioner.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <utility>
2+
#include <functional>
23

34
#include "util.hpp"
45
#include "random_partitioner.hpp"
@@ -33,20 +34,22 @@ RandomPartitioner::RandomPartitioner(std::string basefilename)
3334
<< ", num_edges: " << num_edges;
3435

3536
p = FLAGS_p;
36-
dis.param(std::uniform_int_distribution<int>::param_type(0, p - 1));
3737
}
3838

3939
void RandomPartitioner::split()
4040
{
4141
std::vector<dense_bitset> is_mirrors(p, dense_bitset(num_vertices));
4242
std::vector<size_t> counter(p, 0);
43+
auto hash = std::hash<vid_t>();
4344
while (fin_ptr < fin_end) {
4445
edge_t *e = (edge_t *)fin_ptr;
4546
fin_ptr += sizeof(edge_t);
46-
int bucket = dis(gen);
47+
vid_t u = e->first, v = e->second;
48+
if (u > v) std::swap(u, v);
49+
int bucket = (hash(u) ^ (hash(v) << 1)) % p;
4750
counter[bucket]++;
48-
is_mirrors[bucket].set_bit_unsync(e->first);
49-
is_mirrors[bucket].set_bit_unsync(e->second);
51+
is_mirrors[bucket].set_bit_unsync(u);
52+
is_mirrors[bucket].set_bit_unsync(v);
5053
}
5154

5255
if (munmap(fin_map, filesize) == -1) {

src/random_partitioner.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class RandomPartitioner : public Partitioner
3333

3434
std::random_device rd;
3535
std::mt19937 gen;
36-
std::uniform_int_distribution<int> dis;
3736

3837
public:
3938
RandomPartitioner(std::string basefilename);

0 commit comments

Comments
 (0)