Returns the number of available computational devices.


int mira_GetDeviceCount(mrkernelpmr);


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.


  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