luqmana / rust-opencl

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

Compiling with stable Rust #69

Open IT302 opened 9 years ago

IT302 commented 9 years ago

I am evaluating writing a project in Rust instead of C++. I am not sure if rust-opencl works with the stable Rust compilers. I have tried compiling rust-opencl with rustc 1.1.0 but I am getting "unstable feature" error.

Thanks,

Geoffrey

krupitskas commented 9 years ago

+1

[warezovvv@atlas rust-opencl]$ cargo build
   Compiling opencl v0.3.0-dev (file:///home/warezovvv/Documents/Work/Projects/Robotics/rust-opencl)
src/lib.rs:5:1: 5:22 error: unstable feature
src/lib.rs:5 #![feature(std_misc)]
             ^~~~~~~~~~~~~~~~~~~~~
note: this feature may not be used in the stable release channel
error: aborting due to previous error
Could not compile `opencl`.

To learn more, run the command again with --verbose.
Kerollmops commented 9 years ago

If you want to be more efficient you can install (from brew for example) multirust github, brew formula. Don't forget too uninstall rust previously, (multirust installation is really fast), it install cargo too With this formula you will be capable to use any version of rust you want in all your computer (default rust) and another version for the directories you want (override) (for example nightly version).

rust-opencl compile with nightly version (cf. 60d5956c9cbe32b422ea0d760a82a38515619ac6)

Razican commented 9 years ago

I'd really like to see this in stable rust :)

eholk commented 9 years ago

One thing holding this back right now is needing static mutexes. It looks like some OpenCL implementations do not properly handle multiple calls into the API, so we use a mutex to work around this. https://github.com/luqmana/rust-opencl/blob/282293c4babb41d87ad17bf0aee4e00112b95298/src/hl.rs#L134

It may be that OpenCL implementations are better now than when we added that code, or maybe we can just decide not to support broken implementations. I'm not sure whether calling clGetPlatformsIDs from multiple threads at once is in spec.

eholk commented 9 years ago

I just started a branch that compiles on stable Rust: https://github.com/eholk/rust-opencl/tree/rust-stable

I removed the platform lock, so we'll need some testing and experimentation to see if that was safe. Also, I commented out the memory tests because they use slice_bytes. We should see if we can rewrite the tests not to use slice_bytes.