Skip to content
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

Add XXHash_64 hash function to cudf #13612

Merged
merged 48 commits into from
Jul 19, 2023

Conversation

davidwendt
Copy link
Contributor

@davidwendt davidwendt commented Jun 23, 2023

Description

Add XXHash_64 hash function to libcudf

std::unique_ptr<column> xxhash_64(
  table_view const& input,  uint64_t seed,
  rmm::cuda_stream_view stream,  rmm::mr::device_memory_resource* mr);

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@davidwendt davidwendt added feature request New feature or request 2 - In Progress Currently a work in progress libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change labels Jun 23, 2023
@davidwendt davidwendt self-assigned this Jun 23, 2023
@github-actions github-actions bot added the CMake CMake build issue label Jun 23, 2023
cpp/src/hash/xxhash64.cu Outdated Show resolved Hide resolved
@bdice
Copy link
Contributor

bdice commented Jun 30, 2023

@davidwendt Note that a bug was found in the cuCollections implementation here: NVIDIA/cuCollections#326

@davidwendt
Copy link
Contributor Author

davidwendt commented Jun 30, 2023

Note that a bug was found in the cuCollections implementation here: NVIDIA/cuCollections#326

Already fixed in a5a0d4b

@davidwendt davidwendt changed the title Add XXHash_64 hash function to cudf Add XXHash_64 hash function to cudf Jul 6, 2023
@davidwendt davidwendt requested a review from bdice July 17, 2023 19:34
cpp/src/hash/xxhash64.cu Outdated Show resolved Hide resolved
Copy link
Contributor

@bdice bdice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pick one of the following and then I can approve:

  • xxhash64 (cudf API) and XXHash64 (functor)
  • xxhash_64 (cudf API) and XXHash_64 (functor)

@harrism harrism removed their request for review July 17, 2023 23:14
@davidwendt davidwendt requested a review from bdice July 18, 2023 11:32
@davidwendt davidwendt changed the title Add XXHash_64 hash function to cudf Add XXHash_64 hash function to cudf Jul 18, 2023
cpp/include/cudf/hashing.hpp Outdated Show resolved Hide resolved
cpp/tests/hashing/xxhash_64_test.cpp Outdated Show resolved Hide resolved
cpp/src/hash/xxhash_64.cu Outdated Show resolved Hide resolved
@davidwendt davidwendt requested a review from karthikeyann July 18, 2023 20:27
cpp/src/hash/xxhash_64.cu Show resolved Hide resolved
Comment on lines +47 to +48
auto block = reinterpret_cast<uint8_t const*>(data + offset);
return block[0] | (block[1] << 8) | (block[2] << 16) | (block[3] << 24);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will always emit 4x pipelined LDG.E.U8. I wonder if we should add an extra path that performs a single LDG.E.32 in case the pointer is aligned correctly.
Dumb question: When can the start of a string be not aligned to 4 bytes?

Instead of loading and shifting the result, a common pattern is to use a memcpy for this:

uint32_t ret;
memcpy(&ret, block, sizeof(uint32_t));
return ret;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A string is almost never aligned to 4 bytes. A string is rarely allocated individually but usually part of a larger contiguous block of memory.
The plan is to move these block functions into a separate utilities header where I think we could optimize based on type.
Reference #13706

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A string is rarely allocated individually but usually part of a larger contiguous block of memory.

Good point! Let's leave this as-is for now then.

cpp/src/hash/xxhash_64.cu Outdated Show resolved Hide resolved
cpp/src/hash/xxhash_64.cu Outdated Show resolved Hide resolved
@davidwendt
Copy link
Contributor Author

/merge

@rapids-bot rapids-bot bot merged commit 541c5bf into rapidsai:branch-23.08 Jul 19, 2023
@davidwendt davidwendt deleted the fea-xxhash64 branch July 19, 2023 16:10
sleeepyjack added a commit to NVIDIA/cuCollections that referenced this pull request Jul 29, 2023
When hashing large keys, e.g., strings, we traverse the input key
iteratively in chunks of 4/8 bytes. The current implementation of the
`load_chunk` function falsely assumes that the start of the key is
always aligned to the chunk size, which is not always the case (see
[discussion](rapidsai/cudf#13612 (comment))).

Additionally, this PR fixes some uncaught `[-Wmaybe-uninitialized]`
warnings when compiling the unit tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Ready for Review Ready for review by team CMake CMake build issue feature request New feature or request libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants