On Windows in VisualStudio 2019 when using af.lib only CUDA GPU shows up...

43 views
Skip to first unread message

vduva...@gmail.com

unread,
Oct 3, 2021, 4:40:37 PM10/3/21
to ArrayFire Users
Hi ArrayFire,

I was following your awesome setup instructions on https://arrayfire.org/docs/using_on_windows.htm#section3partC
for setting up ArrayFire with VisualStudio. I'm using VS2019. When I use afopencl.lib, then two targets show up on my laptop ( NVIDIA GPU, Intel GPU, but no Intel CPU). When I use afcpu.lib, then only Intel CPU shows up. When I use afcuda.lib, only NVIDIA GPU shows up. But, when I use af.lib only NVIDIA GPU shows up, instead of all three possible targets.

Is there a way to get all three targets to show up?

Is there a way to use mixed mode across targets at the same time in one executable - e.g. CUDA on NVIDIA GPU, and OpenCL on Intel GPU, and possibly OpenCL on Intel CPU?

Thank you,
-Victor

Pradeep Garigipati

unread,
Oct 4, 2021, 12:34:28 AM10/4/21
to vduva...@gmail.com, ArrayFire Users
Hello Vector,

Unified backend library i.e. libaf isn't intended to expose all possible devices in a single go. The current intended purpose of the unified library is to enable switching/choosing backends inside the user code instead of recompiling the application whenever the target backend changes.

Kindly go through this https://arrayfire.org/docs/unifiedbackend.htm tutorial if you haven't already done so. Hope that clears the confusion.

Regards,
Pradeep.

--
You received this message because you are subscribed to the Google Groups "ArrayFire Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arrayfire-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/arrayfire-users/46506086-1f7e-47ce-8ab4-335e560da8b0n%40googlegroups.com.


--

vduva...@gmail.com

unread,
Oct 4, 2021, 9:42:17 PM10/4/21
to ArrayFire Users
Hello Pradeep,

Thank you for such a quick and good answer. I have your example working and can switch backends.

However, I'm after a slightly different capability. I would like to choose a backend per device. For example, for the NVIDIA device I would like to select the CUDA backend, and for the Intel GPU device (also available in my system) I would like to select the OpenCL backend.  Is this possible to accomplish?

Thank you,
-Victor

Pradeep Garigipati

unread,
Oct 5, 2021, 2:41:23 AM10/5/21
to vduva...@gmail.com, ArrayFire Users
If you are trying to ascertain available devices per backend and switch if one backend doesn't have devices. You can do that using the unified backend specific API and the getDeviceCount function. For example, you can CUDA as your default backend, then call getDeviceCount to figure out if any devices are indeed available and switch to a different backend if there are none. You can also query device info when there are devices available to figure out the vendor.

On another note, if you want to use multiple backends in a single instance of your application simultaneously to make use of both devices, then I believe you have to set up the application using threads with one-to-one mapping from thread to "setBackend" call as we maintain per thread state of active backend. In this case, you have to call setDevice for the given backend's device on the corresponding device and data exchange between these threads can only happen via CPU. I personally have never tried this, so I wouldn't know if there are any pitfalls to this approach but I can say with certainty that graphics functionality wouldn't work.

Hope that helps.
Pradeep.



--
Reply all
Reply to author
Forward
0 new messages