Repository navigation
Fix vector add example runtime validation - #17
Open
cherubrock-seb wants to merge 1 commit into
Open
cherubrock-seb wants to merge 1 commit into
cherubrock-seb wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Problem
The CUDA examples under
examples/vector_addandexamples/vector_add_tilingcurrently crash before they can validate their kernels.On an RTX 3080 with CUDA 12.0, both exact upstream binaries at
67c6589aed8653629209f87d35627ac51dec3ca8terminate with SIGSEGV (exit 139). PR #16 independently notes the same empty-vector failure and intentionally leaves these examples unchanged.Reproduction
Build the examples in Release mode and run:
kernel_float_vecaddkernel_float_vecadd_tilingBoth index zero-sized
output_expected/output_resulthost vectors. The copy-backcudaMemcpyis also reversed, so the host result buffer is never populated correctly.After fixing those two memory issues, the examples expose a second stale check: their expected values still use
i + constant, while the kernels actually compute:vector_add: half-precisionfma(input, input, constant)vector_add_tiling: the half-rounded square multiplied byconstantRoot cause
The example host-side validation code drifted from the kernel behavior:
Minimal fix
Only the two example files are changed:
n;output_devback intooutput_result.data();No library implementation or public API is changed.
Validation
Validated exact candidate head:
1b1feaa8cbb1b678193f98a70580496e7558691cAgainst upstream base:
67c6589aed8653629209f87d35627ac51dec3ca8Environment:
CMAKE_CUDA_ARCHITECTURES=80Results:
kernel_float_vecadd: SIGSEGV, exit 139kernel_float_vecadd_tiling: SIGSEGV, exit 139kernel_float_vecadd: PASS, printsresult correctkernel_float_vecadd_tiling: PASS, printsresult correctgit diff --check: PASSScope and limitations
This fixes only the two standalone CUDA examples and their validation logic. It does not alter kernel_float arithmetic, tests, or runtime behavior outside these examples.