-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEA] Add bitset for ANN pre-filtering and deletion #1803
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
25a85e0
Add bitset
lowener dbabbd2
Update naming and use raft::linalg::map
lowener 4906c3a
Fix shared mem allocation
lowener 463d7f5
Fix copyright
lowener 5227a95
Add documentation
lowener 07671aa
Merge branch 'branch-23.10' into 23.10-bitset-fea
lowener 75b0f82
Simplify code and remove shared mem kernel
lowener f834b18
Enable bitset type template and add flip function
lowener d74bbb2
Add bench for bitset
lowener f9c544e
Merge branch 'branch-23.10' into 23.10-bitset-fea
lowener d075184
Fix namespace typo
lowener 1f54720
Use raft device_uvector in bitset
lowener e0c1d24
Fix build.sh
lowener 8d30c9f
Add n_elements fix size
lowener 480d20e
Fix naming
lowener 240af3e
Fix naming of inputs
lowener 08c43d0
Fix bitset_len in bitset_view
lowener 9115bbb
Move bitset to core and match std::bitset
lowener 121ef46
Merge branch 'branch-23.10' into 23.10-bitset-fea
lowener 541e239
Merge branch 'branch-23.10' into 23.10-bitset-fea
cjnolet b9de2e3
Merge branch 'branch-23.10' into 23.10-bitset-fea
cjnolet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,74 @@ | ||
/* | ||
* Copyright (c) 2023, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <common/benchmark.hpp> | ||
#include <raft/core/bitset.cuh> | ||
#include <raft/core/device_mdspan.hpp> | ||
#include <rmm/device_uvector.hpp> | ||
|
||
namespace raft::bench::core { | ||
|
||
struct bitset_inputs { | ||
uint32_t bitset_len; | ||
uint32_t mask_len; | ||
uint32_t query_len; | ||
}; // struct bitset_inputs | ||
|
||
template <typename bitset_t, typename index_t> | ||
struct bitset_bench : public fixture { | ||
bitset_bench(const bitset_inputs& p) | ||
: params(p), | ||
mask{raft::make_device_vector<index_t, index_t>(res, p.mask_len)}, | ||
queries{raft::make_device_vector<index_t, index_t>(res, p.query_len)}, | ||
outputs{raft::make_device_vector<bool, index_t>(res, p.query_len)} | ||
{ | ||
raft::random::RngState state{42}; | ||
raft::random::uniformInt(res, state, mask.view(), index_t{0}, index_t{p.bitset_len}); | ||
} | ||
|
||
void run_benchmark(::benchmark::State& state) override | ||
{ | ||
loop_on_state(state, [this]() { | ||
auto my_bitset = raft::core::bitset<bitset_t, index_t>( | ||
this->res, raft::make_const_mdspan(mask.view()), params.bitset_len); | ||
my_bitset.test(res, raft::make_const_mdspan(queries.view()), outputs.view()); | ||
}); | ||
} | ||
|
||
private: | ||
raft::resources res; | ||
bitset_inputs params; | ||
raft::device_vector<index_t, index_t> mask, queries; | ||
raft::device_vector<bool, index_t> outputs; | ||
}; // struct bitset | ||
|
||
const std::vector<bitset_inputs> bitset_input_vecs{ | ||
{256 * 1024 * 1024, 64 * 1024 * 1024, 256 * 1024 * 1024}, // Standard Bench | ||
{256 * 1024 * 1024, 64 * 1024 * 1024, 1024 * 1024 * 1024}, // Extra queries | ||
{128 * 1024 * 1024, 1024 * 1024 * 1024, 256 * 1024 * 1024}, // Extra mask to test atomics impact | ||
}; | ||
|
||
using Uint8_32 = bitset_bench<uint8_t, uint32_t>; | ||
using Uint16_64 = bitset_bench<uint16_t, uint32_t>; | ||
using Uint32_32 = bitset_bench<uint32_t, uint32_t>; | ||
using Uint32_64 = bitset_bench<uint32_t, uint64_t>; | ||
|
||
RAFT_BENCH_REGISTER(Uint8_32, "", bitset_input_vecs); | ||
RAFT_BENCH_REGISTER(Uint16_64, "", bitset_input_vecs); | ||
RAFT_BENCH_REGISTER(Uint32_32, "", bitset_input_vecs); | ||
RAFT_BENCH_REGISTER(Uint32_64, "", bitset_input_vecs); | ||
|
||
} // namespace raft::bench::core |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please post the benchmark results as a comment in your PR?