2 releases

0.1.0-alpha.1 Feb 23, 2020
0.1.0-alpha Jan 5, 2020

#679 in Concurrency

Apache-2.0

155KB
3K SLoC

dynamic_ocl

Experimental Rust OpenCL bindings, focusing on simplicity and safety. Currently very WIP, requiring Rust 1.41+ (beta toolchain at time of writing).

Features

  • Minimum overhead
  • Support OpenCL versions up to 2.2
  • Provides both direct bindings to the OpenCL C API, and higher level, safer, easier-to-use bindings
    • High level bindings can be disabled with a feature flag to avoid bloat if desired
  • OpenCL library dynamically loaded at runtime, allowing compilation of a single binary with optional OpenCL support and easier cross-compilation.
  • Types are designed with safety in mind, taking advantage of Rust's type system to prevent various types of runtime errors, including:
    • Kernel argument type mismatch
    • Illegal buffer access (e.g. attempting to read from a HOST_NO_ACCESS buffer)
    • Usage of unsafe types with buffers (e.g. types that have invalid bit patterns that could be created by an OpenCL kernel)

lib.rs:

Dynamic bindings to OpenCL

This library provides dynamically-loaded bindings to the system OpenCL library, allowing you to add optional OpenCL support to an application without requiring it as a linker dependency. Two APIs are available - raw, unsafe, one-to-one bindings to the OpenCL C API, and a higher-level, safe(r) and more convenient Rust API.

The safe Rust API is only provided with the safe feature flag set, which is enabled by default. If you prefer only the unsafe raw bindings, you can disable the feature flag by setting default_features = false for the dependency in your project manifest.

Dependencies

~2.5MB
~52K SLoC