Make the driver feature not depend on nvrtc#468
Conversation
There was a problem hiding this comment.
Code Review
This pull request correctly decouples the driver feature from nvrtc by feature-gating the parts of the code that depend on runtime compilation. The changes are logical and well-contained. I have one suggestion to improve the maintainability of the test code in src/driver/safe/launch.rs by applying the feature gate at the module level.
| #[cfg(test)] | ||
| mod tests { | ||
| use crate::{ | ||
| driver::{CudaContext, DriverError}, | ||
| nvrtc::compile_ptx_with_opts, | ||
| }; | ||
| use crate::driver::{CudaContext, DriverError}; | ||
| #[cfg(feature = "nvrtc")] | ||
| use crate::nvrtc::compile_ptx_with_opts; | ||
|
|
||
| use super::*; | ||
|
|
||
| #[cfg(feature = "nvrtc")] | ||
| #[test] | ||
| fn test_launch_arrays() -> Result<(), DriverError> { |
There was a problem hiding this comment.
For better maintainability, you could apply the nvrtc feature gate to the entire tests module instead of each individual test. This avoids repetition and ensures future tests in this file that rely on nvrtc are correctly gated. You've used a similar pattern in src/driver/safe/unified_memory.rs.
This change would make the code more concise and less error-prone.
| #[cfg(test)] | |
| mod tests { | |
| use crate::{ | |
| driver::{CudaContext, DriverError}, | |
| nvrtc::compile_ptx_with_opts, | |
| }; | |
| use crate::driver::{CudaContext, DriverError}; | |
| #[cfg(feature = "nvrtc")] | |
| use crate::nvrtc::compile_ptx_with_opts; | |
| use super::*; | |
| #[cfg(feature = "nvrtc")] | |
| #[test] | |
| fn test_launch_arrays() -> Result<(), DriverError> { | |
| #[cfg(all(test, feature = "nvrtc"))] | |
| mod tests { | |
| use crate::{ | |
| driver::{CudaContext, DriverError}, | |
| nvrtc::compile_ptx_with_opts, | |
| }; | |
| use super::*; | |
| #[test] | |
| fn test_launch_arrays() -> Result<(), DriverError> { |
|
Ty for the pr! easy review |
The
driverfeature depends on thenvrtcfeature. Remove this dependency and feature-gate its usages (mostly in tests). This is useful when applications use the driver but don't perform runtime compilation of CUDA code.