1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
//! # [![](https://img.shields.io/crates/v/ocl.svg)](https://crates.io/crates/ocl) | [GitHub](https://github.com/cogciprocate/ocl)
//!
//! Rust implementation of the [OpenCL™ API].
//!
//! Some versions of this documentation are built from development branches
//! and may differ slightly between what is on crates.io and the master
//! branch. See the [repo page](https://github.com/cogciprocate/ocl) for links
//! to both versions.
//!
//! Please report unclear documentation or places where examples would be
//! appreciated by filing an [issue].
//!
//!
//! ## Foundations
//!
//! For lower level interfaces and to use OpenCL features that have not yet
//! been implemented on the `standard` (high-level) interface types, see the
//! [`ocl-core`] and [`cl-sys`] crates.
//!
//!
//! ## Help Wanted
//!
//! Please request or help complete any functionality you may need by filing
//! an [issue] or creating a [pull
//! request](https://github.com/cogciprocate/ocl/pulls).
//!
//! Keep an eye out for places where examples would be useful and let us know!
//!
//!
//! ## Feedback appreciated
//!
//! Suggestions and nitpicks are most welcome. Don't hesitate to file an
//! [issue] just to offer constructive criticism.
//!
//!
//! <br/>
//! *“`OpenCL` and the `OpenCL` logo are trademarks of Apple Inc. used by permission by Khronos.”*
//!
//!
//! [OpenCL™ API]: https://www.khronos.org/registry/OpenCL/
//! [issue]: https://github.com/cogciprocate/ocl/issues
//! [`ocl-core`]: https://github.com/cogciprocate/ocl-core
//! [`cl-sys`]: https://github.com/cogciprocate/cl-sys
//! [`Result`]: /ocl/ocl/type.Result.html
//! [examples]: https://github.com/cogciprocate/ocl/tree/master/examples
#![doc(html_root_url = "https://docs.rs/ocl/0.19.7")]
// #![warn(missing_docs)]
extern crate futures;
extern crate num_traits;
pub extern crate ocl_core;
pub use ocl_core as core;
pub mod r#async;
pub mod error;
mod standard;
#[cfg(test)]
mod tests;
pub use self::r#async::{
FutureMemMap, FutureReadGuard, FutureWriteGuard, MemMap, ReadGuard, RwVec, WriteGuard,
};
pub use self::standard::{
Buffer, BufferCmdError, Context, Device, Event, EventArray, EventList, Extensions, Image,
Kernel, Platform, ProQue, Program, Queue, Sampler, SpatialDims,
};
#[doc(no_inline)]
pub use crate::core::ffi;
#[doc(no_inline)]
pub use crate::core::util;
pub use crate::core::Error as OclCoreError;
#[doc(no_inline)]
pub use crate::core::{
CommandQueueProperties, DeviceType, MapFlags, MemFlags, OclPrm, OclScl, OclVec,
};
pub use crate::error::{Error, Result};
pub mod prm {
//! OpenCL scalar and vector primitive types.
//!
//! Rust primitives may have subtly different behaviour than OpenCL
//! primitives within kernels. Wrapping is one example of this. Scalar
//! integers within Rust may do overflow checks where in the kernel they
//! do not. Therefore OpenCL-compatible implementations of each of the
//! types are provided so that host and device side operations can be
//! perfectly consistent.
//!
//! The `cl_...` (`cl_uchar`, `cl_int`, `cl_float`, etc.) types are simple
//! aliases of the Rust built-in primitive types and do **not** behave the
//! same way that the kernel-side equivalents do. The uppercase-named
//! types, on the other hand, (`Uchar`, `Int`, `Float`, etc.) are designed
//! to behave identically to their corresponding types within kernels.
//!
//! Please file an issue if any of the uppercase-named kernel-mimicking
//! types deviate from what they should (as they are reasonably new this
//! is definitely something to watch out for).
//!
//! Vector type fields can be accessed using index operations i.e. [0],
//! [1], [2] ... etc. Plans for other ways of accessing fields (such as
//! `.x()`, `.y()`, `.s0()`, `.s15()`, etc.) will be considered in the
//! future (pending a number of additions/stabilizations to the Rust
//! language). Create an issue if you have an opinion on the matter.
//!
//! [NOTE]: This module may be renamed.
pub use crate::ffi::{
cl_bitfield, cl_bool, cl_char, cl_double, cl_float, cl_half, cl_int, cl_long, cl_short,
cl_uchar, cl_uint, cl_ulong, cl_ushort,
};
pub use crate::ffi::{cl_GLenum, cl_GLint, cl_GLuint};
// Wrapping types. Use these to mimic in-kernel behaviour:
pub use crate::core::{
Char, Char16, Char2, Char3, Char4, Char8, Double, Double16, Double2, Double3, Double4,
Double8, Float, Float16, Float2, Float3, Float4, Float8, Int, Int16, Int2, Int3, Int4,
Int8, Long, Long16, Long2, Long3, Long4, Long8, Short, Short16, Short2, Short3, Short4,
Short8, Uchar, Uchar16, Uchar2, Uchar3, Uchar4, Uchar8, Uint, Uint16, Uint2, Uint3, Uint4,
Uint8, Ulong, Ulong16, Ulong2, Ulong3, Ulong4, Ulong8, Ushort, Ushort16, Ushort2, Ushort3,
Ushort4, Ushort8,
};
}
pub mod traits {
//! Commonly used traits.
pub use crate::core::{OclPrm, OclScl, OclVec};
pub use crate::standard::{IntoMarker, IntoRawEventArray, MemLen, WorkDims};
}
pub mod builders {
//! Builders and associated settings-related types.
pub use crate::core::{ContextProperties, ImageDescriptor, ImageFormat};
pub use crate::standard::{
BufferBuilder, BufferCmd, BufferCmdDataShape, BufferCmdKind, BufferMapCmd, BufferReadCmd,
BufferWriteCmd, BuildOpt, ContextBuilder, DeviceSpecifier, ImageBuilder, ImageCmd,
ImageCmdKind, KernelBuilder, KernelCmd, ProQueBuilder, ProgramBuilder,
};
pub use crate::standard::{ClNullEventPtrEnum, ClWaitListPtrEnum};
// #[cfg(not(release))] pub use standard::BufferTest;
}
pub mod flags {
//! Bitflags for various parameter types.
pub use crate::core::{
// cl_command_queue_properties - bitfield
CommandQueueProperties,
// cl_device_affinity_domain
DeviceAffinityDomain,
// cl_device_exec_capabilities - bitfield
DeviceExecCapabilities,
// cl_device_fp_config - bitfield
DeviceFpConfig,
// cl_device_type - bitfield
DeviceType,
// cl_kernel_arg_type_qualifer
KernelArgTypeQualifier,
// cl_map_flags - bitfield
MapFlags,
// cl_mem_flags - bitfield
MemFlags,
// cl_mem_migration_flags - bitfield
MemMigrationFlags,
// cl_program_binary_type
ProgramBinaryType,
DEVICE_AFFINITY_DOMAIN_L1_CACHE,
DEVICE_AFFINITY_DOMAIN_L2_CACHE,
DEVICE_AFFINITY_DOMAIN_L3_CACHE,
DEVICE_AFFINITY_DOMAIN_L4_CACHE,
DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE,
DEVICE_AFFINITY_DOMAIN_NUMA,
DEVICE_TYPE_ACCELERATOR,
DEVICE_TYPE_ALL,
DEVICE_TYPE_CPU,
DEVICE_TYPE_CUSTOM,
DEVICE_TYPE_DEFAULT,
DEVICE_TYPE_GPU,
EXEC_KERNEL,
EXEC_NATIVE_KERNEL,
FP_CORRECTLY_ROUNDED_DIVIDE_SQRT,
FP_DENORM,
FP_FMA,
FP_INF_NAN,
FP_ROUND_TO_INF,
FP_ROUND_TO_NEAREST,
FP_ROUND_TO_ZERO,
FP_SOFT_FLOAT,
KERNEL_ARG_TYPE_CONST,
KERNEL_ARG_TYPE_NONE,
KERNEL_ARG_TYPE_RESTRICT,
KERNEL_ARG_TYPE_VOLATILE,
MAP_READ,
MAP_WRITE,
MAP_WRITE_INVALIDATE_REGION,
MEM_ALLOC_HOST_PTR,
MEM_COPY_HOST_PTR,
MEM_HOST_NO_ACCESS,
MEM_HOST_READ_ONLY,
MEM_HOST_WRITE_ONLY,
MEM_READ_ONLY,
MEM_READ_WRITE,
MEM_USE_HOST_PTR,
MEM_WRITE_ONLY,
MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED,
MIGRATE_MEM_OBJECT_HOST,
PROGRAM_BINARY_TYPE_COMPILED_OBJECT,
PROGRAM_BINARY_TYPE_EXECUTABLE,
PROGRAM_BINARY_TYPE_LIBRARY,
PROGRAM_BINARY_TYPE_NONE,
QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
QUEUE_PROFILING_ENABLE,
};
}
pub mod enums {
//! Enumerators for settings and information requests.
pub use crate::standard::{BufferCmdDataShape, BufferCmdKind, DeviceSpecifier, WriteSrc};
// API enums.
pub use crate::core::{
AddressingMode, BufferCreateType, Cbool, ChannelType, CommandExecutionStatus,
CommandQueueInfo, CommandType, ContextInfo, ContextInfoOrPropertiesPointerType,
ContextProperty, DeviceInfo, DeviceLocalMemType, DeviceMemCacheType,
DevicePartitionProperty, EventInfo, FilterMode, ImageChannelDataType, ImageChannelOrder,
ImageInfo, KernelArgAccessQualifier, KernelArgAddressQualifier, KernelArgInfo, KernelInfo,
KernelWorkGroupInfo, MemInfo, MemObjectType, PlatformInfo, Polling, ProfilingInfo,
ProgramBuildInfo, ProgramBuildStatus, ProgramInfo, SamplerInfo,
};
// Custom enums.
pub use crate::core::{
ArgVal, CommandQueueInfoResult, ContextInfoResult, ContextPropertyValue, DeviceInfoResult,
EventInfoResult, ImageInfoResult, KernelArgInfoResult, KernelInfoResult,
KernelWorkGroupInfoResult, MemInfoResult, PlatformInfoResult, ProfilingInfoResult,
ProgramBuildInfoResult, ProgramInfoResult, SamplerInfoResult,
};
// Error status.
pub use crate::core::Status;
}