From 5e66b2784f973a56987cf2408f1cde78b0f053e2 Mon Sep 17 00:00:00 2001 From: Louis Sugy Date: Wed, 14 Dec 2022 13:56:17 +0100 Subject: [PATCH 1/3] Fix inefficient grid size in make_blobs that doesn't ever write second value out. --- cpp/include/raft/random/detail/make_blobs.cuh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cpp/include/raft/random/detail/make_blobs.cuh b/cpp/include/raft/random/detail/make_blobs.cuh index 212245a9bf..dea7bd4c81 100644 --- a/cpp/include/raft/random/detail/make_blobs.cuh +++ b/cpp/include/raft/random/detail/make_blobs.cuh @@ -156,8 +156,10 @@ void generate_data(DataT* out, const DataT cluster_std_scalar, raft::random::RngState& rng_state) { + constexpr IdxT block_size = 128; IdxT items = n_rows * n_cols; - IdxT nBlocks = (items + 127) / 128; + // Choose a grid size so that each thread can write two output values. + IdxT nBlocks = ceildiv(items, 2*block_size); // parentheses needed here for kernel, otherwise macro interprets the arguments // of triple chevron notation as macro arguments RAFT_CALL_RNG_FUNC(rng_state, From a4aae8c024fc6ee82747e4f5beaf4b15fe16249e Mon Sep 17 00:00:00 2001 From: Louis Sugy Date: Wed, 14 Dec 2022 14:18:54 +0100 Subject: [PATCH 2/3] Add labels to make_blobs benchmark --- cpp/bench/random/make_blobs.cu | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cpp/bench/random/make_blobs.cu b/cpp/bench/random/make_blobs.cu index fdd4ef61d2..950d80c499 100644 --- a/cpp/bench/random/make_blobs.cu +++ b/cpp/bench/random/make_blobs.cu @@ -25,6 +25,12 @@ struct make_blobs_inputs { bool row_major; }; // struct make_blobs_inputs +inline auto operator<<(std::ostream& os, const make_blobs_inputs& p) -> std::ostream& +{ + os << p.rows << "#" << p.cols << "#" << p.clusters << "#" << p.row_major; + return os; +} + template struct make_blobs : public fixture { make_blobs(const make_blobs_inputs& p) @@ -34,6 +40,10 @@ struct make_blobs : public fixture { void run_benchmark(::benchmark::State& state) override { + std::ostringstream label_stream; + label_stream << params; + state.SetLabel(label_stream.str()); + loop_on_state(state, [this]() { raft::random::make_blobs(data.data(), labels.data(), From cb4c926bff663cd41f551ac7b8a5846638055e17 Mon Sep 17 00:00:00 2001 From: Louis Sugy Date: Wed, 14 Dec 2022 14:32:31 +0100 Subject: [PATCH 3/3] Clang format --- cpp/include/raft/random/detail/make_blobs.cuh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/include/raft/random/detail/make_blobs.cuh b/cpp/include/raft/random/detail/make_blobs.cuh index dea7bd4c81..68c2d56599 100644 --- a/cpp/include/raft/random/detail/make_blobs.cuh +++ b/cpp/include/raft/random/detail/make_blobs.cuh @@ -157,9 +157,9 @@ void generate_data(DataT* out, raft::random::RngState& rng_state) { constexpr IdxT block_size = 128; - IdxT items = n_rows * n_cols; + IdxT items = n_rows * n_cols; // Choose a grid size so that each thread can write two output values. - IdxT nBlocks = ceildiv(items, 2*block_size); + IdxT nBlocks = ceildiv(items, 2 * block_size); // parentheses needed here for kernel, otherwise macro interprets the arguments // of triple chevron notation as macro arguments RAFT_CALL_RNG_FUNC(rng_state,