Skip to content

Commit

Permalink
Merge pull request #124 from GraphStreamingProject/likely_if
Browse files Browse the repository at this point in the history
Faster fast with branch prediction
  • Loading branch information
etwest authored Feb 15, 2023
2 parents f7196f7 + 6a33a14 commit 28e23eb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions include/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ struct GraphUpdate {
Edge edge;
UpdateType type;
};

#define likely_if(x) if(__builtin_expect((bool)(x), true))
#define unlikely_if(x) if (__builtin_expect((bool)(x), false))
2 changes: 1 addition & 1 deletion src/l0_sampling/sketch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void Sketch::update(const vec_t update_idx) {
for (unsigned i = 0; i < num_buckets; ++i) {
col_hash_t depth = Bucket_Boruvka::get_index_depth(update_idx, seed + i, num_guesses);
size_t bucket_id = i * num_guesses + depth;
if (depth < num_guesses)
likely_if(depth < num_guesses)
Bucket_Boruvka::update(bucket_a[bucket_id], bucket_c[bucket_id], update_idx, checksum);
}
}
Expand Down

0 comments on commit 28e23eb

Please sign in to comment.