Skip to content

Commit 607e9eb

Browse files
authored
[Java] Make cudaGetDeviceProperties compatible with CUDA 12 and 13 based on symbol presence (#1323)
In #1273 we addressed a signature change in CUDA 13 by binding different symbols based on a environment variable, `RAPIDS_CUDA_MAJOR`. That works, but forces users of cuvs-java with CUDA 12 to define this environment variable. This PR improves on it by making the symbol lookup dynamic, looking for the CUDA 13 symbol name, and falling back to the CUDA 12 exported name if we fail to locate the first. Authors: - Lorenzo Dematté (https://github.com/ldematte) Approvers: - MithunR (https://github.com/mythrocks) URL: #1323
1 parent 792730c commit 607e9eb

File tree

1 file changed

+2
-6
lines changed
  • java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/common

1 file changed

+2
-6
lines changed

java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/common/Util.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,11 @@ private Util() {}
6565
LINKER.downcallHandle(
6666
cudaMemcpyAsync$address(), cudaMemcpyAsync$descriptor(), Linker.Option.critical(true));
6767

68-
private static final String cudaGetDevicePropertiesSymbolName =
69-
"12".equals(System.getenv("RAPIDS_CUDA_MAJOR"))
70-
? "cudaGetDeviceProperties_v2"
71-
: "cudaGetDeviceProperties";
72-
7368
private static final MethodHandle cudaGetDeviceProperties$mh =
7469
LINKER.downcallHandle(
7570
SYMBOL_LOOKUP
76-
.find(cudaGetDevicePropertiesSymbolName)
71+
.find("cudaGetDeviceProperties") // CUDA 13+ symbol name
72+
.or(() -> SYMBOL_LOOKUP.find("cudaGetDeviceProperties_v2")) // CUDA 12 symbol name
7773
.orElseThrow(UnsatisfiedLinkError::new),
7874
FunctionDescriptor.of(headers_h.C_INT, headers_h.C_POINTER, headers_h.C_INT));
7975

0 commit comments

Comments
 (0)