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
2e9c418a
Commit
2e9c418a
authored
May 05, 2016
by
peastman
Browse files
Merge branch 'master' into gayberne
parents
8f532e31
a4d327f5
Changes
254
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
189 additions
and
48 deletions
+189
-48
platforms/cuda/tests/TestCudaFFT3D.cpp
platforms/cuda/tests/TestCudaFFT3D.cpp
+1
-1
platforms/cuda/tests/TestCudaNonbondedForce.cpp
platforms/cuda/tests/TestCudaNonbondedForce.cpp
+35
-0
platforms/cuda/tests/TestCudaRandom.cpp
platforms/cuda/tests/TestCudaRandom.cpp
+1
-1
platforms/cuda/tests/TestCudaSort.cpp
platforms/cuda/tests/TestCudaSort.cpp
+1
-1
platforms/opencl/include/OpenCLKernels.h
platforms/opencl/include/OpenCLKernels.h
+2
-2
platforms/opencl/include/OpenCLPlatform.h
platforms/opencl/include/OpenCLPlatform.h
+5
-5
platforms/opencl/src/OpenCLContext.cpp
platforms/opencl/src/OpenCLContext.cpp
+8
-3
platforms/opencl/src/OpenCLExpressionUtilities.cpp
platforms/opencl/src/OpenCLExpressionUtilities.cpp
+3
-3
platforms/opencl/src/OpenCLKernels.cpp
platforms/opencl/src/OpenCLKernels.cpp
+59
-22
platforms/opencl/src/OpenCLPlatform.cpp
platforms/opencl/src/OpenCLPlatform.cpp
+9
-1
platforms/opencl/src/kernels/angleForce.cl
platforms/opencl/src/kernels/angleForce.cl
+4
-0
platforms/opencl/src/kernels/bondForce.cl
platforms/opencl/src/kernels/bondForce.cl
+3
-0
platforms/opencl/src/kernels/cmapTorsionForce.cl
platforms/opencl/src/kernels/cmapTorsionForce.cl
+10
-0
platforms/opencl/src/kernels/customCentroidBond.cl
platforms/opencl/src/kernels/customCentroidBond.cl
+5
-2
platforms/opencl/src/kernels/customCompoundBond.cl
platforms/opencl/src/kernels/customCompoundBond.cl
+4
-1
platforms/opencl/src/kernels/customManyParticle.cl
platforms/opencl/src/kernels/customManyParticle.cl
+6
-3
platforms/opencl/src/kernels/torsionForce.cl
platforms/opencl/src/kernels/torsionForce.cl
+5
-0
platforms/opencl/tests/OpenCLTests.h
platforms/opencl/tests/OpenCLTests.h
+3
-3
platforms/reference/include/ReferenceAngleBondIxn.h
platforms/reference/include/ReferenceAngleBondIxn.h
+13
-0
platforms/reference/include/ReferenceCMAPTorsionIxn.h
platforms/reference/include/ReferenceCMAPTorsionIxn.h
+12
-0
No files found.
platforms/cuda/tests/TestCudaFFT3D.cpp
View file @
2e9c418a
...
...
@@ -56,7 +56,7 @@ void testTransform(bool realToComplex, int xsize, int ysize, int zsize) {
system
.
addParticle
(
0.0
);
CudaPlatform
::
PlatformData
platformData
(
NULL
,
system
,
""
,
"true"
,
platform
.
getPropertyDefaultValue
(
"CudaPrecision"
),
"false"
,
platform
.
getPropertyDefaultValue
(
CudaPlatform
::
CudaCompiler
()),
platform
.
getPropertyDefaultValue
(
CudaPlatform
::
CudaTempDirectory
()),
platform
.
getPropertyDefaultValue
(
CudaPlatform
::
CudaHostCompiler
()),
platform
.
getPropertyDefaultValue
(
CudaPlatform
::
CudaDisablePmeStream
()),
1
);
platform
.
getPropertyDefaultValue
(
CudaPlatform
::
CudaHostCompiler
()),
platform
.
getPropertyDefaultValue
(
CudaPlatform
::
CudaDisablePmeStream
()),
"false"
,
1
);
CudaContext
&
context
=
*
platformData
.
contexts
[
0
];
context
.
initialize
();
OpenMM_SFMT
::
SFMT
sfmt
;
...
...
platforms/cuda/tests/TestCudaNonbondedForce.cpp
View file @
2e9c418a
...
...
@@ -118,9 +118,44 @@ void testReordering() {
}
}
void
testDeterministicForces
()
{
// Check that the CudaDeterministicForces property works correctly.
const
int
numParticles
=
1000
;
System
system
;
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
6
,
0
,
0
),
Vec3
(
2.1
,
6
,
0
),
Vec3
(
-
1.5
,
-
0.5
,
6
));
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
PME
);
system
.
addForce
(
nonbonded
);
vector
<
Vec3
>
positions
;
OpenMM_SFMT
::
SFMT
sfmt
;
init_gen_rand
(
0
,
sfmt
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
system
.
addParticle
(
1.0
);
nonbonded
->
addParticle
(
i
%
2
==
0
?
1
:
-
1
,
1
,
0
);
positions
.
push_back
(
Vec3
(
genrand_real2
(
sfmt
)
-
0.5
,
genrand_real2
(
sfmt
)
-
0.5
,
genrand_real2
(
sfmt
)
-
0.5
)
*
6
);
}
VerletIntegrator
integrator
(
0.001
);
map
<
string
,
string
>
properties
;
properties
[
CudaPlatform
::
CudaDeterministicForces
()]
=
"true"
;
Context
context
(
system
,
integrator
,
platform
,
properties
);
context
.
setPositions
(
positions
);
State
state1
=
context
.
getState
(
State
::
Forces
);
State
state2
=
context
.
getState
(
State
::
Forces
);
// All forces should be *exactly* equal.
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
ASSERT_EQUAL
(
state1
.
getForces
()[
i
][
0
],
state2
.
getForces
()[
i
][
0
]);
ASSERT_EQUAL
(
state1
.
getForces
()[
i
][
1
],
state2
.
getForces
()[
i
][
1
]);
ASSERT_EQUAL
(
state1
.
getForces
()[
i
][
2
],
state2
.
getForces
()[
i
][
2
]);
}
}
void
runPlatformTests
()
{
testParallelComputation
(
NonbondedForce
::
NoCutoff
);
testParallelComputation
(
NonbondedForce
::
Ewald
);
testParallelComputation
(
NonbondedForce
::
PME
);
testReordering
();
testDeterministicForces
();
}
platforms/cuda/tests/TestCudaRandom.cpp
View file @
2e9c418a
...
...
@@ -56,7 +56,7 @@ void testGaussian() {
system
.
addParticle
(
1.0
);
CudaPlatform
::
PlatformData
platformData
(
NULL
,
system
,
""
,
"true"
,
platform
.
getPropertyDefaultValue
(
"CudaPrecision"
),
"false"
,
platform
.
getPropertyDefaultValue
(
CudaPlatform
::
CudaCompiler
()),
platform
.
getPropertyDefaultValue
(
CudaPlatform
::
CudaTempDirectory
()),
platform
.
getPropertyDefaultValue
(
CudaPlatform
::
CudaHostCompiler
()),
platform
.
getPropertyDefaultValue
(
CudaPlatform
::
CudaDisablePmeStream
()),
1
);
platform
.
getPropertyDefaultValue
(
CudaPlatform
::
CudaHostCompiler
()),
platform
.
getPropertyDefaultValue
(
CudaPlatform
::
CudaDisablePmeStream
()),
"false"
,
1
);
CudaContext
&
context
=
*
platformData
.
contexts
[
0
];
context
.
initialize
();
context
.
getIntegrationUtilities
().
initRandomNumberGenerator
(
0
);
...
...
platforms/cuda/tests/TestCudaSort.cpp
View file @
2e9c418a
...
...
@@ -66,7 +66,7 @@ void verifySorting(vector<float> array) {
system
.
addParticle
(
0.0
);
CudaPlatform
::
PlatformData
platformData
(
NULL
,
system
,
""
,
"true"
,
platform
.
getPropertyDefaultValue
(
"CudaPrecision"
),
"false"
,
platform
.
getPropertyDefaultValue
(
CudaPlatform
::
CudaCompiler
()),
platform
.
getPropertyDefaultValue
(
CudaPlatform
::
CudaTempDirectory
()),
platform
.
getPropertyDefaultValue
(
CudaPlatform
::
CudaHostCompiler
()),
platform
.
getPropertyDefaultValue
(
CudaPlatform
::
CudaDisablePmeStream
()),
1
);
platform
.
getPropertyDefaultValue
(
CudaPlatform
::
CudaHostCompiler
()),
platform
.
getPropertyDefaultValue
(
CudaPlatform
::
CudaDisablePmeStream
()),
"false"
,
1
);
CudaContext
&
context
=
*
platformData
.
contexts
[
0
];
context
.
initialize
();
CudaArray
data
(
context
,
array
.
size
(),
4
,
"sortData"
);
...
...
platforms/opencl/include/OpenCLKernels.h
View file @
2e9c418a
...
...
@@ -156,7 +156,7 @@ public:
* @param b the vector defining the second edge of the periodic box
* @param c the vector defining the third edge of the periodic box
*/
void
setPeriodicBoxVectors
(
ContextImpl
&
context
,
const
Vec3
&
a
,
const
Vec3
&
b
,
const
Vec3
&
c
)
const
;
void
setPeriodicBoxVectors
(
ContextImpl
&
context
,
const
Vec3
&
a
,
const
Vec3
&
b
,
const
Vec3
&
c
);
/**
* Create a checkpoint recording the current state of the Context.
*
...
...
@@ -698,7 +698,7 @@ public:
*/
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomNonbondedForce
&
force
);
private:
void
initInteractionGroups
(
const
CustomNonbondedForce
&
force
,
const
std
::
string
&
interactionSource
);
void
initInteractionGroups
(
const
CustomNonbondedForce
&
force
,
const
std
::
string
&
interactionSource
,
const
std
::
vector
<
std
::
string
>&
tableTypes
);
OpenCLContext
&
cl
;
OpenCLParameterSet
*
params
;
OpenCLArray
*
globals
;
...
...
platforms/opencl/include/OpenCLPlatform.h
View file @
2e9c418a
...
...
@@ -58,14 +58,14 @@ public:
* This is the name of the parameter for selecting which OpenCL device or devices to use.
*/
static
const
std
::
string
&
OpenCLDeviceIndex
()
{
static
const
std
::
string
key
=
"
OpenCL
DeviceIndex"
;
static
const
std
::
string
key
=
"DeviceIndex"
;
return
key
;
}
/**
* This is the name of the parameter that reports the OpenCL device or devices being used.
*/
static
const
std
::
string
&
OpenCLDeviceName
()
{
static
const
std
::
string
key
=
"
OpenCL
DeviceName"
;
static
const
std
::
string
key
=
"DeviceName"
;
return
key
;
}
/**
...
...
@@ -86,21 +86,21 @@ public:
* This is the name of the parameter for selecting what numerical precision to use.
*/
static
const
std
::
string
&
OpenCLPrecision
()
{
static
const
std
::
string
key
=
"
OpenCL
Precision"
;
static
const
std
::
string
key
=
"Precision"
;
return
key
;
}
/**
* This is the name of the parameter for selecting whether to use the CPU based PME calculation.
*/
static
const
std
::
string
&
OpenCLUseCpuPme
()
{
static
const
std
::
string
key
=
"
OpenCL
UseCpuPme"
;
static
const
std
::
string
key
=
"UseCpuPme"
;
return
key
;
}
/**
* This is the name of the parameter for selecting whether to disable use of a separate stream for PME.
*/
static
const
std
::
string
&
OpenCLDisablePmeStream
()
{
static
const
std
::
string
key
=
"
OpenCL
DisablePmeStream"
;
static
const
std
::
string
key
=
"DisablePmeStream"
;
return
key
;
}
};
...
...
platforms/opencl/src/OpenCLContext.cpp
View file @
2e9c418a
...
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2009-201
5
Stanford University and the Authors. *
* Portions copyright (c) 2009-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -84,7 +84,7 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
useMixedPrecision
=
false
;
}
else
throw
OpenMMException
(
"Illegal value for
OpenCL
Precision: "
+
precision
);
throw
OpenMMException
(
"Illegal value for Precision: "
+
precision
);
try
{
contextIndex
=
platformData
.
contexts
.
size
();
std
::
vector
<
cl
::
Platform
>
platforms
;
...
...
@@ -105,7 +105,7 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
vector
<
cl
::
Device
>
devices
;
platforms
[
j
].
getDevices
(
CL_DEVICE_TYPE_ALL
,
&
devices
);
if
(
deviceIndex
<
-
1
||
deviceIndex
>=
(
int
)
devices
.
size
())
throw
OpenMMException
(
"Illegal value for
OpenCL
DeviceIndex: "
+
intToString
(
deviceIndex
));
throw
OpenMMException
(
"Illegal value for DeviceIndex: "
+
intToString
(
deviceIndex
));
for
(
int
i
=
0
;
i
<
(
int
)
devices
.
size
();
i
++
)
{
// If they supplied a valid deviceIndex, we only look through that one
...
...
@@ -113,6 +113,11 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
continue
;
if
(
platformVendor
==
"Apple"
&&
(
devices
[
i
].
getInfo
<
CL_DEVICE_TYPE
>
()
==
CL_DEVICE_TYPE_CPU
))
continue
;
// The CPU device on OS X won't work correctly.
if
(
useMixedPrecision
||
useDoublePrecision
)
{
bool
supportsDouble
=
(
devices
[
i
].
getInfo
<
CL_DEVICE_EXTENSIONS
>
().
find
(
"cl_khr_fp64"
)
!=
string
::
npos
);
if
(
!
supportsDouble
)
continue
;
// This device does not support double precision.
}
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
)
{
...
...
platforms/opencl/src/OpenCLExpressionUtilities.cpp
View file @
2e9c418a
...
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2009-201
5
Stanford University and the Authors. *
* Portions copyright (c) 2009-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -254,7 +254,7 @@ void OpenCLExpressionUtilities::processExpression(stringstream& out, const Expre
for
(
int
k
=
3
;
k
>=
0
;
k
--
)
for
(
int
m
=
0
;
m
<
4
;
m
++
)
{
int
base
=
4
*
m
;
string
suffix
=
suffixes
[
m
];
string
suffix
=
suffixes
[
k
];
out
<<
"derivy["
<<
m
<<
"] = da*derivy["
<<
m
<<
"] + (3*c["
<<
(
base
+
3
)
<<
"]"
<<
suffix
<<
"*db + 2*c["
<<
(
base
+
2
)
<<
"]"
<<
suffix
<<
")*db + c["
<<
(
base
+
1
)
<<
"]"
<<
suffix
<<
";
\n
"
;
}
out
<<
nodeNames
[
j
]
<<
" = derivy[0] + dc*(derivy[1] + dc*(derivy[2] + dc*derivy[3]));
\n
"
;
...
...
@@ -271,7 +271,7 @@ void OpenCLExpressionUtilities::processExpression(stringstream& out, const Expre
out
<<
nodeNames
[
j
]
<<
" *= "
<<
paramsFloat
[
11
]
<<
";
\n
"
;
}
else
throw
OpenMMException
(
"Unsupported derivative order for Continuous
2
DFunction"
);
throw
OpenMMException
(
"Unsupported derivative order for Continuous
3
DFunction"
);
}
out
<<
"}
\n
"
;
}
...
...
platforms/opencl/src/OpenCLKernels.cpp
View file @
2e9c418a
...
...
@@ -369,10 +369,27 @@ void OpenCLUpdateStateDataKernel::getPeriodicBoxVectors(ContextImpl& context, Ve
cl
.
getPeriodicBoxVectors
(
a
,
b
,
c
);
}
void
OpenCLUpdateStateDataKernel
::
setPeriodicBoxVectors
(
ContextImpl
&
context
,
const
Vec3
&
a
,
const
Vec3
&
b
,
const
Vec3
&
c
)
const
{
void
OpenCLUpdateStateDataKernel
::
setPeriodicBoxVectors
(
ContextImpl
&
context
,
const
Vec3
&
a
,
const
Vec3
&
b
,
const
Vec3
&
c
)
{
vector
<
OpenCLContext
*>&
contexts
=
cl
.
getPlatformData
().
contexts
;
// If any particles have been wrapped to the first periodic box, we need to unwrap them
// to avoid changing their positions.
vector
<
Vec3
>
positions
;
for
(
int
i
=
0
;
i
<
(
int
)
cl
.
getPosCellOffsets
().
size
();
i
++
)
{
mm_int4
&
offset
=
cl
.
getPosCellOffsets
()[
i
];
if
(
offset
.
x
!=
0
||
offset
.
y
!=
0
||
offset
.
z
!=
0
)
{
getPositions
(
context
,
positions
);
break
;
}
}
// Update the vectors.
for
(
int
i
=
0
;
i
<
(
int
)
contexts
.
size
();
i
++
)
contexts
[
i
]
->
setPeriodicBoxVectors
(
a
,
b
,
c
);
if
(
positions
.
size
()
>
0
)
setPositions
(
context
,
positions
);
}
void
OpenCLUpdateStateDataKernel
::
createCheckpoint
(
ContextImpl
&
context
,
ostream
&
stream
)
{
...
...
@@ -527,6 +544,7 @@ void OpenCLCalcHarmonicBondForceKernel::initialize(const System& system, const H
}
params
->
upload
(
paramVector
);
map
<
string
,
string
>
replacements
;
replacements
[
"APPLY_PERIODIC"
]
=
(
force
.
usesPeriodicBoundaryConditions
()
?
"1"
:
"0"
);
replacements
[
"COMPUTE_FORCE"
]
=
OpenCLKernelSources
::
harmonicBondForce
;
replacements
[
"PARAMS"
]
=
cl
.
getBondedUtilities
().
addArgument
(
params
->
getDeviceBuffer
(),
"float2"
);
cl
.
getBondedUtilities
().
addInteraction
(
atoms
,
cl
.
replaceStrings
(
OpenCLKernelSources
::
bondForce
,
replacements
),
force
.
getForceGroup
());
...
...
@@ -660,6 +678,7 @@ void OpenCLCalcCustomBondForceKernel::initialize(const System& system, const Cus
vector
<
pair
<
string
,
string
>
>
functionNames
;
compute
<<
cl
.
getExpressionUtilities
().
createExpressions
(
expressions
,
variables
,
functions
,
functionNames
,
"temp"
);
map
<
string
,
string
>
replacements
;
replacements
[
"APPLY_PERIODIC"
]
=
(
force
.
usesPeriodicBoundaryConditions
()
?
"1"
:
"0"
);
replacements
[
"COMPUTE_FORCE"
]
=
compute
.
str
();
cl
.
getBondedUtilities
().
addInteraction
(
atoms
,
cl
.
replaceStrings
(
OpenCLKernelSources
::
bondForce
,
replacements
),
force
.
getForceGroup
());
}
...
...
@@ -756,6 +775,7 @@ void OpenCLCalcHarmonicAngleForceKernel::initialize(const System& system, const
}
params
->
upload
(
paramVector
);
map
<
string
,
string
>
replacements
;
replacements
[
"APPLY_PERIODIC"
]
=
(
force
.
usesPeriodicBoundaryConditions
()
?
"1"
:
"0"
);
replacements
[
"COMPUTE_FORCE"
]
=
OpenCLKernelSources
::
harmonicAngleForce
;
replacements
[
"PARAMS"
]
=
cl
.
getBondedUtilities
().
addArgument
(
params
->
getDeviceBuffer
(),
"float2"
);
cl
.
getBondedUtilities
().
addInteraction
(
atoms
,
cl
.
replaceStrings
(
OpenCLKernelSources
::
angleForce
,
replacements
),
force
.
getForceGroup
());
...
...
@@ -890,6 +910,7 @@ void OpenCLCalcCustomAngleForceKernel::initialize(const System& system, const Cu
vector
<
pair
<
string
,
string
>
>
functionNames
;
compute
<<
cl
.
getExpressionUtilities
().
createExpressions
(
expressions
,
variables
,
functions
,
functionNames
,
"temp"
);
map
<
string
,
string
>
replacements
;
replacements
[
"APPLY_PERIODIC"
]
=
(
force
.
usesPeriodicBoundaryConditions
()
?
"1"
:
"0"
);
replacements
[
"COMPUTE_FORCE"
]
=
compute
.
str
();
cl
.
getBondedUtilities
().
addInteraction
(
atoms
,
cl
.
replaceStrings
(
OpenCLKernelSources
::
angleForce
,
replacements
),
force
.
getForceGroup
());
}
...
...
@@ -987,6 +1008,7 @@ void OpenCLCalcPeriodicTorsionForceKernel::initialize(const System& system, cons
}
params
->
upload
(
paramVector
);
map
<
string
,
string
>
replacements
;
replacements
[
"APPLY_PERIODIC"
]
=
(
force
.
usesPeriodicBoundaryConditions
()
?
"1"
:
"0"
);
replacements
[
"COMPUTE_FORCE"
]
=
OpenCLKernelSources
::
periodicTorsionForce
;
replacements
[
"PARAMS"
]
=
cl
.
getBondedUtilities
().
addArgument
(
params
->
getDeviceBuffer
(),
"float4"
);
cl
.
getBondedUtilities
().
addInteraction
(
atoms
,
cl
.
replaceStrings
(
OpenCLKernelSources
::
torsionForce
,
replacements
),
force
.
getForceGroup
());
...
...
@@ -1073,6 +1095,7 @@ void OpenCLCalcRBTorsionForceKernel::initialize(const System& system, const RBTo
}
params
->
upload
(
paramVector
);
map
<
string
,
string
>
replacements
;
replacements
[
"APPLY_PERIODIC"
]
=
(
force
.
usesPeriodicBoundaryConditions
()
?
"1"
:
"0"
);
replacements
[
"COMPUTE_FORCE"
]
=
OpenCLKernelSources
::
rbTorsionForce
;
replacements
[
"PARAMS"
]
=
cl
.
getBondedUtilities
().
addArgument
(
params
->
getDeviceBuffer
(),
"float8"
);
cl
.
getBondedUtilities
().
addInteraction
(
atoms
,
cl
.
replaceStrings
(
OpenCLKernelSources
::
torsionForce
,
replacements
),
force
.
getForceGroup
());
...
...
@@ -1184,6 +1207,7 @@ void OpenCLCalcCMAPTorsionForceKernel::initialize(const System& system, const CM
mapPositions
->
upload
(
mapPositionsVec
);
torsionMaps
->
upload
(
torsionMapsVec
);
map
<
string
,
string
>
replacements
;
replacements
[
"APPLY_PERIODIC"
]
=
(
force
.
usesPeriodicBoundaryConditions
()
?
"1"
:
"0"
);
replacements
[
"COEFF"
]
=
cl
.
getBondedUtilities
().
addArgument
(
coefficients
->
getDeviceBuffer
(),
"float4"
);
replacements
[
"MAP_POS"
]
=
cl
.
getBondedUtilities
().
addArgument
(
mapPositions
->
getDeviceBuffer
(),
"int2"
);
replacements
[
"MAPS"
]
=
cl
.
getBondedUtilities
().
addArgument
(
torsionMaps
->
getDeviceBuffer
(),
"int"
);
...
...
@@ -1338,6 +1362,7 @@ void OpenCLCalcCustomTorsionForceKernel::initialize(const System& system, const
vector
<
pair
<
string
,
string
>
>
functionNames
;
compute
<<
cl
.
getExpressionUtilities
().
createExpressions
(
expressions
,
variables
,
functions
,
functionNames
,
"temp"
);
map
<
string
,
string
>
replacements
;
replacements
[
"APPLY_PERIODIC"
]
=
(
force
.
usesPeriodicBoundaryConditions
()
?
"1"
:
"0"
);
replacements
[
"COMPUTE_FORCE"
]
=
compute
.
str
();
cl
.
getBondedUtilities
().
addInteraction
(
atoms
,
cl
.
replaceStrings
(
OpenCLKernelSources
::
torsionForce
,
replacements
),
force
.
getForceGroup
());
}
...
...
@@ -1502,9 +1527,9 @@ public:
events
[
0
]
=
event
;
event
=
cl
::
Event
();
cl
.
getQueue
().
enqueueWaitForEvents
(
events
);
if
(
includeEnergy
)
cl
.
executeKernel
(
addEnergyKernel
,
pmeEnergyBuffer
.
getSize
());
}
if
(
includeEnergy
)
cl
.
executeKernel
(
addEnergyKernel
,
pmeEnergyBuffer
.
getSize
());
return
0.0
;
}
private:
...
...
@@ -2222,6 +2247,7 @@ void OpenCLCalcCustomNonbondedForceKernel::initialize(const System& system, cons
map
<
string
,
Lepton
::
CustomFunction
*>
functions
;
vector
<
pair
<
string
,
string
>
>
functionDefinitions
;
vector
<
const
TabulatedFunction
*>
functionList
;
vector
<
string
>
tableTypes
;
for
(
int
i
=
0
;
i
<
force
.
getNumFunctions
();
i
++
)
{
functionList
.
push_back
(
&
force
.
getTabulatedFunction
(
i
));
string
name
=
force
.
getTabulatedFunctionName
(
i
);
...
...
@@ -2233,6 +2259,10 @@ void OpenCLCalcCustomNonbondedForceKernel::initialize(const System& system, cons
tabulatedFunctions
.
push_back
(
OpenCLArray
::
create
<
float
>
(
cl
,
f
.
size
(),
"TabulatedFunction"
));
tabulatedFunctions
[
tabulatedFunctions
.
size
()
-
1
]
->
upload
(
f
);
cl
.
getNonbondedUtilities
().
addArgument
(
OpenCLNonbondedUtilities
::
ParameterInfo
(
arrayName
,
"float"
,
width
,
width
*
sizeof
(
float
),
tabulatedFunctions
[
tabulatedFunctions
.
size
()
-
1
]
->
getDeviceBuffer
()));
if
(
width
==
1
)
tableTypes
.
push_back
(
"float"
);
else
tableTypes
.
push_back
(
"float"
+
cl
.
intToString
(
width
));
}
// Record information for the expressions.
...
...
@@ -2285,7 +2315,7 @@ void OpenCLCalcCustomNonbondedForceKernel::initialize(const System& system, cons
}
string
source
=
cl
.
replaceStrings
(
OpenCLKernelSources
::
customNonbonded
,
replacements
);
if
(
force
.
getNumInteractionGroups
()
>
0
)
initInteractionGroups
(
force
,
source
);
initInteractionGroups
(
force
,
source
,
tableTypes
);
else
{
cl
.
getNonbondedUtilities
().
addInteraction
(
useCutoff
,
usePeriodic
,
true
,
force
.
getCutoffDistance
(),
exclusionList
,
source
,
force
.
getForceGroup
());
for
(
int
i
=
0
;
i
<
(
int
)
params
->
getBuffers
().
size
();
i
++
)
{
...
...
@@ -2311,7 +2341,7 @@ void OpenCLCalcCustomNonbondedForceKernel::initialize(const System& system, cons
}
}
void
OpenCLCalcCustomNonbondedForceKernel
::
initInteractionGroups
(
const
CustomNonbondedForce
&
force
,
const
string
&
interactionSource
)
{
void
OpenCLCalcCustomNonbondedForceKernel
::
initInteractionGroups
(
const
CustomNonbondedForce
&
force
,
const
string
&
interactionSource
,
const
vector
<
string
>&
tableTypes
)
{
// Process groups to form tiles.
vector
<
vector
<
int
>
>
atomLists
;
...
...
@@ -2502,6 +2532,8 @@ void OpenCLCalcCustomNonbondedForceKernel::initInteractionGroups(const CustomNon
stringstream
args
;
for
(
int
i
=
0
;
i
<
(
int
)
buffers
.
size
();
i
++
)
args
<<
", __global const "
<<
buffers
[
i
].
getType
()
<<
"* restrict global_params"
<<
(
i
+
1
);
for
(
int
i
=
0
;
i
<
(
int
)
tabulatedFunctions
.
size
();
i
++
)
args
<<
", __global const "
<<
tableTypes
[
i
]
<<
"* restrict table"
<<
i
;
if
(
globals
!=
NULL
)
args
<<
", __global const float* restrict globals"
;
replacements
[
"PARAMETER_ARGUMENTS"
]
=
args
.
str
();
...
...
@@ -2591,6 +2623,8 @@ double OpenCLCalcCustomNonbondedForceKernel::execute(ContextImpl& context, bool
index
+=
5
;
for
(
int
i
=
0
;
i
<
(
int
)
params
->
getBuffers
().
size
();
i
++
)
interactionGroupKernel
.
setArg
<
cl
::
Memory
>
(
index
++
,
params
->
getBuffers
()[
i
].
getMemory
());
for
(
int
i
=
0
;
i
<
(
int
)
tabulatedFunctions
.
size
();
i
++
)
interactionGroupKernel
.
setArg
<
cl
::
Memory
>
(
index
++
,
tabulatedFunctions
[
i
]
->
getDeviceBuffer
());
if
(
globals
!=
NULL
)
interactionGroupKernel
.
setArg
<
cl
::
Buffer
>
(
index
++
,
globals
->
getDeviceBuffer
());
}
...
...
@@ -4712,7 +4746,7 @@ void OpenCLCalcCustomCentroidBondForceKernel::initialize(const System& system, c
const
vector
<
int
>&
groups
=
iter
->
second
;
string
deltaName
=
atomNames
[
groups
[
0
]]
+
atomNames
[
groups
[
1
]];
if
(
computedDeltas
.
count
(
deltaName
)
==
0
)
{
compute
<<
"real4 delta"
<<
deltaName
<<
" = delta("
<<
posNames
[
groups
[
0
]]
<<
", "
<<
posNames
[
groups
[
1
]]
<<
");
\n
"
;
compute
<<
"real4 delta"
<<
deltaName
<<
" = delta("
<<
posNames
[
groups
[
0
]]
<<
", "
<<
posNames
[
groups
[
1
]]
<<
"
, "
<<
force
.
usesPeriodicBoundaryConditions
()
<<
", periodicBoxSize, invPeriodicBoxSize, periodicBoxVecX, periodicBoxVecY, periodicBoxVecZ
);
\n
"
;
computedDeltas
.
insert
(
deltaName
);
}
compute
<<
"real r_"
<<
deltaName
<<
" = sqrt(delta"
<<
deltaName
<<
".w);
\n
"
;
...
...
@@ -4726,11 +4760,11 @@ void OpenCLCalcCustomCentroidBondForceKernel::initialize(const System& system, c
string
deltaName2
=
atomNames
[
groups
[
1
]]
+
atomNames
[
groups
[
2
]];
string
angleName
=
"angle_"
+
atomNames
[
groups
[
0
]]
+
atomNames
[
groups
[
1
]]
+
atomNames
[
groups
[
2
]];
if
(
computedDeltas
.
count
(
deltaName1
)
==
0
)
{
compute
<<
"real4 delta"
<<
deltaName1
<<
" = delta("
<<
posNames
[
groups
[
1
]]
<<
", "
<<
posNames
[
groups
[
0
]]
<<
");
\n
"
;
compute
<<
"real4 delta"
<<
deltaName1
<<
" = delta("
<<
posNames
[
groups
[
1
]]
<<
", "
<<
posNames
[
groups
[
0
]]
<<
"
, "
<<
force
.
usesPeriodicBoundaryConditions
()
<<
", periodicBoxSize, invPeriodicBoxSize, periodicBoxVecX, periodicBoxVecY, periodicBoxVecZ
);
\n
"
;
computedDeltas
.
insert
(
deltaName1
);
}
if
(
computedDeltas
.
count
(
deltaName2
)
==
0
)
{
compute
<<
"real4 delta"
<<
deltaName2
<<
" = delta("
<<
posNames
[
groups
[
1
]]
<<
", "
<<
posNames
[
groups
[
2
]]
<<
");
\n
"
;
compute
<<
"real4 delta"
<<
deltaName2
<<
" = delta("
<<
posNames
[
groups
[
1
]]
<<
", "
<<
posNames
[
groups
[
2
]]
<<
"
, "
<<
force
.
usesPeriodicBoundaryConditions
()
<<
", periodicBoxSize, invPeriodicBoxSize, periodicBoxVecX, periodicBoxVecY, periodicBoxVecZ
);
\n
"
;
computedDeltas
.
insert
(
deltaName2
);
}
compute
<<
"real "
<<
angleName
<<
" = computeAngle(delta"
<<
deltaName1
<<
", delta"
<<
deltaName2
<<
");
\n
"
;
...
...
@@ -4747,15 +4781,15 @@ void OpenCLCalcCustomCentroidBondForceKernel::initialize(const System& system, c
string
crossName2
=
"cross_"
+
deltaName2
+
"_"
+
deltaName3
;
string
dihedralName
=
"dihedral_"
+
atomNames
[
groups
[
0
]]
+
atomNames
[
groups
[
1
]]
+
atomNames
[
groups
[
2
]]
+
atomNames
[
groups
[
3
]];
if
(
computedDeltas
.
count
(
deltaName1
)
==
0
)
{
compute
<<
"real4 delta"
<<
deltaName1
<<
" = delta("
<<
posNames
[
groups
[
0
]]
<<
", "
<<
posNames
[
groups
[
1
]]
<<
");
\n
"
;
compute
<<
"real4 delta"
<<
deltaName1
<<
" = delta("
<<
posNames
[
groups
[
0
]]
<<
", "
<<
posNames
[
groups
[
1
]]
<<
"
, "
<<
force
.
usesPeriodicBoundaryConditions
()
<<
", periodicBoxSize, invPeriodicBoxSize, periodicBoxVecX, periodicBoxVecY, periodicBoxVecZ
);
\n
"
;
computedDeltas
.
insert
(
deltaName1
);
}
if
(
computedDeltas
.
count
(
deltaName2
)
==
0
)
{
compute
<<
"real4 delta"
<<
deltaName2
<<
" = delta("
<<
posNames
[
groups
[
2
]]
<<
", "
<<
posNames
[
groups
[
1
]]
<<
");
\n
"
;
compute
<<
"real4 delta"
<<
deltaName2
<<
" = delta("
<<
posNames
[
groups
[
2
]]
<<
", "
<<
posNames
[
groups
[
1
]]
<<
"
, "
<<
force
.
usesPeriodicBoundaryConditions
()
<<
", periodicBoxSize, invPeriodicBoxSize, periodicBoxVecX, periodicBoxVecY, periodicBoxVecZ
);
\n
"
;
computedDeltas
.
insert
(
deltaName2
);
}
if
(
computedDeltas
.
count
(
deltaName3
)
==
0
)
{
compute
<<
"real4 delta"
<<
deltaName3
<<
" = delta("
<<
posNames
[
groups
[
2
]]
<<
", "
<<
posNames
[
groups
[
3
]]
<<
");
\n
"
;
compute
<<
"real4 delta"
<<
deltaName3
<<
" = delta("
<<
posNames
[
groups
[
2
]]
<<
", "
<<
posNames
[
groups
[
3
]]
<<
"
, "
<<
force
.
usesPeriodicBoundaryConditions
()
<<
", periodicBoxSize, invPeriodicBoxSize, periodicBoxVecX, periodicBoxVecY, periodicBoxVecZ
);
\n
"
;
computedDeltas
.
insert
(
deltaName3
);
}
compute
<<
"real4 "
<<
crossName1
<<
" = computeCross(delta"
<<
deltaName1
<<
", delta"
<<
deltaName2
<<
");
\n
"
;
...
...
@@ -4876,6 +4910,7 @@ void OpenCLCalcCustomCentroidBondForceKernel::initialize(const System& system, c
index
++
;
// Energy buffer hasn't been created yet
groupForcesKernel
.
setArg
<
cl
::
Buffer
>
(
index
++
,
centerPositions
->
getDeviceBuffer
());
groupForcesKernel
.
setArg
<
cl
::
Buffer
>
(
index
++
,
bondGroups
->
getDeviceBuffer
());
index
+=
5
;
// Periodic box information
for
(
int
i
=
0
;
i
<
tabulatedFunctions
.
size
();
i
++
)
groupForcesKernel
.
setArg
<
cl
::
Buffer
>
(
index
++
,
tabulatedFunctions
[
i
]
->
getDeviceBuffer
());
if
(
globals
!=
NULL
)
...
...
@@ -4906,6 +4941,7 @@ double OpenCLCalcCustomCentroidBondForceKernel::execute(ContextImpl& context, bo
}
cl
.
executeKernel
(
computeCentersKernel
,
OpenCLContext
::
TileSize
*
numGroups
);
groupForcesKernel
.
setArg
<
cl
::
Buffer
>
(
1
,
cl
.
getEnergyBuffer
().
getDeviceBuffer
());
setPeriodicBoxArgs
(
cl
,
groupForcesKernel
,
4
);
cl
.
executeKernel
(
groupForcesKernel
,
numBonds
);
applyForcesKernel
.
setArg
<
cl
::
Buffer
>
(
4
,
cl
.
getLongForceBuffer
().
getDeviceBuffer
());
cl
.
executeKernel
(
applyForcesKernel
,
OpenCLContext
::
TileSize
*
numGroups
);
...
...
@@ -5061,7 +5097,7 @@ void OpenCLCalcCustomCompoundBondForceKernel::initialize(const System& system, c
const
vector
<
int
>&
atoms
=
iter
->
second
;
string
deltaName
=
atomNames
[
atoms
[
0
]]
+
atomNames
[
atoms
[
1
]];
if
(
computedDeltas
.
count
(
deltaName
)
==
0
)
{
compute
<<
"real4 delta"
<<
deltaName
<<
" = ccb_delta("
<<
posNames
[
atoms
[
0
]]
<<
", "
<<
posNames
[
atoms
[
1
]]
<<
");
\n
"
;
compute
<<
"real4 delta"
<<
deltaName
<<
" = ccb_delta("
<<
posNames
[
atoms
[
0
]]
<<
", "
<<
posNames
[
atoms
[
1
]]
<<
"
, "
<<
force
.
usesPeriodicBoundaryConditions
()
<<
", periodicBoxSize, invPeriodicBoxSize, periodicBoxVecX, periodicBoxVecY, periodicBoxVecZ
);
\n
"
;
computedDeltas
.
insert
(
deltaName
);
}
compute
<<
"real r_"
<<
deltaName
<<
" = sqrt(delta"
<<
deltaName
<<
".w);
\n
"
;
...
...
@@ -5075,11 +5111,11 @@ void OpenCLCalcCustomCompoundBondForceKernel::initialize(const System& system, c
string
deltaName2
=
atomNames
[
atoms
[
1
]]
+
atomNames
[
atoms
[
2
]];
string
angleName
=
"angle_"
+
atomNames
[
atoms
[
0
]]
+
atomNames
[
atoms
[
1
]]
+
atomNames
[
atoms
[
2
]];
if
(
computedDeltas
.
count
(
deltaName1
)
==
0
)
{
compute
<<
"real4 delta"
<<
deltaName1
<<
" = ccb_delta("
<<
posNames
[
atoms
[
1
]]
<<
", "
<<
posNames
[
atoms
[
0
]]
<<
");
\n
"
;
compute
<<
"real4 delta"
<<
deltaName1
<<
" = ccb_delta("
<<
posNames
[
atoms
[
1
]]
<<
", "
<<
posNames
[
atoms
[
0
]]
<<
"
, "
<<
force
.
usesPeriodicBoundaryConditions
()
<<
", periodicBoxSize, invPeriodicBoxSize, periodicBoxVecX, periodicBoxVecY, periodicBoxVecZ
);
\n
"
;
computedDeltas
.
insert
(
deltaName1
);
}
if
(
computedDeltas
.
count
(
deltaName2
)
==
0
)
{
compute
<<
"real4 delta"
<<
deltaName2
<<
" = ccb_delta("
<<
posNames
[
atoms
[
1
]]
<<
", "
<<
posNames
[
atoms
[
2
]]
<<
");
\n
"
;
compute
<<
"real4 delta"
<<
deltaName2
<<
" = ccb_delta("
<<
posNames
[
atoms
[
1
]]
<<
", "
<<
posNames
[
atoms
[
2
]]
<<
"
, "
<<
force
.
usesPeriodicBoundaryConditions
()
<<
", periodicBoxSize, invPeriodicBoxSize, periodicBoxVecX, periodicBoxVecY, periodicBoxVecZ
);
\n
"
;
computedDeltas
.
insert
(
deltaName2
);
}
compute
<<
"real "
<<
angleName
<<
" = ccb_computeAngle(delta"
<<
deltaName1
<<
", delta"
<<
deltaName2
<<
");
\n
"
;
...
...
@@ -5096,15 +5132,15 @@ void OpenCLCalcCustomCompoundBondForceKernel::initialize(const System& system, c
string
crossName2
=
"cross_"
+
deltaName2
+
"_"
+
deltaName3
;
string
dihedralName
=
"dihedral_"
+
atomNames
[
atoms
[
0
]]
+
atomNames
[
atoms
[
1
]]
+
atomNames
[
atoms
[
2
]]
+
atomNames
[
atoms
[
3
]];
if
(
computedDeltas
.
count
(
deltaName1
)
==
0
)
{
compute
<<
"real4 delta"
<<
deltaName1
<<
" = ccb_delta("
<<
posNames
[
atoms
[
0
]]
<<
", "
<<
posNames
[
atoms
[
1
]]
<<
");
\n
"
;
compute
<<
"real4 delta"
<<
deltaName1
<<
" = ccb_delta("
<<
posNames
[
atoms
[
0
]]
<<
", "
<<
posNames
[
atoms
[
1
]]
<<
"
, "
<<
force
.
usesPeriodicBoundaryConditions
()
<<
", periodicBoxSize, invPeriodicBoxSize, periodicBoxVecX, periodicBoxVecY, periodicBoxVecZ
);
\n
"
;
computedDeltas
.
insert
(
deltaName1
);
}
if
(
computedDeltas
.
count
(
deltaName2
)
==
0
)
{
compute
<<
"real4 delta"
<<
deltaName2
<<
" = ccb_delta("
<<
posNames
[
atoms
[
2
]]
<<
", "
<<
posNames
[
atoms
[
1
]]
<<
");
\n
"
;
compute
<<
"real4 delta"
<<
deltaName2
<<
" = ccb_delta("
<<
posNames
[
atoms
[
2
]]
<<
", "
<<
posNames
[
atoms
[
1
]]
<<
"
, "
<<
force
.
usesPeriodicBoundaryConditions
()
<<
", periodicBoxSize, invPeriodicBoxSize, periodicBoxVecX, periodicBoxVecY, periodicBoxVecZ
);
\n
"
;
computedDeltas
.
insert
(
deltaName2
);
}
if
(
computedDeltas
.
count
(
deltaName3
)
==
0
)
{
compute
<<
"real4 delta"
<<
deltaName3
<<
" = ccb_delta("
<<
posNames
[
atoms
[
2
]]
<<
", "
<<
posNames
[
atoms
[
3
]]
<<
");
\n
"
;
compute
<<
"real4 delta"
<<
deltaName3
<<
" = ccb_delta("
<<
posNames
[
atoms
[
2
]]
<<
", "
<<
posNames
[
atoms
[
3
]]
<<
"
, "
<<
force
.
usesPeriodicBoundaryConditions
()
<<
", periodicBoxSize, invPeriodicBoxSize, periodicBoxVecX, periodicBoxVecY, periodicBoxVecZ
);
\n
"
;
computedDeltas
.
insert
(
deltaName3
);
}
compute
<<
"real4 "
<<
crossName1
<<
" = ccb_computeCross(delta"
<<
deltaName1
<<
", delta"
<<
deltaName2
<<
");
\n
"
;
...
...
@@ -6513,9 +6549,9 @@ void OpenCLIntegrateCustomStepKernel::prepareForComputation(ContextImpl& context
for
(
int
step
=
0
;
step
<
numSteps
;
step
++
)
{
string
expr
;
integrator
.
getComputationStep
(
step
,
stepType
[
step
],
variable
[
step
],
expr
);
if
(
stepType
[
step
]
==
CustomIntegrator
::
Begin
WhileBlock
)
if
(
stepType
[
step
]
==
CustomIntegrator
::
WhileBlock
Start
)
blockEnd
[
blockEnd
[
step
]]
=
step
;
// Record where to branch back to.
if
(
stepType
[
step
]
==
CustomIntegrator
::
ComputeGlobal
||
stepType
[
step
]
==
CustomIntegrator
::
Begin
IfBlock
||
stepType
[
step
]
==
CustomIntegrator
::
Begin
WhileBlock
)
if
(
stepType
[
step
]
==
CustomIntegrator
::
ComputeGlobal
||
stepType
[
step
]
==
CustomIntegrator
::
IfBlock
Start
||
stepType
[
step
]
==
CustomIntegrator
::
WhileBlock
Start
)
for
(
int
i
=
0
;
i
<
(
int
)
expression
[
step
].
size
();
i
++
)
globalExpressions
[
step
].
push_back
(
expression
[
step
][
i
].
createCompiledExpression
());
}
...
...
@@ -6961,15 +6997,15 @@ void OpenCLIntegrateCustomStepKernel::execute(ContextImpl& context, CustomIntegr
else
if
(
stepType
[
step
]
==
CustomIntegrator
::
ConstrainVelocities
)
{
cl
.
getIntegrationUtilities
().
applyVelocityConstraints
(
integrator
.
getConstraintTolerance
());
}
else
if
(
stepType
[
step
]
==
CustomIntegrator
::
Begin
IfBlock
)
{
else
if
(
stepType
[
step
]
==
CustomIntegrator
::
IfBlock
Start
)
{
if
(
!
evaluateCondition
(
step
))
nextStep
=
blockEnd
[
step
]
+
1
;
}
else
if
(
stepType
[
step
]
==
CustomIntegrator
::
Begin
WhileBlock
)
{
else
if
(
stepType
[
step
]
==
CustomIntegrator
::
WhileBlock
Start
)
{
if
(
!
evaluateCondition
(
step
))
nextStep
=
blockEnd
[
step
]
+
1
;
}
else
if
(
stepType
[
step
]
==
CustomIntegrator
::
End
Block
)
{
else
if
(
stepType
[
step
]
==
CustomIntegrator
::
Block
End
)
{
if
(
blockEnd
[
step
]
!=
-
1
)
nextStep
=
blockEnd
[
step
];
// Return to the start of a while block.
}
...
...
@@ -7053,6 +7089,7 @@ void OpenCLIntegrateCustomStepKernel::recordGlobalValue(double value, GlobalTarg
case
DT
:
if
(
value
!=
globalValuesDouble
[
dtVariableIndex
])
deviceGlobalsAreCurrent
=
false
;
expressionSet
.
setVariable
(
dtVariableIndex
,
value
);
globalValuesDouble
[
dtVariableIndex
]
=
value
;
cl
.
getIntegrationUtilities
().
setNextStepSize
(
value
);
break
;
...
...
platforms/opencl/src/OpenCLPlatform.cpp
View file @
2e9c418a
...
...
@@ -56,6 +56,11 @@ extern "C" OPENMM_EXPORT_OPENCL void registerPlatforms() {
#endif
OpenCLPlatform
::
OpenCLPlatform
()
{
deprecatedPropertyReplacements
[
"OpenCLDeviceIndex"
]
=
OpenCLDeviceIndex
();
deprecatedPropertyReplacements
[
"OpenCLDeviceName"
]
=
OpenCLDeviceName
();
deprecatedPropertyReplacements
[
"OpenCLPrecision"
]
=
OpenCLPrecision
();
deprecatedPropertyReplacements
[
"OpenCLUseCpuPme"
]
=
OpenCLUseCpuPme
();
deprecatedPropertyReplacements
[
"OpenCLDisablePmeStream"
]
=
OpenCLDisablePmeStream
();
OpenCLKernelFactory
*
factory
=
new
OpenCLKernelFactory
();
registerKernelFactory
(
CalcForcesAndEnergyKernel
::
Name
(),
factory
);
registerKernelFactory
(
UpdateStateDataKernel
::
Name
(),
factory
);
...
...
@@ -139,7 +144,10 @@ bool OpenCLPlatform::isPlatformSupported() {
const
string
&
OpenCLPlatform
::
getPropertyValue
(
const
Context
&
context
,
const
string
&
property
)
const
{
const
ContextImpl
&
impl
=
getContextImpl
(
context
);
const
PlatformData
*
data
=
reinterpret_cast
<
const
PlatformData
*>
(
impl
.
getPlatformData
());
map
<
string
,
string
>::
const_iterator
value
=
data
->
propertyValues
.
find
(
property
);
string
propertyName
=
property
;
if
(
deprecatedPropertyReplacements
.
find
(
property
)
!=
deprecatedPropertyReplacements
.
end
())
propertyName
=
deprecatedPropertyReplacements
.
find
(
property
)
->
second
;
map
<
string
,
string
>::
const_iterator
value
=
data
->
propertyValues
.
find
(
propertyName
);
if
(
value
!=
data
->
propertyValues
.
end
())
return
value
->
second
;
return
Platform
::
getPropertyValue
(
context
,
property
);
...
...
platforms/opencl/src/kernels/angleForce.cl
View file @
2e9c418a
real4
v0
=
pos2-pos1
;
real4
v1
=
pos2-pos3
;
#
if
APPLY_PERIODIC
APPLY_PERIODIC_TO_DELTA
(
v0
)
APPLY_PERIODIC_TO_DELTA
(
v1
)
#
endif
real4
cp
=
cross
(
v0,
v1
)
;
real
rp
=
cp.x*cp.x
+
cp.y*cp.y
+
cp.z*cp.z
;
rp
=
max
(
SQRT
(
rp
)
,
(
real
)
1.0e-06f
)
;
...
...
platforms/opencl/src/kernels/bondForce.cl
View file @
2e9c418a
real4
delta
=
pos2-pos1
;
#
if
APPLY_PERIODIC
APPLY_PERIODIC_TO_DELTA
(
delta
)
#
endif
real
r
=
SQRT
(
delta.x*delta.x
+
delta.y*delta.y
+
delta.z*delta.z
)
;
COMPUTE_FORCE
dEdR
=
(
r
>
0.0f
)
?
(
dEdR
/
r
)
:
0.0f
;
...
...
platforms/opencl/src/kernels/cmapTorsionForce.cl
View file @
2e9c418a
...
...
@@ -5,6 +5,11 @@ const real PI = 3.14159265358979323846f;
real4
v0a
=
(
real4
)
(
pos1.xyz-pos2.xyz,
0.0f
)
;
real4
v1a
=
(
real4
)
(
pos3.xyz-pos2.xyz,
0.0f
)
;
real4
v2a
=
(
real4
)
(
pos3.xyz-pos4.xyz,
0.0f
)
;
#
if
APPLY_PERIODIC
APPLY_PERIODIC_TO_DELTA
(
v0a
)
APPLY_PERIODIC_TO_DELTA
(
v1a
)
APPLY_PERIODIC_TO_DELTA
(
v2a
)
#
endif
real4
cp0a
=
cross
(
v0a,
v1a
)
;
real4
cp1a
=
cross
(
v1a,
v2a
)
;
real
cosangle
=
dot
(
normalize
(
cp0a
)
,
normalize
(
cp1a
))
;
...
...
@@ -28,6 +33,11 @@ angleA = fmod(angleA+2.0f*PI, 2.0f*PI);
real4 v0b = (real4) (pos5.xyz-pos6.xyz, 0.0f);
real4 v1b = (real4) (pos7.xyz-pos6.xyz, 0.0f);
real4 v2b = (real4) (pos7.xyz-pos8.xyz, 0.0f);
#if APPLY_PERIODIC
APPLY_PERIODIC_TO_DELTA(v0b)
APPLY_PERIODIC_TO_DELTA(v1b)
APPLY_PERIODIC_TO_DELTA(v2b)
#endif
real4 cp0b = cross(v0b, v1b);
real4 cp1b = cross(v1b, v2b);
cosangle = dot(normalize(cp0b), normalize(cp1b));
...
...
platforms/opencl/src/kernels/customCentroidBond.cl
View file @
2e9c418a
...
...
@@ -70,8 +70,11 @@ __kernel void computeGroupCenters(__global const real4* restrict posq, __global
/**
*
Compute
the
difference
between
two
vectors,
setting
the
fourth
component
to
the
squared
magnitude.
*/
real4
delta
(
real4
vec1,
real4
vec2
)
{
real4
delta
(
real4
vec1,
real4
vec2,
bool
periodic,
real4
periodicBoxSize,
real4
invPeriodicBoxSize,
real4
periodicBoxVecX,
real4
periodicBoxVecY,
real4
periodicBoxVecZ
)
{
real4
result
=
(
real4
)
(
vec1.x-vec2.x,
vec1.y-vec2.y,
vec1.z-vec2.z,
0
)
;
if
(
periodic
)
APPLY_PERIODIC_TO_DELTA
(
result
)
;
result.w
=
result.x*result.x
+
result.y*result.y
+
result.z*result.z
;
return
result
;
}
...
...
@@ -110,7 +113,7 @@ real4 computeCross(real4 vec1, real4 vec2) {
*
Compute
the
forces
on
groups
based
on
the
bonds.
*/
__kernel
void
computeGroupForces
(
__global
long*
restrict
groupForce,
__global
mixed*
restrict
energyBuffer,
__global
const
real4*
restrict
centerPositions,
__global
const
int*
restrict
bondGroups
__global
const
int*
restrict
bondGroups
,
real4
periodicBoxSize,
real4
invPeriodicBoxSize,
real4
periodicBoxVecX,
real4
periodicBoxVecY,
real4
periodicBoxVecZ
EXTRA_ARGS
)
{
mixed
energy
=
0
;
for
(
int
index
=
get_global_id
(
0
)
; index < NUM_BONDS; index += get_global_size(0)) {
...
...
platforms/opencl/src/kernels/customCompoundBond.cl
View file @
2e9c418a
/**
*
Compute
the
difference
between
two
vectors,
setting
the
fourth
component
to
the
squared
magnitude.
*/
real4
ccb_delta
(
real4
vec1,
real4
vec2
)
{
real4
ccb_delta
(
real4
vec1,
real4
vec2,
bool
periodic,
real4
periodicBoxSize,
real4
invPeriodicBoxSize,
real4
periodicBoxVecX,
real4
periodicBoxVecY,
real4
periodicBoxVecZ
)
{
real4
result
=
(
real4
)
(
vec1.x-vec2.x,
vec1.y-vec2.y,
vec1.z-vec2.z,
0
)
;
if
(
periodic
)
APPLY_PERIODIC_TO_DELTA
(
result
)
;
result.w
=
result.x*result.x
+
result.y*result.y
+
result.z*result.z
;
return
result
;
}
...
...
platforms/opencl/src/kernels/customManyParticle.cl
View file @
2e9c418a
...
...
@@ -55,7 +55,7 @@ inline real4 computeCross(real4 vec1, real4 vec2) {
/**
*
Determine
whether
a
particular
interaction
is
in
the
list
of
exclusions.
*/
inline
bool
isInteractionExcluded
(
int
atom1,
int
atom2,
__global
int*
restrict
exclusions,
__global
int*
restrict
exclusionStartIndex
)
{
inline
bool
isInteractionExcluded
(
int
atom1,
int
atom2,
__global
const
int*
restrict
exclusions,
__global
const
int*
restrict
exclusionStartIndex
)
{
int
first
=
exclusionStartIndex[atom1]
;
int
last
=
exclusionStartIndex[atom1+1]
;
for
(
int
i
=
last-1
; i >= first; i--) {
...
...
@@ -174,7 +174,7 @@ __kernel void findNeighbors(real4 periodicBoxSize, real4 invPeriodicBoxSize, rea
__global
const
real4*
restrict
posq,
__global
const
real4*
restrict
blockCenter,
__global
const
real4*
restrict
blockBoundingBox,
__global
int2*
restrict
neighborPairs,
__global
int*
restrict
numNeighborPairs,
__global
int*
restrict
numNeighborsForAtom,
int
maxNeighborPairs
#
ifdef
USE_EXCLUSIONS
,
__global
int*
restrict
exclusions,
__global
int*
restrict
exclusionStartIndex
,
__global
const
int*
restrict
exclusions,
__global
const
int*
restrict
exclusionStartIndex
#
endif
)
{
__local
real4
positionCache[FIND_NEIGHBORS_WORKGROUP_SIZE]
;
...
...
@@ -264,7 +264,9 @@ __kernel void findNeighbors(real4 periodicBoxSize, real4 invPeriodicBoxSize, rea
}
}
}
numNeighborsForAtom[atom1]
=
totalNeighborsForAtom1
;
if
(
atom1
<
NUM_ATOMS
)
numNeighborsForAtom[atom1]
=
totalNeighborsForAtom1
;
SYNC_WARPS
;
}
}
...
...
@@ -307,6 +309,7 @@ __kernel void computeNeighborStartIndices(__global int* restrict numNeighborsFor
numNeighborsForAtom[globalIndex]
=
0
; // Clear this so the next kernel can use it as a counter
}
globalOffset
+=
posBuffer[get_local_size
(
0
)
-1]
;
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
}
if
(
get_local_id
(
0
)
==
0
)
neighborStartIndex[0]
=
0
;
...
...
platforms/opencl/src/kernels/torsionForce.cl
View file @
2e9c418a
...
...
@@ -2,6 +2,11 @@ const real PI = 3.14159265358979323846f;
real4
v0
=
(
real4
)
(
pos1.xyz-pos2.xyz,
0.0f
)
;
real4
v1
=
(
real4
)
(
pos3.xyz-pos2.xyz,
0.0f
)
;
real4
v2
=
(
real4
)
(
pos3.xyz-pos4.xyz,
0.0f
)
;
#
if
APPLY_PERIODIC
APPLY_PERIODIC_TO_DELTA
(
v0
)
APPLY_PERIODIC_TO_DELTA
(
v1
)
APPLY_PERIODIC_TO_DELTA
(
v2
)
#
endif
real4
cp0
=
cross
(
v0,
v1
)
;
real4
cp1
=
cross
(
v1,
v2
)
;
real
cosangle
=
dot
(
normalize
(
cp0
)
,
normalize
(
cp1
))
;
...
...
platforms/opencl/tests/OpenCLTests.h
View file @
2e9c418a
...
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2015 Stanford University and the Authors.
*
* Portions copyright (c) 2015
-2016
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -39,9 +39,9 @@ OpenMM::OpenCLPlatform platform;
void
initializeTests
(
int
argc
,
char
*
argv
[])
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"
OpenCL
Precision"
,
std
::
string
(
argv
[
1
]));
platform
.
setPropertyDefaultValue
(
"Precision"
,
std
::
string
(
argv
[
1
]));
if
(
argc
>
2
)
platform
.
setPropertyDefaultValue
(
"OpenCLPlatformIndex"
,
std
::
string
(
argv
[
2
]));
if
(
argc
>
3
)
platform
.
setPropertyDefaultValue
(
"
OpenCL
DeviceIndex"
,
std
::
string
(
argv
[
3
]));
platform
.
setPropertyDefaultValue
(
"DeviceIndex"
,
std
::
string
(
argv
[
3
]));
}
platforms/reference/include/ReferenceAngleBondIxn.h
View file @
2e9c418a
...
...
@@ -33,6 +33,9 @@ class OPENMM_EXPORT ReferenceAngleBondIxn : public ReferenceBondIxn {
private:
bool
usePeriodic
;
RealVec
boxVectors
[
3
];
public:
/**---------------------------------------------------------------------------------------
...
...
@@ -51,6 +54,16 @@ class OPENMM_EXPORT ReferenceAngleBondIxn : public ReferenceBondIxn {
~
ReferenceAngleBondIxn
();
/**---------------------------------------------------------------------------------------
Set the force to use periodic boundary conditions.
@param vectors the vectors defining the periodic box
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
OpenMM
::
RealVec
*
vectors
);
/**---------------------------------------------------------------------------------------
Get dEdR and energy term for angle bond
...
...
platforms/reference/include/ReferenceCMAPTorsionIxn.h
View file @
2e9c418a
...
...
@@ -38,6 +38,8 @@ private:
std
::
vector
<
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>
>
coeff
;
std
::
vector
<
int
>
torsionMaps
;
std
::
vector
<
std
::
vector
<
int
>
>
torsionIndices
;
bool
usePeriodic
;
RealVec
boxVectors
[
3
];
/**---------------------------------------------------------------------------------------
...
...
@@ -65,6 +67,16 @@ public:
const
std
::
vector
<
int
>&
torsionMaps
,
const
std
::
vector
<
std
::
vector
<
int
>
>&
torsionIndices
);
/**---------------------------------------------------------------------------------------
Set the force to use periodic boundary conditions.
@param vectors the vectors defining the periodic box
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
OpenMM
::
RealVec
*
vectors
);
/**---------------------------------------------------------------------------------------
Calculate torsion interaction
...
...
Prev
1
2
3
4
5
6
7
8
9
…
13
Next
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