Selecting OpenCL device?
Opened this issue · 1 comments
fmckeogh commented
Hello!
Is there currently any way to manually list and select the OpenCL device?
Thanks! :)
calebwin commented
Hi!
This is not possible at the moment, unfortunately. I recently open-sourced a new version of Emu (not yet published to Crates.io) with significant changes to improve robustness, ease-of-use, and performance. This new version, too, at the moment will use the first device found.
I believe single-GPU, single-threaded is a good default but here is an idea I have for allowing selection, concurrency-
#[gpu_use]
fn main() {
let mut data = vec![0.0; 1000];
gpu_do!(load(data));
gpu_do!(launch());
for i in 0..1000 {
data[i] = data[i] + 0.1;
}
gpu_do!(read(data));
}
#[gpu_use("nvidia", "nvidia")] // initialize first 2 devices with names containing substring "nvidia"
fn main() {
let mut a = vec![0.0; 1000];
let mut b = vec![0.0; 1000];
let mut c = vec![0.0; 1000];
gpu_do!(open(1)); // specify that 2nd in initialized list should be used; if not specified, default is 1st in initialized list to be used
gpu_do!(load_async(a));
gpu_do!(load_async(b));
gpu_do!(load_async(c)); // all of a, b, c can be loaded asynchronously
gpu_do!(await()); // wait for all loading to finish
gpu_do!(launch()); // this could also be launch_async if we wanted to do something while running on GPU
for i in 0..1000 {
c[i] = a[i] + b[i];
}
gpu_do!(read_async(data)); // reading can be async while we do some computation until we actually need the data
}