Expand description

A minimal OpenCL, CUDA and host CPU array manipulation engine / framework written in Rust. This crate provides the tools for executing custom array operations with the CPU, as well as with CUDA and OpenCL devices.
This guide demonstrates how operations can be implemented for the compute devices: implement_operations.md
or to see it at a larger scale, look here: [custos-math]

Examples

Using the host CPU as the compute device:

cpu_readme.rs

use custos::{CPU, ClearBuf, VecRead, Buffer};

let device = CPU::new();
let mut a = Buffer::from(( &device, [1, 2, 3, 4, 5, 6]));
     
// specify device for operation
device.clear(&mut a);
assert_eq!(device.read(&a), [0; 6]);

let device = CPU::new();

let mut a = Buffer::from(( &device, [1, 2, 3, 4, 5, 6]));
a.clear();

assert_eq!(a.read(), vec![0; 6]);

Re-exports

pub use libs::opencl::CLDevice;
pub use libs::opencl::InternCLDevice;
pub use libs::*;

Modules

Macros

Return a device that implements the trait provided thus giving access to the functions implemented by the trait.

Structs

The underlying non-growable array structure. A Buffer may be encapsulated in other structs.

A CPU is used to perform calculations on the host CPU. To make new operations invocable, a trait providing new functions should be implemented for CPU.

used to reset the cache count

Used to perform calculations with a CUDA capable device. To make new calculations invocable, a trait providing new operations should be implemented for CudaDevice.

Device is another representation of a compute device.
It stores the type of the device and a pointer to the device from which Device originates from.
This is used instead of another “device” generic for Buffer.

Enums

Used to determine which device type Device is of.

Constants

Traits

This trait allocates memory on the implemented device.

This trait is a non-generic variant for calling Alloc’s Alloc::<T>::as_dev(..)

This trait is used to retrieve a cached buffer from a specific device type.

Trait for implementing the clear() operation for the compute devices.

This trait is used to clone a buffer based on a specific device type.

Trait for reading buffers.

Trait for writing data to buffers.

Functions

Adds a buffer to the “cache chain”. Following calls will return this buffer, if the corresponding internal count matches with the id used in the cache.

inclusive range used to reset the cache count in loops as every operation increases the cache count, which would break the “cache cycle” if the cache count would not be reset.

Type Definitions