Skip to content

Commit

Permalink
[gen] rmat use uint32_t instead of float for distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
sbeamer committed Oct 6, 2023
1 parent bd39534 commit 71b37dc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <algorithm>
#include <cassert>
#include <cinttypes>
#include <limits>
#include <random>

#include "graph.h"
Expand Down Expand Up @@ -115,19 +116,19 @@ class Generator {
}

EdgeList MakeRMatEL() {
const float A = 0.57f, B = 0.19f, C = 0.19f;
const uint32_t max = std::numeric_limits<uint32_t>::max();
const uint32_t A = 0.57*max, B = 0.19*max, C = 0.19*max;
EdgeList el(num_edges_);
#pragma omp parallel
{
std::mt19937 rng;
std::uniform_real_distribution<float> udist(0, 1.0f);
#pragma omp for
for (int64_t block=0; block < num_edges_; block+=block_size) {
rng.seed(kRandSeed + block/block_size);
for (int64_t e=block; e < std::min(block+block_size, num_edges_); e++) {
NodeID_ src = 0, dst = 0;
for (int depth=0; depth < scale_; depth++) {
float rand_point = udist(rng);
uint32_t rand_point = rng();
src = src << 1;
dst = dst << 1;
if (rand_point < A+B) {
Expand Down
2 changes: 1 addition & 1 deletion test/reference/graph-u10.out
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Graph has 1024 nodes and 16103 undirected edges for degree: 15
Graph has 1024 nodes and 16125 undirected edges for degree: 15

0 comments on commit 71b37dc

Please sign in to comment.