// Returns (hopefully) the discrete GPU in devices. If none are found, then the
// first GPU is returned.
cl::Device &OpenclImageProcessor::GetBestDevice() {
  if (devices_.size() == 0)
    throw std::out_of_range("No devices in devices vector.");

  // look for nvidia, amd, or ati. This may yield a false positive for
  // integrated amd GPUs, but it's better than the current solution.
  std::regex valid_device("(NVIDIA|AMD|ATI)", std::regex_constants::icase);
  for (auto &d : devices_) {
    if (std::regex_search(d.getInfo<CL_DEVICE_VENDOR>(), valid_device))
      return d;
  }

  return devices_[0];
}
示例#2
0
userport_device_list_t *userport_device_register(userport_device_t *device)
{
    userport_device_list_t *current = &userport_head;
    userport_device_list_t *retval = NULL;

    if (valid_device(device)) {
        retval = lib_malloc(sizeof(userport_device_list_t));

        while (current->next != NULL) {
            current = current->next;
        }
        current->next = retval;
        retval->previous = current;
        retval->device = device;
        retval->next = NULL;
        retval->device->order = order++;
    }

    return retval;
}