Struct custos_math::custos::OpenCL
source · pub struct OpenCL {
pub kernel_cache: RefCell<KernelCacheCL>,
pub cache: RefCell<Cache<OpenCL>>,
pub inner: RefCell<CLDevice>,
pub graph: RefCell<Graph>,
pub cpu: CPU,
}Expand description
Used to perform calculations with an OpenCL capable device. To make new calculations invocable, a trait providing new operations should be implemented for CLDevice.
Example
use custos::{OpenCL, Read, Buffer, Error};
fn main() -> Result<(), Error> {
let device = OpenCL::new(0)?;
let a = Buffer::from((&device, [1.3; 25]));
let out = device.read(&a);
assert_eq!(out, vec![1.3; 5*5]);
Ok(())
}Fields§
§kernel_cache: RefCell<KernelCacheCL>§cache: RefCell<Cache<OpenCL>>§inner: RefCell<CLDevice>§graph: RefCell<Graph>§cpu: CPUImplementations§
source§impl OpenCL
impl OpenCL
sourcepub fn new(
device_idx: usize
) -> Result<OpenCL, Box<dyn Error + Send + Sync + 'static, Global>>
pub fn new( device_idx: usize ) -> Result<OpenCL, Box<dyn Error + Send + Sync + 'static, Global>>
sourcepub fn reset(&'static mut self)
pub fn reset(&'static mut self)
Sets the values of the attributes cache, kernel cache, graph and CPU to their default. This cleans up any accumulated allocations.
pub fn ctx(&self) -> Ref<'_, Context>
pub fn queue(&self) -> Ref<'_, CommandQueue>
pub fn device(&self) -> CLIntDevice
pub fn global_mem_size_in_gb( &self ) -> Result<f64, Box<dyn Error + Send + Sync + 'static, Global>>
pub fn max_mem_alloc_in_gb( &self ) -> Result<f64, Box<dyn Error + Send + Sync + 'static, Global>>
pub fn name( &self ) -> Result<String, Box<dyn Error + Send + Sync + 'static, Global>>
pub fn version( &self ) -> Result<String, Box<dyn Error + Send + Sync + 'static, Global>>
sourcepub fn unified_mem(&self) -> bool
pub fn unified_mem(&self) -> bool
Checks whether the device supports unified memory.
pub fn set_unified_mem(&self, unified_mem: bool)
👎Deprecated since 0.6.0: Use the environment variable ‘CUSTOS_USE_UNIFIED’ set to ‘true’, ‘false’ or ‘default’[=hardware dependent] instead.
Trait Implementations§
source§impl<T: CDatatype + Float> ActivationOps<T, (), OpenCL> for OpenCL
impl<T: CDatatype + Float> ActivationOps<T, (), OpenCL> for OpenCL
fn sigmoid(&self, x: &Matrix<'_, T, Self>) -> Matrix<'_, T, Self>
fn sigmoid_grad(&self, x: &Matrix<'_, T, Self>) -> Matrix<'_, T, Self>
fn tanh(&self, x: &Matrix<'_, T, Self>) -> Matrix<'_, T, Self>
fn tanh_grad(&self, x: &Matrix<'_, T, Self>) -> Matrix<'_, T, Self>
fn relu(&self, x: &Matrix<'_, T, Self>) -> Matrix<'_, T, Self>
fn relu_grad(&self, x: &Matrix<'_, T, Self>) -> Matrix<'_, T, Self>
source§fn relu_grad_mut(&self, x: &mut Matrix<'_, T, Self, ()>)
fn relu_grad_mut(&self, x: &mut Matrix<'_, T, Self, ()>)
inplace
source§impl<T: CDatatype> AdditionalOps<T, (), OpenCL> for OpenCL
impl<T: CDatatype> AdditionalOps<T, (), OpenCL> for OpenCL
fn adds(&self, lhs: &Matrix<'_, T, Self>, rhs: T) -> Matrix<'_, T, Self>
fn subs(&self, lhs: &Matrix<'_, T, Self, ()>, rhs: T) -> Matrix<'_, T, Self, ()>
fn muls(&self, lhs: &Matrix<'_, T, Self>, rhs: T) -> Matrix<'_, T, Self>
fn divs(&self, lhs: &Matrix<'_, T, Self>, rhs: T) -> Matrix<'_, T, Self>
source§impl<T: CDatatype> BaseOps<T, (), OpenCL> for OpenCL
impl<T: CDatatype> BaseOps<T, (), OpenCL> for OpenCL
source§fn add(
&self,
lhs: &Matrix<'_, T, Self>,
rhs: &Matrix<'_, T, Self>
) -> Matrix<'_, T, Self>
fn add( &self, lhs: &Matrix<'_, T, Self>, rhs: &Matrix<'_, T, Self> ) -> Matrix<'_, T, Self>
Element-wise addition Read more
source§fn sub(
&self,
lhs: &Matrix<'_, T, Self>,
rhs: &Matrix<'_, T, Self>
) -> Matrix<'_, T, Self>
fn sub( &self, lhs: &Matrix<'_, T, Self>, rhs: &Matrix<'_, T, Self> ) -> Matrix<'_, T, Self>
Element-wise subtraction Read more