Function ocl_core::verify_context [] [src]

pub fn verify_context<C>(context: C) -> OclResult<()> where
    C: ClContextPtr

Verifies that the context is in fact a context object pointer.

Assumptions

Some (most?/all?) OpenCL implementations do not correctly error if non- context pointers are passed. This function relies on the fact that passing the CL_CONTEXT_DEVICES as the param_name to clGetContextInfo will (at least on my AMD implementation) often return a huge result size if context is not actually a cl_context pointer due to the fact that it's reading from some random memory location on non-context structs. Also checks for zero because a context must have at least one device (true?). Should probably choose a value lower than 10kB because it seems unlikely any result would be that big but w/e.

[UPDATE]: This function may no longer be necessary now that the core pointers have wrappers but it still prevents a hard to track down bug so it will stay intact for now.