binius_compute/cpu/
alloc.rs1use std::fmt::Debug;
4
5use bytemuck::zeroed_vec;
6
7use crate::alloc::HostBumpAllocator;
8
9pub struct CpuComputeAllocator<F> {
10 data: Vec<F>,
11}
12
13impl<F> CpuComputeAllocator<F>
14where
15 F: Sync + Debug + Send + 'static,
16{
17 pub fn into_bump_allocator(&mut self) -> HostBumpAllocator<'_, F> {
18 HostBumpAllocator::new(self.data.as_mut_slice())
19 }
20}
21
22impl<F> CpuComputeAllocator<F>
23where
24 F: Sync + 'static + bytemuck::Zeroable,
25{
26 pub fn new(capacity: usize) -> Self {
27 Self {
28 data: zeroed_vec(capacity),
29 }
30 }
31}