mira_SetDevice
Sets the computational device to use.
int mira_SetDevice(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:
MIRA_OK (0) or an error code.
Description:
mira_SetDevice will set the specified device as computational device, it requires that the devices have been scanned 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));
- int deviceInd = 0;
- MIRAACQ_CHECK(mira_SetDevice(pmr, deviceInd));
- printf("Device opened: %d '%s'\n", deviceInd, mira_GetDeviceName(pmr, deviceInd));
- Error:
- if (res != MIRA_OK) {
- printf("Error %d: %s", mira_GetErrorCode(pmr), mira_GetErrorMsg(pmr));
- }
Output:
Device selected: 1 'CUDA: NVIDIA RTX A2000 12GB, 12032 MB, CUDA Compute 8.6'