| 
 | 1 | +// Test CUDA atomic operations compile correctly  | 
 | 2 | +// build-pass  | 
 | 3 | + | 
 | 4 | +use core::sync::atomic::Ordering;  | 
 | 5 | +use cuda_std::atomic::{  | 
 | 6 | + AtomicF32, AtomicF64, BlockAtomicF32, BlockAtomicF64, SystemAtomicF32, SystemAtomicF64,  | 
 | 7 | +};  | 
 | 8 | +use cuda_std::kernel;  | 
 | 9 | + | 
 | 10 | +#[kernel]  | 
 | 11 | +pub unsafe fn test_cuda_atomic_floats() {  | 
 | 12 | + // Device-scoped atomic float  | 
 | 13 | + let atomic_f32 = AtomicF32::new(3.14);  | 
 | 14 | + let _old = atomic_f32.fetch_add(1.0, Ordering::Relaxed);  | 
 | 15 | + let _val = atomic_f32.load(Ordering::Relaxed);  | 
 | 16 | + atomic_f32.store(2.718, Ordering::Relaxed);  | 
 | 17 | + | 
 | 18 | + // Block-scoped atomic float  | 
 | 19 | + let block_atomic = BlockAtomicF32::new(1.5);  | 
 | 20 | + let _old = block_atomic.fetch_add(0.5, Ordering::Relaxed);  | 
 | 21 | + | 
 | 22 | + // System-scoped atomic float  | 
 | 23 | + let system_atomic = SystemAtomicF32::new(0.0);  | 
 | 24 | + let _old = system_atomic.fetch_add(1.0, Ordering::Relaxed);  | 
 | 25 | + | 
 | 26 | + // Test f64 as well  | 
 | 27 | + let atomic_f64 = AtomicF64::new(3.14159);  | 
 | 28 | + let _old = atomic_f64.fetch_add(1.0, Ordering::Relaxed);  | 
 | 29 | + | 
 | 30 | + // Test block-scoped f64  | 
 | 31 | + let block_f64 = BlockAtomicF64::new(2.718);  | 
 | 32 | + let _old = block_f64.fetch_sub(0.5, Ordering::Relaxed);  | 
 | 33 | + | 
 | 34 | + // Test bitwise operations on floats  | 
 | 35 | + let _old = atomic_f32.fetch_and(3.14, Ordering::Relaxed);  | 
 | 36 | + let _old = atomic_f32.fetch_or(1.0, Ordering::Relaxed);  | 
 | 37 | + let _old = atomic_f32.fetch_xor(2.0, Ordering::Relaxed);  | 
 | 38 | +}  | 
0 commit comments