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
2a1e9acf
"platforms/reference/vscode:/vscode.git/clone" did not exist on "1dac981a63300a2a53a7925f570995914f7163ed"
Commit
2a1e9acf
authored
Feb 15, 2017
by
Peter Eastman
Browse files
Optimizations to updateParametersInContext() for CUDA
parent
67091abf
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
181 additions
and
88 deletions
+181
-88
platforms/cuda/include/CudaContext.h
platforms/cuda/include/CudaContext.h
+13
-1
platforms/cuda/include/CudaKernels.h
platforms/cuda/include/CudaKernels.h
+37
-1
platforms/cuda/src/CudaContext.cpp
platforms/cuda/src/CudaContext.cpp
+43
-10
platforms/cuda/src/CudaKernels.cpp
platforms/cuda/src/CudaKernels.cpp
+81
-76
platforms/cuda/src/kernels/utilities.cu
platforms/cuda/src/kernels/utilities.cu
+7
-0
No files found.
platforms/cuda/include/CudaContext.h
View file @
2a1e9acf
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* *
* Portions copyright (c) 2009-201
6
Stanford University and the Authors. *
* Portions copyright (c) 2009-201
7
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -494,6 +494,10 @@ public:
...
@@ -494,6 +494,10 @@ public:
CudaNonbondedUtilities
&
getNonbondedUtilities
()
{
CudaNonbondedUtilities
&
getNonbondedUtilities
()
{
return
*
nonbonded
;
return
*
nonbonded
;
}
}
/**
* Set the particle charges. These are packed into the fourth element of the posq array.
*/
void
setCharges
(
const
std
::
vector
<
double
>&
charges
);
/**
/**
* Get the thread used by this context for executing parallel computations.
* Get the thread used by this context for executing parallel computations.
*/
*/
...
@@ -577,6 +581,12 @@ public:
...
@@ -577,6 +581,12 @@ public:
* and order to be revalidated.
* and order to be revalidated.
*/
*/
void
invalidateMolecules
();
void
invalidateMolecules
();
/**
* Mark that the current molecule definitions from one particular force (and hence the atom order)
* may be invalid. This should be called whenever force field parameters change. It will cause the
* definitions and order to be revalidated.
*/
bool
invalidateMolecules
(
CudaForceInfo
*
force
);
private:
private:
/**
/**
* Compute a sorted list of device indices in decreasing order of desirability
* Compute a sorted list of device indices in decreasing order of desirability
...
@@ -626,6 +636,7 @@ private:
...
@@ -626,6 +636,7 @@ private:
CUfunction
clearFourBuffersKernel
;
CUfunction
clearFourBuffersKernel
;
CUfunction
clearFiveBuffersKernel
;
CUfunction
clearFiveBuffersKernel
;
CUfunction
clearSixBuffersKernel
;
CUfunction
clearSixBuffersKernel
;
CUfunction
setChargesKernel
;
std
::
vector
<
CudaForceInfo
*>
forces
;
std
::
vector
<
CudaForceInfo
*>
forces
;
std
::
vector
<
Molecule
>
molecules
;
std
::
vector
<
Molecule
>
molecules
;
std
::
vector
<
MoleculeGroup
>
moleculeGroups
;
std
::
vector
<
MoleculeGroup
>
moleculeGroups
;
...
@@ -638,6 +649,7 @@ private:
...
@@ -638,6 +649,7 @@ private:
CudaArray
*
energyBuffer
;
CudaArray
*
energyBuffer
;
CudaArray
*
energyParamDerivBuffer
;
CudaArray
*
energyParamDerivBuffer
;
CudaArray
*
atomIndexDevice
;
CudaArray
*
atomIndexDevice
;
CudaArray
*
chargeBuffer
;
std
::
vector
<
std
::
string
>
energyParamDerivNames
;
std
::
vector
<
std
::
string
>
energyParamDerivNames
;
std
::
map
<
std
::
string
,
double
>
energyParamDerivWorkspace
;
std
::
map
<
std
::
string
,
double
>
energyParamDerivWorkspace
;
std
::
vector
<
int
>
atomIndex
;
std
::
vector
<
int
>
atomIndex
;
...
...
platforms/cuda/include/CudaKernels.h
View file @
2a1e9acf
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* *
* Portions copyright (c) 2008-201
6
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
7
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -292,9 +292,11 @@ public:
...
@@ -292,9 +292,11 @@ public:
*/
*/
void
copyParametersToContext
(
ContextImpl
&
context
,
const
HarmonicBondForce
&
force
);
void
copyParametersToContext
(
ContextImpl
&
context
,
const
HarmonicBondForce
&
force
);
private:
private:
class
ForceInfo
;
int
numBonds
;
int
numBonds
;
bool
hasInitializedKernel
;
bool
hasInitializedKernel
;
CudaContext
&
cu
;
CudaContext
&
cu
;
ForceInfo
*
info
;
const
System
&
system
;
const
System
&
system
;
CudaArray
*
params
;
CudaArray
*
params
;
};
};
...
@@ -332,9 +334,11 @@ public:
...
@@ -332,9 +334,11 @@ public:
*/
*/
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomBondForce
&
force
);
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomBondForce
&
force
);
private:
private:
class
ForceInfo
;
int
numBonds
;
int
numBonds
;
bool
hasInitializedKernel
;
bool
hasInitializedKernel
;
CudaContext
&
cu
;
CudaContext
&
cu
;
ForceInfo
*
info
;
const
System
&
system
;
const
System
&
system
;
CudaParameterSet
*
params
;
CudaParameterSet
*
params
;
CudaArray
*
globals
;
CudaArray
*
globals
;
...
@@ -375,9 +379,11 @@ public:
...
@@ -375,9 +379,11 @@ public:
*/
*/
void
copyParametersToContext
(
ContextImpl
&
context
,
const
HarmonicAngleForce
&
force
);
void
copyParametersToContext
(
ContextImpl
&
context
,
const
HarmonicAngleForce
&
force
);
private:
private:
class
ForceInfo
;
int
numAngles
;
int
numAngles
;
bool
hasInitializedKernel
;
bool
hasInitializedKernel
;
CudaContext
&
cu
;
CudaContext
&
cu
;
ForceInfo
*
info
;
const
System
&
system
;
const
System
&
system
;
CudaArray
*
params
;
CudaArray
*
params
;
};
};
...
@@ -415,9 +421,11 @@ public:
...
@@ -415,9 +421,11 @@ public:
*/
*/
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomAngleForce
&
force
);
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomAngleForce
&
force
);
private:
private:
class
ForceInfo
;
int
numAngles
;
int
numAngles
;
bool
hasInitializedKernel
;
bool
hasInitializedKernel
;
CudaContext
&
cu
;
CudaContext
&
cu
;
ForceInfo
*
info
;
const
System
&
system
;
const
System
&
system
;
CudaParameterSet
*
params
;
CudaParameterSet
*
params
;
CudaArray
*
globals
;
CudaArray
*
globals
;
...
@@ -458,9 +466,11 @@ public:
...
@@ -458,9 +466,11 @@ public:
*/
*/
void
copyParametersToContext
(
ContextImpl
&
context
,
const
PeriodicTorsionForce
&
force
);
void
copyParametersToContext
(
ContextImpl
&
context
,
const
PeriodicTorsionForce
&
force
);
private:
private:
class
ForceInfo
;
int
numTorsions
;
int
numTorsions
;
bool
hasInitializedKernel
;
bool
hasInitializedKernel
;
CudaContext
&
cu
;
CudaContext
&
cu
;
ForceInfo
*
info
;
const
System
&
system
;
const
System
&
system
;
CudaArray
*
params
;
CudaArray
*
params
;
};
};
...
@@ -498,9 +508,11 @@ public:
...
@@ -498,9 +508,11 @@ public:
*/
*/
void
copyParametersToContext
(
ContextImpl
&
context
,
const
RBTorsionForce
&
force
);
void
copyParametersToContext
(
ContextImpl
&
context
,
const
RBTorsionForce
&
force
);
private:
private:
class
ForceInfo
;
int
numTorsions
;
int
numTorsions
;
bool
hasInitializedKernel
;
bool
hasInitializedKernel
;
CudaContext
&
cu
;
CudaContext
&
cu
;
ForceInfo
*
info
;
const
System
&
system
;
const
System
&
system
;
CudaArray
*
params1
;
CudaArray
*
params1
;
CudaArray
*
params2
;
CudaArray
*
params2
;
...
@@ -539,9 +551,11 @@ public:
...
@@ -539,9 +551,11 @@ public:
*/
*/
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CMAPTorsionForce
&
force
);
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CMAPTorsionForce
&
force
);
private:
private:
class
ForceInfo
;
int
numTorsions
;
int
numTorsions
;
bool
hasInitializedKernel
;
bool
hasInitializedKernel
;
CudaContext
&
cu
;
CudaContext
&
cu
;
ForceInfo
*
info
;
const
System
&
system
;
const
System
&
system
;
std
::
vector
<
int2
>
mapPositionsVec
;
std
::
vector
<
int2
>
mapPositionsVec
;
CudaArray
*
coefficients
;
CudaArray
*
coefficients
;
...
@@ -582,9 +596,11 @@ public:
...
@@ -582,9 +596,11 @@ public:
*/
*/
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomTorsionForce
&
force
);
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomTorsionForce
&
force
);
private:
private:
class
ForceInfo
;
int
numTorsions
;
int
numTorsions
;
bool
hasInitializedKernel
;
bool
hasInitializedKernel
;
CudaContext
&
cu
;
CudaContext
&
cu
;
ForceInfo
*
info
;
const
System
&
system
;
const
System
&
system
;
CudaParameterSet
*
params
;
CudaParameterSet
*
params
;
CudaArray
*
globals
;
CudaArray
*
globals
;
...
@@ -647,12 +663,14 @@ private:
...
@@ -647,12 +663,14 @@ private:
const
char
*
getMaxValue
()
const
{
return
"make_int2(2147483647, 2147483647)"
;}
const
char
*
getMaxValue
()
const
{
return
"make_int2(2147483647, 2147483647)"
;}
const
char
*
getSortKey
()
const
{
return
"value.y"
;}
const
char
*
getSortKey
()
const
{
return
"value.y"
;}
};
};
class
ForceInfo
;
class
PmeIO
;
class
PmeIO
;
class
PmePreComputation
;
class
PmePreComputation
;
class
PmePostComputation
;
class
PmePostComputation
;
class
SyncStreamPreComputation
;
class
SyncStreamPreComputation
;
class
SyncStreamPostComputation
;
class
SyncStreamPostComputation
;
CudaContext
&
cu
;
CudaContext
&
cu
;
ForceInfo
*
info
;
bool
hasInitializedFFT
;
bool
hasInitializedFFT
;
CudaArray
*
sigmaEpsilon
;
CudaArray
*
sigmaEpsilon
;
CudaArray
*
exceptionParams
;
CudaArray
*
exceptionParams
;
...
@@ -724,8 +742,10 @@ public:
...
@@ -724,8 +742,10 @@ public:
*/
*/
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomNonbondedForce
&
force
);
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomNonbondedForce
&
force
);
private:
private:
class
ForceInfo
;
void
initInteractionGroups
(
const
CustomNonbondedForce
&
force
,
const
std
::
string
&
interactionSource
,
const
std
::
vector
<
std
::
string
>&
tableTypes
);
void
initInteractionGroups
(
const
CustomNonbondedForce
&
force
,
const
std
::
string
&
interactionSource
,
const
std
::
vector
<
std
::
string
>&
tableTypes
);
CudaContext
&
cu
;
CudaContext
&
cu
;
ForceInfo
*
info
;
CudaParameterSet
*
params
;
CudaParameterSet
*
params
;
CudaArray
*
globals
;
CudaArray
*
globals
;
CudaArray
*
interactionGroupData
;
CudaArray
*
interactionGroupData
;
...
@@ -775,10 +795,12 @@ public:
...
@@ -775,10 +795,12 @@ public:
*/
*/
void
copyParametersToContext
(
ContextImpl
&
context
,
const
GBSAOBCForce
&
force
);
void
copyParametersToContext
(
ContextImpl
&
context
,
const
GBSAOBCForce
&
force
);
private:
private:
class
ForceInfo
;
double
prefactor
,
surfaceAreaFactor
,
cutoff
;
double
prefactor
,
surfaceAreaFactor
,
cutoff
;
bool
hasCreatedKernels
;
bool
hasCreatedKernels
;
int
maxTiles
;
int
maxTiles
;
CudaContext
&
cu
;
CudaContext
&
cu
;
ForceInfo
*
info
;
CudaArray
*
params
;
CudaArray
*
params
;
CudaArray
*
bornSum
;
CudaArray
*
bornSum
;
CudaArray
*
bornRadii
;
CudaArray
*
bornRadii
;
...
@@ -825,10 +847,12 @@ public:
...
@@ -825,10 +847,12 @@ public:
*/
*/
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomGBForce
&
force
);
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomGBForce
&
force
);
private:
private:
class
ForceInfo
;
double
cutoff
;
double
cutoff
;
bool
hasInitializedKernels
,
needParameterGradient
,
needEnergyParamDerivs
;
bool
hasInitializedKernels
,
needParameterGradient
,
needEnergyParamDerivs
;
int
maxTiles
,
numComputedValues
;
int
maxTiles
,
numComputedValues
;
CudaContext
&
cu
;
CudaContext
&
cu
;
ForceInfo
*
info
;
CudaParameterSet
*
params
;
CudaParameterSet
*
params
;
CudaParameterSet
*
computedValues
;
CudaParameterSet
*
computedValues
;
CudaParameterSet
*
energyDerivs
;
CudaParameterSet
*
energyDerivs
;
...
@@ -882,9 +906,11 @@ public:
...
@@ -882,9 +906,11 @@ public:
*/
*/
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomExternalForce
&
force
);
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomExternalForce
&
force
);
private:
private:
class
ForceInfo
;
int
numParticles
;
int
numParticles
;
bool
hasInitializedKernel
;
bool
hasInitializedKernel
;
CudaContext
&
cu
;
CudaContext
&
cu
;
ForceInfo
*
info
;
const
System
&
system
;
const
System
&
system
;
CudaParameterSet
*
params
;
CudaParameterSet
*
params
;
CudaArray
*
globals
;
CudaArray
*
globals
;
...
@@ -926,9 +952,11 @@ public:
...
@@ -926,9 +952,11 @@ public:
*/
*/
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomHbondForce
&
force
);
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomHbondForce
&
force
);
private:
private:
class
ForceInfo
;
int
numDonors
,
numAcceptors
;
int
numDonors
,
numAcceptors
;
bool
hasInitializedKernel
;
bool
hasInitializedKernel
;
CudaContext
&
cu
;
CudaContext
&
cu
;
ForceInfo
*
info
;
CudaParameterSet
*
donorParams
;
CudaParameterSet
*
donorParams
;
CudaParameterSet
*
acceptorParams
;
CudaParameterSet
*
acceptorParams
;
CudaArray
*
globals
;
CudaArray
*
globals
;
...
@@ -978,9 +1006,11 @@ public:
...
@@ -978,9 +1006,11 @@ public:
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomCentroidBondForce
&
force
);
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomCentroidBondForce
&
force
);
private:
private:
class
ForceInfo
;
int
numGroups
,
numBonds
;
int
numGroups
,
numBonds
;
bool
needEnergyParamDerivs
;
bool
needEnergyParamDerivs
;
CudaContext
&
cu
;
CudaContext
&
cu
;
ForceInfo
*
info
;
CudaParameterSet
*
params
;
CudaParameterSet
*
params
;
CudaArray
*
globals
;
CudaArray
*
globals
;
CudaArray
*
groupParticles
;
CudaArray
*
groupParticles
;
...
@@ -1031,8 +1061,10 @@ public:
...
@@ -1031,8 +1061,10 @@ public:
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomCompoundBondForce
&
force
);
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomCompoundBondForce
&
force
);
private:
private:
class
ForceInfo
;
int
numBonds
;
int
numBonds
;
CudaContext
&
cu
;
CudaContext
&
cu
;
ForceInfo
*
info
;
CudaParameterSet
*
params
;
CudaParameterSet
*
params
;
CudaArray
*
globals
;
CudaArray
*
globals
;
std
::
vector
<
std
::
string
>
globalParamNames
;
std
::
vector
<
std
::
string
>
globalParamNames
;
...
@@ -1077,7 +1109,9 @@ public:
...
@@ -1077,7 +1109,9 @@ public:
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomManyParticleForce
&
force
);
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomManyParticleForce
&
force
);
private:
private:
class
ForceInfo
;
CudaContext
&
cu
;
CudaContext
&
cu
;
ForceInfo
*
info
;
bool
hasInitializedKernel
;
bool
hasInitializedKernel
;
NonbondedMethod
nonbondedMethod
;
NonbondedMethod
nonbondedMethod
;
int
maxNeighborPairs
,
forceWorkgroupSize
,
findNeighborsWorkgroupSize
;
int
maxNeighborPairs
,
forceWorkgroupSize
,
findNeighborsWorkgroupSize
;
...
@@ -1139,9 +1173,11 @@ public:
...
@@ -1139,9 +1173,11 @@ public:
*/
*/
void
copyParametersToContext
(
ContextImpl
&
context
,
const
GayBerneForce
&
force
);
void
copyParametersToContext
(
ContextImpl
&
context
,
const
GayBerneForce
&
force
);
private:
private:
class
ForceInfo
;
class
ReorderListener
;
class
ReorderListener
;
void
sortAtoms
();
void
sortAtoms
();
CudaContext
&
cu
;
CudaContext
&
cu
;
ForceInfo
*
info
;
bool
hasInitializedKernels
;
bool
hasInitializedKernels
;
int
numRealParticles
,
numExceptions
,
maxNeighborBlocks
;
int
numRealParticles
,
numExceptions
,
maxNeighborBlocks
;
GayBerneForce
::
NonbondedMethod
nonbondedMethod
;
GayBerneForce
::
NonbondedMethod
nonbondedMethod
;
...
...
platforms/cuda/src/CudaContext.cpp
View file @
2a1e9acf
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* *
* Portions copyright (c) 2009-201
6
Stanford University and the Authors. *
* Portions copyright (c) 2009-201
7
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -108,7 +108,8 @@ static int executeInWindows(const string &command) {
...
@@ -108,7 +108,8 @@ static int executeInWindows(const string &command) {
CudaContext
::
CudaContext
(
const
System
&
system
,
int
deviceIndex
,
bool
useBlockingSync
,
const
string
&
precision
,
const
string
&
compiler
,
CudaContext
::
CudaContext
(
const
System
&
system
,
int
deviceIndex
,
bool
useBlockingSync
,
const
string
&
precision
,
const
string
&
compiler
,
const
string
&
tempDir
,
const
std
::
string
&
hostCompiler
,
CudaPlatform
::
PlatformData
&
platformData
)
:
system
(
system
),
currentStream
(
0
),
const
string
&
tempDir
,
const
std
::
string
&
hostCompiler
,
CudaPlatform
::
PlatformData
&
platformData
)
:
system
(
system
),
currentStream
(
0
),
time
(
0.0
),
platformData
(
platformData
),
stepCount
(
0
),
computeForceCount
(
0
),
stepsSinceReorder
(
99999
),
contextIsValid
(
false
),
atomsWereReordered
(
false
),
hasCompilerKernel
(
false
),
isNvccAvailable
(
false
),
time
(
0.0
),
platformData
(
platformData
),
stepCount
(
0
),
computeForceCount
(
0
),
stepsSinceReorder
(
99999
),
contextIsValid
(
false
),
atomsWereReordered
(
false
),
hasCompilerKernel
(
false
),
isNvccAvailable
(
false
),
pinnedBuffer
(
NULL
),
posq
(
NULL
),
posqCorrection
(
NULL
),
velm
(
NULL
),
force
(
NULL
),
energyBuffer
(
NULL
),
energyParamDerivBuffer
(
NULL
),
atomIndexDevice
(
NULL
),
integration
(
NULL
),
expression
(
NULL
),
bonded
(
NULL
),
nonbonded
(
NULL
),
thread
(
NULL
)
{
pinnedBuffer
(
NULL
),
posq
(
NULL
),
posqCorrection
(
NULL
),
velm
(
NULL
),
force
(
NULL
),
energyBuffer
(
NULL
),
energyParamDerivBuffer
(
NULL
),
atomIndexDevice
(
NULL
),
chargeBuffer
(
NULL
),
integration
(
NULL
),
expression
(
NULL
),
bonded
(
NULL
),
nonbonded
(
NULL
),
thread
(
NULL
)
{
// Determine what compiler to use.
// Determine what compiler to use.
this
->
compiler
=
"
\"
"
+
compiler
+
"
\"
"
;
this
->
compiler
=
"
\"
"
+
compiler
+
"
\"
"
;
...
@@ -291,6 +292,7 @@ CudaContext::CudaContext(const System& system, int deviceIndex, bool useBlocking
...
@@ -291,6 +292,7 @@ CudaContext::CudaContext(const System& system, int deviceIndex, bool useBlocking
clearFourBuffersKernel
=
getKernel
(
utilities
,
"clearFourBuffers"
);
clearFourBuffersKernel
=
getKernel
(
utilities
,
"clearFourBuffers"
);
clearFiveBuffersKernel
=
getKernel
(
utilities
,
"clearFiveBuffers"
);
clearFiveBuffersKernel
=
getKernel
(
utilities
,
"clearFiveBuffers"
);
clearSixBuffersKernel
=
getKernel
(
utilities
,
"clearSixBuffers"
);
clearSixBuffersKernel
=
getKernel
(
utilities
,
"clearSixBuffers"
);
setChargesKernel
=
getKernel
(
utilities
,
"setCharges"
);
// Set defines based on the requested precision.
// Set defines based on the requested precision.
...
@@ -407,6 +409,8 @@ CudaContext::~CudaContext() {
...
@@ -407,6 +409,8 @@ CudaContext::~CudaContext() {
delete
energyParamDerivBuffer
;
delete
energyParamDerivBuffer
;
if
(
atomIndexDevice
!=
NULL
)
if
(
atomIndexDevice
!=
NULL
)
delete
atomIndexDevice
;
delete
atomIndexDevice
;
if
(
chargeBuffer
!=
NULL
)
delete
chargeBuffer
;
if
(
integration
!=
NULL
)
if
(
integration
!=
NULL
)
delete
integration
;
delete
integration
;
if
(
expression
!=
NULL
)
if
(
expression
!=
NULL
)
...
@@ -860,6 +864,25 @@ void CudaContext::clearAutoclearBuffers() {
...
@@ -860,6 +864,25 @@ void CudaContext::clearAutoclearBuffers() {
}
}
}
}
void
CudaContext
::
setCharges
(
const
vector
<
double
>&
charges
)
{
if
(
chargeBuffer
==
NULL
)
chargeBuffer
=
new
CudaArray
(
*
this
,
numAtoms
,
useDoublePrecision
?
sizeof
(
double
)
:
sizeof
(
float
),
"chargeBuffer"
);
if
(
getUseDoublePrecision
())
{
double
*
c
=
(
double
*
)
getPinnedBuffer
();
for
(
int
i
=
0
;
i
<
charges
.
size
();
i
++
)
c
[
i
]
=
charges
[
i
];
chargeBuffer
->
upload
(
c
);
}
else
{
float
*
c
=
(
float
*
)
getPinnedBuffer
();
for
(
int
i
=
0
;
i
<
charges
.
size
();
i
++
)
c
[
i
]
=
(
float
)
charges
[
i
];
chargeBuffer
->
upload
(
c
);
}
void
*
args
[]
=
{
&
chargeBuffer
->
getDevicePointer
(),
&
posq
->
getDevicePointer
(),
&
atomIndexDevice
->
getDevicePointer
(),
&
numAtoms
};
executeKernel
(
setChargesKernel
,
args
,
numAtoms
);
}
/**
/**
* This class ensures that atom reordering doesn't break virtual sites.
* This class ensures that atom reordering doesn't break virtual sites.
*/
*/
...
@@ -1058,9 +1081,19 @@ void CudaContext::findMoleculeGroups() {
...
@@ -1058,9 +1081,19 @@ void CudaContext::findMoleculeGroups() {
}
}
void
CudaContext
::
invalidateMolecules
()
{
void
CudaContext
::
invalidateMolecules
()
{
if
(
numAtoms
==
0
||
nonbonded
==
NULL
||
!
nonbonded
->
getUseCutoff
())
for
(
int
i
=
0
;
i
<
forces
.
size
();
i
++
)
if
(
invalidateMolecules
(
forces
[
i
]))
return
;
return
;
}
bool
CudaContext
::
invalidateMolecules
(
CudaForceInfo
*
force
)
{
if
(
numAtoms
==
0
||
nonbonded
==
NULL
||
!
nonbonded
->
getUseCutoff
())
return
false
;
bool
valid
=
true
;
bool
valid
=
true
;
int
forceIndex
=
-
1
;
for
(
int
i
=
0
;
i
<
forces
.
size
();
i
++
)
if
(
forces
[
i
]
==
force
)
forceIndex
=
i
;
for
(
int
group
=
0
;
valid
&&
group
<
(
int
)
moleculeGroups
.
size
();
group
++
)
{
for
(
int
group
=
0
;
valid
&&
group
<
(
int
)
moleculeGroups
.
size
();
group
++
)
{
MoleculeGroup
&
mol
=
moleculeGroups
[
group
];
MoleculeGroup
&
mol
=
moleculeGroups
[
group
];
vector
<
int
>&
instances
=
mol
.
instances
;
vector
<
int
>&
instances
=
mol
.
instances
;
...
@@ -1075,22 +1108,21 @@ void CudaContext::invalidateMolecules() {
...
@@ -1075,22 +1108,21 @@ void CudaContext::invalidateMolecules() {
Molecule
&
m2
=
molecules
[
instances
[
j
]];
Molecule
&
m2
=
molecules
[
instances
[
j
]];
int
offset2
=
offsets
[
j
];
int
offset2
=
offsets
[
j
];
for
(
int
i
=
0
;
i
<
(
int
)
atoms
.
size
()
&&
valid
;
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
atoms
.
size
()
&&
valid
;
i
++
)
{
for
(
int
k
=
0
;
k
<
(
int
)
forces
.
size
();
k
++
)
if
(
!
force
->
areParticlesIdentical
(
atoms
[
i
]
+
offset1
,
atoms
[
i
]
+
offset2
))
if
(
!
forces
[
k
]
->
areParticlesIdentical
(
atoms
[
i
]
+
offset1
,
atoms
[
i
]
+
offset2
))
valid
=
false
;
valid
=
false
;
}
}
// See if the force groups are identical.
// See if the force groups are identical.
for
(
int
i
=
0
;
i
<
(
int
)
forces
.
size
()
&&
valid
;
i
++
)
{
if
(
valid
&&
forceIndex
>
-
1
)
{
for
(
int
k
=
0
;
k
<
(
int
)
m1
.
groups
[
i
].
size
()
&&
valid
;
k
++
)
for
(
int
k
=
0
;
k
<
(
int
)
m1
.
groups
[
forceIndex
].
size
()
&&
valid
;
k
++
)
if
(
!
force
s
[
i
]
->
areGroupsIdentical
(
m1
.
groups
[
i
][
k
],
m2
.
groups
[
i
][
k
]))
if
(
!
force
->
areGroupsIdentical
(
m1
.
groups
[
forceIndex
][
k
],
m2
.
groups
[
forceIndex
][
k
]))
valid
=
false
;
valid
=
false
;
}
}
}
}
}
}
if
(
valid
)
if
(
valid
)
return
;
return
false
;
// The list of which molecules are identical is no longer valid. We need to restore the
// The list of which molecules are identical is no longer valid. We need to restore the
// atoms to their original order, rebuild the list of identical molecules, and sort them
// atoms to their original order, rebuild the list of identical molecules, and sort them
...
@@ -1158,6 +1190,7 @@ void CudaContext::invalidateMolecules() {
...
@@ -1158,6 +1190,7 @@ void CudaContext::invalidateMolecules() {
for
(
int
i
=
0
;
i
<
(
int
)
reorderListeners
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
reorderListeners
.
size
();
i
++
)
reorderListeners
[
i
]
->
execute
();
reorderListeners
[
i
]
->
execute
();
reorderAtoms
();
reorderAtoms
();
return
true
;
}
}
void
CudaContext
::
reorderAtoms
()
{
void
CudaContext
::
reorderAtoms
()
{
...
...
platforms/cuda/src/CudaKernels.cpp
View file @
2a1e9acf
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* *
* Portions copyright (c) 2008-201
6
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
7
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -502,9 +502,9 @@ void CudaVirtualSitesKernel::computePositions(ContextImpl& context) {
...
@@ -502,9 +502,9 @@ void CudaVirtualSitesKernel::computePositions(ContextImpl& context) {
cu
.
getIntegrationUtilities
().
computeVirtualSites
();
cu
.
getIntegrationUtilities
().
computeVirtualSites
();
}
}
class CudaHarmonicBondForceInfo : public CudaForceInfo {
class
Cuda
Calc
HarmonicBond
ForceKernel
::
ForceInfo
:
public
CudaForceInfo
{
public:
public:
CudaHarmonicBond
ForceInfo(const HarmonicBondForce& force) : force(force) {
ForceInfo
(
const
HarmonicBondForce
&
force
)
:
force
(
force
)
{
}
}
int
getNumParticleGroups
()
{
int
getNumParticleGroups
()
{
return
force
.
getNumBonds
();
return
force
.
getNumBonds
();
...
@@ -556,7 +556,8 @@ void CudaCalcHarmonicBondForceKernel::initialize(const System& system, const Har
...
@@ -556,7 +556,8 @@ void CudaCalcHarmonicBondForceKernel::initialize(const System& system, const Har
replacements
[
"COMPUTE_FORCE"
]
=
CudaKernelSources
::
harmonicBondForce
;
replacements
[
"COMPUTE_FORCE"
]
=
CudaKernelSources
::
harmonicBondForce
;
replacements
[
"PARAMS"
]
=
cu
.
getBondedUtilities
().
addArgument
(
params
->
getDevicePointer
(),
"float2"
);
replacements
[
"PARAMS"
]
=
cu
.
getBondedUtilities
().
addArgument
(
params
->
getDevicePointer
(),
"float2"
);
cu
.
getBondedUtilities
().
addInteraction
(
atoms
,
cu
.
replaceStrings
(
CudaKernelSources
::
bondForce
,
replacements
),
force
.
getForceGroup
());
cu
.
getBondedUtilities
().
addInteraction
(
atoms
,
cu
.
replaceStrings
(
CudaKernelSources
::
bondForce
,
replacements
),
force
.
getForceGroup
());
cu.addForce(new CudaHarmonicBondForceInfo(force));
info
=
new
ForceInfo
(
force
);
cu
.
addForce
(
info
);
}
}
double
CudaCalcHarmonicBondForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
double
CudaCalcHarmonicBondForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
...
@@ -589,9 +590,9 @@ void CudaCalcHarmonicBondForceKernel::copyParametersToContext(ContextImpl& conte
...
@@ -589,9 +590,9 @@ void CudaCalcHarmonicBondForceKernel::copyParametersToContext(ContextImpl& conte
cu
.
invalidateMolecules
();
cu
.
invalidateMolecules
();
}
}
class CudaCustomBondForceInfo : public CudaForceInfo {
class
CudaC
alcC
ustomBond
ForceKernel
::
ForceInfo
:
public
CudaForceInfo
{
public:
public:
CudaCustomBond
ForceInfo(const CustomBondForce& force) : force(force) {
ForceInfo
(
const
CustomBondForce
&
force
)
:
force
(
force
)
{
}
}
int
getNumParticleGroups
()
{
int
getNumParticleGroups
()
{
return
force
.
getNumBonds
();
return
force
.
getNumBonds
();
...
@@ -645,7 +646,8 @@ void CudaCalcCustomBondForceKernel::initialize(const System& system, const Custo
...
@@ -645,7 +646,8 @@ void CudaCalcCustomBondForceKernel::initialize(const System& system, const Custo
paramVector
[
i
][
j
]
=
(
float
)
parameters
[
j
];
paramVector
[
i
][
j
]
=
(
float
)
parameters
[
j
];
}
}
params
->
setParameterValues
(
paramVector
);
params
->
setParameterValues
(
paramVector
);
cu.addForce(new CudaCustomBondForceInfo(force));
info
=
new
ForceInfo
(
force
);
cu
.
addForce
(
info
);
// Record information for the expressions.
// Record information for the expressions.
...
@@ -743,9 +745,9 @@ void CudaCalcCustomBondForceKernel::copyParametersToContext(ContextImpl& context
...
@@ -743,9 +745,9 @@ void CudaCalcCustomBondForceKernel::copyParametersToContext(ContextImpl& context
cu
.
invalidateMolecules
();
cu
.
invalidateMolecules
();
}
}
class CudaHarmonicAngleForceInfo : public CudaForceInfo {
class
Cuda
Calc
HarmonicAngle
ForceKernel
::
ForceInfo
:
public
CudaForceInfo
{
public:
public:
CudaHarmonicAngle
ForceInfo(const HarmonicAngleForce& force) : force(force) {
ForceInfo
(
const
HarmonicAngleForce
&
force
)
:
force
(
force
)
{
}
}
int
getNumParticleGroups
()
{
int
getNumParticleGroups
()
{
return
force
.
getNumAngles
();
return
force
.
getNumAngles
();
...
@@ -799,7 +801,8 @@ void CudaCalcHarmonicAngleForceKernel::initialize(const System& system, const Ha
...
@@ -799,7 +801,8 @@ void CudaCalcHarmonicAngleForceKernel::initialize(const System& system, const Ha
replacements
[
"COMPUTE_FORCE"
]
=
CudaKernelSources
::
harmonicAngleForce
;
replacements
[
"COMPUTE_FORCE"
]
=
CudaKernelSources
::
harmonicAngleForce
;
replacements
[
"PARAMS"
]
=
cu
.
getBondedUtilities
().
addArgument
(
params
->
getDevicePointer
(),
"float2"
);
replacements
[
"PARAMS"
]
=
cu
.
getBondedUtilities
().
addArgument
(
params
->
getDevicePointer
(),
"float2"
);
cu
.
getBondedUtilities
().
addInteraction
(
atoms
,
cu
.
replaceStrings
(
CudaKernelSources
::
angleForce
,
replacements
),
force
.
getForceGroup
());
cu
.
getBondedUtilities
().
addInteraction
(
atoms
,
cu
.
replaceStrings
(
CudaKernelSources
::
angleForce
,
replacements
),
force
.
getForceGroup
());
cu.addForce(new CudaHarmonicAngleForceInfo(force));
info
=
new
ForceInfo
(
force
);
cu
.
addForce
(
info
);
}
}
double
CudaCalcHarmonicAngleForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
double
CudaCalcHarmonicAngleForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
...
@@ -832,9 +835,9 @@ void CudaCalcHarmonicAngleForceKernel::copyParametersToContext(ContextImpl& cont
...
@@ -832,9 +835,9 @@ void CudaCalcHarmonicAngleForceKernel::copyParametersToContext(ContextImpl& cont
cu
.
invalidateMolecules
();
cu
.
invalidateMolecules
();
}
}
class CudaCustomAngleForceInfo : public CudaForceInfo {
class
CudaC
alcC
ustomAngle
ForceKernel
::
ForceInfo
:
public
CudaForceInfo
{
public:
public:
CudaCustomAngle
ForceInfo(const CustomAngleForce& force) : force(force) {
ForceInfo
(
const
CustomAngleForce
&
force
)
:
force
(
force
)
{
}
}
int
getNumParticleGroups
()
{
int
getNumParticleGroups
()
{
return
force
.
getNumAngles
();
return
force
.
getNumAngles
();
...
@@ -889,7 +892,8 @@ void CudaCalcCustomAngleForceKernel::initialize(const System& system, const Cust
...
@@ -889,7 +892,8 @@ void CudaCalcCustomAngleForceKernel::initialize(const System& system, const Cust
paramVector
[
i
][
j
]
=
(
float
)
parameters
[
j
];
paramVector
[
i
][
j
]
=
(
float
)
parameters
[
j
];
}
}
params
->
setParameterValues
(
paramVector
);
params
->
setParameterValues
(
paramVector
);
cu.addForce(new CudaCustomAngleForceInfo(force));
info
=
new
ForceInfo
(
force
);
cu
.
addForce
(
info
);
// Record information for the expressions.
// Record information for the expressions.
...
@@ -987,9 +991,9 @@ void CudaCalcCustomAngleForceKernel::copyParametersToContext(ContextImpl& contex
...
@@ -987,9 +991,9 @@ void CudaCalcCustomAngleForceKernel::copyParametersToContext(ContextImpl& contex
cu
.
invalidateMolecules
();
cu
.
invalidateMolecules
();
}
}
class CudaPeriodicTorsionForceInfo : public CudaForceInfo {
class
Cuda
Calc
PeriodicTorsion
ForceKernel
::
ForceInfo
:
public
CudaForceInfo
{
public:
public:
CudaPeriodicTorsion
ForceInfo(const PeriodicTorsionForce& force) : force(force) {
ForceInfo
(
const
PeriodicTorsionForce
&
force
)
:
force
(
force
)
{
}
}
int
getNumParticleGroups
()
{
int
getNumParticleGroups
()
{
return
force
.
getNumTorsions
();
return
force
.
getNumTorsions
();
...
@@ -1044,7 +1048,8 @@ void CudaCalcPeriodicTorsionForceKernel::initialize(const System& system, const
...
@@ -1044,7 +1048,8 @@ void CudaCalcPeriodicTorsionForceKernel::initialize(const System& system, const
replacements
[
"COMPUTE_FORCE"
]
=
CudaKernelSources
::
periodicTorsionForce
;
replacements
[
"COMPUTE_FORCE"
]
=
CudaKernelSources
::
periodicTorsionForce
;
replacements
[
"PARAMS"
]
=
cu
.
getBondedUtilities
().
addArgument
(
params
->
getDevicePointer
(),
"float4"
);
replacements
[
"PARAMS"
]
=
cu
.
getBondedUtilities
().
addArgument
(
params
->
getDevicePointer
(),
"float4"
);
cu
.
getBondedUtilities
().
addInteraction
(
atoms
,
cu
.
replaceStrings
(
CudaKernelSources
::
torsionForce
,
replacements
),
force
.
getForceGroup
());
cu
.
getBondedUtilities
().
addInteraction
(
atoms
,
cu
.
replaceStrings
(
CudaKernelSources
::
torsionForce
,
replacements
),
force
.
getForceGroup
());
cu.addForce(new CudaPeriodicTorsionForceInfo(force));
info
=
new
ForceInfo
(
force
);
cu
.
addForce
(
info
);
}
}
double
CudaCalcPeriodicTorsionForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
double
CudaCalcPeriodicTorsionForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
...
@@ -1077,9 +1082,9 @@ void CudaCalcPeriodicTorsionForceKernel::copyParametersToContext(ContextImpl& co
...
@@ -1077,9 +1082,9 @@ void CudaCalcPeriodicTorsionForceKernel::copyParametersToContext(ContextImpl& co
cu
.
invalidateMolecules
();
cu
.
invalidateMolecules
();
}
}
class CudaRBTorsionForceInfo : public CudaForceInfo {
class
Cuda
Calc
RBTorsion
ForceKernel
::
ForceInfo
:
public
CudaForceInfo
{
public:
public:
CudaRBTorsion
ForceInfo(const RBTorsionForce& force) : force(force) {
ForceInfo
(
const
RBTorsionForce
&
force
)
:
force
(
force
)
{
}
}
int
getNumParticleGroups
()
{
int
getNumParticleGroups
()
{
return
force
.
getNumTorsions
();
return
force
.
getNumTorsions
();
...
@@ -1141,7 +1146,8 @@ void CudaCalcRBTorsionForceKernel::initialize(const System& system, const RBTors
...
@@ -1141,7 +1146,8 @@ void CudaCalcRBTorsionForceKernel::initialize(const System& system, const RBTors
replacements
[
"PARAMS1"
]
=
cu
.
getBondedUtilities
().
addArgument
(
params1
->
getDevicePointer
(),
"float4"
);
replacements
[
"PARAMS1"
]
=
cu
.
getBondedUtilities
().
addArgument
(
params1
->
getDevicePointer
(),
"float4"
);
replacements
[
"PARAMS2"
]
=
cu
.
getBondedUtilities
().
addArgument
(
params2
->
getDevicePointer
(),
"float2"
);
replacements
[
"PARAMS2"
]
=
cu
.
getBondedUtilities
().
addArgument
(
params2
->
getDevicePointer
(),
"float2"
);
cu
.
getBondedUtilities
().
addInteraction
(
atoms
,
cu
.
replaceStrings
(
CudaKernelSources
::
torsionForce
,
replacements
),
force
.
getForceGroup
());
cu
.
getBondedUtilities
().
addInteraction
(
atoms
,
cu
.
replaceStrings
(
CudaKernelSources
::
torsionForce
,
replacements
),
force
.
getForceGroup
());
cu.addForce(new CudaRBTorsionForceInfo(force));
info
=
new
ForceInfo
(
force
);
cu
.
addForce
(
info
);
}
}
double
CudaCalcRBTorsionForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
double
CudaCalcRBTorsionForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
...
@@ -1177,9 +1183,9 @@ void CudaCalcRBTorsionForceKernel::copyParametersToContext(ContextImpl& context,
...
@@ -1177,9 +1183,9 @@ void CudaCalcRBTorsionForceKernel::copyParametersToContext(ContextImpl& context,
cu
.
invalidateMolecules
();
cu
.
invalidateMolecules
();
}
}
class CudaCMAPTorsionForceInfo : public CudaForceInfo {
class
CudaC
alcC
MAPTorsion
ForceKernel
::
ForceInfo
:
public
CudaForceInfo
{
public:
public:
CudaCMAPTorsion
ForceInfo(const CMAPTorsionForce& force) : force(force) {
ForceInfo
(
const
CMAPTorsionForce
&
force
)
:
force
(
force
)
{
}
}
int
getNumParticleGroups
()
{
int
getNumParticleGroups
()
{
return
force
.
getNumTorsions
();
return
force
.
getNumTorsions
();
...
@@ -1259,7 +1265,8 @@ void CudaCalcCMAPTorsionForceKernel::initialize(const System& system, const CMAP
...
@@ -1259,7 +1265,8 @@ void CudaCalcCMAPTorsionForceKernel::initialize(const System& system, const CMAP
replacements
[
"MAP_POS"
]
=
cu
.
getBondedUtilities
().
addArgument
(
mapPositions
->
getDevicePointer
(),
"int2"
);
replacements
[
"MAP_POS"
]
=
cu
.
getBondedUtilities
().
addArgument
(
mapPositions
->
getDevicePointer
(),
"int2"
);
replacements
[
"MAPS"
]
=
cu
.
getBondedUtilities
().
addArgument
(
torsionMaps
->
getDevicePointer
(),
"int"
);
replacements
[
"MAPS"
]
=
cu
.
getBondedUtilities
().
addArgument
(
torsionMaps
->
getDevicePointer
(),
"int"
);
cu
.
getBondedUtilities
().
addInteraction
(
atoms
,
cu
.
replaceStrings
(
CudaKernelSources
::
cmapTorsionForce
,
replacements
),
force
.
getForceGroup
());
cu
.
getBondedUtilities
().
addInteraction
(
atoms
,
cu
.
replaceStrings
(
CudaKernelSources
::
cmapTorsionForce
,
replacements
),
force
.
getForceGroup
());
cu.addForce(new CudaCMAPTorsionForceInfo(force));
info
=
new
ForceInfo
(
force
);
cu
.
addForce
(
info
);
}
}
double
CudaCalcCMAPTorsionForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
double
CudaCalcCMAPTorsionForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
...
@@ -1309,9 +1316,9 @@ void CudaCalcCMAPTorsionForceKernel::copyParametersToContext(ContextImpl& contex
...
@@ -1309,9 +1316,9 @@ void CudaCalcCMAPTorsionForceKernel::copyParametersToContext(ContextImpl& contex
torsionMaps
->
upload
(
torsionMapsVec
);
torsionMaps
->
upload
(
torsionMapsVec
);
}
}
class CudaCustomTorsionForceInfo : public CudaForceInfo {
class
CudaC
alcC
ustomTorsion
ForceKernel
::
ForceInfo
:
public
CudaForceInfo
{
public:
public:
CudaCustomTorsion
ForceInfo(const CustomTorsionForce& force) : force(force) {
ForceInfo
(
const
CustomTorsionForce
&
force
)
:
force
(
force
)
{
}
}
int
getNumParticleGroups
()
{
int
getNumParticleGroups
()
{
return
force
.
getNumTorsions
();
return
force
.
getNumTorsions
();
...
@@ -1366,7 +1373,8 @@ void CudaCalcCustomTorsionForceKernel::initialize(const System& system, const Cu
...
@@ -1366,7 +1373,8 @@ void CudaCalcCustomTorsionForceKernel::initialize(const System& system, const Cu
paramVector
[
i
][
j
]
=
(
float
)
parameters
[
j
];
paramVector
[
i
][
j
]
=
(
float
)
parameters
[
j
];
}
}
params
->
setParameterValues
(
paramVector
);
params
->
setParameterValues
(
paramVector
);
cu.addForce(new CudaCustomTorsionForceInfo(force));
info
=
new
ForceInfo
(
force
);
cu
.
addForce
(
info
);
// Record information for the expressions.
// Record information for the expressions.
...
@@ -1464,9 +1472,9 @@ void CudaCalcCustomTorsionForceKernel::copyParametersToContext(ContextImpl& cont
...
@@ -1464,9 +1472,9 @@ void CudaCalcCustomTorsionForceKernel::copyParametersToContext(ContextImpl& cont
cu
.
invalidateMolecules
();
cu
.
invalidateMolecules
();
}
}
class CudaNonbondedForceInfo : public CudaForceInfo {
class
Cuda
Calc
Nonbonded
ForceKernel
::
ForceInfo
:
public
CudaForceInfo
{
public:
public:
CudaNonbonded
ForceInfo(const NonbondedForce& force) : force(force) {
ForceInfo
(
const
NonbondedForce
&
force
)
:
force
(
force
)
{
}
}
bool
areParticlesIdentical
(
int
particle1
,
int
particle2
)
{
bool
areParticlesIdentical
(
int
particle1
,
int
particle2
)
{
double
charge1
,
charge2
,
sigma1
,
sigma2
,
epsilon1
,
epsilon2
;
double
charge1
,
charge2
,
sigma1
,
sigma2
,
epsilon1
,
epsilon2
;
...
@@ -1946,7 +1954,8 @@ void CudaCalcNonbondedForceKernel::initialize(const System& system, const Nonbon
...
@@ -1946,7 +1954,8 @@ void CudaCalcNonbondedForceKernel::initialize(const System& system, const Nonbon
replacements
[
"PARAMS"
]
=
cu
.
getBondedUtilities
().
addArgument
(
exceptionParams
->
getDevicePointer
(),
"float4"
);
replacements
[
"PARAMS"
]
=
cu
.
getBondedUtilities
().
addArgument
(
exceptionParams
->
getDevicePointer
(),
"float4"
);
cu
.
getBondedUtilities
().
addInteraction
(
atoms
,
cu
.
replaceStrings
(
CudaKernelSources
::
nonbondedExceptions
,
replacements
),
force
.
getForceGroup
());
cu
.
getBondedUtilities
().
addInteraction
(
atoms
,
cu
.
replaceStrings
(
CudaKernelSources
::
nonbondedExceptions
,
replacements
),
force
.
getForceGroup
());
}
}
cu.addForce(new CudaNonbondedForceInfo(force));
info
=
new
ForceInfo
(
force
);
cu
.
addForce
(
info
);
}
}
double
CudaCalcNonbondedForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
,
bool
includeDirect
,
bool
includeReciprocal
)
{
double
CudaCalcNonbondedForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
,
bool
includeDirect
,
bool
includeReciprocal
)
{
...
@@ -2087,25 +2096,18 @@ void CudaCalcNonbondedForceKernel::copyParametersToContext(ContextImpl& context,
...
@@ -2087,25 +2096,18 @@ void CudaCalcNonbondedForceKernel::copyParametersToContext(ContextImpl& context,
// Record the per-particle parameters.
// Record the per-particle parameters.
CudaArray& posq = cu.getPosq();
vector
<
double
>
chargeVector
(
cu
.
getNumAtoms
());
posq.download(cu.getPinnedBuffer());
float4* posqf = (float4*) cu.getPinnedBuffer();
double4* posqd = (double4*) cu.getPinnedBuffer();
vector
<
float2
>
sigmaEpsilonVector
(
cu
.
getPaddedNumAtoms
(),
make_float2
(
0
,
0
));
vector
<
float2
>
sigmaEpsilonVector
(
cu
.
getPaddedNumAtoms
(),
make_float2
(
0
,
0
));
double
sumSquaredCharges
=
0.0
;
double
sumSquaredCharges
=
0.0
;
const
vector
<
int
>&
order
=
cu
.
getAtomIndex
();
const
vector
<
int
>&
order
=
cu
.
getAtomIndex
();
for
(
int
i
=
0
;
i
<
force
.
getNumParticles
();
i
++
)
{
for
(
int
i
=
0
;
i
<
force
.
getNumParticles
();
i
++
)
{
int index = order[i];
double
charge
,
sigma
,
epsilon
;
double
charge
,
sigma
,
epsilon
;
force.getParticleParameters(index, charge, sigma, epsilon);
force
.
getParticleParameters
(
i
,
charge
,
sigma
,
epsilon
);
if (cu.getUseDoublePrecision())
chargeVector
[
i
]
=
charge
;
posqd[i].w = charge;
sigmaEpsilonVector
[
i
]
=
make_float2
((
float
)
(
0.5
*
sigma
),
(
float
)
(
2.0
*
sqrt
(
epsilon
)));
else
posqf[i].w = (float) charge;
sigmaEpsilonVector[index] = make_float2((float) (0.5*sigma), (float) (2.0*sqrt(epsilon)));
sumSquaredCharges
+=
charge
*
charge
;
sumSquaredCharges
+=
charge
*
charge
;
}
}
posq.upload(
cu.
g
et
PinnedBuffer()
);
cu
.
s
et
Charges
(
chargeVector
);
sigmaEpsilon
->
upload
(
sigmaEpsilonVector
);
sigmaEpsilon
->
upload
(
sigmaEpsilonVector
);
// Record the exceptions.
// Record the exceptions.
...
@@ -2143,9 +2145,9 @@ void CudaCalcNonbondedForceKernel::getPMEParameters(double& alpha, int& nx, int&
...
@@ -2143,9 +2145,9 @@ void CudaCalcNonbondedForceKernel::getPMEParameters(double& alpha, int& nx, int&
}
}
}
}
class CudaCustomNonbondedForceInfo : public CudaForceInfo {
class
CudaC
alcC
ustomNonbonded
ForceKernel
::
ForceInfo
:
public
CudaForceInfo
{
public:
public:
CudaCustomNonbonded
ForceInfo(const CustomNonbondedForce& force) : force(force) {
ForceInfo
(
const
CustomNonbondedForce
&
force
)
:
force
(
force
)
{
if
(
force
.
getNumInteractionGroups
()
>
0
)
{
if
(
force
.
getNumInteractionGroups
()
>
0
)
{
groupsForParticle
.
resize
(
force
.
getNumParticles
());
groupsForParticle
.
resize
(
force
.
getNumParticles
());
for
(
int
i
=
0
;
i
<
force
.
getNumInteractionGroups
();
i
++
)
{
for
(
int
i
=
0
;
i
<
force
.
getNumInteractionGroups
();
i
++
)
{
...
@@ -2324,7 +2326,8 @@ void CudaCalcCustomNonbondedForceKernel::initialize(const System& system, const
...
@@ -2324,7 +2326,8 @@ void CudaCalcCustomNonbondedForceKernel::initialize(const System& system, const
cu
.
getNonbondedUtilities
().
addArgument
(
CudaNonbondedUtilities
::
ParameterInfo
(
prefix
+
"globals"
,
"float"
,
1
,
sizeof
(
float
),
globals
->
getDevicePointer
()));
cu
.
getNonbondedUtilities
().
addArgument
(
CudaNonbondedUtilities
::
ParameterInfo
(
prefix
+
"globals"
,
"float"
,
1
,
sizeof
(
float
),
globals
->
getDevicePointer
()));
}
}
}
}
cu.addForce(new CudaCustomNonbondedForceInfo(force));
info
=
new
ForceInfo
(
force
);
cu
.
addForce
(
info
);
// Record information for the long range correction.
// Record information for the long range correction.
...
@@ -2660,9 +2663,9 @@ void CudaCalcCustomNonbondedForceKernel::copyParametersToContext(ContextImpl& co
...
@@ -2660,9 +2663,9 @@ void CudaCalcCustomNonbondedForceKernel::copyParametersToContext(ContextImpl& co
cu
.
invalidateMolecules
();
cu
.
invalidateMolecules
();
}
}
class CudaGBSAOBCForceInfo : public CudaForceInfo {
class
Cuda
Calc
GBSAOBC
ForceKernel
::
ForceInfo
:
public
CudaForceInfo
{
public:
public:
CudaGBSAOBC
ForceInfo(const GBSAOBCForce& force) : force(force) {
ForceInfo
(
const
GBSAOBCForce
&
force
)
:
force
(
force
)
{
}
}
bool
areParticlesIdentical
(
int
particle1
,
int
particle2
)
{
bool
areParticlesIdentical
(
int
particle1
,
int
particle2
)
{
double
charge1
,
charge2
,
radius1
,
radius2
,
scale1
,
scale2
;
double
charge1
,
charge2
,
radius1
,
radius2
,
scale1
,
scale2
;
...
@@ -2733,7 +2736,8 @@ void CudaCalcGBSAOBCForceKernel::initialize(const System& system, const GBSAOBCF
...
@@ -2733,7 +2736,8 @@ void CudaCalcGBSAOBCForceKernel::initialize(const System& system, const GBSAOBCF
nb
.
addInteraction
(
useCutoff
,
usePeriodic
,
false
,
cutoff
,
vector
<
vector
<
int
>
>
(),
source
,
force
.
getForceGroup
());
nb
.
addInteraction
(
useCutoff
,
usePeriodic
,
false
,
cutoff
,
vector
<
vector
<
int
>
>
(),
source
,
force
.
getForceGroup
());
nb
.
addParameter
(
CudaNonbondedUtilities
::
ParameterInfo
(
"obcParams"
,
"float"
,
2
,
sizeof
(
float2
),
params
->
getDevicePointer
()));
nb
.
addParameter
(
CudaNonbondedUtilities
::
ParameterInfo
(
"obcParams"
,
"float"
,
2
,
sizeof
(
float2
),
params
->
getDevicePointer
()));
nb
.
addParameter
(
CudaNonbondedUtilities
::
ParameterInfo
(
"bornForce"
,
"long long"
,
1
,
sizeof
(
long
long
),
bornForce
->
getDevicePointer
()));
nb
.
addParameter
(
CudaNonbondedUtilities
::
ParameterInfo
(
"bornForce"
,
"long long"
,
1
,
sizeof
(
long
long
),
bornForce
->
getDevicePointer
()));
cu.addForce(new CudaGBSAOBCForceInfo(force));
info
=
new
ForceInfo
(
force
);
cu
.
addForce
(
info
);
}
}
double
CudaCalcGBSAOBCForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
double
CudaCalcGBSAOBCForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
...
@@ -2846,23 +2850,17 @@ void CudaCalcGBSAOBCForceKernel::copyParametersToContext(ContextImpl& context, c
...
@@ -2846,23 +2850,17 @@ void CudaCalcGBSAOBCForceKernel::copyParametersToContext(ContextImpl& context, c
// Record the per-particle parameters.
// Record the per-particle parameters.
CudaArray& posq = cu.getPosq();
vector
<
double
>
chargeVector
(
cu
.
getNumAtoms
());
float4* posqf = (float4*) cu.getPinnedBuffer();
double4* posqd = (double4*) cu.getPinnedBuffer();
posq.download(cu.getPinnedBuffer());
vector
<
float2
>
paramsVector
(
cu
.
getPaddedNumAtoms
(),
make_float2
(
1
,
1
));
vector
<
float2
>
paramsVector
(
cu
.
getPaddedNumAtoms
(),
make_float2
(
1
,
1
));
const
double
dielectricOffset
=
0.009
;
const
double
dielectricOffset
=
0.009
;
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
double
charge
,
radius
,
scalingFactor
;
double
charge
,
radius
,
scalingFactor
;
force
.
getParticleParameters
(
i
,
charge
,
radius
,
scalingFactor
);
force
.
getParticleParameters
(
i
,
charge
,
radius
,
scalingFactor
);
chargeVector
[
i
]
=
charge
;
radius
-=
dielectricOffset
;
radius
-=
dielectricOffset
;
paramsVector
[
i
]
=
make_float2
((
float
)
radius
,
(
float
)
(
scalingFactor
*
radius
));
paramsVector
[
i
]
=
make_float2
((
float
)
radius
,
(
float
)
(
scalingFactor
*
radius
));
if (cu.getUseDoublePrecision())
posqd[i].w = charge;
else
posqf[i].w = (float) charge;
}
}
posq.upload(
cu.
g
et
PinnedBuffer()
);
cu
.
s
et
Charges
(
chargeVector
);
params
->
upload
(
paramsVector
);
params
->
upload
(
paramsVector
);
// Mark that the current reordering may be invalid.
// Mark that the current reordering may be invalid.
...
@@ -2870,9 +2868,9 @@ void CudaCalcGBSAOBCForceKernel::copyParametersToContext(ContextImpl& context, c
...
@@ -2870,9 +2868,9 @@ void CudaCalcGBSAOBCForceKernel::copyParametersToContext(ContextImpl& context, c
cu
.
invalidateMolecules
();
cu
.
invalidateMolecules
();
}
}
class CudaCustomGBForceInfo : public CudaForceInfo {
class
CudaC
alcC
ustomGB
ForceKernel
::
ForceInfo
:
public
CudaForceInfo
{
public:
public:
CudaCustomGB
ForceInfo(const CustomGBForce& force) : force(force) {
ForceInfo
(
const
CustomGBForce
&
force
)
:
force
(
force
)
{
}
}
bool
areParticlesIdentical
(
int
particle1
,
int
particle2
)
{
bool
areParticlesIdentical
(
int
particle1
,
int
particle2
)
{
vector
<
double
>
params1
;
vector
<
double
>
params1
;
...
@@ -3660,7 +3658,8 @@ void CudaCalcCustomGBForceKernel::initialize(const System& system, const CustomG
...
@@ -3660,7 +3658,8 @@ void CudaCalcCustomGBForceKernel::initialize(const System& system, const CustomG
for
(
int
i
=
0
;
i
<
(
int
)
arguments
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
arguments
.
size
();
i
++
)
cu
.
getNonbondedUtilities
().
addArgument
(
arguments
[
i
]);
cu
.
getNonbondedUtilities
().
addArgument
(
arguments
[
i
]);
}
}
cu.addForce(new CudaCustomGBForceInfo(force));
info
=
new
ForceInfo
(
force
);
cu
.
addForce
(
info
);
cu
.
addAutoclearBuffer
(
*
longEnergyDerivs
);
cu
.
addAutoclearBuffer
(
*
longEnergyDerivs
);
}
}
...
@@ -3876,9 +3875,9 @@ void CudaCalcCustomGBForceKernel::copyParametersToContext(ContextImpl& context,
...
@@ -3876,9 +3875,9 @@ void CudaCalcCustomGBForceKernel::copyParametersToContext(ContextImpl& context,
cu
.
invalidateMolecules
();
cu
.
invalidateMolecules
();
}
}
class CudaCustomExternalForceInfo : public CudaForceInfo {
class
CudaC
alcC
ustomExternal
ForceKernel
::
ForceInfo
:
public
CudaForceInfo
{
public:
public:
CudaCustomExternal
ForceInfo(const CustomExternalForce& force, int numParticles) : force(force), indices(numParticles, -1) {
ForceInfo
(
const
CustomExternalForce
&
force
,
int
numParticles
)
:
force
(
force
),
indices
(
numParticles
,
-
1
)
{
vector
<
double
>
params
;
vector
<
double
>
params
;
for
(
int
i
=
0
;
i
<
force
.
getNumParticles
();
i
++
)
{
for
(
int
i
=
0
;
i
<
force
.
getNumParticles
();
i
++
)
{
int
particle
;
int
particle
;
...
@@ -3935,7 +3934,8 @@ void CudaCalcCustomExternalForceKernel::initialize(const System& system, const C
...
@@ -3935,7 +3934,8 @@ void CudaCalcCustomExternalForceKernel::initialize(const System& system, const C
paramVector
[
i
][
j
]
=
(
float
)
parameters
[
j
];
paramVector
[
i
][
j
]
=
(
float
)
parameters
[
j
];
}
}
params
->
setParameterValues
(
paramVector
);
params
->
setParameterValues
(
paramVector
);
cu.addForce(new CudaCustomExternalForceInfo(force, system.getNumParticles()));
info
=
new
ForceInfo
(
force
,
system
.
getNumParticles
());
cu
.
addForce
(
info
);
// Record information for the expressions.
// Record information for the expressions.
...
@@ -4034,9 +4034,9 @@ void CudaCalcCustomExternalForceKernel::copyParametersToContext(ContextImpl& con
...
@@ -4034,9 +4034,9 @@ void CudaCalcCustomExternalForceKernel::copyParametersToContext(ContextImpl& con
cu
.
invalidateMolecules
();
cu
.
invalidateMolecules
();
}
}
class CudaCustomHbondForceInfo : public CudaForceInfo {
class
CudaC
alcC
ustomHbond
ForceKernel
::
ForceInfo
:
public
CudaForceInfo
{
public:
public:
CudaCustomHbond
ForceInfo(const CustomHbondForce& force) : force(force) {
ForceInfo
(
const
CustomHbondForce
&
force
)
:
force
(
force
)
{
}
}
bool
areParticlesIdentical
(
int
particle1
,
int
particle2
)
{
bool
areParticlesIdentical
(
int
particle1
,
int
particle2
)
{
return
true
;
return
true
;
...
@@ -4183,7 +4183,8 @@ void CudaCalcCustomHbondForceKernel::initialize(const System& system, const Cust
...
@@ -4183,7 +4183,8 @@ void CudaCalcCustomHbondForceKernel::initialize(const System& system, const Cust
}
}
acceptors
->
upload
(
acceptorVector
);
acceptors
->
upload
(
acceptorVector
);
acceptorParams
->
setParameterValues
(
acceptorParamVector
);
acceptorParams
->
setParameterValues
(
acceptorParamVector
);
cu.addForce(new CudaCustomHbondForceInfo(force));
info
=
new
ForceInfo
(
force
);
cu
.
addForce
(
info
);
// Record exclusions.
// Record exclusions.
...
@@ -4551,9 +4552,9 @@ void CudaCalcCustomHbondForceKernel::copyParametersToContext(ContextImpl& contex
...
@@ -4551,9 +4552,9 @@ void CudaCalcCustomHbondForceKernel::copyParametersToContext(ContextImpl& contex
cu
.
invalidateMolecules
();
cu
.
invalidateMolecules
();
}
}
class CudaCustomCentroidBondForceInfo : public CudaForceInfo {
class
CudaC
alcC
ustomCentroidBond
ForceKernel
::
ForceInfo
:
public
CudaForceInfo
{
public:
public:
CudaCustomCentroidBond
ForceInfo(const CustomCentroidBondForce& force) : force(force) {
ForceInfo
(
const
CustomCentroidBondForce
&
force
)
:
force
(
force
)
{
}
}
int
getNumParticleGroups
()
{
int
getNumParticleGroups
()
{
return
force
.
getNumBonds
();
return
force
.
getNumBonds
();
...
@@ -4621,7 +4622,8 @@ void CudaCalcCustomCentroidBondForceKernel::initialize(const System& system, con
...
@@ -4621,7 +4622,8 @@ void CudaCalcCustomCentroidBondForceKernel::initialize(const System& system, con
numBonds
=
force
.
getNumBonds
();
numBonds
=
force
.
getNumBonds
();
if
(
numBonds
==
0
)
if
(
numBonds
==
0
)
return
;
return
;
cu.addForce(new CudaCustomCentroidBondForceInfo(force));
info
=
new
ForceInfo
(
force
);
cu
.
addForce
(
info
);
// Record the groups.
// Record the groups.
...
@@ -5009,9 +5011,9 @@ void CudaCalcCustomCentroidBondForceKernel::copyParametersToContext(ContextImpl&
...
@@ -5009,9 +5011,9 @@ void CudaCalcCustomCentroidBondForceKernel::copyParametersToContext(ContextImpl&
cu
.
invalidateMolecules
();
cu
.
invalidateMolecules
();
}
}
class CudaCustomCompoundBondForceInfo : public CudaForceInfo {
class
CudaC
alcC
ustomCompoundBond
ForceKernel
::
ForceInfo
:
public
CudaForceInfo
{
public:
public:
CudaCustomCompoundBond
ForceInfo(const CustomCompoundBondForce& force) : force(force) {
ForceInfo
(
const
CustomCompoundBondForce
&
force
)
:
force
(
force
)
{
}
}
int
getNumParticleGroups
()
{
int
getNumParticleGroups
()
{
return
force
.
getNumBonds
();
return
force
.
getNumBonds
();
...
@@ -5064,7 +5066,8 @@ void CudaCalcCustomCompoundBondForceKernel::initialize(const System& system, con
...
@@ -5064,7 +5066,8 @@ void CudaCalcCustomCompoundBondForceKernel::initialize(const System& system, con
paramVector
[
i
][
j
]
=
(
float
)
parameters
[
j
];
paramVector
[
i
][
j
]
=
(
float
)
parameters
[
j
];
}
}
params
->
setParameterValues
(
paramVector
);
params
->
setParameterValues
(
paramVector
);
cu.addForce(new CudaCustomCompoundBondForceInfo(force));
info
=
new
ForceInfo
(
force
);
cu
.
addForce
(
info
);
// Record the tabulated functions.
// Record the tabulated functions.
...
@@ -5325,9 +5328,9 @@ void CudaCalcCustomCompoundBondForceKernel::copyParametersToContext(ContextImpl&
...
@@ -5325,9 +5328,9 @@ void CudaCalcCustomCompoundBondForceKernel::copyParametersToContext(ContextImpl&
cu
.
invalidateMolecules
();
cu
.
invalidateMolecules
();
}
}
class CudaCustomManyParticleForceInfo : public CudaForceInfo {
class
CudaC
alcC
ustomManyParticle
ForceKernel
::
ForceInfo
:
public
CudaForceInfo
{
public:
public:
CudaCustomManyParticle
ForceInfo(const CustomManyParticleForce& force) : force(force) {
ForceInfo
(
const
CustomManyParticleForce
&
force
)
:
force
(
force
)
{
}
}
bool
areParticlesIdentical
(
int
particle1
,
int
particle2
)
{
bool
areParticlesIdentical
(
int
particle1
,
int
particle2
)
{
vector
<
double
>
params1
,
params2
;
vector
<
double
>
params1
,
params2
;
...
@@ -5412,7 +5415,8 @@ void CudaCalcCustomManyParticleForceKernel::initialize(const System& system, con
...
@@ -5412,7 +5415,8 @@ void CudaCalcCustomManyParticleForceKernel::initialize(const System& system, con
paramVector
[
i
][
j
]
=
(
float
)
parameters
[
j
];
paramVector
[
i
][
j
]
=
(
float
)
parameters
[
j
];
}
}
params
->
setParameterValues
(
paramVector
);
params
->
setParameterValues
(
paramVector
);
cu.addForce(new CudaCustomManyParticleForceInfo(force));
info
=
new
ForceInfo
(
force
);
cu
.
addForce
(
info
);
// Record the tabulated functions.
// Record the tabulated functions.
...
@@ -5992,9 +5996,9 @@ void CudaCalcCustomManyParticleForceKernel::copyParametersToContext(ContextImpl&
...
@@ -5992,9 +5996,9 @@ void CudaCalcCustomManyParticleForceKernel::copyParametersToContext(ContextImpl&
cu
.
invalidateMolecules
();
cu
.
invalidateMolecules
();
}
}
class CudaGayBerneForceInfo : public CudaForceInfo {
class
Cuda
Calc
GayBerne
ForceKernel
::
ForceInfo
:
public
CudaForceInfo
{
public:
public:
CudaGayBerne
ForceInfo(const GayBerneForce& force) : force(force) {
ForceInfo
(
const
GayBerneForce
&
force
)
:
force
(
force
)
{
}
}
bool
areParticlesIdentical
(
int
particle1
,
int
particle2
)
{
bool
areParticlesIdentical
(
int
particle1
,
int
particle2
)
{
int
xparticle1
,
yparticle1
;
int
xparticle1
,
yparticle1
;
...
@@ -6205,7 +6209,8 @@ void CudaCalcGayBerneForceKernel::initialize(const System& system, const GayBern
...
@@ -6205,7 +6209,8 @@ void CudaCalcGayBerneForceKernel::initialize(const System& system, const GayBern
neighborsKernel
=
cu
.
getKernel
(
module
,
"findNeighbors"
);
neighborsKernel
=
cu
.
getKernel
(
module
,
"findNeighbors"
);
forceKernel
=
cu
.
getKernel
(
module
,
"computeForce"
);
forceKernel
=
cu
.
getKernel
(
module
,
"computeForce"
);
torqueKernel
=
cu
.
getKernel
(
module
,
"applyTorques"
);
torqueKernel
=
cu
.
getKernel
(
module
,
"applyTorques"
);
cu.addForce(new CudaGayBerneForceInfo(force));
info
=
new
ForceInfo
(
force
);
cu
.
addForce
(
info
);
cu
.
addReorderListener
(
new
ReorderListener
(
*
this
));
cu
.
addReorderListener
(
new
ReorderListener
(
*
this
));
}
}
...
...
platforms/cuda/src/kernels/utilities.cu
View file @
2a1e9acf
...
@@ -73,4 +73,11 @@ __global__ void clearSixBuffers(int* __restrict__ buffer1, int size1, int* __res
...
@@ -73,4 +73,11 @@ __global__ void clearSixBuffers(int* __restrict__ buffer1, int size1, int* __res
clearSingleBuffer
(
buffer6
,
size6
);
clearSingleBuffer
(
buffer6
,
size6
);
}
}
/**
* Record the atomic charges into the posq array.
*/
__global__
void
setCharges
(
real
*
__restrict__
charges
,
real4
*
__restrict__
posq
,
int
*
__restrict__
atomOrder
,
int
numAtoms
)
{
for
(
int
i
=
blockDim
.
x
*
blockIdx
.
x
+
threadIdx
.
x
;
i
<
numAtoms
;
i
+=
blockDim
.
x
*
gridDim
.
x
)
posq
[
i
].
w
=
charges
[
atomOrder
[
i
]];
}
}
}
\ No newline at end of file
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