Skip to content

Commit

Permalink
Merge pull request #401 from clEsperanto/update-test-and-device
Browse files Browse the repository at this point in the history
update pre-release
  • Loading branch information
StRigaud authored Nov 20, 2024
2 parents 93cc378 + a733d25 commit dfb9047
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 2 additions & 4 deletions clic/src/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ Array::~Array()
{
if (initialized())
{
if (data_.use_count() == 1 && get() != nullptr)
{
backend_.freeMemory(device(), mtype(), get());
}
backend_.freeMemory(device(), mtype(), get());
data_.reset();
initialized_ = false;
}
}

Expand Down
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 dfb9047

Please sign in to comment.