pub struct CpuComputeDispatch {
pub kernel: ComputeKernelKind,
pub workgroup_size: WorkgroupSize,
}Expand description
Dispatcher that executes compute kernels on the CPU.
Fields§
§kernel: ComputeKernelKindWhich kernel this dispatcher is configured for.
workgroup_size: WorkgroupSizeWorkgroup size hint (informational on the CPU path).
Implementations§
Source§impl CpuComputeDispatch
impl CpuComputeDispatch
Sourcepub fn new(kernel: ComputeKernelKind, wg: WorkgroupSize) -> Self
pub fn new(kernel: ComputeKernelKind, wg: WorkgroupSize) -> Self
Create a new dispatcher.
Sourcepub fn dispatch_velocity_update(
&self,
pos: &mut ComputeBuffer,
vel: &mut ComputeBuffer,
force: &ComputeBuffer,
mass: &ComputeBuffer,
dt: f32,
n: usize,
)
pub fn dispatch_velocity_update( &self, pos: &mut ComputeBuffer, vel: &mut ComputeBuffer, force: &ComputeBuffer, mass: &ComputeBuffer, dt: f32, n: usize, )
Semi-implicit Euler integration for n particles.
pos[i] += vel[i] * dt then vel[i] += force[i] / mass[i] * dt.
Sourcepub fn dispatch_pressure_jacobi(
&self,
p: &mut ComputeBuffer,
p_old: &ComputeBuffer,
rhs: &ComputeBuffer,
nx: usize,
ny: usize,
dx: f32,
)
pub fn dispatch_pressure_jacobi( &self, p: &mut ComputeBuffer, p_old: &ComputeBuffer, rhs: &ComputeBuffer, nx: usize, ny: usize, dx: f32, )
Single Jacobi pressure iteration over an nx × ny grid.
Interior points only; boundary cells are left unchanged.
p[i,j] = (p_old[i+1,j] + p_old[i-1,j] + p_old[i,j+1] + p_old[i,j-1] - dx² * rhs[i,j]) / 4
Sourcepub fn dispatch_particle_force(
&self,
pos: &ComputeBuffer,
force: &mut ComputeBuffer,
eps: f32,
sigma: f32,
n: usize,
)
pub fn dispatch_particle_force( &self, pos: &ComputeBuffer, force: &mut ComputeBuffer, eps: f32, sigma: f32, n: usize, )
O(n²) Lennard-Jones force accumulation.
Positions are stored as interleaved [x0, y0, x1, y1, …].
Forces are accumulated in-place (force is zeroed first).
Auto Trait Implementations§
impl Freeze for CpuComputeDispatch
impl RefUnwindSafe for CpuComputeDispatch
impl Send for CpuComputeDispatch
impl Sync for CpuComputeDispatch
impl Unpin for CpuComputeDispatch
impl UnsafeUnpin for CpuComputeDispatch
impl UnwindSafe for CpuComputeDispatch
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more