Skip to main content

Crate baracuda_cufft

Crate baracuda_cufft 

Source
Expand description

Safe Rust wrappers for NVIDIA cuFFT.

v0.1 covers cufftPlan1d/cufftPlan2d/cufftPlan3d and the R2C/C2R/C2C single-precision transforms. Multi-GPU (cufftXt) and batched descriptor-style plans land in a follow-up.

use baracuda_driver::{Context, Device, DeviceBuffer};
use baracuda_cufft::{Plan1d, Transform};

let device = Device::get(0)?;
let ctx = Context::new(&device)?;
let host: Vec<f32> = (0..1024).map(|i| (i as f32 * 0.05).sin()).collect();
let mut d_in = DeviceBuffer::from_slice(&ctx, &host)?;
let mut d_out: DeviceBuffer<baracuda_types::Complex32> =
    DeviceBuffer::new(&ctx, host.len() / 2 + 1)?;

let plan = Plan1d::new(host.len() as i32, Transform::R2C, 1)?;
plan.exec_r2c(&mut d_in, &mut d_out)?;

Modules§

callback
Pre/post callbacks attached to a cuFFT plan via the cufftXt* callback entry points. The callback ABI is fixed by NVIDIA: each callback receives the input/output element index, a caller-info pointer, and the data; see the cuFFT reference for the exact signatures by callback type. We expose only the raw setters because the function-pointer types are PTX-shaped, not regular extern "C" functions — they ship as device-side __device__ functions linked into the user’s CUBIN.
xt
Multi-GPU (XT) extension helpers. Use these to distribute a cuFFT plan across multiple GPUs via cufftXtSetGPUs + cufftXtExec.

Structs§

Plan
Generic cuFFT plan that supports the modern two-step creation flow: Plan::create gets you a fresh handle, then one of the make_plan_* methods configures the rank and reports the workspace size — useful when you want to allocate the work area yourself (call [set_auto_allocation(false)] before make_plan_*).
Plan1d
A 1-D cuFFT plan.
Plan2d
A 2-D cuFFT plan.
Plan3d
Owned 3-D cuFFT plan.
PlanMany
A batched / many-rank plan (cufftPlanMany). Handles arbitrary rank + advanced-data-layout transforms.

Enums§

Direction
Direction for C2C transforms.
Transform
Transform kind.

Functions§

estimate_1d
Sizing estimates (workspace bytes) for a plan shape.
estimate_2d
2-D workspace-size estimate (bytes) for a plan of the given shape. Wraps cufftEstimate2d.
estimate_3d
3-D workspace-size estimate (bytes) for a plan of the given shape. Wraps cufftEstimate3d.
get_size
Scratch bytes this plan currently needs.
set_auto_allocation
Disable / re-enable automatic work-area allocation.
set_work_area
Set a user-allocated scratch work area (cufftSetWorkArea).
version
cuFFT library version, e.g. 11300 for cuFFT 11.3.0.

Type Aliases§

Error
Error type for cuFFT operations.
Result
Result alias.