arrayfire / arrayfire-rust

Rust wrapper for ArrayFire
BSD 3-Clause "New" or "Revised" License
810 stars 58 forks source link

Multi GPU Support #366

Closed nickmachnik closed 1 year ago

nickmachnik commented 1 year ago

Description

Dear Devs, thanks for the crate, I find it immensely useful!

I was wondering if there is any way to split work among multiple GPUs through the Rust API? I cannot to find any examples or documentation on this, Without having tried it myself, it seems like this is possible through the c++ API, see @9prady9 's gist here or this post on the official AF blog.

9prady9 commented 1 year ago

@nickmachnik Thank you for using the crate.

The C++ example should be easily translatable to rust. Except few API differences like where becoming locate in rust, the library itself doesn't change it's capabilities across languages. 99% of API calls are async, you can write a loop shown in the gist in rust too. You have to call set_device in each thread to make sure the compute backend's thread context is properly initialized. You can see that I am doing that in C++ example here. In rust equivalent call is arrayfire::set_device.

nickmachnik commented 1 year ago

Cool, thanks for the pointers, will give this a go!