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.