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
8fe2b5a5
Unverified
Commit
8fe2b5a5
authored
Mar 27, 2018
by
peastman
Committed by
GitHub
Mar 27, 2018
Browse files
Merge pull request #2024 from peastman/copyparams
Optimizations to updateParametersInContext()
parents
6b32fc32
af57bf98
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
50 deletions
+70
-50
platforms/cuda/src/CudaContext.cpp
platforms/cuda/src/CudaContext.cpp
+29
-23
platforms/cuda/src/CudaKernels.cpp
platforms/cuda/src/CudaKernels.cpp
+6
-2
platforms/opencl/src/OpenCLContext.cpp
platforms/opencl/src/OpenCLContext.cpp
+29
-23
platforms/opencl/src/OpenCLKernels.cpp
platforms/opencl/src/OpenCLKernels.cpp
+6
-2
No files found.
platforms/cuda/src/CudaContext.cpp
View file @
8fe2b5a5
...
...
@@ -1119,33 +1119,39 @@ bool CudaContext::invalidateMolecules(CudaForceInfo* force) {
for
(
int
i
=
0
;
i
<
forces
.
size
();
i
++
)
if
(
forces
[
i
]
==
force
)
forceIndex
=
i
;
for
(
int
group
=
0
;
valid
&&
group
<
(
int
)
moleculeGroups
.
size
();
group
++
)
{
MoleculeGroup
&
mol
=
moleculeGroups
[
group
];
vector
<
int
>&
instances
=
mol
.
instances
;
vector
<
int
>&
offsets
=
mol
.
offsets
;
vector
<
int
>&
atoms
=
mol
.
atoms
;
int
numMolecules
=
instances
.
size
();
Molecule
&
m1
=
molecules
[
instances
[
0
]];
int
offset1
=
offsets
[
0
];
for
(
int
j
=
1
;
valid
&&
j
<
numMolecules
;
j
++
)
{
// See if the atoms are identical.
Molecule
&
m2
=
molecules
[
instances
[
j
]];
int
offset2
=
offsets
[
j
];
for
(
int
i
=
0
;
i
<
(
int
)
atoms
.
size
()
&&
valid
;
i
++
)
{
if
(
!
force
->
areParticlesIdentical
(
atoms
[
i
]
+
offset1
,
atoms
[
i
]
+
offset2
))
valid
=
false
;
}
getPlatformData
().
threads
.
execute
([
&
]
(
ThreadPool
&
threads
,
int
threadIndex
)
{
for
(
int
group
=
0
;
valid
&&
group
<
(
int
)
moleculeGroups
.
size
();
group
++
)
{
MoleculeGroup
&
mol
=
moleculeGroups
[
group
];
vector
<
int
>&
instances
=
mol
.
instances
;
vector
<
int
>&
offsets
=
mol
.
offsets
;
vector
<
int
>&
atoms
=
mol
.
atoms
;
int
numMolecules
=
instances
.
size
();
Molecule
&
m1
=
molecules
[
instances
[
0
]];
int
offset1
=
offsets
[
0
];
int
numThreads
=
threads
.
getNumThreads
();
int
start
=
max
(
1
,
threadIndex
*
numMolecules
/
numThreads
);
int
end
=
(
threadIndex
+
1
)
*
numMolecules
/
numThreads
;
for
(
int
j
=
start
;
j
<
end
;
j
++
)
{
// See if the atoms are identical.
Molecule
&
m2
=
molecules
[
instances
[
j
]];
int
offset2
=
offsets
[
j
];
for
(
int
i
=
0
;
i
<
(
int
)
atoms
.
size
()
&&
valid
;
i
++
)
{
if
(
!
force
->
areParticlesIdentical
(
atoms
[
i
]
+
offset1
,
atoms
[
i
]
+
offset2
))
valid
=
false
;
}
// See if the force groups are identical.
// See if the force groups are identical.
if
(
valid
&&
forceIndex
>
-
1
)
{
for
(
int
k
=
0
;
k
<
(
int
)
m1
.
groups
[
forceIndex
].
size
()
&&
valid
;
k
++
)
if
(
!
force
->
areGroupsIdentical
(
m1
.
groups
[
forceIndex
][
k
],
m2
.
groups
[
forceIndex
][
k
]))
valid
=
false
;
if
(
valid
&&
forceIndex
>
-
1
)
{
for
(
int
k
=
0
;
k
<
(
int
)
m1
.
groups
[
forceIndex
].
size
()
&&
valid
;
k
++
)
if
(
!
force
->
areGroupsIdentical
(
m1
.
groups
[
forceIndex
][
k
],
m2
.
groups
[
forceIndex
][
k
]))
valid
=
false
;
}
}
}
}
});
getPlatformData
().
threads
.
waitForThreads
();
if
(
valid
)
return
false
;
...
...
platforms/cuda/src/CudaKernels.cpp
View file @
8fe2b5a5
...
...
@@ -2165,7 +2165,7 @@ void CudaCalcNonbondedForceKernel::copyParametersToContext(ContextImpl& context,
// Record the per-particle parameters.
vector<double> chargeVector(cu.getNumAtoms());
vector<float2> sigmaEpsilonVector(cu.getPaddedNumAtoms()
, make_float2(0, 0)
);
vector<float2> sigmaEpsilonVector(cu.getPaddedNumAtoms());
double sumSquaredCharges = 0.0;
double sumSquaredC6 = 0.0;
const vector<int>& order = cu.getAtomIndex();
...
...
@@ -2180,6 +2180,8 @@ void CudaCalcNonbondedForceKernel::copyParametersToContext(ContextImpl& context,
sumSquaredC6 += C6*C6;
sumSquaredCharges += charge*charge;
}
for (int i = force.getNumParticles(); i < cu.getPaddedNumAtoms(); i++)
sigmaEpsilonVector[i] = make_float2(0,0);
cu.setCharges(chargeVector);
sigmaEpsilon.upload(sigmaEpsilonVector);
...
...
@@ -2977,7 +2979,7 @@ void CudaCalcGBSAOBCForceKernel::copyParametersToContext(ContextImpl& context, c
// Record the per-particle parameters.
vector<double> chargeVector(cu.getNumAtoms());
vector<float2> paramsVector(cu.getPaddedNumAtoms()
, make_float2(1, 1)
);
vector<float2> paramsVector(cu.getPaddedNumAtoms());
const double dielectricOffset = 0.009;
for (int i = 0; i < numParticles; i++) {
double charge, radius, scalingFactor;
...
...
@@ -2986,6 +2988,8 @@ void CudaCalcGBSAOBCForceKernel::copyParametersToContext(ContextImpl& context, c
radius -= dielectricOffset;
paramsVector[i] = make_float2((float) radius, (float) (scalingFactor*radius));
}
for (int i = numParticles; i < cu.getPaddedNumAtoms(); i++)
paramsVector[i] = make_float2(1, 1);
cu.setCharges(chargeVector);
params.upload(paramsVector);
...
...
platforms/opencl/src/OpenCLContext.cpp
View file @
8fe2b5a5
...
...
@@ -1006,33 +1006,39 @@ bool OpenCLContext::invalidateMolecules(OpenCLForceInfo* force) {
for
(
int
i
=
0
;
i
<
forces
.
size
();
i
++
)
if
(
forces
[
i
]
==
force
)
forceIndex
=
i
;
for
(
int
group
=
0
;
valid
&&
group
<
(
int
)
moleculeGroups
.
size
();
group
++
)
{
MoleculeGroup
&
mol
=
moleculeGroups
[
group
];
vector
<
int
>&
instances
=
mol
.
instances
;
vector
<
int
>&
offsets
=
mol
.
offsets
;
vector
<
int
>&
atoms
=
mol
.
atoms
;
int
numMolecules
=
instances
.
size
();
Molecule
&
m1
=
molecules
[
instances
[
0
]];
int
offset1
=
offsets
[
0
];
for
(
int
j
=
1
;
valid
&&
j
<
numMolecules
;
j
++
)
{
// See if the atoms are identical.
Molecule
&
m2
=
molecules
[
instances
[
j
]];
int
offset2
=
offsets
[
j
];
for
(
int
i
=
0
;
i
<
(
int
)
atoms
.
size
()
&&
valid
;
i
++
)
{
if
(
!
force
->
areParticlesIdentical
(
atoms
[
i
]
+
offset1
,
atoms
[
i
]
+
offset2
))
valid
=
false
;
}
getPlatformData
().
threads
.
execute
([
&
]
(
ThreadPool
&
threads
,
int
threadIndex
)
{
for
(
int
group
=
0
;
valid
&&
group
<
(
int
)
moleculeGroups
.
size
();
group
++
)
{
MoleculeGroup
&
mol
=
moleculeGroups
[
group
];
vector
<
int
>&
instances
=
mol
.
instances
;
vector
<
int
>&
offsets
=
mol
.
offsets
;
vector
<
int
>&
atoms
=
mol
.
atoms
;
int
numMolecules
=
instances
.
size
();
Molecule
&
m1
=
molecules
[
instances
[
0
]];
int
offset1
=
offsets
[
0
];
int
numThreads
=
threads
.
getNumThreads
();
int
start
=
max
(
1
,
threadIndex
*
numMolecules
/
numThreads
);
int
end
=
(
threadIndex
+
1
)
*
numMolecules
/
numThreads
;
for
(
int
j
=
start
;
j
<
end
;
j
++
)
{
// See if the atoms are identical.
Molecule
&
m2
=
molecules
[
instances
[
j
]];
int
offset2
=
offsets
[
j
];
for
(
int
i
=
0
;
i
<
(
int
)
atoms
.
size
();
i
++
)
{
if
(
!
force
->
areParticlesIdentical
(
atoms
[
i
]
+
offset1
,
atoms
[
i
]
+
offset2
))
valid
=
false
;
}
// See if the force groups are identical.
// See if the force groups are identical.
if
(
valid
&&
forceIndex
>
-
1
)
{
for
(
int
k
=
0
;
k
<
(
int
)
m1
.
groups
[
forceIndex
].
size
()
&&
valid
;
k
++
)
if
(
!
force
->
areGroupsIdentical
(
m1
.
groups
[
forceIndex
][
k
],
m2
.
groups
[
forceIndex
][
k
]))
valid
=
false
;
if
(
valid
&&
forceIndex
>
-
1
)
{
for
(
int
k
=
0
;
k
<
(
int
)
m1
.
groups
[
forceIndex
].
size
();
k
++
)
if
(
!
force
->
areGroupsIdentical
(
m1
.
groups
[
forceIndex
][
k
],
m2
.
groups
[
forceIndex
][
k
]))
valid
=
false
;
}
}
}
}
});
getPlatformData
().
threads
.
waitForThreads
();
if
(
valid
)
return
false
;
...
...
platforms/opencl/src/OpenCLKernels.cpp
View file @
8fe2b5a5
...
...
@@ -2296,7 +2296,7 @@ void OpenCLCalcNonbondedForceKernel::copyParametersToContext(ContextImpl& contex
// Record the per-particle parameters.
vector<double> chargeVector(cl.getNumAtoms());
vector<mm_float2> sigmaEpsilonVector(cl.getPaddedNumAtoms()
, mm_float2(0,0)
);
vector<mm_float2> sigmaEpsilonVector(cl.getPaddedNumAtoms());
double sumSquaredCharges = 0.0;
for (int i = 0; i < force.getNumParticles(); i++) {
double charge, sigma, epsilon;
...
...
@@ -2305,6 +2305,8 @@ void OpenCLCalcNonbondedForceKernel::copyParametersToContext(ContextImpl& contex
sigmaEpsilonVector[i] = mm_float2((float) (0.5*sigma), (float) (2.0*sqrt(epsilon)));
sumSquaredCharges += charge*charge;
}
for (int i = force.getNumParticles(); i < cl.getPaddedNumAtoms(); i++)
sigmaEpsilonVector[i] = mm_float2(0,0);
cl.setCharges(chargeVector);
sigmaEpsilon.upload(sigmaEpsilonVector);
...
...
@@ -3123,7 +3125,7 @@ void OpenCLCalcGBSAOBCForceKernel::copyParametersToContext(ContextImpl& context,
// Record the per-particle parameters.
vector<double> chargeVector(cl.getNumAtoms());
vector<mm_float2> paramsVector(cl.getPaddedNumAtoms()
, mm_float2(1,1)
);
vector<mm_float2> paramsVector(cl.getPaddedNumAtoms());
const double dielectricOffset = 0.009;
for (int i = 0; i < numParticles; i++) {
double charge, radius, scalingFactor;
...
...
@@ -3132,6 +3134,8 @@ void OpenCLCalcGBSAOBCForceKernel::copyParametersToContext(ContextImpl& context,
radius -= dielectricOffset;
paramsVector[i] = mm_float2((float) radius, (float) (scalingFactor*radius));
}
for (int i = numParticles; i < cl.getPaddedNumAtoms(); i++)
paramsVector[i] = mm_float2(1,1);
cl.setCharges(chargeVector);
params.upload(paramsVector);
...
...
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