Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
ff555815
Unverified
Commit
ff555815
authored
Jan 30, 2020
by
peastman
Committed by
GitHub
Jan 30, 2020
Browse files
Merge pull request #2542 from peastman/cldevice
Catch exception when an OpenCL platform has no devices
parents
b7a4960f
06a2c7c8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
platforms/opencl/src/OpenCLContext.cpp
platforms/opencl/src/OpenCLContext.cpp
+7
-1
platforms/opencl/tests/TestOpenCLDeviceQuery.cpp
platforms/opencl/tests/TestOpenCLDeviceQuery.cpp
+7
-1
No files found.
platforms/opencl/src/OpenCLContext.cpp
View file @
ff555815
...
...
@@ -104,7 +104,13 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
string
platformVendor
=
platforms
[
j
].
getInfo
<
CL_PLATFORM_VENDOR
>
();
vector
<
cl
::
Device
>
devices
;
platforms
[
j
].
getDevices
(
CL_DEVICE_TYPE_ALL
,
&
devices
);
try
{
platforms
[
j
].
getDevices
(
CL_DEVICE_TYPE_ALL
,
&
devices
);
}
catch
(...)
{
// There are no devices available for this platform.
continue
;
}
if
(
deviceIndex
<
-
1
||
deviceIndex
>=
(
int
)
devices
.
size
())
throw
OpenMMException
(
"Illegal value for DeviceIndex: "
+
intToString
(
deviceIndex
));
...
...
platforms/opencl/tests/TestOpenCLDeviceQuery.cpp
View file @
ff555815
...
...
@@ -47,7 +47,13 @@ int main() {
for
(
int
j
=
0
;
j
<
platforms
.
size
();
j
++
)
{
vector
<
cl
::
Device
>
devices
;
platforms
[
j
].
getDevices
(
CL_DEVICE_TYPE_ALL
,
&
devices
);
try
{
platforms
[
j
].
getDevices
(
CL_DEVICE_TYPE_ALL
,
&
devices
);
}
catch
(...)
{
// There are no devices available for this platform.
continue
;
}
for
(
int
i
=
0
;
i
<
devices
.
size
();
i
++
)
{
cl
::
Device
d
=
devices
[
i
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment