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

Implementing multiple GPU support?

Open edude03 opened this issue 10 years ago • 1 comments

I'm trying to write some quick example code using rust + opencl, I'm pretty new to rust but when I run

let (device, ctx, queue) = opencl::util::create_compute_context_prefer(opencl::util::PreferedType::GPUPrefered).unwrap();
let (device1, ctx1, queue1) = opencl::util::create_compute_context_prefer(opencl::util::PreferedType::GPUPrefered).unwrap();

println!("{}", device.name()); //GT120
println!("{}", device1.name()); //GT120

Both of my device names are "Geforce GT120". In my PC however I have a GT120 in addition to a Radeon 7970.

Looking at the code I see that multiple devices are a TODO, what needs to be done to implement this?

edude03 avatar Dec 23 '14 16:12 edude03

opencl::util::create_compute_context_prefer just selects the first GPU and platform that match its requirement. You will probably want to manually select the GPU you want. Since you have both a GT120 and a Radeon 7970 you can't actually use both with the same OpenCL context. But you should be able to select the OpenCL device you want. You will just have to do it manually.

If you look at https://github.com/luqmana/rust-opencl/blob/master/tests/test.rs#L22 shows you how to create a context for every possible compute device connected to your system. We use this for testing, but you should be able to modify it to select the Radeon 7970.

ghost avatar Dec 23 '14 19:12 ghost