[−][src]Trait accel::memory::Memory
Has unique head address and allocated size.
Associated Types
Loading content...Required methods
fn head_addr(&self) -> *const Self::Elem
Get head address of the memory as a const pointer
fn head_addr_mut(&mut self) -> *mut Self::Elem
Get head address of the memory as a mutable pointer
fn num_elem(&self) -> usize
Number of elements
fn memory_type(&self) -> MemoryType
Get memory type, See MemoryType for detail.
fn set(&mut self, value: Self::Elem)
Set all elements by value
Examples
- Set
i32
let mut mem = DeviceMemory::<i32>::zeros(&ctx, 12); mem.set(1234); for &val in mem.as_slice() { assert_eq!(val, 1234); }
- Set
f32
- Be sure that
f64
is not supported yet because CUDA does not support 64-bit memset.
- Be sure that
let mut mem = DeviceMemory::<f32>::zeros(&ctx, 12); mem.set(1.0); for &val in mem.as_slice() { assert_eq!(val, 1.0); }
- Set for host memory equals to
mem.iter_mut().for_each(|v| *v = value)
let mut mem = PageLockedMemory::<i32>::zeros(&ctx, 12); mem.set(1234); for &val in mem.as_slice() { assert_eq!(val, 1234); }