mira_GetDeviceCount
Returns the number of available computational devices.
int mira_GetDeviceCount(mrkernel* pmr);
Parameters:
- pmr: A pointer to the runtime kernel returned by mira_Init.
Return value:
The number of available computational devices found if the value (>= 0) or an error code (< 0).
Description:
mira_GetDeviceCount will return the number of available devices found by mira_RefreshDeviceList. The name of each available device can be retrieved using mira_GetDeviceName.
Example:
Note the MIRA_CHECK macro, which will check if the return value was MIRA_OK (0) or an error code. In case of an error code, it will jump to a label called Error.
- MIRA_CHECK(mira_RefreshDeviceList(pmr, 1, 0));
- const int deviceCount = mira_GetDeviceCount(pmr);
- printf("%d devices:\n", deviceCount);
- for (int i = 0; i < deviceCount; i++) {
- printf(" %d : %s\n", i, mira_GetDeviceName(pmr, i));
- }
- Error:
- if (res != MIRA_OK) {
- printf("Error %d: %s", mira_GetErrorCode(pmr), mira_GetErrorMsg(pmr));
- }
Output:
2 devices:
0 : CPU: Intel: 13th Gen Intel(R) Core(TM) i7-13700
1 : CUDA: NVIDIA RTX A2000 12GB, 12032 MB, CUDA Compute 8.6