Expand description
GPU acceleration foundation for spintronics (v0.9.0).
This module provides a Device trait abstraction that lets the same LLG
simulation code run on CPU or GPU backends. v0.9.0 ships:
CpuDevice— always available, drop-in baseline that reuses the existingcrate::dynamics::llg::calc_dm_dtscalar path- [
CudaDevice] (feature =cuda) — stub that constructs successfully but reportsis_available() == falseand returnscrate::error::Error::NumericalErroron every operation. v1.0.0 will wire this to a real CUDA backend (planned:cudarc+ PTX kernels) without breaking existing call sites.
The intent is to establish the type signatures and contracts now so that the v1.0.0 CUDA implementation can land as a drop-in replacement.
§Design intent
Operations work on flat &mut [[f64; 3]] arrays (per-spin x, y, z) for
FFI-friendliness and zero-copy compatibility with future GPU memory
buffers. Implementations decide whether to copy data to GPU and back per
call, batch operations, or maintain persistent device buffers.
The Device trait is intentionally object-safe so users can store
Box<dyn Device> and switch backends at runtime via
select_best_device.
§Example
ⓘ
use spintronics::gpu::{CpuDevice, Device};
let device = CpuDevice::new();
let mut spins = vec![[1.0_f64, 0.0, 0.0], [0.0, 1.0, 0.0]];
let h_eff = vec![[0.0_f64, 0.0, 1.0e5]; 2];
device.step_llg_rk4(&mut spins, &h_eff, 0.01, 1.0e-13).unwrap();§References
- A. Vansteenkiste, J. Leliaert, M. Dvornik, M. Helsen, F. Garcia-Sanchez, and B. Van Waeyenberge, “The design and verification of MuMax3”, AIP Advances 4, 107133 (2014).
- MuMAX³ Pro — GPU-accelerated micromagnetics framework (reference design for batched LLG kernels).
Re-exports§
pub use cpu::CpuDevice;
Modules§
Traits§
- Device
- Device abstraction for LLG simulation on CPU or GPU backends.
Functions§
- available_
devices - Enumerate all devices that the current build can construct.
- select_
best_ device - Select the best available device.