Expand description
A Rust adapter for the Khronos OpenCL API.
§Description
A functional, safe Rust interface to the Khronos OpenCL 3.0
C API
based upon the opencl-sys OpenCL
FFI bindings.
OpenCL 3.0
is a unified specification that adds little new functionality to previous OpenCL
versions.
It specifies that all OpenCL 1.2
features are mandatory, while all
OpenCL 2.x
and OpenCL 3.0
features are now optional.
§Design
This crate applies the adapter pattern
to convert OpenCL
C API functions into Rust functions that return a
Result containing the desired result of
the C function or the OpenCL
error code.
The exception is svm_free
, which just provides a safe wrapper for the
clSVMFree
C API function.
Most of the modules are named after their equivalent OpenCL
“API” sections in
cl.h.
They contain Rust adapter functions for the OpenCL
API C functions defined
in those sections with their associated types and constants. The exceptions are:
error_codes
- contains theOpenCL
API error codes from cl.h and a function (error_text
) to convert an error code to it’s enum name from cl.h.info_type
- contains a Rust enum (InfoType
) to hold theOpenCL
types that can be returned fromOpenCL
“Info” functions, e.g. clGetPlatformInfo, clGetDeviceInfo, clGetProgramInfo, etc.macros
- contains Rust macros to call theOpenCL
“Info” functions and return the appropriateInfoType
in a Rust Result.
It is vital to call the correct InfoType
method type when decoding the
result of “Info” functions, since the methods will panic if called with the
wrong type, see info_type
.
§Use
See cl3.
§License
Licensed under the Apache License, Version 2.0, as per Khronos Group OpenCL
.
You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
OpenCL
and the OpenCL
logo are trademarks of Apple Inc. used under license by Khronos.
Modules§
- command_
queue OpenCL
Command Queue API.- context
OpenCL
Context API.- d3d10
- FFI bindings for
cl_d3d10.h
- d3d11
- FFI bindings for
cl_d3d11.h
- device
OpenCL
Device API.- dx9_
media_ sharing - FFI bindings for
cl_dx9_media_sharing.h
- egl
OpenCL
OpenGL
ES Interoperability API.- error_
codes OpenCL
API Error Codes.- event
OpenCL
Event Object API.- ext
OpenCL
extensions that don’t have external (OpenGL, D3D) dependencies. See: OpenCL Extension Specification- gl
OpenCL
OpenGL
Interoperability API.- info_
type - kernel
OpenCL
Kernel Object API.- layer
OpenCL
layer extensions- macros
- memory
OpenCL
Memory Object API.- platform
OpenCL
Platform API.- program
OpenCL
Program Object API.- sampler
OpenCL
Sampler API.- types
OpenCL
API data types.
Macros§
Structs§
- OpenCl
- Wrapper for the
OpenCL
API functions.
Functions§
- is_
opencl_ runtime_ available - Utility function to check if the
OpenCL
shared library is loaded successfully. - load_
library - Utility function to load the
OpenCL
shared library (actual load will be performed only once).
Type Aliases§
- Open
ClRuntime dlopen2
container with all loaded API functions.