[][src]Trait accel::memory::Memory

pub trait Memory {
    type Elem: Scalar;
    fn head_addr(&self) -> *const Self::Elem;
fn head_addr_mut(&mut self) -> *mut Self::Elem;
fn num_elem(&self) -> usize;
fn memory_type(&self) -> MemoryType;
fn set(&mut self, value: Self::Elem); }

Has unique head address and allocated size.

Associated Types

type Elem: Scalar

Scalar type of each element

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.
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);
}
Loading content...

Implementations on Foreign Types

impl<T: Scalar> Memory for [T][src]

type Elem = T

Loading content...

Implementors

impl<'_, T: Scalar> Memory for RegisteredMemory<'_, T>[src]

type Elem = T

impl<T: Scalar> Memory for DeviceMemory<T>[src]

type Elem = T

impl<T: Scalar> Memory for PageLockedMemory<T>[src]

type Elem = T

impl<T: Scalar, Dim: Dimension> Memory for Array<T, Dim>[src]

type Elem = T

Loading content...