Skip to content

Commit

Permalink
fix device selection
Browse files Browse the repository at this point in the history
  • Loading branch information
StRigaud committed Nov 20, 2024
1 parent dc4326e commit b547928
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions clic/src/openclbackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ OpenCLBackend::getDevice(const std::string & name, const std::string & type) con
{
#if USE_OPENCL
auto devices = getDevices(type);
if (devices.empty())
{
return device_list_.back();
}
if (!name.empty())
{
auto lower_case_name = to_lower(name);
Expand All @@ -193,8 +197,9 @@ OpenCLBackend::getDevice(const std::string & name, const std::string & type) con
}
if (!devices.empty())
{
return device_list_.back();
return devices.back();
}

std::cerr << "Warning: Fail to find any OpenCL compatible devices." << std::endl;
return nullptr;
#else
Expand All @@ -207,13 +212,17 @@ OpenCLBackend::getDeviceFromIndex(size_t index, const std::string & type) const
{
#if USE_OPENCL
auto devices = getDevices(type);
if (devices.empty())
{
return device_list_.back();
}
if (index < devices.size())
{
return devices[index];
}
if (!devices.empty())
{
return device_list_.back();
return devices.back();
}
std::cerr << "Warning: Fail to find any OpenCL compatible devices." << std::endl;
return nullptr;
Expand Down

0 comments on commit b547928

Please sign in to comment.