Returns the name of an available computational device.


const char* mira_GetDeviceName(mrkernelpmr, 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.


  1. MIRA_CHECK(mira_RefreshDeviceList(pmr, 1, 0));

  2. const int deviceCount = mira_GetDeviceCount(pmr);
  3. printf("%d devices:\n", deviceCount);
  4. for (int i = 0; i < deviceCount; i++) {
  5.     printf(" %d : %s\n", imira_GetDeviceName(pmr, i));
  6. }

  7. Error:
  8. if (res != MIRA_OK) {
  9.     printf("Error %d: %s", mira_GetErrorCode(pmr), mira_GetErrorMsg(pmr));
  10. }


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