| 226 | } |
| 227 | |
| 228 | af_err af_set_device(const int device) { |
| 229 | try { |
| 230 | ARG_ASSERT(0, device >= 0); |
| 231 | if (setDevice(device) < 0) { |
| 232 | int ndevices = getDeviceCount(); |
| 233 | if (ndevices == 0) { |
| 234 | AF_ERROR( |
| 235 | "No devices were found on this system. Ensure " |
| 236 | "you have installed the device driver as well as the " |
| 237 | "necessary runtime libraries for your platform.", |
| 238 | AF_ERR_RUNTIME); |
| 239 | } else { |
| 240 | char buf[512]; |
| 241 | char err_msg[] = |
| 242 | "The device index of %d is out of range. Use a value " |
| 243 | "between 0 and %d."; |
| 244 | snprintf(buf, 512, err_msg, device, ndevices - 1); // NOLINT |
| 245 | AF_ERROR(buf, AF_ERR_ARG); |
| 246 | } |
| 247 | } |
| 248 | } |
| 249 | CATCHALL; |
| 250 | |
| 251 | return AF_SUCCESS; |
| 252 | } |
| 253 | |
| 254 | af_err af_sync(const int device) { |
| 255 | try { |
no test coverage detected