andrewmusselman opened a new pull request, #1321:
URL: https://github.com/apache/mahout/pull/1321
Fixes Issue #1318 .
`qdp-core/build.rs` (extended; it already existed for protoc) now:
- probes for `nvcc` with the same logic as `qdp-kernels/build.rs`,
- emits `cargo:rustc-link-search=native=$CUDA_PATH/lib64` and
`cargo:rustc-link-lib=cudart` when found,
- emits `cargo:rustc-cfg=qdp_no_cuda` when not found, with a clear
`cargo:warning` pointing at the toolkit install,
- respects `QDP_NO_CUDA=1` for explicit forcing (matching `qdp-kernels`).
`qdp-core/src/gpu/cuda_ffi.rs` wraps the `extern "C"` block in
`#[cfg(not(qdp_no_cuda))]` and adds matching `#[cfg(qdp_no_cuda)] mod
no_cuda_stubs { ... }` with `pub(crate) unsafe fn` stubs for all 14
declared functions. Each stub returns `999` — the same sentinel
`qdp-kernels` uses for its kernel-launcher stubs — so existing caller
error paths (`if ret != 0 { return Err(...) }`) surface a clean runtime
error if anyone calls a CUDA function on a no-toolkit build, instead of
failing at link time. The whole stub module is wrapped in a single
`#[allow(non_snake_case)]` since the originals are camelCase to match
the real CUDA Runtime API.
Cross-crate behaviour after this PR:
| environment | qdp-kernels | qdp-core | result
|
|--------------------------|-------------------|------------------|-------------------------|
| toolkit installed | links cudart | links cudart | normal
GPU build |
| driver only / macOS / CI | stub launchers | stub Runtime API | links;
runtime err 999 |
| `QDP_NO_CUDA=1` | stub launchers | stub Runtime API | links;
runtime err 999 |
Verified on Linux + CUDA 12.4: `cargo build --workspace --tests
--exclude qdp-python` succeeds both with and without `QDP_NO_CUDA=1`;
`make test_rust` runs full integration tests on the GPU; 12 lint
warnings introduced by the stubs are silenced.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]