forked from pyg-team/pyg-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the `generate_range_of_ints` function, which uses MKL to generate integer numbers within a given range. Results obtained using the neighbor.py benchmark showed an average speedup equal to 1.27x. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Matthias Fey <[email protected]> Co-authored-by: Damian Szwichtenberg <[email protected]>
- Loading branch information
1 parent
6e9e3b8
commit 4f34071
Showing
8 changed files
with
146 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <vector> | ||
|
||
#include <benchmark/benchmark.h> | ||
|
||
#include <pyg_lib/csrc/random/cpu/rand_engine.h> | ||
|
||
constexpr int64_t beg = 0; | ||
constexpr int64_t end = 1 << 15; | ||
|
||
void BenchmarkRandEngineWithMKL(benchmark::State& state) { | ||
const int64_t count = state.range(0); | ||
pyg::random::RandintEngine<int64_t> generator; | ||
|
||
for (auto _ : state) { | ||
const auto out = | ||
std::move(generator.generate_range_of_ints(beg, end, count)); | ||
benchmark::DoNotOptimize(out); | ||
} | ||
} | ||
BENCHMARK(BenchmarkRandEngineWithMKL) | ||
->RangeMultiplier(2) | ||
->Range(1 << 8, 1 << 12); | ||
|
||
void BenchmarkRandEngineWithPrefetching(benchmark::State& state) { | ||
const int64_t count = state.range(0); | ||
pyg::random::RandintEngine<int64_t> generator; | ||
|
||
for (auto _ : state) { | ||
for (int64_t i = 0; i < count; ++i) { | ||
const auto out = generator(beg, end); | ||
benchmark::DoNotOptimize(out); | ||
} | ||
} | ||
} | ||
BENCHMARK(BenchmarkRandEngineWithPrefetching) | ||
->RangeMultiplier(2) | ||
->Range(1 << 8, 1 << 12); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters