Skip to content

Commit a0a0a33

Browse files
committed
Fixed unit tests on computers where the first OpenCL platforms' device list is empty because it has no associated GPU devices.
All platforms with no associated devices are now deleted from the platforms vector before commencing the unit tests. Furthermore the test now throws an exception if the list of platforms is empty.
1 parent 95b4e28 commit a0a0a33

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

UnitTest/clw_test.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@ class CLW : public ::testing::Test
4747
// Create all available platforms
4848
CLWPlatform::CreateAllPlatforms(platforms);
4949

50+
// Remove platforms that don't have any associated devices
51+
for (auto it = platforms.begin(); it != platforms.end();)
52+
{
53+
if (it->GetDeviceCount() == 0)
54+
{
55+
it = platforms.erase(it);
56+
}
57+
else
58+
{
59+
++it;
60+
}
61+
}
62+
63+
ThrowIf(platforms.empty(), CL_DEVICE_NOT_FOUND, "CLW::SetUp failed => no available OpenCL platforms with at least 1 device!");
64+
5065
// Try to find AMD platform and set a flag if found
5166
bool amdctx_ = false;
5267
for (int i = 0; i < platforms.size(); ++i)

0 commit comments

Comments
 (0)