Repository navigation
Preserve size_t counts in managed-memory advice and prefetch - #60
Draft
RicheyWorks wants to merge 1 commit into
Draft
RicheyWorks wants to merge 1 commit into
RicheyWorks wants to merge 1 commit into
Conversation
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.
The driver/runtime managed-memory advice and prefetch wrappers cast Java's 64-bit
countthrough Clong. On Win64,longis 32 bits while CUDA takessize_t, so the wrappers silently lose the high bits. For example, advice for 4 GiB + 64 KiB is sent as just 64 KiB and can return success for a small allocation instead of rejecting the invalid range. Counts with bit 31 set may also sign-extend incorrectly.Use
size_t nativeCount = (size_t)countin all four affected wrappers (cuMemAdvise,cudaMemAdvise,cuMemPrefetchAsync,cudaMemPrefetchAsync), matching the CUDA signatures and nearby range-query wrappers. Four changed lines, no Java/JNI signature change. This is one count-width defect covering both APIs and operations.Add six real driver/runtime advice cases: a valid 64 KiB range, 4 GiB + 64 KiB and 8 GiB + 64 KiB, each against an allocation of only 64 KiB. High-range cases require CUDA's invalid-value result, so a wrapped small success is observable without allocating gigabytes. Tests use private CPU-thread contexts, explicit status checks, managed-memory capability/64-bit checks and
finallycleanup. No global exception-mode changes, prefetch calls, kernels, transfers or reset.Verification on Windows x86_64, RTX 4090/driver 617.42, Temurin JDK 22/JUnit 4.13.1:
jcuda-common9d41fb5: all six pass under-Xcheck:jni, zero failures/errors/skips and no JNI warnings. JVM logging confirms both rebuilt DLL paths.CUDA contracts: driver unified addressing, runtime memory management.