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
4a3f1743
Commit
4a3f1743
authored
Sep 09, 2015
by
peastman
Browse files
Fixed various bugs in CustomCentroidBondForce
parent
8dece9f1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
11 deletions
+14
-11
platforms/cuda/src/CudaKernels.cpp
platforms/cuda/src/CudaKernels.cpp
+4
-5
platforms/opencl/src/OpenCLKernels.cpp
platforms/opencl/src/OpenCLKernels.cpp
+4
-5
platforms/opencl/src/kernels/customCentroidBond.cl
platforms/opencl/src/kernels/customCentroidBond.cl
+6
-1
No files found.
platforms/cuda/src/CudaKernels.cpp
View file @
4a3f1743
...
@@ -4634,6 +4634,8 @@ void CudaCalcCustomCentroidBondForceKernel::initialize(const System& system, con
...
@@ -4634,6 +4634,8 @@ void CudaCalcCustomCentroidBondForceKernel::initialize(const System& system, con
}
}
double
CudaCalcCustomCentroidBondForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
double
CudaCalcCustomCentroidBondForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
if
(
numBonds
==
0
)
return
0.0
;
if
(
globals
!=
NULL
)
{
if
(
globals
!=
NULL
)
{
bool
changed
=
false
;
bool
changed
=
false
;
for
(
int
i
=
0
;
i
<
(
int
)
globalParamNames
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
globalParamNames
.
size
();
i
++
)
{
...
@@ -4658,10 +4660,7 @@ double CudaCalcCustomCentroidBondForceKernel::execute(ContextImpl& context, bool
...
@@ -4658,10 +4660,7 @@ double CudaCalcCustomCentroidBondForceKernel::execute(ContextImpl& context, bool
void
CudaCalcCustomCentroidBondForceKernel
::
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomCentroidBondForce
&
force
)
{
void
CudaCalcCustomCentroidBondForceKernel
::
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomCentroidBondForce
&
force
)
{
cu
.
setAsCurrent
();
cu
.
setAsCurrent
();
int
numContexts
=
cu
.
getPlatformData
().
contexts
.
size
();
if
(
numBonds
!=
force
.
getNumBonds
())
int
startIndex
=
cu
.
getContextIndex
()
*
force
.
getNumBonds
()
/
numContexts
;
int
endIndex
=
(
cu
.
getContextIndex
()
+
1
)
*
force
.
getNumBonds
()
/
numContexts
;
if
(
numBonds
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of bonds has changed"
);
throw
OpenMMException
(
"updateParametersInContext: The number of bonds has changed"
);
if
(
numBonds
==
0
)
if
(
numBonds
==
0
)
return
;
return
;
...
@@ -4672,7 +4671,7 @@ void CudaCalcCustomCentroidBondForceKernel::copyParametersToContext(ContextImpl&
...
@@ -4672,7 +4671,7 @@ void CudaCalcCustomCentroidBondForceKernel::copyParametersToContext(ContextImpl&
vector
<
int
>
particles
;
vector
<
int
>
particles
;
vector
<
double
>
parameters
;
vector
<
double
>
parameters
;
for
(
int
i
=
0
;
i
<
numBonds
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numBonds
;
i
++
)
{
force
.
getBondParameters
(
startIndex
+
i
,
particles
,
parameters
);
force
.
getBondParameters
(
i
,
particles
,
parameters
);
paramVector
[
i
].
resize
(
parameters
.
size
());
paramVector
[
i
].
resize
(
parameters
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
parameters
.
size
();
j
++
)
for
(
int
j
=
0
;
j
<
(
int
)
parameters
.
size
();
j
++
)
paramVector
[
i
][
j
]
=
(
float
)
parameters
[
j
];
paramVector
[
i
][
j
]
=
(
float
)
parameters
[
j
];
...
...
platforms/opencl/src/OpenCLKernels.cpp
View file @
4a3f1743
...
@@ -4837,6 +4837,8 @@ void OpenCLCalcCustomCentroidBondForceKernel::initialize(const System& system, c
...
@@ -4837,6 +4837,8 @@ void OpenCLCalcCustomCentroidBondForceKernel::initialize(const System& system, c
}
}
double OpenCLCalcCustomCentroidBondForceKernel::execute(ContextImpl& context, bool includeForces, bool includeEnergy) {
double OpenCLCalcCustomCentroidBondForceKernel::execute(ContextImpl& context, bool includeForces, bool includeEnergy) {
if (numBonds == 0)
return 0.0;
if (globals != NULL) {
if (globals != NULL) {
bool changed = false;
bool changed = false;
for (int i = 0; i < (int) globalParamNames.size(); i++) {
for (int i = 0; i < (int) globalParamNames.size(); i++) {
...
@@ -4857,10 +4859,7 @@ double OpenCLCalcCustomCentroidBondForceKernel::execute(ContextImpl& context, bo
...
@@ -4857,10 +4859,7 @@ double OpenCLCalcCustomCentroidBondForceKernel::execute(ContextImpl& context, bo
}
}
void OpenCLCalcCustomCentroidBondForceKernel::copyParametersToContext(ContextImpl& context, const CustomCentroidBondForce& force) {
void OpenCLCalcCustomCentroidBondForceKernel::copyParametersToContext(ContextImpl& context, const CustomCentroidBondForce& force) {
int
numContexts
=
cl
.
getPlatformData
().
contexts
.
size
();
if (numBonds != force.getNumBonds())
int
startIndex
=
cl
.
getContextIndex
()
*
force
.
getNumBonds
()
/
numContexts
;
int
endIndex
=
(
cl
.
getContextIndex
()
+
1
)
*
force
.
getNumBonds
()
/
numContexts
;
if
(
numBonds
!=
endIndex
-
startIndex
)
throw OpenMMException("updateParametersInContext: The number of bonds has changed");
throw OpenMMException("updateParametersInContext: The number of bonds has changed");
if (numBonds == 0)
if (numBonds == 0)
return;
return;
...
@@ -4871,7 +4870,7 @@ void OpenCLCalcCustomCentroidBondForceKernel::copyParametersToContext(ContextImp
...
@@ -4871,7 +4870,7 @@ void OpenCLCalcCustomCentroidBondForceKernel::copyParametersToContext(ContextImp
vector<int> particles;
vector<int> particles;
vector<double> parameters;
vector<double> parameters;
for (int i = 0; i < numBonds; i++) {
for (int i = 0; i < numBonds; i++) {
force
.
getBondParameters
(
startIndex
+
i
,
particles
,
parameters
);
force.getBondParameters(i, particles, parameters);
paramVector[i].resize(parameters.size());
paramVector[i].resize(parameters.size());
for (int j = 0; j < (int) parameters.size(); j++)
for (int j = 0; j < (int) parameters.size(); j++)
paramVector[i][j] = (float) parameters[j];
paramVector[i][j] = (float) parameters[j];
...
...
platforms/opencl/src/kernels/customCentroidBond.cl
View file @
4a3f1743
...
@@ -27,30 +27,35 @@ __kernel void computeGroupCenters(__global const real4* restrict posq, __global
...
@@ -27,30 +27,35 @@ __kernel void computeGroupCenters(__global const real4* restrict posq, __global
temp[thread].x
=
center.x
;
temp[thread].x
=
center.x
;
temp[thread].y
=
center.y
;
temp[thread].y
=
center.y
;
temp[thread].z
=
center.z
;
temp[thread].z
=
center.z
;
__syncthreads
(
)
;
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
if
(
thread
<
32
)
{
if
(
thread
<
32
)
{
temp[thread].x
+=
temp[thread+32].x
;
temp[thread].x
+=
temp[thread+32].x
;
temp[thread].y
+=
temp[thread+32].y
;
temp[thread].y
+=
temp[thread+32].y
;
temp[thread].z
+=
temp[thread+32].z
;
temp[thread].z
+=
temp[thread+32].z
;
SYNC_WARPS
;
if
(
thread
<
16
)
{
if
(
thread
<
16
)
{
temp[thread].x
+=
temp[thread+16].x
;
temp[thread].x
+=
temp[thread+16].x
;
temp[thread].y
+=
temp[thread+16].y
;
temp[thread].y
+=
temp[thread+16].y
;
temp[thread].z
+=
temp[thread+16].z
;
temp[thread].z
+=
temp[thread+16].z
;
SYNC_WARPS
;
}
}
if
(
thread
<
8
)
{
if
(
thread
<
8
)
{
temp[thread].x
+=
temp[thread+8].x
;
temp[thread].x
+=
temp[thread+8].x
;
temp[thread].y
+=
temp[thread+8].y
;
temp[thread].y
+=
temp[thread+8].y
;
temp[thread].z
+=
temp[thread+8].z
;
temp[thread].z
+=
temp[thread+8].z
;
SYNC_WARPS
;
}
}
if
(
thread
<
4
)
{
if
(
thread
<
4
)
{
temp[thread].x
+=
temp[thread+4].x
;
temp[thread].x
+=
temp[thread+4].x
;
temp[thread].y
+=
temp[thread+4].y
;
temp[thread].y
+=
temp[thread+4].y
;
temp[thread].z
+=
temp[thread+4].z
;
temp[thread].z
+=
temp[thread+4].z
;
SYNC_WARPS
;
}
}
if
(
thread
<
2
)
{
if
(
thread
<
2
)
{
temp[thread].x
+=
temp[thread+2].x
;
temp[thread].x
+=
temp[thread+2].x
;
temp[thread].y
+=
temp[thread+2].y
;
temp[thread].y
+=
temp[thread+2].y
;
temp[thread].z
+=
temp[thread+2].z
;
temp[thread].z
+=
temp[thread+2].z
;
SYNC_WARPS
;
}
}
}
}
if
(
thread
==
0
)
if
(
thread
==
0
)
...
...
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