Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selecting OpenCL device? #24

Open
fmckeogh opened this issue Oct 18, 2019 · 1 comment
Open

Selecting OpenCL device? #24

fmckeogh opened this issue Oct 18, 2019 · 1 comment

Comments

@fmckeogh
Copy link

Hello!

Is there currently any way to manually list and select the OpenCL device?

Thanks! :)

@calebwin
Copy link
Owner

calebwin commented Oct 19, 2019

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
}

@calebwin calebwin reopened this Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants