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
6a14b5b1
Commit
6a14b5b1
authored
Nov 22, 2012
by
Peter Eastman
Browse files
Avoid errors in updateParametersInContext() when a force contains no bonds.
parent
38071b45
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
34 deletions
+92
-34
platforms/cuda/src/CudaKernels.cpp
platforms/cuda/src/CudaKernels.cpp
+40
-17
platforms/opencl/src/OpenCLKernels.cpp
platforms/opencl/src/OpenCLKernels.cpp
+40
-17
plugins/amoeba/platforms/cuda/src/AmoebaCudaKernels.cpp
plugins/amoeba/platforms/cuda/src/AmoebaCudaKernels.cpp
+12
-0
No files found.
platforms/cuda/src/CudaKernels.cpp
View file @
6a14b5b1
...
...
@@ -477,6 +477,8 @@ void CudaCalcHarmonicBondForceKernel::copyParametersToContext(ContextImpl& conte
int
endIndex
=
(
cu
.
getContextIndex
()
+
1
)
*
force
.
getNumBonds
()
/
numContexts
;
if
(
numBonds
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of bonds has changed"
);
if
(
numBonds
==
0
)
return
;
// Record the per-bond parameters.
...
...
@@ -619,6 +621,8 @@ void CudaCalcCustomBondForceKernel::copyParametersToContext(ContextImpl& context
int
endIndex
=
(
cu
.
getContextIndex
()
+
1
)
*
force
.
getNumBonds
()
/
numContexts
;
if
(
numBonds
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of bonds has changed"
);
if
(
numBonds
==
0
)
return
;
// Record the per-bond parameters.
...
...
@@ -707,6 +711,8 @@ void CudaCalcHarmonicAngleForceKernel::copyParametersToContext(ContextImpl& cont
int
endIndex
=
(
cu
.
getContextIndex
()
+
1
)
*
force
.
getNumAngles
()
/
numContexts
;
if
(
numAngles
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of angles has changed"
);
if
(
numAngles
==
0
)
return
;
// Record the per-angle parameters.
...
...
@@ -850,6 +856,8 @@ void CudaCalcCustomAngleForceKernel::copyParametersToContext(ContextImpl& contex
int
endIndex
=
(
cu
.
getContextIndex
()
+
1
)
*
force
.
getNumAngles
()
/
numContexts
;
if
(
numAngles
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of angles has changed"
);
if
(
numAngles
==
0
)
return
;
// Record the per-angle parameters.
...
...
@@ -939,6 +947,8 @@ void CudaCalcPeriodicTorsionForceKernel::copyParametersToContext(ContextImpl& co
int
endIndex
=
(
cu
.
getContextIndex
()
+
1
)
*
force
.
getNumTorsions
()
/
numContexts
;
if
(
numTorsions
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of torsions has changed"
);
if
(
numTorsions
==
0
)
return
;
// Record the per-torsion parameters.
...
...
@@ -1033,6 +1043,8 @@ void CudaCalcRBTorsionForceKernel::copyParametersToContext(ContextImpl& context,
int
endIndex
=
(
cu
.
getContextIndex
()
+
1
)
*
force
.
getNumTorsions
()
/
numContexts
;
if
(
numTorsions
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of torsions has changed"
);
if
(
numTorsions
==
0
)
return
;
// Record the per-torsion parameters.
...
...
@@ -1267,6 +1279,8 @@ void CudaCalcCustomTorsionForceKernel::copyParametersToContext(ContextImpl& cont
int
endIndex
=
(
cu
.
getContextIndex
()
+
1
)
*
force
.
getNumTorsions
()
/
numContexts
;
if
(
numTorsions
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of torsions has changed"
);
if
(
numTorsions
==
0
)
return
;
// Record the per-torsion parameters.
...
...
@@ -3112,6 +3126,8 @@ void CudaCalcCustomExternalForceKernel::copyParametersToContext(ContextImpl& con
int
endIndex
=
(
cu
.
getContextIndex
()
+
1
)
*
force
.
getNumParticles
()
/
numContexts
;
if
(
numParticles
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of particles has changed"
);
if
(
numParticles
==
0
)
return
;
// Record the per-particle parameters.
...
...
@@ -3622,28 +3638,33 @@ void CudaCalcCustomHbondForceKernel::copyParametersToContext(ContextImpl& contex
// Record the per-donor parameters.
vector
<
vector
<
float
>
>
donorParamVector
(
numDonors
);
vector
<
double
>
parameters
;
for
(
int
i
=
0
;
i
<
numDonors
;
i
++
)
{
int
d1
,
d2
,
d3
;
force
.
getDonorParameters
(
startIndex
+
i
,
d1
,
d2
,
d3
,
parameters
);
donorParamVector
[
i
].
resize
(
parameters
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
parameters
.
size
();
j
++
)
donorParamVector
[
i
][
j
]
=
(
float
)
parameters
[
j
];
if
(
numDonors
>
0
)
{
vector
<
vector
<
float
>
>
donorParamVector
(
numDonors
);
vector
<
double
>
parameters
;
for
(
int
i
=
0
;
i
<
numDonors
;
i
++
)
{
int
d1
,
d2
,
d3
;
force
.
getDonorParameters
(
startIndex
+
i
,
d1
,
d2
,
d3
,
parameters
);
donorParamVector
[
i
].
resize
(
parameters
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
parameters
.
size
();
j
++
)
donorParamVector
[
i
][
j
]
=
(
float
)
parameters
[
j
];
}
donorParams
->
setParameterValues
(
donorParamVector
);
}
donorParams
->
setParameterValues
(
donorParamVector
);
// Record the per-acceptor parameters.
vector
<
vector
<
float
>
>
acceptorParamVector
(
numAcceptors
);
for
(
int
i
=
0
;
i
<
numAcceptors
;
i
++
)
{
int
a1
,
a2
,
a3
;
force
.
getAcceptorParameters
(
i
,
a1
,
a2
,
a3
,
parameters
);
acceptorParamVector
[
i
].
resize
(
parameters
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
parameters
.
size
();
j
++
)
acceptorParamVector
[
i
][
j
]
=
(
float
)
parameters
[
j
];
if
(
numAcceptors
>
0
)
{
vector
<
vector
<
float
>
>
acceptorParamVector
(
numAcceptors
);
vector
<
double
>
parameters
;
for
(
int
i
=
0
;
i
<
numAcceptors
;
i
++
)
{
int
a1
,
a2
,
a3
;
force
.
getAcceptorParameters
(
i
,
a1
,
a2
,
a3
,
parameters
);
acceptorParamVector
[
i
].
resize
(
parameters
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
parameters
.
size
();
j
++
)
acceptorParamVector
[
i
][
j
]
=
(
float
)
parameters
[
j
];
}
acceptorParams
->
setParameterValues
(
acceptorParamVector
);
}
acceptorParams
->
setParameterValues
(
acceptorParamVector
);
// Mark that the current reordering may be invalid.
...
...
@@ -3951,6 +3972,8 @@ void CudaCalcCustomCompoundBondForceKernel::copyParametersToContext(ContextImpl&
int
endIndex
=
(
cu
.
getContextIndex
()
+
1
)
*
force
.
getNumBonds
()
/
numContexts
;
if
(
numBonds
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of bonds has changed"
);
if
(
numBonds
==
0
)
return
;
// Record the per-bond parameters.
...
...
platforms/opencl/src/OpenCLKernels.cpp
View file @
6a14b5b1
...
...
@@ -499,6 +499,8 @@ void OpenCLCalcHarmonicBondForceKernel::copyParametersToContext(ContextImpl& con
int
endIndex
=
(
cl
.
getContextIndex
()
+
1
)
*
force
.
getNumBonds
()
/
numContexts
;
if
(
numBonds
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of bonds has changed"
);
if
(
numBonds
==
0
)
return
;
// Record the per-bond parameters.
...
...
@@ -638,6 +640,8 @@ void OpenCLCalcCustomBondForceKernel::copyParametersToContext(ContextImpl& conte
int
endIndex
=
(
cl
.
getContextIndex
()
+
1
)
*
force
.
getNumBonds
()
/
numContexts
;
if
(
numBonds
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of bonds has changed"
);
if
(
numBonds
==
0
)
return
;
// Record the per-bond parameters.
...
...
@@ -723,6 +727,8 @@ void OpenCLCalcHarmonicAngleForceKernel::copyParametersToContext(ContextImpl& co
int
endIndex
=
(
cl
.
getContextIndex
()
+
1
)
*
force
.
getNumAngles
()
/
numContexts
;
if
(
numAngles
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of angles has changed"
);
if
(
numAngles
==
0
)
return
;
// Record the per-angle parameters.
...
...
@@ -863,6 +869,8 @@ void OpenCLCalcCustomAngleForceKernel::copyParametersToContext(ContextImpl& cont
int
endIndex
=
(
cl
.
getContextIndex
()
+
1
)
*
force
.
getNumAngles
()
/
numContexts
;
if
(
numAngles
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of angles has changed"
);
if
(
numAngles
==
0
)
return
;
// Record the per-angle parameters.
...
...
@@ -949,6 +957,8 @@ void OpenCLCalcPeriodicTorsionForceKernel::copyParametersToContext(ContextImpl&
int
endIndex
=
(
cl
.
getContextIndex
()
+
1
)
*
force
.
getNumTorsions
()
/
numContexts
;
if
(
numTorsions
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of torsions has changed"
);
if
(
numTorsions
==
0
)
return
;
// Record the per-torsion parameters.
...
...
@@ -1033,6 +1043,8 @@ void OpenCLCalcRBTorsionForceKernel::copyParametersToContext(ContextImpl& contex
int
endIndex
=
(
cl
.
getContextIndex
()
+
1
)
*
force
.
getNumTorsions
()
/
numContexts
;
if
(
numTorsions
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of torsions has changed"
);
if
(
numTorsions
==
0
)
return
;
// Record the per-torsion parameters.
...
...
@@ -1261,6 +1273,8 @@ void OpenCLCalcCustomTorsionForceKernel::copyParametersToContext(ContextImpl& co
int
endIndex
=
(
cl
.
getContextIndex
()
+
1
)
*
force
.
getNumTorsions
()
/
numContexts
;
if
(
numTorsions
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of torsions has changed"
);
if
(
numTorsions
==
0
)
return
;
// Record the per-torsion parameters.
...
...
@@ -3272,6 +3286,8 @@ void OpenCLCalcCustomExternalForceKernel::copyParametersToContext(ContextImpl& c
int
endIndex
=
(
cl
.
getContextIndex
()
+
1
)
*
force
.
getNumParticles
()
/
numContexts
;
if
(
numParticles
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of particles has changed"
);
if
(
numParticles
==
0
)
return
;
// Record the per-particle parameters.
...
...
@@ -3812,28 +3828,33 @@ void OpenCLCalcCustomHbondForceKernel::copyParametersToContext(ContextImpl& cont
// Record the per-donor parameters.
vector
<
vector
<
cl_float
>
>
donorParamVector
(
numDonors
);
vector
<
double
>
parameters
;
for
(
int
i
=
0
;
i
<
numDonors
;
i
++
)
{
int
d1
,
d2
,
d3
;
force
.
getDonorParameters
(
startIndex
+
i
,
d1
,
d2
,
d3
,
parameters
);
donorParamVector
[
i
].
resize
(
parameters
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
parameters
.
size
();
j
++
)
donorParamVector
[
i
][
j
]
=
(
cl_float
)
parameters
[
j
];
if
(
numDonors
>
0
)
{
vector
<
vector
<
cl_float
>
>
donorParamVector
(
numDonors
);
vector
<
double
>
parameters
;
for
(
int
i
=
0
;
i
<
numDonors
;
i
++
)
{
int
d1
,
d2
,
d3
;
force
.
getDonorParameters
(
startIndex
+
i
,
d1
,
d2
,
d3
,
parameters
);
donorParamVector
[
i
].
resize
(
parameters
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
parameters
.
size
();
j
++
)
donorParamVector
[
i
][
j
]
=
(
cl_float
)
parameters
[
j
];
}
donorParams
->
setParameterValues
(
donorParamVector
);
}
donorParams
->
setParameterValues
(
donorParamVector
);
// Record the per-acceptor parameters.
vector
<
vector
<
cl_float
>
>
acceptorParamVector
(
numAcceptors
);
for
(
int
i
=
0
;
i
<
numAcceptors
;
i
++
)
{
int
a1
,
a2
,
a3
;
force
.
getAcceptorParameters
(
i
,
a1
,
a2
,
a3
,
parameters
);
acceptorParamVector
[
i
].
resize
(
parameters
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
parameters
.
size
();
j
++
)
acceptorParamVector
[
i
][
j
]
=
(
cl_float
)
parameters
[
j
];
if
(
numAcceptors
>
0
)
{
vector
<
vector
<
cl_float
>
>
acceptorParamVector
(
numAcceptors
);
vector
<
double
>
parameters
;
for
(
int
i
=
0
;
i
<
numAcceptors
;
i
++
)
{
int
a1
,
a2
,
a3
;
force
.
getAcceptorParameters
(
i
,
a1
,
a2
,
a3
,
parameters
);
acceptorParamVector
[
i
].
resize
(
parameters
.
size
());
for
(
int
j
=
0
;
j
<
(
int
)
parameters
.
size
();
j
++
)
acceptorParamVector
[
i
][
j
]
=
(
cl_float
)
parameters
[
j
];
}
acceptorParams
->
setParameterValues
(
acceptorParamVector
);
}
acceptorParams
->
setParameterValues
(
acceptorParamVector
);
// Mark that the current reordering may be invalid.
...
...
@@ -4138,6 +4159,8 @@ void OpenCLCalcCustomCompoundBondForceKernel::copyParametersToContext(ContextImp
int
endIndex
=
(
cl
.
getContextIndex
()
+
1
)
*
force
.
getNumBonds
()
/
numContexts
;
if
(
numBonds
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of bonds has changed"
);
if
(
numBonds
==
0
)
return
;
// Record the per-bond parameters.
...
...
plugins/amoeba/platforms/cuda/src/AmoebaCudaKernels.cpp
View file @
6a14b5b1
...
...
@@ -130,6 +130,8 @@ void CudaCalcAmoebaBondForceKernel::copyParametersToContext(ContextImpl& context
int
endIndex
=
(
cu
.
getContextIndex
()
+
1
)
*
force
.
getNumBonds
()
/
numContexts
;
if
(
numBonds
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of bonds has changed"
);
if
(
numBonds
==
0
)
return
;
// Record the per-bond parameters.
...
...
@@ -228,6 +230,8 @@ void CudaCalcAmoebaAngleForceKernel::copyParametersToContext(ContextImpl& contex
int
endIndex
=
(
cu
.
getContextIndex
()
+
1
)
*
force
.
getNumAngles
()
/
numContexts
;
if
(
numAngles
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of angles has changed"
);
if
(
numAngles
==
0
)
return
;
// Record the per-angle parameters.
...
...
@@ -326,6 +330,8 @@ void CudaCalcAmoebaInPlaneAngleForceKernel::copyParametersToContext(ContextImpl&
int
endIndex
=
(
cu
.
getContextIndex
()
+
1
)
*
force
.
getNumAngles
()
/
numContexts
;
if
(
numAngles
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of in-plane angles has changed"
);
if
(
numAngles
==
0
)
return
;
// Record the per-angle parameters.
...
...
@@ -421,6 +427,8 @@ void CudaCalcAmoebaPiTorsionForceKernel::copyParametersToContext(ContextImpl& co
int
endIndex
=
(
cu
.
getContextIndex
()
+
1
)
*
force
.
getNumPiTorsions
()
/
numContexts
;
if
(
numPiTorsions
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of torsions has changed"
);
if
(
numPiTorsions
==
0
)
return
;
// Record the per-torsion parameters.
...
...
@@ -514,6 +522,8 @@ void CudaCalcAmoebaStretchBendForceKernel::copyParametersToContext(ContextImpl&
int
endIndex
=
(
cu
.
getContextIndex
()
+
1
)
*
force
.
getNumStretchBends
()
/
numContexts
;
if
(
numStretchBends
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of bend-stretch terms has changed"
);
if
(
numStretchBends
==
0
)
return
;
// Record the per-stretch-bend parameters.
...
...
@@ -612,6 +622,8 @@ void CudaCalcAmoebaOutOfPlaneBendForceKernel::copyParametersToContext(ContextImp
int
endIndex
=
(
cu
.
getContextIndex
()
+
1
)
*
force
.
getNumOutOfPlaneBends
()
/
numContexts
;
if
(
numOutOfPlaneBends
!=
endIndex
-
startIndex
)
throw
OpenMMException
(
"updateParametersInContext: The number of out-of-plane bends has changed"
);
if
(
numOutOfPlaneBends
==
0
)
return
;
// Record the per-bend parameters.
...
...
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