rust-opencl icon indicating copy to clipboard operation
rust-opencl copied to clipboard

Newer OpenCL versions

Open kazimuth opened this issue 10 years ago • 3 comments

As far as I can tell, rust-opencl implements OpenCL 1.1. Would it be possible to support OpenCL 1.2 and 2.0? (And maybe 1.0, I suppose.) I don't believe there are backwards-incompatible changes; things are deprecated, but not removed. It might be possible to set up version selection with a cargo build-time feature. The OpenCL headers are nicely annotated with version information. It would be really cool to be able to select at runtime, based on the result of clGetPlatformInfo, at least for the high-level interface; I'm not sure what the best way to implement that would be, though.

kazimuth avatar Dec 27 '14 01:12 kazimuth

I wonder if the correct thing to do is something like what Rust does for OpenGL: https://github.com/bjz/gl-rs

Basically, we'd dynamically load whatever library happens to be available.

In the short term, I don't see any reason not to add the newer APIs to these bindings.

For dynamically selecting versions at run time, I guess the main thing is what to do if it fails. We could have an API like get_opencl_context_2_0 which returns one that supports 2.0 and fails if it's not supported. Alternatively, all the existing APIs could follow the way Rust does IO, and maybe return an unimplemented error if the OpenCL version isn't high enough.

eholk avatar Dec 27 '14 01:12 eholk

Returning Result<Context, String> is basically what I've been doing with extension-loading code, actually.

kazimuth avatar Dec 27 '14 02:12 kazimuth

I think the correct way forward might be to break this library into two libraries. opencl-sys would be the FFI bindings and opencl-rs could contain the idiomatic wrappers for opencl.

ghost avatar Dec 27 '14 21:12 ghost