mira_RefreshDeviceList
Refreshes the computational device list.
int mira_RefreshDeviceList(mrkernel* pmr, int listNVIDIA, int listOpenCL);
Parameters:
- pmr: A pointer to the runtime kernel returned by mira_Init.
- listNVIDIA: 1 to enable scanning for NVIDIA CUDA devices, 0 to skip.
- listOpenCL: 1 to enable scanning for OpenCL devices, 0 to skip.
Return value:
MIRA_OK (0) or an error code.
Description:
mira_RefreshDeviceList will search for available computational devices on the computer, like CPU, OpenCL, or CUDA. After this function it will be possible to get the number of available devices using mira_GetDeviceCount, get their names using mira_GetDeviceName, and set the one to use using mira_SetDevice.
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