Repository navigation
[FEA] RTCX: Replace Software SHA256 with SIMD-accelerated xxHash128 for JIT cache #22920
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
69690ee
Refactor hash handling: Replace sha256 with hash128
lamarrr c479bad
Fix index calculation in hash128 operator[] for correct byte access
lamarrr 454a036
Add state creation checks for XXH3 in hash computation functions
lamarrr b8bf0f2
Add null terminator update in hash function for XXH3
lamarrr 99f5d91
remove heap allocation in xxhash state
lamarrr 9f5e887
Refactor hash state initialization in get_kernel function
lamarrr 510ecdc
Add xxHash integration and update dependencies in CMake configuration
lamarrr a5d330f
Update copyright statements in CMake files to include "AFFILIATES" fo…
lamarrr 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 hidden or 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 hidden or 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 hidden or 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,106 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <array> | ||
| #include <bit> | ||
| #include <charconv> | ||
| #include <cstdint> | ||
| #include <cstring> | ||
| #include <format> | ||
| #include <span> | ||
| #include <stdexcept> | ||
| #include <string_view> | ||
|
|
||
| namespace rtcx { | ||
|
|
||
| struct [[nodiscard]] hash128_hex_string { | ||
| static constexpr std::size_t NUM_HEX_DIGITS = 32; | ||
| static constexpr std::size_t NUM_HEX_BYTES = NUM_HEX_DIGITS / 2; | ||
|
|
||
| char data_[NUM_HEX_DIGITS + 1]; // NOLINT(modernize-avoid-c-arrays) | ||
|
|
||
| [[nodiscard]] constexpr std::string_view view() const | ||
| { | ||
| return std::string_view{data_, NUM_HEX_DIGITS}; | ||
| } | ||
|
|
||
| [[nodiscard]] constexpr operator std::string_view() const { return view(); } | ||
|
|
||
| [[nodiscard]] char const* data() const { return data_; } | ||
|
|
||
| [[nodiscard]] char const* c_str() const { return data_; } | ||
|
|
||
| [[nodiscard]] static constexpr std::size_t size() { return NUM_HEX_DIGITS; } | ||
|
|
||
| static hash128_hex_string make(std::span<std::uint8_t const, NUM_HEX_BYTES> input) | ||
| { | ||
| constexpr char const HEX_CHARS[] = "0123456789abcdef"; // NOLINT(modernize-avoid-c-arrays) | ||
| hash128_hex_string hex; | ||
| for (std::size_t i = 0; i < NUM_HEX_BYTES; ++i) { | ||
| hex.data_[i * 2] = HEX_CHARS[(input[i] >> 4) & 0x0F]; | ||
| hex.data_[i * 2 + 1] = HEX_CHARS[input[i] & 0x0F]; | ||
| } | ||
| hex.data_[NUM_HEX_DIGITS] = '\0'; | ||
| return hex; | ||
| } | ||
|
|
||
| static hash128_hex_string make(__uint128_t hash) | ||
| { | ||
| auto array = std::bit_cast<std::array<std::uint8_t, NUM_HEX_BYTES>>(hash); | ||
| return make(array); | ||
| } | ||
| }; | ||
|
|
||
| struct hash128 { | ||
| __uint128_t value; | ||
|
|
||
| constexpr hash128(__uint128_t v = 0) : value(v) {} | ||
|
|
||
| constexpr hash128(std::uint64_t high, std::uint64_t low) | ||
| : value((static_cast<__uint128_t>(high) << 64) | low) | ||
| { | ||
| } | ||
|
|
||
| [[nodiscard]] constexpr bool operator==(hash128 const&) const = default; | ||
|
|
||
| [[nodiscard]] std::uint8_t operator[](std::size_t index) const | ||
| { | ||
| return reinterpret_cast<std::uint8_t const*>(&value)[16 - index]; | ||
| } | ||
|
lamarrr marked this conversation as resolved.
Resolved
|
||
|
|
||
| [[nodiscard]] std::size_t size() const { return 16; } | ||
|
|
||
| [[nodiscard]] std::uint8_t const* data() const | ||
| { | ||
| return reinterpret_cast<std::uint8_t const*>(&value); | ||
| } | ||
|
|
||
| hash128_hex_string to_hex_string() const { return hash128_hex_string::make(value); } | ||
|
|
||
| static hash128 parse(std::string_view hex) | ||
| { | ||
| if (hex.size() != hash128_hex_string::NUM_HEX_DIGITS) { | ||
| throw std::invalid_argument( | ||
| std::format("Invalid hash128 hex string length, expected {} got {} (hash: `{}`)", | ||
| hash128_hex_string::NUM_HEX_DIGITS, | ||
| hex.size(), | ||
| hex)); | ||
| } | ||
| std::array<std::uint8_t, hash128_hex_string::NUM_HEX_BYTES> data{}; | ||
| for (std::size_t i = 0; i < hash128_hex_string::NUM_HEX_BYTES; ++i) { | ||
| auto hex_byte = hex.substr(i * 2, 2); | ||
| auto [ptr, ec] = std::from_chars(hex_byte.begin(), hex_byte.end(), data[i], 16); | ||
| if (ec != std::errc()) { | ||
| throw std::invalid_argument( | ||
| std::format("Invalid hex character {} in HEX string: `{}`", hex_byte, hex)); | ||
| } | ||
| } | ||
| return hash128{std::bit_cast<__uint128_t>(data)}; | ||
| } | ||
| }; | ||
|
|
||
| } // namespace rtcx | ||
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.