luqmana / rust-opencl

OpenCL bindings for Rust.
Other
170 stars 42 forks source link

Newer OpenCL versions #51

Open kazimuth opened 9 years ago

kazimuth commented 9 years ago

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.

eholk commented 9 years ago

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.

kazimuth commented 9 years ago

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

ghost commented 9 years ago

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.