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
602f7af9
Commit
602f7af9
authored
Oct 01, 2014
by
Peter Eastman
Browse files
Enable OpenCL on OS X 10.10 and later
parent
ce5559f2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
22 deletions
+10
-22
CMakeLists.txt
CMakeLists.txt
+3
-3
platforms/opencl/src/OpenCLContext.cpp
platforms/opencl/src/OpenCLContext.cpp
+2
-5
platforms/opencl/src/OpenCLPlatform.cpp
platforms/opencl/src/OpenCLPlatform.cpp
+5
-7
platforms/opencl/src/OpenCLSort.cpp
platforms/opencl/src/OpenCLSort.cpp
+0
-1
platforms/opencl/src/kernels/sort.cl
platforms/opencl/src/kernels/sort.cl
+0
-6
No files found.
CMakeLists.txt
View file @
602f7af9
...
...
@@ -384,11 +384,11 @@ MARK_AS_ADVANCED(CUDA_BUILD_CUBIN)
MARK_AS_ADVANCED
(
CUDA_BUILD_EMULATION
)
FIND_PACKAGE
(
OpenCL QUIET
)
IF
(
OPENCL_FOUND
AND NOT APPLE
)
IF
(
OPENCL_FOUND
)
SET
(
OPENMM_BUILD_OPENCL_LIB ON CACHE BOOL
"Build OpenMMOpenCL library"
)
ELSE
(
OPENCL_FOUND
AND NOT APPLE
)
ELSE
(
OPENCL_FOUND
)
SET
(
OPENMM_BUILD_OPENCL_LIB OFF CACHE BOOL
"Build OpenMMOpenCL library"
)
ENDIF
(
OPENCL_FOUND
AND NOT APPLE
)
ENDIF
(
OPENCL_FOUND
)
IF
(
OPENMM_BUILD_OPENCL_LIB
)
ADD_SUBDIRECTORY
(
platforms/opencl
)
ENDIF
(
OPENMM_BUILD_OPENCL_LIB
)
...
...
platforms/opencl/src/OpenCLContext.cpp
View file @
602f7af9
...
...
@@ -106,9 +106,8 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
// 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_TYPE
>
()
==
CL_DEVICE_TYPE_CPU
||
devices
[
i
].
getInfo
<
CL_DEVICE_VENDOR
>
()
==
"AMD"
))
continue
;
// The CPU device on OS X won't work correctly, and there are serious bugs using AMD GPUs.
if
(
platformVendor
==
"Apple"
&&
(
devices
[
i
].
getInfo
<
CL_DEVICE_TYPE
>
()
==
CL_DEVICE_TYPE_CPU
))
continue
;
// The CPU device on OS X won't work correctly.
int
maxSize
=
devices
[
i
].
getInfo
<
CL_DEVICE_MAX_WORK_ITEM_SIZES
>
()[
0
];
int
processingElementsPerComputeUnit
=
8
;
if
(
devices
[
i
].
getInfo
<
CL_DEVICE_TYPE
>
()
!=
CL_DEVICE_TYPE_GPU
)
{
...
...
@@ -234,8 +233,6 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
}
else
simdWidth
=
1
;
if
(
platformVendor
==
"Apple"
&&
vendor
==
"AMD"
)
compilationDefines
[
"MAC_AMD_WORKAROUND"
]
=
""
;
if
(
supports64BitGlobalAtomics
)
compilationDefines
[
"SUPPORTS_64_BIT_ATOMICS"
]
=
""
;
if
(
supportsDoublePrecision
)
...
...
platforms/opencl/src/OpenCLPlatform.cpp
View file @
602f7af9
...
...
@@ -109,7 +109,7 @@ bool OpenCLPlatform::supportsDoublePrecision() const {
bool
OpenCLPlatform
::
isPlatformSupported
()
{
// Return false for OpenCL implementations that are known
// to be buggy (Apple OSX
since 10.7.5)
// to be buggy (Apple OS
X
prior to 10.10).
#ifdef __APPLE__
char
str
[
256
];
...
...
@@ -122,12 +122,10 @@ bool OpenCLPlatform::isPlatformSupported() {
if
(
sscanf
(
str
,
"%d.%d.%d"
,
&
major
,
&
minor
,
&
micro
)
!=
3
)
return
false
;
if
((
major
>
11
)
||
(
major
==
11
&&
minor
>
4
)
||
(
major
==
11
&&
minor
==
4
&&
micro
>=
2
))
// 11.4.2 is the darwin release corresponding to OSX 10.7.5, which is the
// point at which a number of serious bugs were introduced into the
// Apple OpenCL libraries, resulting in catistrophically incorrect MD simulations
// (see https://github.com/SimTk/openmm/issues/395 for example). Once a fix is released,
// this version check should be updated.
if
(
major
<
14
)
// 14.0.0 is the darwin release corresponding to OS X 10.10.0. Versions prior to that
// contained a number of serious bugs in the Apple OpenCL libraries.
// (See https://github.com/SimTk/openmm/issues/395 for example.)
return
false
;
#endif
...
...
platforms/opencl/src/OpenCLSort.cpp
View file @
602f7af9
...
...
@@ -42,7 +42,6 @@ OpenCLSort::OpenCLSort(OpenCLContext& context, SortTrait* trait, unsigned int le
replacements
[
"MIN_KEY"
]
=
trait
->
getMinKey
();
replacements
[
"MAX_KEY"
]
=
trait
->
getMaxKey
();
replacements
[
"MAX_VALUE"
]
=
trait
->
getMaxValue
();
replacements
[
"VALUE_IS_INT2"
]
=
(
trait
->
getDataType
()
==
std
::
string
(
"int2"
)
?
"1"
:
"0"
);
cl
::
Program
program
=
context
.
createProgram
(
context
.
replaceStrings
(
OpenCLKernelSources
::
sort
,
replacements
));
shortListKernel
=
cl
::
Kernel
(
program
,
"sortShortList"
);
computeRangeKernel
=
cl
::
Kernel
(
program
,
"computeRange"
);
...
...
platforms/opencl/src/kernels/sort.cl
View file @
602f7af9
...
...
@@ -103,13 +103,7 @@ __kernel void assignElementsToBuckets(__global const DATA_TYPE* restrict data, u
float
maxValue
=
(
float
)
(
range[1]
)
;
float
bucketWidth
=
(
maxValue-minValue
)
/numBuckets
;
for
(
uint
index
=
get_global_id
(
0
)
; index < length; index += get_global_size(0)) {
#
if
defined
(
MAC_AMD_WORKAROUND
)
&&
VALUE_IS_INT2
__global
int*
d
=
(
__global
int*
)
data
;
int2
element
=
(
int2
)
(
d[2*index],
d[2*index+1]
)
;
float
key
=
(
float
)
getValue
(
element
)
;
#
else
float
key
=
(
float
)
getValue
(
data[index]
)
;
#
endif
uint
bucketIndex
=
min
((
uint
)
((
key-minValue
)
/bucketWidth
)
,
numBuckets-1
)
;
offsetInBucket[index]
=
atom_inc
(
&bucketOffset[bucketIndex]
)
;
bucketOfElement[index]
=
bucketIndex
;
...
...
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