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
fb68776e
"...ssh:/git@developer.sourcefind.cn:2222/tsoc/openmm.git" did not exist on "3654b7885a07c27deca4efa23ac48bf7d30cd560"
Commit
fb68776e
authored
Jul 13, 2020
by
peastman
Browse files
Added check for unsupported OpenCL implementation
parent
ac5a8f71
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
platforms/opencl/src/OpenCLContext.cpp
platforms/opencl/src/OpenCLContext.cpp
+17
-0
No files found.
platforms/opencl/src/OpenCLContext.cpp
View file @
fb68776e
...
@@ -69,6 +69,14 @@ static void CL_CALLBACK errorCallback(const char* errinfo, const void* private_i
...
@@ -69,6 +69,14 @@ static void CL_CALLBACK errorCallback(const char* errinfo, const void* private_i
std
::
cerr
<<
"OpenCL internal error: "
<<
errinfo
<<
std
::
endl
;
std
::
cerr
<<
"OpenCL internal error: "
<<
errinfo
<<
std
::
endl
;
}
}
static
bool
isSupported
(
cl
::
Platform
platform
)
{
string
vendor
=
platform
.
getInfo
<
CL_PLATFORM_VENDOR
>
();
return
(
vendor
.
find
(
"NVIDIA"
)
==
0
||
vendor
.
find
(
"Advanced Micro Devices"
)
==
0
||
vendor
.
find
(
"Apple"
)
==
0
||
vendor
.
find
(
"Intel"
)
==
0
);
}
OpenCLContext
::
OpenCLContext
(
const
System
&
system
,
int
platformIndex
,
int
deviceIndex
,
const
string
&
precision
,
OpenCLPlatform
::
PlatformData
&
platformData
,
OpenCLContext
*
originalContext
)
:
OpenCLContext
::
OpenCLContext
(
const
System
&
system
,
int
platformIndex
,
int
deviceIndex
,
const
string
&
precision
,
OpenCLPlatform
::
PlatformData
&
platformData
,
OpenCLContext
*
originalContext
)
:
ComputeContext
(
system
),
platformData
(
platformData
),
numForceBuffers
(
0
),
hasAssignedPosqCharges
(
false
),
ComputeContext
(
system
),
platformData
(
platformData
),
numForceBuffers
(
0
),
hasAssignedPosqCharges
(
false
),
integration
(
NULL
),
expression
(
NULL
),
bonded
(
NULL
),
nonbonded
(
NULL
)
{
integration
(
NULL
),
expression
(
NULL
),
bonded
(
NULL
),
nonbonded
(
NULL
)
{
...
@@ -99,11 +107,16 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
...
@@ -99,11 +107,16 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
int
bestSpeed
=
-
1
;
int
bestSpeed
=
-
1
;
int
bestDevice
=
-
1
;
int
bestDevice
=
-
1
;
int
bestPlatform
=
-
1
;
int
bestPlatform
=
-
1
;
bool
bestSupported
=
false
;
for
(
int
j
=
0
;
j
<
platforms
.
size
();
j
++
)
{
for
(
int
j
=
0
;
j
<
platforms
.
size
();
j
++
)
{
// If they supplied a valid platformIndex, we only look through that platform
// If they supplied a valid platformIndex, we only look through that platform
if
(
j
!=
platformIndex
&&
platformIndex
!=
-
1
)
if
(
j
!=
platformIndex
&&
platformIndex
!=
-
1
)
continue
;
continue
;
// Always prefer a supported platform over an unsupported one.
bool
supported
=
isSupported
(
platforms
[
j
]);
if
(
!
supported
&&
bestSupported
)
continue
;
string
platformVendor
=
platforms
[
j
].
getInfo
<
CL_PLATFORM_VENDOR
>
();
string
platformVendor
=
platforms
[
j
].
getInfo
<
CL_PLATFORM_VENDOR
>
();
vector
<
cl
::
Device
>
devices
;
vector
<
cl
::
Device
>
devices
;
try
{
try
{
...
@@ -164,6 +177,7 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
...
@@ -164,6 +177,7 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
bestDevice
=
i
;
bestDevice
=
i
;
bestSpeed
=
speed
;
bestSpeed
=
speed
;
bestPlatform
=
j
;
bestPlatform
=
j
;
bestSupported
=
supported
;
}
}
}
}
}
}
...
@@ -173,6 +187,9 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
...
@@ -173,6 +187,9 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
if
(
bestDevice
==
-
1
)
if
(
bestDevice
==
-
1
)
throw
OpenMMException
(
"No compatible OpenCL device is available"
);
throw
OpenMMException
(
"No compatible OpenCL device is available"
);
if
(
!
bestSupported
)
cout
<<
"WARNING: Using an unsupported OpenCL implementation. Results may be incorrect."
<<
endl
;
vector
<
cl
::
Device
>
devices
;
vector
<
cl
::
Device
>
devices
;
platforms
[
bestPlatform
].
getDevices
(
CL_DEVICE_TYPE_ALL
,
&
devices
);
platforms
[
bestPlatform
].
getDevices
(
CL_DEVICE_TYPE_ALL
,
&
devices
);
...
...
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