From d56b46d220ff306bc8acae93997340322f8e7494 Mon Sep 17 00:00:00 2001 From: Alexander Droste Date: Mon, 2 Feb 2026 19:38:05 +0000 Subject: [PATCH 1/2] fix: separate ptx build profiles Signed-off-by: Alexander Droste --- vortex-cuda/build.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/vortex-cuda/build.rs b/vortex-cuda/build.rs index c648b4ade2b..521de11883f 100644 --- a/vortex-cuda/build.rs +++ b/vortex-cuda/build.rs @@ -20,11 +20,12 @@ pub mod cuda_kernel_generator; fn main() { let manifest_dir = env::var("CARGO_MANIFEST_DIR").expect("Failed to get manifest dir"); + let profile = env::var("PROFILE").unwrap_or_else(|_| "debug".to_string()); // Source directory for kernels (hand-written and generated .cu/.cuh files) let kernels_src = Path::new(&manifest_dir).join("kernels/src"); - // Output directory for compiled .ptx files - let kernels_gen = Path::new(&manifest_dir).join("kernels/gen"); + // Output directory for compiled .ptx files - separate by profile. + let kernels_gen = Path::new(&manifest_dir).join("kernels/gen").join(&profile); std::fs::create_dir_all(&kernels_gen).expect("Failed to create kernels/gen directory"); @@ -37,6 +38,8 @@ fn main() { kernels_gen.display() ); + println!("cargo:rerun-if-env-changed=PROFILE"); + // Regenerate bit_unpack kernels only when the generator changes for entry in std::fs::read_dir(Path::new(&manifest_dir).join("cuda_kernel_generator")) .expect("Failed to read cuda_kernel_generator directory") @@ -70,7 +73,7 @@ fn main() { println!("cargo:rerun-if-changed={}", path.display()); } // Compile all .cu files to PTX in gen directory - nvcc_compile_ptx(&kernels_src, &kernels_gen, &path) + nvcc_compile_ptx(&kernels_src, &kernels_gen, &path, &profile) .map_err(|e| { format!("Failed to compile CUDA kernel {}: {}", path.display(), e) }) @@ -88,12 +91,14 @@ fn generate_unpack(output_dir: &Path, thread_count: usize) -> io:: generate_cuda_unpack_for_width::(&mut cu_writer, thread_count) } -fn nvcc_compile_ptx(include_dir: &Path, output_dir: &Path, cu_path: &Path) -> io::Result<()> { - // https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts - let profile = env::var("PROFILE").unwrap(); - +fn nvcc_compile_ptx( + include_dir: &Path, + output_dir: &Path, + cu_path: &Path, + profile: &str, +) -> io::Result<()> { let mut cmd = Command::new("nvcc"); - if profile.as_str() == "debug" { + if profile == "debug" { cmd.arg("-O0"); // NVCC debugging options: From af3119cd89826900fd40b9d97ed676bcf511dc57 Mon Sep 17 00:00:00 2001 From: Alexander Droste Date: Mon, 2 Feb 2026 19:51:09 +0000 Subject: [PATCH 2/2] keep doc Signed-off-by: Alexander Droste --- vortex-cuda/build.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vortex-cuda/build.rs b/vortex-cuda/build.rs index 521de11883f..fb3ae2e42c7 100644 --- a/vortex-cuda/build.rs +++ b/vortex-cuda/build.rs @@ -20,7 +20,8 @@ pub mod cuda_kernel_generator; fn main() { let manifest_dir = env::var("CARGO_MANIFEST_DIR").expect("Failed to get manifest dir"); - let profile = env::var("PROFILE").unwrap_or_else(|_| "debug".to_string()); + // https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts + let profile = env::var("PROFILE").unwrap(); // Source directory for kernels (hand-written and generated .cu/.cuh files) let kernels_src = Path::new(&manifest_dir).join("kernels/src");