-
Notifications
You must be signed in to change notification settings - Fork 89
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
make murmurhash3_x64_128 compatible with existing cuco data structures #501
Merged
sleeepyjack
merged 6 commits into
NVIDIA:dev
from
srinivasyadav18:murmur128_compatibility
Jun 19, 2024
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2001837
Make murmurhash3_x64_128 compatible with existing cuco data structures
srinivasyadav18 56efe03
move back sanitize_hash to utils.cuh
srinivasyadav18 3ae1afe
fix sanitize_hash edge case
srinivasyadav18 c203168
minor styling changes with CG
srinivasyadav18 8feddca
Always use curly braces
sleeepyjack 6657e23
Re-order CG Type
srinivasyadav18 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
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,72 @@ | ||
/* | ||
* Copyright (c) 2024, 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 <test_utils.hpp> | ||
|
||
#include <cuco/hash_functions.cuh> | ||
#include <cuco/static_map.cuh> | ||
|
||
#include <thrust/device_vector.h> | ||
#include <thrust/functional.h> | ||
#include <thrust/iterator/counting_iterator.h> | ||
#include <thrust/iterator/transform_iterator.h> | ||
|
||
#include <catch2/catch_template_test_macros.hpp> | ||
|
||
using size_type = std::size_t; | ||
|
||
template <typename Key, typename Hash> | ||
void test_hash_function() | ||
{ | ||
using Value = int64_t; | ||
|
||
constexpr size_type num_keys{400}; | ||
|
||
auto map = cuco::static_map<Key, | ||
Value, | ||
cuco::extent<size_type>, | ||
cuda::thread_scope_device, | ||
thrust::equal_to<Key>, | ||
cuco::linear_probing<1, Hash>, | ||
cuco::cuda_allocator<std::byte>, | ||
cuco::storage<2>>{ | ||
num_keys, cuco::empty_key<Key>{-1}, cuco::empty_value<Value>{-1}}; | ||
|
||
auto keys_begin = thrust::counting_iterator<Key>(1); | ||
|
||
auto pairs_begin = thrust::make_transform_iterator( | ||
keys_begin, cuda::proclaim_return_type<cuco::pair<Key, Value>>([] __device__(auto i) { | ||
return cuco::pair<Key, Value>(i, i); | ||
})); | ||
|
||
thrust::device_vector<bool> d_keys_exist(num_keys); | ||
|
||
map.insert(pairs_begin, pairs_begin + num_keys); | ||
|
||
REQUIRE(map.size() == num_keys); | ||
|
||
map.contains(keys_begin, keys_begin + num_keys, d_keys_exist.begin()); | ||
|
||
REQUIRE(cuco::test::all_of(d_keys_exist.begin(), d_keys_exist.end(), thrust::identity{})); | ||
} | ||
|
||
TEMPLATE_TEST_CASE_SIG("static_map hash tests", "", ((typename Key)), (int32_t), (int64_t)) | ||
{ | ||
test_hash_function<Key, cuco::murmurhash3_32<Key>>(); | ||
test_hash_function<Key, cuco::murmurhash3_x64_128<Key>>(); | ||
test_hash_function<Key, cuco::xxhash_32<Key>>(); | ||
test_hash_function<Key, cuco::xxhash_64<Key>>(); | ||
} |
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.
I would move the
size_type
to the front of the tparam list so you don't have to specify thecg_type
as it can be inferred fromg
.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.
It's about the intention of the API and the syntax consistency.
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.
Sure, the
g
parameter should be the first one for consistency reasons but we can still use a different ordering for the tparam list, i.e., the one that lets us make use of automatic type inference. The only tparam that cannot be inferred is the result size type so specifying the CG type is redundant.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.
It's an internal API so I don't want to bikeshed too much. I'm okay with merging it as is.