pub struct Context(/* private fields */);
Expand description
A context for a particular platform and set of device types.
Thread safety and destruction for any enclosed pointers are all handled automatically. Clone, store, and share between threads to your heart’s content.
Implementations§
source§impl Context
impl Context
sourcepub fn builder() -> ContextBuilder
pub fn builder() -> ContextBuilder
Returns a ContextBuilder
.
This is the preferred way to create a Context.
sourcepub fn new(
properties: Option<ContextProperties>,
device_spec: Option<DeviceSpecifier>,
pfn_notify: Option<CreateContextCallbackFn>,
user_data: Option<UserDataPtr>
) -> OclResult<Context>
pub fn new( properties: Option<ContextProperties>, device_spec: Option<DeviceSpecifier>, pfn_notify: Option<CreateContextCallbackFn>, user_data: Option<UserDataPtr> ) -> OclResult<Context>
Returns a newly created context.
Prefer Context::builder()...
instead of this method unless you know
what you’re doing. Please also immediately contact us if you do, in
fact, know what you’re doing so that you can be added to the
development team as the one who does.
§Defaults
- The ‘NULL’ platform (which is not to be relied on but is generally the first avaliable).
- All devices associated with the ‘NULL’ platform
- No notify callback function or user data.
Don’t rely on these defaults, instead rely on the ContextBuilder
defaults. In other words, use: Context::builder().build().unwrap()
rather than Context::new(None, None, None, None).unwrap()
.
§Panics
[TEMPORARY] Passing a Some
variant for pfn_notify
or user_data
is
not yet supported. File an issue if you need this.
sourcepub fn resolve_wrapping_device_idxs(&self, idxs: &[usize]) -> Vec<Device>
pub fn resolve_wrapping_device_idxs(&self, idxs: &[usize]) -> Vec<Device>
Resolves a list of zero-based device indices into a list of Devices.
If any index is out of bounds it will wrap around zero (%) to the next valid device index.
sourcepub fn get_device_by_wrapping_index(&self, index: usize) -> Device
pub fn get_device_by_wrapping_index(&self, index: usize) -> Device
Returns a device by its ordinal count within this context.
Round-robins (%) to the next valid device.
sourcepub fn platform_info(
&self,
info_kind: PlatformInfo
) -> OclResult<PlatformInfoResult>
pub fn platform_info( &self, info_kind: PlatformInfo ) -> OclResult<PlatformInfoResult>
Returns info about the platform associated with the context.
sourcepub fn device_info(
&self,
index: usize,
info_kind: DeviceInfo
) -> OclResult<DeviceInfoResult>
pub fn device_info( &self, index: usize, info_kind: DeviceInfo ) -> OclResult<DeviceInfoResult>
Returns info about the device indexed by index
associated with this
context.
sourcepub fn info(&self, info_kind: ContextInfo) -> OclResult<ContextInfoResult>
pub fn info(&self, info_kind: ContextInfo) -> OclResult<ContextInfoResult>
Returns info about the context.
sourcepub fn as_core(&self) -> &ContextCore
pub fn as_core(&self) -> &ContextCore
Returns a reference to the core pointer wrapper, usable by functions in
the core
module.
sourcepub fn devices(&self) -> Vec<Device>
pub fn devices(&self) -> Vec<Device>
Returns the list of devices associated with this context.
Panics upon any OpenCL error.
sourcepub fn device_versions(&self) -> OclResult<Vec<OpenclVersion>>
pub fn device_versions(&self) -> OclResult<Vec<OpenclVersion>>
Returns the list of device versions associated with this context.