Closed hugues31 closed 5 years ago
Same problem for me. I noticed the transfert between CPU and GPU as mentionned in the Readme.md.
Just to let y'all know, Emu 0.3.0 makes reading, writing, and launching explicit operations.
That doesn't eliminate the overhead, of course (and this O(N)
overhead will exist and is not specific to Emu (which is why I'm closing this), though if you are doing computationally intensive stuff every iteration or have an algorithm that is O(N^2)
or greater, this overhead will generally become negligible with more data). What this does mean is that the overhead is explicit in the code. Generally speaking, more code = more overhead.
For example, it should be more or less obvious that the following is introducing unnecessary overhead.
#[gpu_use(add, multiply)]
fn main() {
let mut data = vec![0.0; 1000];
gpu_do!(load(data));
data = add(data, 0.5);
gpu_do!(read(data));
gpu_do!(load(data));
data = multiply(data, 2.0);
gpu_do!(read(data));
println!("{:?}", data);
}
Instead, you can be more efficient and just do-
#[gpu_use(add, multiply)]
fn main() {
let mut data = vec![0.0; 1000];
gpu_do!(load(data));
data = add(data, 0.5);
data = multiply(data, 2.0);
gpu_do!(read(data));
println!("{:?}", data);
}
I really like this - performance should feel ergonomic.
Hello !
First, thanks for this crate and your contribution to the Rust community. This is amazingly simple to use, even for me who has not ever touch OpenCL.
I tried running a simple benchmark program and I found the result unsatisfying. I suppose this example is so trivial, the initial cost of initializing the opencl environment each time is heavy and this is slowing down the entire function call.
The program is (based on your example) :
And the result is :
My initial intention was to write a recurrent network as efficiently as possible. Do you think using Emu is a good choice ?