8000 Preserve device identity array outputs when JNI copies storage by RicheyWorks · Pull Request #61 · jcuda/jcuda · GitHub
[go: up one dir, main page]

Skip to content

Preserve device identity array outputs when JNI copies storage - #61

Draft
RicheyWorks wants to merge 1 commit into
jcuda:masterfrom
RicheyWorks:fix/device-property-array-copyback
Draft

RicheyWorks wants to merge 1 commit into
jcuda:masterfrom
RicheyWorks:fix/device-property-array-copyback

Conversation

@RicheyWorks
Copy link
Copy Markdown

Device identity array outputs are lost when JNI supplies copied array storage. setCudaDeviceProp explicitly releases the name, UUID and LUID outputs with JNI_ABORT; cuDeviceGetName conditionally aborts based on isCopy, which also loses output with HotSpot's JNI checker. Successful queries can therefore leave empty arrays or the caller's old bytes.

Request copy-back (0) for these four output releases. The JNI contract permits copied critical-array storage; output should not depend on pinning or an implementation's copy flag. No signatures or field layouts change.

This is one device-identity output contribution across driver/runtime. It is independent of jcuda/jcuda-common#4: these APIs release arrays directly, bypassing that shared PointerData helper, so the shared fix alone does not correct them. This branch contains neither that patch nor any other pending contribution.

Add three real metadata tests comparing runtime device name, UUID and LUID with driver queries. Prefill output arrays with sentinel bytes, require a nonempty driver name, compare NUL-terminated names and exact UUID/LUID bytes, and check the LUID node mask. Skip LUID where CUDA defines it as unavailable (non-Windows/TCC). Each test uses and destroys a private CPU-thread context without changing exception mode, allocating data buffers, launching kernels, transferring data or resetting a device.

Verification on Windows x86_64, RTX 4090 WDDM/driver 617.42, Temurin JDK 22/JUnit 4.13.1:

  • Published 12.6.0 JNI libraries: all three pass normally; all three fail under -Xcheck:jni because identity output is discarded.
  • Rebuilt driver/runtime JNI libraries with only these four release changes and pristine jcuda-common 9d41fb5: all three pass under JNI checking, zero failures/errors/skips and no JNI warnings. JVM logging confirms both rebuilt DLL paths in a dedicated test directory.
  • Existing MSVC/CMake and checksum-verified workspace CUDA 12.6 headers/import libraries; runtime dependency directory added only to the test process PATH. Java uses proposed parent Target Java 8 in the parent compiler configuration jcuda-parent#2 installed normally. No installation or global environment change.
  • Searches found no overlapping device-property/UUID/name PR or issue. Current upstream base remains 5ecd90c.
  • No full CUDA suite, other JVM implementation, Linux/TCC LUID behavior or other GPU model validated. The change is metadata copy-back, not a performance or new platform-support claim. Other workloads and Processing originals were untouched.

JNI contract: critical-array release modes.

mvn -f JCudaJava/pom.xml -Dtest=JCudaDeviceIdentityTest "-DargLine=-Xcheck:jni -Djava.library.path=<rebuilt-native-directory>" test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0