mira_GetDeviceName
Returns the name of an available computational device.
const char* mira_GetDeviceName(mrkernel* pmr, int deviceInd);
Parameters:
- pmr: A pointer to the runtime kernel returned by mira_Init.
- deviceInd: Device index to get the name from, must be less than mira_GetDeviceCount.
Return value:
The name of the device as string or NULL if there was an error.
Description:
mira_GetDeviceName will return the name of an available computational device, it requires that the devices have been refreshed using mira_RefreshDeviceList.
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