rtx-cfd legacy GPU tests: the current CudaKernelManager API (Arc-held manager, allocate-on-copy, copy_from_device returning the host vector), MatrixOpsKernel::tridiagonal_matvec added over the existing kernel, PoissonKernel::solve_jacobi_2d kept as the older name; CfdConfig literals take ..Default
CI / Build (macos-latest) (push) Waiting to run
CI / Test (macos-latest) (push) Blocked by required conditions
CI / Test (ubuntu-latest) (push) Blocked by required conditions
CI / Python Bindings (maturin) (macos-latest) (push) Blocked by required conditions
CI / Python Bindings (maturin) (ubuntu-latest) (push) Blocked by required conditions
CI / WASM Build + Size Check (push) Blocked by required conditions
CI / Distributed Training Tests (push) Blocked by required conditions
CI / CI Success (push) Blocked by required conditions
CI / Build CPU-Only (Explicit) (push) Failing after 6s
CI / Build (ubuntu-latest) (push) Failing after 6s
Documentation / Build API Documentation (push) Failing after 6s
Documentation / Build User Guide (push) Successful in 7s
CI / Format Check (push) Failing after 13s
CI / Clippy Check (push) Failing after 37s
Performance Benchmarks / Run Benchmarks (push) Successful in 3m23s

This commit is contained in:
Omar Sobh
2026-09-16 07:18:34 -05:00
parent af19860c04
commit 1381b5b633
6 changed files with 109 additions and 48 deletions
@@ -20,7 +20,7 @@ mod cuda_tests {
#[tokio::test]
async fn test_advection_kernel_upwind() -> CfdResult<()> {
let config = CfdConfig::new().with_gpu(true);
let kernel_manager = CudaKernelManager::new(&config)?;
let kernel_manager = std::sync::Arc::new(CudaKernelManager::new(&config)?);
let advection_kernel = AdvectionKernel::new(&kernel_manager, AdvectionScheme::Upwind)?;
// Test data: 1D advection with known analytical solution
@@ -43,14 +43,14 @@ mod cuda_tests {
let d_phi_new = kernel_manager.allocate_f32(nx)?;
// Copy to GPU
kernel_manager.copy_to_device(&phi, &mut d_phi)?;
d_phi = kernel_manager.copy_to_device(&phi)?;
// Run advection kernel
advection_kernel.apply(&d_phi, &d_phi_new, velocity as f32, dt as f32, dx as f32)?;
// Copy result back
let mut result = vec![0.0f32; nx];
kernel_manager.copy_from_device(&d_phi_new, &mut result)?;
result = kernel_manager.copy_from_device(&d_phi_new)?;
// Verify that the pulse has moved (mass conservation)
let initial_mass: f32 = phi.iter().sum();
@@ -82,7 +82,7 @@ mod cuda_tests {
#[tokio::test]
async fn test_advection_kernel_central() -> CfdResult<()> {
let config = CfdConfig::new().with_gpu(true);
let kernel_manager = CudaKernelManager::new(&config)?;
let kernel_manager = std::sync::Arc::new(CudaKernelManager::new(&config)?);
let advection_kernel = AdvectionKernel::new(&kernel_manager, AdvectionScheme::Central)?;
// Test data: smooth sinusoidal wave
@@ -100,11 +100,11 @@ mod cuda_tests {
let mut d_phi = kernel_manager.allocate_f32(nx)?;
let d_phi_new = kernel_manager.allocate_f32(nx)?;
kernel_manager.copy_to_device(&phi, &mut d_phi)?;
d_phi = kernel_manager.copy_to_device(&phi)?;
advection_kernel.apply(&d_phi, &d_phi_new, velocity as f32, dt as f32, dx as f32)?;
let mut result = vec![0.0f32; nx];
kernel_manager.copy_from_device(&d_phi_new, &mut result)?;
result = kernel_manager.copy_from_device(&d_phi_new)?;
// For central scheme, verify mass conservation and smoothness
let initial_mass: f32 = phi.iter().sum();
@@ -117,7 +117,7 @@ mod cuda_tests {
#[tokio::test]
async fn test_diffusion_kernel_explicit() -> CfdResult<()> {
let config = CfdConfig::new().with_gpu(true);
let kernel_manager = CudaKernelManager::new(&config)?;
let kernel_manager = std::sync::Arc::new(CudaKernelManager::new(&config)?);
let diffusion_kernel = DiffusionKernel::new(&kernel_manager, DiffusionScheme::Explicit)?;
// Test 1D heat equation with analytical solution
@@ -135,11 +135,11 @@ mod cuda_tests {
let mut d_temp = kernel_manager.allocate_f32(nx)?;
let d_temp_new = kernel_manager.allocate_f32(nx)?;
kernel_manager.copy_to_device(&temperature, &mut d_temp)?;
d_temp = kernel_manager.copy_to_device(&temperature)?;
diffusion_kernel.apply(&d_temp, &d_temp_new, alpha as f32, dt as f32, dx as f32)?;
let mut result = vec![0.0f32; nx];
kernel_manager.copy_from_device(&d_temp_new, &mut result)?;
result = kernel_manager.copy_from_device(&d_temp_new)?;
// Verify diffusion: edges should be smoother, total heat conserved
let initial_total: f32 = temperature.iter().sum();
@@ -160,7 +160,7 @@ mod cuda_tests {
#[tokio::test]
async fn test_poisson_kernel_2d() -> CfdResult<()> {
let config = CfdConfig::new().with_gpu(true);
let kernel_manager = CudaKernelManager::new(&config)?;
let kernel_manager = std::sync::Arc::new(CudaKernelManager::new(&config)?);
let poisson_kernel = PoissonKernel::new(&kernel_manager)?;
// Test 2D Poisson equation: ∇²φ = f
@@ -190,8 +190,8 @@ mod cuda_tests {
let mut d_phi = kernel_manager.allocate_f32(nx * ny)?;
let mut d_source = kernel_manager.allocate_f32(nx * ny)?;
kernel_manager.copy_to_device(&phi, &mut d_phi)?;
kernel_manager.copy_to_device(&source, &mut d_source)?;
d_phi = kernel_manager.copy_to_device(&phi)?;
d_source = kernel_manager.copy_to_device(&source)?;
// Solve Poisson equation
let max_iterations = 1000;
@@ -208,7 +208,7 @@ mod cuda_tests {
)?;
let mut result = vec![0.0f32; nx * ny];
kernel_manager.copy_from_device(&d_phi, &mut result)?;
result = kernel_manager.copy_from_device(&d_phi)?;
// Verify against analytical solution
let mut max_error = 0.0f32;
@@ -233,7 +233,7 @@ mod cuda_tests {
#[tokio::test]
async fn test_matrix_ops_kernel() -> CfdResult<()> {
let config = CfdConfig::new().with_gpu(true);
let kernel_manager = CudaKernelManager::new(&config)?;
let kernel_manager = std::sync::Arc::new(CudaKernelManager::new(&config)?);
let matrix_ops = MatrixOpsKernel::new(&kernel_manager)?;
// Test sparse matrix-vector multiplication (typical in CFD)
@@ -246,17 +246,17 @@ mod cuda_tests {
let mut d_diag = kernel_manager.allocate_f32(n)?;
let mut d_off_diag = kernel_manager.allocate_f32(n - 1)?;
let mut d_x = kernel_manager.allocate_f32(n)?;
let d_y = kernel_manager.allocate_f32(n)?;
let mut d_y = kernel_manager.allocate_f32(n)?;
kernel_manager.copy_to_device(&diagonal, &mut d_diag)?;
kernel_manager.copy_to_device(&off_diagonal, &mut d_off_diag)?;
kernel_manager.copy_to_device(&x, &mut d_x)?;
d_diag = kernel_manager.copy_to_device(&diagonal)?;
d_off_diag = kernel_manager.copy_to_device(&off_diagonal)?;
d_x = kernel_manager.copy_to_device(&x)?;
// Perform A*x = y operation
matrix_ops.tridiagonal_matvec(&d_diag, &d_off_diag, &d_x, &d_y, n)?;
matrix_ops.tridiagonal_matvec(&d_diag, &d_off_diag, &d_x, &mut d_y)?;
let mut result = vec![0.0f32; n];
kernel_manager.copy_from_device(&d_y, &mut result)?;
result = kernel_manager.copy_from_device(&d_y)?;
// Verify result manually for first few elements
assert_relative_eq!(result[0], 2.0 * x[0] - x[1], epsilon = 1e-6);
@@ -287,7 +287,7 @@ async fn test_kernel_manager_initialization() -> CfdResult<()> {
#[cfg(feature = "cuda")]
{
// Should successfully create kernel manager
let result = rtx_cfd::kernels::CudaKernelManager::new(&config);
let mut result = rtx_cfd::kernels::CudaKernelManager::new(&config);
// May fail if no CUDA device available - that's expected in CI
match result {
Ok(_) => println!("CUDA kernel manager created successfully"),