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
97840b96
Unverified
Commit
97840b96
authored
Oct 15, 2018
by
peastman
Committed by
GitHub
Oct 15, 2018
Browse files
Merge pull request #2189 from peastman/drudeparallel
Fixed error using DrudeForce with multiple GPUs
parents
f8dcb728
b494be1a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
36 deletions
+24
-36
plugins/drude/platforms/cuda/src/CudaDrudeKernels.cpp
plugins/drude/platforms/cuda/src/CudaDrudeKernels.cpp
+12
-18
plugins/drude/platforms/opencl/src/OpenCLDrudeKernels.cpp
plugins/drude/platforms/opencl/src/OpenCLDrudeKernels.cpp
+12
-18
No files found.
plugins/drude/platforms/cuda/src/CudaDrudeKernels.cpp
View file @
97840b96
...
...
@@ -102,10 +102,9 @@ private:
void
CudaCalcDrudeForceKernel
::
initialize
(
const
System
&
system
,
const
DrudeForce
&
force
)
{
cu
.
setAsCurrent
();
int
numContexts
=
cu
.
getPlatformData
().
contexts
.
size
();
int
startParticleIndex
=
cu
.
getContextIndex
()
*
force
.
getNumParticles
()
/
numContexts
;
int
endParticleIndex
=
(
cu
.
getContextIndex
()
+
1
)
*
force
.
getNumParticles
()
/
numContexts
;
int
numParticles
=
endParticleIndex
-
startParticleIndex
;
if
(
cu
.
getContextIndex
()
!=
0
)
return
;
// This is run entirely on one device
int
numParticles
=
force
.
getNumParticles
();
if
(
numParticles
>
0
)
{
// Create the harmonic interaction .
...
...
@@ -114,7 +113,7 @@ void CudaCalcDrudeForceKernel::initialize(const System& system, const DrudeForce
vector
<
float4
>
paramVector
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
double
charge
,
polarizability
,
aniso12
,
aniso34
;
force
.
getParticleParameters
(
startParticleIndex
+
i
,
atoms
[
i
][
0
],
atoms
[
i
][
1
],
atoms
[
i
][
2
],
atoms
[
i
][
3
],
atoms
[
i
][
4
],
charge
,
polarizability
,
aniso12
,
aniso34
);
force
.
getParticleParameters
(
i
,
atoms
[
i
][
0
],
atoms
[
i
][
1
],
atoms
[
i
][
2
],
atoms
[
i
][
3
],
atoms
[
i
][
4
],
charge
,
polarizability
,
aniso12
,
aniso34
);
double
a1
=
(
atoms
[
i
][
2
]
==
-
1
?
1
:
aniso12
);
double
a2
=
(
atoms
[
i
][
3
]
==
-
1
||
atoms
[
i
][
4
]
==
-
1
?
1
:
aniso34
);
double
a3
=
3
-
a1
-
a2
;
...
...
@@ -137,9 +136,7 @@ void CudaCalcDrudeForceKernel::initialize(const System& system, const DrudeForce
replacements
[
"PARAMS"
]
=
cu
.
getBondedUtilities
().
addArgument
(
particleParams
.
getDevicePointer
(),
"float4"
);
cu
.
getBondedUtilities
().
addInteraction
(
atoms
,
cu
.
replaceStrings
(
CudaDrudeKernelSources
::
drudeParticleForce
,
replacements
),
force
.
getForceGroup
());
}
int
startPairIndex
=
cu
.
getContextIndex
()
*
force
.
getNumScreenedPairs
()
/
numContexts
;
int
endPairIndex
=
(
cu
.
getContextIndex
()
+
1
)
*
force
.
getNumScreenedPairs
()
/
numContexts
;
int
numPairs
=
endPairIndex
-
startPairIndex
;
int
numPairs
=
force
.
getNumScreenedPairs
();
if
(
numPairs
>
0
)
{
// Create the screened interaction between dipole pairs.
...
...
@@ -149,7 +146,7 @@ void CudaCalcDrudeForceKernel::initialize(const System& system, const DrudeForce
for
(
int
i
=
0
;
i
<
numPairs
;
i
++
)
{
int
drude1
,
drude2
;
double
thole
;
force
.
getScreenedPairParameters
(
startPairIndex
+
i
,
drude1
,
drude2
,
thole
);
force
.
getScreenedPairParameters
(
i
,
drude1
,
drude2
,
thole
);
int
p2
,
p3
,
p4
;
double
charge1
,
charge2
,
polarizability1
,
polarizability2
,
aniso12
,
aniso34
;
force
.
getParticleParameters
(
drude1
,
atoms
[
i
][
0
],
atoms
[
i
][
1
],
p2
,
p3
,
p4
,
charge1
,
polarizability1
,
aniso12
,
aniso34
);
...
...
@@ -171,13 +168,12 @@ double CudaCalcDrudeForceKernel::execute(ContextImpl& context, bool includeForce
}
void
CudaCalcDrudeForceKernel
::
copyParametersToContext
(
ContextImpl
&
context
,
const
DrudeForce
&
force
)
{
int
numContexts
=
cu
.
getPlatformData
().
contexts
.
size
();
if
(
cu
.
getContextIndex
()
!=
0
)
return
;
// This is run entirely on one device
// Set the particle parameters.
int
startParticleIndex
=
cu
.
getContextIndex
()
*
force
.
getNumParticles
()
/
numContexts
;
int
endParticleIndex
=
(
cu
.
getContextIndex
()
+
1
)
*
force
.
getNumParticles
()
/
numContexts
;
int
numParticles
=
endParticleIndex
-
startParticleIndex
;
int
numParticles
=
force
.
getNumParticles
();
if
(
numParticles
>
0
)
{
if
(
!
particleParams
.
isInitialized
()
||
numParticles
!=
particleParams
.
getSize
())
throw
OpenMMException
(
"updateParametersInContext: The number of Drude particles has changed"
);
...
...
@@ -185,7 +181,7 @@ void CudaCalcDrudeForceKernel::copyParametersToContext(ContextImpl& context, con
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
int
p
,
p1
,
p2
,
p3
,
p4
;
double
charge
,
polarizability
,
aniso12
,
aniso34
;
force
.
getParticleParameters
(
startParticleIndex
+
i
,
p
,
p1
,
p2
,
p3
,
p4
,
charge
,
polarizability
,
aniso12
,
aniso34
);
force
.
getParticleParameters
(
i
,
p
,
p1
,
p2
,
p3
,
p4
,
charge
,
polarizability
,
aniso12
,
aniso34
);
double
a1
=
(
p2
==
-
1
?
1
:
aniso12
);
double
a2
=
(
p3
==
-
1
||
p4
==
-
1
?
1
:
aniso34
);
double
a3
=
3
-
a1
-
a2
;
...
...
@@ -203,9 +199,7 @@ void CudaCalcDrudeForceKernel::copyParametersToContext(ContextImpl& context, con
// Set the pair parameters.
int
startPairIndex
=
cu
.
getContextIndex
()
*
force
.
getNumScreenedPairs
()
/
numContexts
;
int
endPairIndex
=
(
cu
.
getContextIndex
()
+
1
)
*
force
.
getNumScreenedPairs
()
/
numContexts
;
int
numPairs
=
endPairIndex
-
startPairIndex
;
int
numPairs
=
force
.
getNumScreenedPairs
();
if
(
numPairs
>
0
)
{
if
(
!
pairParams
.
isInitialized
()
||
numPairs
!=
pairParams
.
getSize
())
throw
OpenMMException
(
"updateParametersInContext: The number of screened pairs has changed"
);
...
...
@@ -213,7 +207,7 @@ void CudaCalcDrudeForceKernel::copyParametersToContext(ContextImpl& context, con
for
(
int
i
=
0
;
i
<
numPairs
;
i
++
)
{
int
drude1
,
drude2
;
double
thole
;
force
.
getScreenedPairParameters
(
startPairIndex
+
i
,
drude1
,
drude2
,
thole
);
force
.
getScreenedPairParameters
(
i
,
drude1
,
drude2
,
thole
);
int
p
,
p1
,
p2
,
p3
,
p4
;
double
charge1
,
charge2
,
polarizability1
,
polarizability2
,
aniso12
,
aniso34
;
force
.
getParticleParameters
(
drude1
,
p
,
p1
,
p2
,
p3
,
p4
,
charge1
,
polarizability1
,
aniso12
,
aniso34
);
...
...
plugins/drude/platforms/opencl/src/OpenCLDrudeKernels.cpp
View file @
97840b96
...
...
@@ -108,10 +108,9 @@ private:
};
void
OpenCLCalcDrudeForceKernel
::
initialize
(
const
System
&
system
,
const
DrudeForce
&
force
)
{
int
numContexts
=
cl
.
getPlatformData
().
contexts
.
size
();
int
startParticleIndex
=
cl
.
getContextIndex
()
*
force
.
getNumParticles
()
/
numContexts
;
int
endParticleIndex
=
(
cl
.
getContextIndex
()
+
1
)
*
force
.
getNumParticles
()
/
numContexts
;
int
numParticles
=
endParticleIndex
-
startParticleIndex
;
if
(
cl
.
getContextIndex
()
!=
0
)
return
;
// This is run entirely on one device
int
numParticles
=
force
.
getNumParticles
();
if
(
numParticles
>
0
)
{
// Create the harmonic interaction .
...
...
@@ -120,7 +119,7 @@ void OpenCLCalcDrudeForceKernel::initialize(const System& system, const DrudeFor
vector
<
mm_float4
>
paramVector
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
double
charge
,
polarizability
,
aniso12
,
aniso34
;
force
.
getParticleParameters
(
startParticleIndex
+
i
,
atoms
[
i
][
0
],
atoms
[
i
][
1
],
atoms
[
i
][
2
],
atoms
[
i
][
3
],
atoms
[
i
][
4
],
charge
,
polarizability
,
aniso12
,
aniso34
);
force
.
getParticleParameters
(
i
,
atoms
[
i
][
0
],
atoms
[
i
][
1
],
atoms
[
i
][
2
],
atoms
[
i
][
3
],
atoms
[
i
][
4
],
charge
,
polarizability
,
aniso12
,
aniso34
);
double
a1
=
(
atoms
[
i
][
2
]
==
-
1
?
1
:
aniso12
);
double
a2
=
(
atoms
[
i
][
3
]
==
-
1
||
atoms
[
i
][
4
]
==
-
1
?
1
:
aniso34
);
double
a3
=
3
-
a1
-
a2
;
...
...
@@ -143,9 +142,7 @@ void OpenCLCalcDrudeForceKernel::initialize(const System& system, const DrudeFor
replacements
[
"PARAMS"
]
=
cl
.
getBondedUtilities
().
addArgument
(
particleParams
.
getDeviceBuffer
(),
"float4"
);
cl
.
getBondedUtilities
().
addInteraction
(
atoms
,
cl
.
replaceStrings
(
OpenCLDrudeKernelSources
::
drudeParticleForce
,
replacements
),
force
.
getForceGroup
());
}
int
startPairIndex
=
cl
.
getContextIndex
()
*
force
.
getNumScreenedPairs
()
/
numContexts
;
int
endPairIndex
=
(
cl
.
getContextIndex
()
+
1
)
*
force
.
getNumScreenedPairs
()
/
numContexts
;
int
numPairs
=
endPairIndex
-
startPairIndex
;
int
numPairs
=
force
.
getNumScreenedPairs
();
if
(
numPairs
>
0
)
{
// Create the screened interaction between dipole pairs.
...
...
@@ -155,7 +152,7 @@ void OpenCLCalcDrudeForceKernel::initialize(const System& system, const DrudeFor
for
(
int
i
=
0
;
i
<
numPairs
;
i
++
)
{
int
drude1
,
drude2
;
double
thole
;
force
.
getScreenedPairParameters
(
startPairIndex
+
i
,
drude1
,
drude2
,
thole
);
force
.
getScreenedPairParameters
(
i
,
drude1
,
drude2
,
thole
);
int
p2
,
p3
,
p4
;
double
charge1
,
charge2
,
polarizability1
,
polarizability2
,
aniso12
,
aniso34
;
force
.
getParticleParameters
(
drude1
,
atoms
[
i
][
0
],
atoms
[
i
][
1
],
p2
,
p3
,
p4
,
charge1
,
polarizability1
,
aniso12
,
aniso34
);
...
...
@@ -177,13 +174,12 @@ double OpenCLCalcDrudeForceKernel::execute(ContextImpl& context, bool includeFor
}
void
OpenCLCalcDrudeForceKernel
::
copyParametersToContext
(
ContextImpl
&
context
,
const
DrudeForce
&
force
)
{
int
numContexts
=
cl
.
getPlatformData
().
contexts
.
size
();
if
(
cl
.
getContextIndex
()
!=
0
)
return
;
// This is run entirely on one device
// Set the particle parameters.
int
startParticleIndex
=
cl
.
getContextIndex
()
*
force
.
getNumParticles
()
/
numContexts
;
int
endParticleIndex
=
(
cl
.
getContextIndex
()
+
1
)
*
force
.
getNumParticles
()
/
numContexts
;
int
numParticles
=
endParticleIndex
-
startParticleIndex
;
int
numParticles
=
force
.
getNumParticles
();
if
(
numParticles
>
0
)
{
if
(
!
particleParams
.
isInitialized
()
||
numParticles
!=
particleParams
.
getSize
())
throw
OpenMMException
(
"updateParametersInContext: The number of Drude particles has changed"
);
...
...
@@ -191,7 +187,7 @@ void OpenCLCalcDrudeForceKernel::copyParametersToContext(ContextImpl& context, c
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
int
p
,
p1
,
p2
,
p3
,
p4
;
double
charge
,
polarizability
,
aniso12
,
aniso34
;
force
.
getParticleParameters
(
startParticleIndex
+
i
,
p
,
p1
,
p2
,
p3
,
p4
,
charge
,
polarizability
,
aniso12
,
aniso34
);
force
.
getParticleParameters
(
i
,
p
,
p1
,
p2
,
p3
,
p4
,
charge
,
polarizability
,
aniso12
,
aniso34
);
double
a1
=
(
p2
==
-
1
?
1
:
aniso12
);
double
a2
=
(
p3
==
-
1
||
p4
==
-
1
?
1
:
aniso34
);
double
a3
=
3
-
a1
-
a2
;
...
...
@@ -209,9 +205,7 @@ void OpenCLCalcDrudeForceKernel::copyParametersToContext(ContextImpl& context, c
// Set the pair parameters.
int
startPairIndex
=
cl
.
getContextIndex
()
*
force
.
getNumScreenedPairs
()
/
numContexts
;
int
endPairIndex
=
(
cl
.
getContextIndex
()
+
1
)
*
force
.
getNumScreenedPairs
()
/
numContexts
;
int
numPairs
=
endPairIndex
-
startPairIndex
;
int
numPairs
=
force
.
getNumScreenedPairs
();
if
(
numPairs
>
0
)
{
if
(
!
pairParams
.
isInitialized
()
||
numPairs
!=
pairParams
.
getSize
())
throw
OpenMMException
(
"updateParametersInContext: The number of screened pairs has changed"
);
...
...
@@ -219,7 +213,7 @@ void OpenCLCalcDrudeForceKernel::copyParametersToContext(ContextImpl& context, c
for
(
int
i
=
0
;
i
<
numPairs
;
i
++
)
{
int
drude1
,
drude2
;
double
thole
;
force
.
getScreenedPairParameters
(
startPairIndex
+
i
,
drude1
,
drude2
,
thole
);
force
.
getScreenedPairParameters
(
i
,
drude1
,
drude2
,
thole
);
int
p
,
p1
,
p2
,
p3
,
p4
;
double
charge1
,
charge2
,
polarizability1
,
polarizability2
,
aniso12
,
aniso34
;
force
.
getParticleParameters
(
drude1
,
p
,
p1
,
p2
,
p3
,
p4
,
charge1
,
polarizability1
,
aniso12
,
aniso34
);
...
...
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