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
576eb902
Commit
576eb902
authored
Aug 22, 2013
by
Robert McGibbon
Browse files
initial commit on this idea
parent
193c8d97
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
14 deletions
+31
-14
platforms/opencl/src/OpenCLContext.cpp
platforms/opencl/src/OpenCLContext.cpp
+30
-13
platforms/opencl/src/OpenCLPlatform.cpp
platforms/opencl/src/OpenCLPlatform.cpp
+1
-1
No files found.
platforms/opencl/src/OpenCLContext.cpp
View file @
576eb902
...
...
@@ -88,17 +88,25 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
contextIndex
=
platformData
.
contexts
.
size
();
std
::
vector
<
cl
::
Platform
>
platforms
;
cl
::
Platform
::
get
(
&
platforms
);
if
(
platformIndex
<
0
||
platformIndex
>=
(
int
)
platforms
.
size
())
throw
OpenMMException
(
"Illegal value for OpenCL platform index"
);
string
platformVendor
=
platforms
[
platformIndex
].
getInfo
<
CL_PLATFORM_VENDOR
>
();
vector
<
cl
::
Device
>
devices
;
platforms
[
platformIndex
].
getDevices
(
CL_DEVICE_TYPE_ALL
,
&
devices
);
const
int
minThreadBlockSize
=
32
;
if
(
deviceIndex
<
0
||
deviceIndex
>=
(
int
)
devices
.
size
())
{
// Try to figure out which device is the fastest.
int
bestSpeed
=
-
1
;
int
bestSpeed
=
-
1
;
int
bestDevice
=
-
1
;
int
bestPlatform
=
-
1
;
for
(
j
=
0
;
i
<
platforms
.
size
();
j
++
)
{
// if they supplied a valid platformIndex, we only look through that platform
if
(
j
!=
plaformIndex
&&
platformIndex
>=
0
&&
platformIndex
<
(
int
)
platforms
.
size
())
continue
;
string
platformVendor
=
platforms
[
j
].
getInfo
<
CL_PLATFORM_VENDOR
>
();
vector
<
cl
::
Device
>
devices
;
platforms
[
j
].
getDevices
(
CL_DEVICE_TYPE_ALL
,
&
devices
);
const
int
minThreadBlockSize
=
32
;
for
(
int
i
=
0
;
i
<
(
int
)
devices
.
size
();
i
++
)
{
// if they supplied a valid deviceIndex, we only look through that one
if
(
i
!=
deviceIndex
&&
deviceIndex
>=
0
&&
deviceIndex
<
(
int
)
devices
.
size
())
continue
;
if
(
platformVendor
==
"Apple"
&&
devices
[
i
].
getInfo
<
CL_DEVICE_VENDOR
>
()
==
"AMD"
)
continue
;
// Don't use AMD GPUs on OS X due to serious bugs.
int
maxSize
=
devices
[
i
].
getInfo
<
CL_DEVICE_MAX_WORK_ITEM_SIZES
>
()[
0
];
...
...
@@ -137,15 +145,24 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
}
int
speed
=
devices
[
i
].
getInfo
<
CL_DEVICE_MAX_COMPUTE_UNITS
>
()
*
processingElementsPerComputeUnit
*
devices
[
i
].
getInfo
<
CL_DEVICE_MAX_CLOCK_FREQUENCY
>
();
if
(
maxSize
>=
minThreadBlockSize
&&
speed
>
bestSpeed
)
{
deviceIndex
=
i
;
bestDevice
=
i
;
bestSpeed
=
speed
;
bestPlatform
=
j
;
}
}
}
if
(
deviceIndex
==
-
1
)
if
(
bestPlatform
==
-
1
)
throw
OpenMMException
(
"No compatible OpenCL platform is available"
);
if
(
bestDevice
==
-
1
)
throw
OpenMMException
(
"No compatible OpenCL device is available"
);
device
=
devices
[
deviceIndex
];
this
->
deviceIndex
=
deviceIndex
;
vector
<
cl
::
Device
>
devices
;
platforms
[
bestPlatform
].
getDevices
(
CL_DEVICE_TYPE_ALL
,
&
devices
);
device
=
devices
[
bestDevice
];
this
->
deviceIndex
=
bestDevice
;
if
(
device
.
getInfo
<
CL_DEVICE_MAX_WORK_GROUP_SIZE
>
()
<
minThreadBlockSize
)
throw
OpenMMException
(
"The specified OpenCL device is not compatible with OpenMM"
);
compilationDefines
[
"WORK_GROUP_SIZE"
]
=
intToString
(
ThreadBlockSize
);
...
...
platforms/opencl/src/OpenCLPlatform.cpp
View file @
576eb902
...
...
@@ -133,7 +133,7 @@ void OpenCLPlatform::contextDestroyed(ContextImpl& context) const {
OpenCLPlatform
::
PlatformData
::
PlatformData
(
const
System
&
system
,
const
string
&
platformPropValue
,
const
string
&
deviceIndexProperty
,
const
string
&
precisionProperty
,
const
string
&
cpuPmeProperty
)
:
removeCM
(
false
),
stepCount
(
0
),
computeForceCount
(
0
),
time
(
0.0
)
{
int
platformIndex
=
0
;
int
platformIndex
=
-
1
;
if
(
platformPropValue
.
length
()
>
0
)
stringstream
(
platformPropValue
)
>>
platformIndex
;
vector
<
string
>
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