Optimize the switching function of coordnum on GPU - #956
Open
HanatoK wants to merge 8 commits into
Open
Conversation
Member
Author
|
In my intial benchmarks, this PR should be almost double the GPU speeds reported in #940 (comment) and #940 (comment). |
HanatoK
force-pushed
the
opt_coordnum_switching_function
branch
3 times, most recently
from
September 4, 2026 16:03
cfc46d0 to
269ffdc
Compare
This commit allows colvar::coordnum::switching_function to use static en and ed, which could potentially improve the CPU and GPU performance.
HanatoK
force-pushed
the
opt_coordnum_switching_function
branch
from
September 4, 2026 18:53
269ffdc to
ff11860
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The valid static exponent pair (2,4) currently causes a compile-time assertion failure.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Optimizes GPU coordination-number switching functions using compile-time exponent specialization.
Changes:
- Adds static exponent template parameters and optimized power evaluation.
- Dispatches common
(4,8)and(6,12)GPU kernel variants. - Improves unsupported-warp error classification.
File summaries
| File | Description |
|---|---|
src/cuda/colvarcomp_coordnums_kernel.cu |
Selects specialized CUDA/HIP kernels. |
src/colvarmodule.h |
Adds compile-time integer exponentiation. |
src/colvarcomp_coordnums.h |
Implements static switching-function specialization. |
Review details
Suppressed comments (1)
src/cuda/colvarcomp_coordnums_kernel.cu:1032
- The HIP branch has the same diagnostic regression: the new message omits
calc_value_coordnum_self_group, leaving only the vague textUnsupported warp size in:. Retain the function name from the prior error message.
default: return cvmodule->error("Unsupported warp size in: " + cvm::to_str(gpu_warp_size) + "\n", COLVARS_BUG_ERROR);} \
- Files reviewed: 3/3 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
This PR partially supersedes #926 and depends on #955.
This PR changes the template arguments of
colvar::coordnum::switching_functionandcolvar::coordnum::compute_pair_coordnumto accept additionalstatic_enandstatic_edas static template parameters forenanded. If any ofstatic_enandstatic_edis zero, then the dynamicenandedwould be used. This PR also instantiates commonly used(en, ed)for the GPU kernels. This PR does not include any CPU optimizations (unlike #926).