Fixed decorators on max min clamp for CUDA 13.0 - #358
Merged
morousg merged 1 commit intoAug 25, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the CUDA-side constexpr_cmath polyfills used when <cuda/std/algorithm> is unavailable (CUDA < 13.3), aiming to fix CUDA 13.0 compilation by adjusting the host/device decorators on max, min, and clamp.
Changes:
- Replaced ad-hoc
constexpr __host__ __device__decorators with the project macroFK_HOST_DEVICE_CNSTformax,min, andclamp. - Changed the polyfill signatures for
max/min/clampfromconst T¶meters/return to pass/return by value (T).
Suppressed comments (2)
include/fused_kernel/core/constexpr_libs/constexpr_cmath.h:64
- Same as
max: the CUDA < 13.3 polyfillbase::minreturns by value while CUDA >= 13.3 aliasescuda::std::min(and non-CUDA aliasesstd::min) returningconst T&. Keeping signatures consistent across branches avoids subtle compilation differences between CUDA versions.
template <typename T>
FK_HOST_DEVICE_CNST T min(const T a, const T b) {
return (b < a) ? b : a;
}
include/fused_kernel/core/constexpr_libs/constexpr_cmath.h:69
- The CUDA < 13.3 polyfill
base::clampreturnsTby value, but CUDA >= 13.3 aliasescuda::std::clamp(and non-CUDA aliasesstd::clamp) returningconst T&. This can lead to different types/behavior depending on CUDA version. Consider matching the standard signature here and only changing the decorators.
template <typename T>
FK_HOST_DEVICE_CNST T clamp(const T v, const T lo, const T hi) {
return (v < lo) ? lo : ((hi < v) ? hi : v);
}
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
morousg
deleted the
352-fix-missing-fk_host_device_cnst-macro-in-cxpmin-max-clamp-cuda-130-implementations
branch
August 25, 2026 23:17
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.