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
73183c61
Commit
73183c61
authored
May 31, 2016
by
ChayaSt
Browse files
resolved conflict
parents
0e218233
32e08b87
Changes
267
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
214 additions
and
129 deletions
+214
-129
openmmapi/src/MonteCarloAnisotropicBarostat.cpp
openmmapi/src/MonteCarloAnisotropicBarostat.cpp
+3
-3
openmmapi/src/MonteCarloAnisotropicBarostatImpl.cpp
openmmapi/src/MonteCarloAnisotropicBarostatImpl.cpp
+3
-2
openmmapi/src/MonteCarloBarostat.cpp
openmmapi/src/MonteCarloBarostat.cpp
+3
-3
openmmapi/src/MonteCarloBarostatImpl.cpp
openmmapi/src/MonteCarloBarostatImpl.cpp
+2
-1
openmmapi/src/MonteCarloMembraneBarostat.cpp
openmmapi/src/MonteCarloMembraneBarostat.cpp
+3
-3
openmmapi/src/MonteCarloMembraneBarostatImpl.cpp
openmmapi/src/MonteCarloMembraneBarostatImpl.cpp
+3
-2
openmmapi/src/PeriodicTorsionForce.cpp
openmmapi/src/PeriodicTorsionForce.cpp
+10
-2
openmmapi/src/RBTorsionForce.cpp
openmmapi/src/RBTorsionForce.cpp
+10
-2
platforms/cpu/include/CpuKernels.h
platforms/cpu/include/CpuKernels.h
+8
-8
platforms/cpu/include/CpuNeighborList.h
platforms/cpu/include/CpuNeighborList.h
+2
-1
platforms/cpu/include/CpuPlatform.h
platforms/cpu/include/CpuPlatform.h
+9
-2
platforms/cpu/src/CpuCustomGBForce.cpp
platforms/cpu/src/CpuCustomGBForce.cpp
+10
-7
platforms/cpu/src/CpuCustomNonbondedForce.cpp
platforms/cpu/src/CpuCustomNonbondedForce.cpp
+4
-3
platforms/cpu/src/CpuKernels.cpp
platforms/cpu/src/CpuKernels.cpp
+74
-75
platforms/cpu/src/CpuNeighborList.cpp
platforms/cpu/src/CpuNeighborList.cpp
+4
-0
platforms/cpu/src/CpuPlatform.cpp
platforms/cpu/src/CpuPlatform.cpp
+33
-3
platforms/cuda/include/CudaContext.h
platforms/cuda/include/CudaContext.h
+13
-1
platforms/cuda/include/CudaKernels.h
platforms/cuda/include/CudaKernels.h
+2
-2
platforms/cuda/include/CudaNonbondedUtilities.h
platforms/cuda/include/CudaNonbondedUtilities.h
+2
-0
platforms/cuda/include/CudaPlatform.h
platforms/cuda/include/CudaPlatform.h
+16
-9
No files found.
openmmapi/src/MonteCarloAnisotropicBarostat.cpp
View file @
73183c61
...
@@ -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) 2010 Stanford University and the Authors.
*
* Portions copyright (c) 2010
-2016
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -34,8 +34,8 @@
...
@@ -34,8 +34,8 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
MonteCarloAnisotropicBarostat
::
MonteCarloAnisotropicBarostat
(
const
Vec3
&
defaultPressure
,
double
t
emperature
,
bool
scaleX
,
bool
scaleY
,
bool
scaleZ
,
int
frequency
)
:
MonteCarloAnisotropicBarostat
::
MonteCarloAnisotropicBarostat
(
const
Vec3
&
defaultPressure
,
double
defaultT
emperature
,
bool
scaleX
,
bool
scaleY
,
bool
scaleZ
,
int
frequency
)
:
defaultPressure
(
defaultPressure
),
t
emperature
(
t
emperature
),
scaleX
(
scaleX
),
scaleY
(
scaleY
),
scaleZ
(
scaleZ
),
frequency
(
frequency
)
{
defaultPressure
(
defaultPressure
),
defaultT
emperature
(
defaultT
emperature
),
scaleX
(
scaleX
),
scaleY
(
scaleY
),
scaleZ
(
scaleZ
),
frequency
(
frequency
)
{
setRandomNumberSeed
(
0
);
setRandomNumberSeed
(
0
);
}
}
...
...
openmmapi/src/MonteCarloAnisotropicBarostatImpl.cpp
View file @
73183c61
...
@@ -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) 2010-201
3
Stanford University and the Authors. *
* Portions copyright (c) 2010-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman, Lee-Ping Wang *
* Authors: Peter Eastman, Lee-Ping Wang *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -119,7 +119,7 @@ void MonteCarloAnisotropicBarostatImpl::updateContextState(ContextImpl& context)
...
@@ -119,7 +119,7 @@ void MonteCarloAnisotropicBarostatImpl::updateContextState(ContextImpl& context)
// Compute the energy of the modified system.
// Compute the energy of the modified system.
double
finalEnergy
=
context
.
getOwner
().
getState
(
State
::
Energy
).
getPotentialEnergy
();
double
finalEnergy
=
context
.
getOwner
().
getState
(
State
::
Energy
).
getPotentialEnergy
();
double
kT
=
BOLTZ
*
owner
.
get
Temperature
();
double
kT
=
BOLTZ
*
context
.
getParameter
(
MonteCarloAnisotropicBarostat
::
Temperature
()
)
;
double
w
=
finalEnergy
-
initialEnergy
+
pressure
*
deltaVolume
-
context
.
getMolecules
().
size
()
*
kT
*
std
::
log
(
newVolume
/
volume
);
double
w
=
finalEnergy
-
initialEnergy
+
pressure
*
deltaVolume
-
context
.
getMolecules
().
size
()
*
kT
*
std
::
log
(
newVolume
/
volume
);
if
(
w
>
0
&&
genrand_real2
(
random
)
>
std
::
exp
(
-
w
/
kT
))
{
if
(
w
>
0
&&
genrand_real2
(
random
)
>
std
::
exp
(
-
w
/
kT
))
{
// Reject the step.
// Reject the step.
...
@@ -150,6 +150,7 @@ std::map<std::string, double> MonteCarloAnisotropicBarostatImpl::getDefaultParam
...
@@ -150,6 +150,7 @@ std::map<std::string, double> MonteCarloAnisotropicBarostatImpl::getDefaultParam
parameters
[
MonteCarloAnisotropicBarostat
::
PressureX
()]
=
getOwner
().
getDefaultPressure
()[
0
];
parameters
[
MonteCarloAnisotropicBarostat
::
PressureX
()]
=
getOwner
().
getDefaultPressure
()[
0
];
parameters
[
MonteCarloAnisotropicBarostat
::
PressureY
()]
=
getOwner
().
getDefaultPressure
()[
1
];
parameters
[
MonteCarloAnisotropicBarostat
::
PressureY
()]
=
getOwner
().
getDefaultPressure
()[
1
];
parameters
[
MonteCarloAnisotropicBarostat
::
PressureZ
()]
=
getOwner
().
getDefaultPressure
()[
2
];
parameters
[
MonteCarloAnisotropicBarostat
::
PressureZ
()]
=
getOwner
().
getDefaultPressure
()[
2
];
parameters
[
MonteCarloAnisotropicBarostat
::
Temperature
()]
=
getOwner
().
getDefaultTemperature
();
return
parameters
;
return
parameters
;
}
}
...
...
openmmapi/src/MonteCarloBarostat.cpp
View file @
73183c61
...
@@ -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) 2010 Stanford University and the Authors.
*
* Portions copyright (c) 2010
-2016
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -34,8 +34,8 @@
...
@@ -34,8 +34,8 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
MonteCarloBarostat
::
MonteCarloBarostat
(
double
defaultPressure
,
double
t
emperature
,
int
frequency
)
:
MonteCarloBarostat
::
MonteCarloBarostat
(
double
defaultPressure
,
double
defaultT
emperature
,
int
frequency
)
:
defaultPressure
(
defaultPressure
),
t
emperature
(
t
emperature
),
frequency
(
frequency
)
{
defaultPressure
(
defaultPressure
),
defaultT
emperature
(
defaultT
emperature
),
frequency
(
frequency
)
{
setRandomNumberSeed
(
0
);
setRandomNumberSeed
(
0
);
}
}
...
...
openmmapi/src/MonteCarloBarostatImpl.cpp
View file @
73183c61
...
@@ -89,7 +89,7 @@ void MonteCarloBarostatImpl::updateContextState(ContextImpl& context) {
...
@@ -89,7 +89,7 @@ void MonteCarloBarostatImpl::updateContextState(ContextImpl& context) {
double
finalEnergy
=
context
.
getOwner
().
getState
(
State
::
Energy
).
getPotentialEnergy
();
double
finalEnergy
=
context
.
getOwner
().
getState
(
State
::
Energy
).
getPotentialEnergy
();
double
pressure
=
context
.
getParameter
(
MonteCarloBarostat
::
Pressure
())
*
(
AVOGADRO
*
1e-25
);
double
pressure
=
context
.
getParameter
(
MonteCarloBarostat
::
Pressure
())
*
(
AVOGADRO
*
1e-25
);
double
kT
=
BOLTZ
*
owner
.
get
Temperature
();
double
kT
=
BOLTZ
*
context
.
getParameter
(
MonteCarloBarostat
::
Temperature
()
)
;
double
w
=
finalEnergy
-
initialEnergy
+
pressure
*
deltaVolume
-
context
.
getMolecules
().
size
()
*
kT
*
std
::
log
(
newVolume
/
volume
);
double
w
=
finalEnergy
-
initialEnergy
+
pressure
*
deltaVolume
-
context
.
getMolecules
().
size
()
*
kT
*
std
::
log
(
newVolume
/
volume
);
if
(
w
>
0
&&
genrand_real2
(
random
)
>
std
::
exp
(
-
w
/
kT
))
{
if
(
w
>
0
&&
genrand_real2
(
random
)
>
std
::
exp
(
-
w
/
kT
))
{
// Reject the step.
// Reject the step.
...
@@ -118,6 +118,7 @@ void MonteCarloBarostatImpl::updateContextState(ContextImpl& context) {
...
@@ -118,6 +118,7 @@ void MonteCarloBarostatImpl::updateContextState(ContextImpl& context) {
std
::
map
<
std
::
string
,
double
>
MonteCarloBarostatImpl
::
getDefaultParameters
()
{
std
::
map
<
std
::
string
,
double
>
MonteCarloBarostatImpl
::
getDefaultParameters
()
{
std
::
map
<
std
::
string
,
double
>
parameters
;
std
::
map
<
std
::
string
,
double
>
parameters
;
parameters
[
MonteCarloBarostat
::
Pressure
()]
=
getOwner
().
getDefaultPressure
();
parameters
[
MonteCarloBarostat
::
Pressure
()]
=
getOwner
().
getDefaultPressure
();
parameters
[
MonteCarloBarostat
::
Temperature
()]
=
getOwner
().
getDefaultTemperature
();
return
parameters
;
return
parameters
;
}
}
...
...
openmmapi/src/MonteCarloMembraneBarostat.cpp
View file @
73183c61
...
@@ -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) 2010-201
4
Stanford University and the Authors. *
* Portions copyright (c) 2010-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -34,8 +34,8 @@
...
@@ -34,8 +34,8 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
MonteCarloMembraneBarostat
::
MonteCarloMembraneBarostat
(
double
defaultPressure
,
double
defaultSurfaceTension
,
double
t
emperature
,
XYMode
xymode
,
ZMode
zmode
,
int
frequency
)
:
MonteCarloMembraneBarostat
::
MonteCarloMembraneBarostat
(
double
defaultPressure
,
double
defaultSurfaceTension
,
double
defaultT
emperature
,
XYMode
xymode
,
ZMode
zmode
,
int
frequency
)
:
defaultPressure
(
defaultPressure
),
defaultSurfaceTension
(
defaultSurfaceTension
),
t
emperature
(
t
emperature
),
defaultPressure
(
defaultPressure
),
defaultSurfaceTension
(
defaultSurfaceTension
),
defaultT
emperature
(
defaultT
emperature
),
xymode
(
xymode
),
zmode
(
zmode
),
frequency
(
frequency
)
{
xymode
(
xymode
),
zmode
(
zmode
),
frequency
(
frequency
)
{
setRandomNumberSeed
(
0
);
setRandomNumberSeed
(
0
);
}
}
...
...
openmmapi/src/MonteCarloMembraneBarostatImpl.cpp
View file @
73183c61
...
@@ -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) 2010-201
4
Stanford University and the Authors. *
* Portions copyright (c) 2010-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman, Lee-Ping Wang *
* Authors: Peter Eastman, Lee-Ping Wang *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -120,7 +120,7 @@ void MonteCarloMembraneBarostatImpl::updateContextState(ContextImpl& context) {
...
@@ -120,7 +120,7 @@ void MonteCarloMembraneBarostatImpl::updateContextState(ContextImpl& context) {
// Compute the energy of the modified system.
// Compute the energy of the modified system.
double
finalEnergy
=
context
.
getOwner
().
getState
(
State
::
Energy
).
getPotentialEnergy
();
double
finalEnergy
=
context
.
getOwner
().
getState
(
State
::
Energy
).
getPotentialEnergy
();
double
kT
=
BOLTZ
*
owner
.
get
Temperature
();
double
kT
=
BOLTZ
*
context
.
getParameter
(
MonteCarloMembraneBarostat
::
Temperature
()
)
;
double
w
=
finalEnergy
-
initialEnergy
+
pressure
*
deltaVolume
-
tension
*
deltaArea
-
context
.
getMolecules
().
size
()
*
kT
*
std
::
log
(
newVolume
/
volume
);
double
w
=
finalEnergy
-
initialEnergy
+
pressure
*
deltaVolume
-
tension
*
deltaArea
-
context
.
getMolecules
().
size
()
*
kT
*
std
::
log
(
newVolume
/
volume
);
if
(
w
>
0
&&
genrand_real2
(
random
)
>
std
::
exp
(
-
w
/
kT
))
{
if
(
w
>
0
&&
genrand_real2
(
random
)
>
std
::
exp
(
-
w
/
kT
))
{
// Reject the step.
// Reject the step.
...
@@ -150,6 +150,7 @@ std::map<std::string, double> MonteCarloMembraneBarostatImpl::getDefaultParamete
...
@@ -150,6 +150,7 @@ std::map<std::string, double> MonteCarloMembraneBarostatImpl::getDefaultParamete
std
::
map
<
std
::
string
,
double
>
parameters
;
std
::
map
<
std
::
string
,
double
>
parameters
;
parameters
[
MonteCarloMembraneBarostat
::
Pressure
()]
=
getOwner
().
getDefaultPressure
();
parameters
[
MonteCarloMembraneBarostat
::
Pressure
()]
=
getOwner
().
getDefaultPressure
();
parameters
[
MonteCarloMembraneBarostat
::
SurfaceTension
()]
=
getOwner
().
getDefaultSurfaceTension
();
parameters
[
MonteCarloMembraneBarostat
::
SurfaceTension
()]
=
getOwner
().
getDefaultSurfaceTension
();
parameters
[
MonteCarloMembraneBarostat
::
Temperature
()]
=
getOwner
().
getDefaultTemperature
();
return
parameters
;
return
parameters
;
}
}
...
...
openmmapi/src/PeriodicTorsionForce.cpp
View file @
73183c61
...
@@ -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
2
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
PeriodicTorsionForce
::
PeriodicTorsionForce
()
{
PeriodicTorsionForce
::
PeriodicTorsionForce
()
:
usePeriodic
(
false
)
{
}
}
int
PeriodicTorsionForce
::
addTorsion
(
int
particle1
,
int
particle2
,
int
particle3
,
int
particle4
,
int
periodicity
,
double
phase
,
double
k
)
{
int
PeriodicTorsionForce
::
addTorsion
(
int
particle1
,
int
particle2
,
int
particle3
,
int
particle4
,
int
periodicity
,
double
phase
,
double
k
)
{
...
@@ -74,3 +74,11 @@ ForceImpl* PeriodicTorsionForce::createImpl() const {
...
@@ -74,3 +74,11 @@ ForceImpl* PeriodicTorsionForce::createImpl() const {
void
PeriodicTorsionForce
::
updateParametersInContext
(
Context
&
context
)
{
void
PeriodicTorsionForce
::
updateParametersInContext
(
Context
&
context
)
{
dynamic_cast
<
PeriodicTorsionForceImpl
&>
(
getImplInContext
(
context
)).
updateParametersInContext
(
getContextImpl
(
context
));
dynamic_cast
<
PeriodicTorsionForceImpl
&>
(
getImplInContext
(
context
)).
updateParametersInContext
(
getContextImpl
(
context
));
}
}
void
PeriodicTorsionForce
::
setUsesPeriodicBoundaryConditions
(
bool
periodic
)
{
usePeriodic
=
periodic
;
}
bool
PeriodicTorsionForce
::
usesPeriodicBoundaryConditions
()
const
{
return
usePeriodic
;
}
openmmapi/src/RBTorsionForce.cpp
View file @
73183c61
...
@@ -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
2
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
RBTorsionForce
::
RBTorsionForce
()
{
RBTorsionForce
::
RBTorsionForce
()
:
usePeriodic
(
false
)
{
}
}
int
RBTorsionForce
::
addTorsion
(
int
particle1
,
int
particle2
,
int
particle3
,
int
particle4
,
double
c0
,
double
c1
,
double
c2
,
double
c3
,
double
c4
,
double
c5
)
{
int
RBTorsionForce
::
addTorsion
(
int
particle1
,
int
particle2
,
int
particle3
,
int
particle4
,
double
c0
,
double
c1
,
double
c2
,
double
c3
,
double
c4
,
double
c5
)
{
...
@@ -80,3 +80,11 @@ ForceImpl* RBTorsionForce::createImpl() const {
...
@@ -80,3 +80,11 @@ ForceImpl* RBTorsionForce::createImpl() const {
void
RBTorsionForce
::
updateParametersInContext
(
Context
&
context
)
{
void
RBTorsionForce
::
updateParametersInContext
(
Context
&
context
)
{
dynamic_cast
<
RBTorsionForceImpl
&>
(
getImplInContext
(
context
)).
updateParametersInContext
(
getContextImpl
(
context
));
dynamic_cast
<
RBTorsionForceImpl
&>
(
getImplInContext
(
context
)).
updateParametersInContext
(
getContextImpl
(
context
));
}
}
void
RBTorsionForce
::
setUsesPeriodicBoundaryConditions
(
bool
periodic
)
{
usePeriodic
=
periodic
;
}
bool
RBTorsionForce
::
usesPeriodicBoundaryConditions
()
const
{
return
usePeriodic
;
}
platforms/cpu/include/CpuKernels.h
View file @
73183c61
...
@@ -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) 2013 Stanford University and the Authors.
*
* Portions copyright (c) 2013
-2016
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -90,6 +90,7 @@ public:
...
@@ -90,6 +90,7 @@ public:
private:
private:
CpuPlatform
::
PlatformData
&
data
;
CpuPlatform
::
PlatformData
&
data
;
Kernel
referenceKernel
;
Kernel
referenceKernel
;
std
::
vector
<
RealVec
>
lastPositions
;
};
};
/**
/**
...
@@ -98,7 +99,7 @@ private:
...
@@ -98,7 +99,7 @@ private:
class
CpuCalcHarmonicAngleForceKernel
:
public
CalcHarmonicAngleForceKernel
{
class
CpuCalcHarmonicAngleForceKernel
:
public
CalcHarmonicAngleForceKernel
{
public:
public:
CpuCalcHarmonicAngleForceKernel
(
std
::
string
name
,
const
Platform
&
platform
,
CpuPlatform
::
PlatformData
&
data
)
:
CpuCalcHarmonicAngleForceKernel
(
std
::
string
name
,
const
Platform
&
platform
,
CpuPlatform
::
PlatformData
&
data
)
:
CalcHarmonicAngleForceKernel
(
name
,
platform
),
data
(
data
),
angleIndexArray
(
NULL
),
angleParamArray
(
NULL
)
{
CalcHarmonicAngleForceKernel
(
name
,
platform
),
data
(
data
),
angleIndexArray
(
NULL
),
angleParamArray
(
NULL
)
,
usePeriodic
(
false
)
{
}
}
~
CpuCalcHarmonicAngleForceKernel
();
~
CpuCalcHarmonicAngleForceKernel
();
/**
/**
...
@@ -130,6 +131,7 @@ private:
...
@@ -130,6 +131,7 @@ private:
int
**
angleIndexArray
;
int
**
angleIndexArray
;
RealOpenMM
**
angleParamArray
;
RealOpenMM
**
angleParamArray
;
CpuBondForce
bondForce
;
CpuBondForce
bondForce
;
bool
usePeriodic
;
};
};
/**
/**
...
@@ -138,7 +140,7 @@ private:
...
@@ -138,7 +140,7 @@ private:
class
CpuCalcPeriodicTorsionForceKernel
:
public
CalcPeriodicTorsionForceKernel
{
class
CpuCalcPeriodicTorsionForceKernel
:
public
CalcPeriodicTorsionForceKernel
{
public:
public:
CpuCalcPeriodicTorsionForceKernel
(
std
::
string
name
,
const
Platform
&
platform
,
CpuPlatform
::
PlatformData
&
data
)
:
CpuCalcPeriodicTorsionForceKernel
(
std
::
string
name
,
const
Platform
&
platform
,
CpuPlatform
::
PlatformData
&
data
)
:
CalcPeriodicTorsionForceKernel
(
name
,
platform
),
data
(
data
),
torsionIndexArray
(
NULL
),
torsionParamArray
(
NULL
)
{
CalcPeriodicTorsionForceKernel
(
name
,
platform
),
data
(
data
),
torsionIndexArray
(
NULL
),
torsionParamArray
(
NULL
)
,
usePeriodic
(
false
)
{
}
}
~
CpuCalcPeriodicTorsionForceKernel
();
~
CpuCalcPeriodicTorsionForceKernel
();
/**
/**
...
@@ -170,6 +172,7 @@ private:
...
@@ -170,6 +172,7 @@ private:
int
**
torsionIndexArray
;
int
**
torsionIndexArray
;
RealOpenMM
**
torsionParamArray
;
RealOpenMM
**
torsionParamArray
;
CpuBondForce
bondForce
;
CpuBondForce
bondForce
;
bool
usePeriodic
;
};
};
/**
/**
...
@@ -178,7 +181,7 @@ private:
...
@@ -178,7 +181,7 @@ private:
class
CpuCalcRBTorsionForceKernel
:
public
CalcRBTorsionForceKernel
{
class
CpuCalcRBTorsionForceKernel
:
public
CalcRBTorsionForceKernel
{
public:
public:
CpuCalcRBTorsionForceKernel
(
std
::
string
name
,
const
Platform
&
platform
,
CpuPlatform
::
PlatformData
&
data
)
:
CpuCalcRBTorsionForceKernel
(
std
::
string
name
,
const
Platform
&
platform
,
CpuPlatform
::
PlatformData
&
data
)
:
CalcRBTorsionForceKernel
(
name
,
platform
),
data
(
data
),
torsionIndexArray
(
NULL
),
torsionParamArray
(
NULL
)
{
CalcRBTorsionForceKernel
(
name
,
platform
),
data
(
data
),
torsionIndexArray
(
NULL
),
torsionParamArray
(
NULL
)
,
usePeriodic
(
false
)
{
}
}
~
CpuCalcRBTorsionForceKernel
();
~
CpuCalcRBTorsionForceKernel
();
/**
/**
...
@@ -210,6 +213,7 @@ private:
...
@@ -210,6 +213,7 @@ private:
int
**
torsionIndexArray
;
int
**
torsionIndexArray
;
RealOpenMM
**
torsionParamArray
;
RealOpenMM
**
torsionParamArray
;
CpuBondForce
bondForce
;
CpuBondForce
bondForce
;
bool
usePeriodic
;
};
};
/**
/**
...
@@ -264,9 +268,7 @@ private:
...
@@ -264,9 +268,7 @@ private:
bool
useSwitchingFunction
,
useOptimizedPme
,
hasInitializedPme
;
bool
useSwitchingFunction
,
useOptimizedPme
,
hasInitializedPme
;
std
::
vector
<
std
::
set
<
int
>
>
exclusions
;
std
::
vector
<
std
::
set
<
int
>
>
exclusions
;
std
::
vector
<
std
::
pair
<
float
,
float
>
>
particleParams
;
std
::
vector
<
std
::
pair
<
float
,
float
>
>
particleParams
;
std
::
vector
<
RealVec
>
lastPositions
;
NonbondedMethod
nonbondedMethod
;
NonbondedMethod
nonbondedMethod
;
CpuNeighborList
*
neighborList
;
CpuNonbondedForce
*
nonbonded
;
CpuNonbondedForce
*
nonbonded
;
Kernel
optimizedPme
;
Kernel
optimizedPme
;
CpuBondForce
bondForce
;
CpuBondForce
bondForce
;
...
@@ -314,7 +316,6 @@ private:
...
@@ -314,7 +316,6 @@ private:
std
::
vector
<
std
::
string
>
parameterNames
,
globalParameterNames
;
std
::
vector
<
std
::
string
>
parameterNames
,
globalParameterNames
;
std
::
vector
<
std
::
pair
<
std
::
set
<
int
>
,
std
::
set
<
int
>
>
>
interactionGroups
;
std
::
vector
<
std
::
pair
<
std
::
set
<
int
>
,
std
::
set
<
int
>
>
>
interactionGroups
;
NonbondedMethod
nonbondedMethod
;
NonbondedMethod
nonbondedMethod
;
CpuNeighborList
*
neighborList
;
CpuCustomNonbondedForce
*
nonbonded
;
CpuCustomNonbondedForce
*
nonbonded
;
};
};
...
@@ -400,7 +401,6 @@ private:
...
@@ -400,7 +401,6 @@ private:
std
::
vector
<
OpenMM
::
CustomGBForce
::
ComputationType
>
valueTypes
;
std
::
vector
<
OpenMM
::
CustomGBForce
::
ComputationType
>
valueTypes
;
std
::
vector
<
OpenMM
::
CustomGBForce
::
ComputationType
>
energyTypes
;
std
::
vector
<
OpenMM
::
CustomGBForce
::
ComputationType
>
energyTypes
;
NonbondedMethod
nonbondedMethod
;
NonbondedMethod
nonbondedMethod
;
CpuNeighborList
*
neighborList
;
};
};
/**
/**
...
...
platforms/cpu/include/CpuNeighborList.h
View file @
73183c61
...
@@ -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) 2013-201
5
Stanford University and the Authors. *
* Portions copyright (c) 2013-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -51,6 +51,7 @@ public:
...
@@ -51,6 +51,7 @@ public:
void
computeNeighborList
(
int
numAtoms
,
const
AlignedArray
<
float
>&
atomLocations
,
const
std
::
vector
<
std
::
set
<
int
>
>&
exclusions
,
void
computeNeighborList
(
int
numAtoms
,
const
AlignedArray
<
float
>&
atomLocations
,
const
std
::
vector
<
std
::
set
<
int
>
>&
exclusions
,
const
RealVec
*
periodicBoxVectors
,
bool
usePeriodic
,
float
maxDistance
,
ThreadPool
&
threads
);
const
RealVec
*
periodicBoxVectors
,
bool
usePeriodic
,
float
maxDistance
,
ThreadPool
&
threads
);
int
getNumBlocks
()
const
;
int
getNumBlocks
()
const
;
int
getBlockSize
()
const
;
const
std
::
vector
<
int
>&
getSortedAtoms
()
const
;
const
std
::
vector
<
int
>&
getSortedAtoms
()
const
;
const
std
::
vector
<
int
>&
getBlockNeighbors
(
int
blockIndex
)
const
;
const
std
::
vector
<
int
>&
getBlockNeighbors
(
int
blockIndex
)
const
;
const
std
::
vector
<
char
>&
getBlockExclusions
(
int
blockIndex
)
const
;
const
std
::
vector
<
char
>&
getBlockExclusions
(
int
blockIndex
)
const
;
...
...
platforms/cpu/include/CpuPlatform.h
View file @
73183c61
...
@@ -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) 2013 Stanford University and the Authors.
*
* Portions copyright (c) 2013
-2016
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#include "AlignedArray.h"
#include "AlignedArray.h"
#include "CpuRandom.h"
#include "CpuRandom.h"
#include "CpuNeighborList.h"
#include "ReferencePlatform.h"
#include "ReferencePlatform.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/ThreadPool.h"
#include "openmm/internal/ThreadPool.h"
...
@@ -64,7 +65,7 @@ public:
...
@@ -64,7 +65,7 @@ public:
* This is the name of the parameter for selecting the number of threads to use.
* This is the name of the parameter for selecting the number of threads to use.
*/
*/
static
const
std
::
string
&
CpuThreads
()
{
static
const
std
::
string
&
CpuThreads
()
{
static
const
std
::
string
key
=
"
Cpu
Threads"
;
static
const
std
::
string
key
=
"Threads"
;
return
key
;
return
key
;
}
}
/**
/**
...
@@ -80,12 +81,18 @@ private:
...
@@ -80,12 +81,18 @@ private:
class
CpuPlatform
::
PlatformData
{
class
CpuPlatform
::
PlatformData
{
public:
public:
PlatformData
(
int
numParticles
,
int
numThreads
);
PlatformData
(
int
numParticles
,
int
numThreads
);
~
PlatformData
();
void
requestNeighborList
(
double
cutoffDistance
,
double
padding
,
bool
useExclusions
,
std
::
vector
<
std
::
set
<
int
>
>&
exclusionList
);
AlignedArray
<
float
>
posq
;
AlignedArray
<
float
>
posq
;
std
::
vector
<
AlignedArray
<
float
>
>
threadForce
;
std
::
vector
<
AlignedArray
<
float
>
>
threadForce
;
ThreadPool
threads
;
ThreadPool
threads
;
bool
isPeriodic
;
bool
isPeriodic
;
CpuRandom
random
;
CpuRandom
random
;
std
::
map
<
std
::
string
,
std
::
string
>
propertyValues
;
std
::
map
<
std
::
string
,
std
::
string
>
propertyValues
;
CpuNeighborList
*
neighborList
;
double
cutoff
,
paddedCutoff
;
bool
anyExclusions
;
std
::
vector
<
std
::
set
<
int
>
>
exclusions
;
};
};
}
// namespace OpenMM
}
// namespace OpenMM
...
...
platforms/cpu/src/CpuCustomGBForce.cpp
View file @
73183c61
/* Portions copyright (c) 2009-201
4
Stanford University and Simbios.
/* Portions copyright (c) 2009-201
6
Stanford University and Simbios.
* Contributors: Peter Eastman
* Contributors: Peter Eastman
*
*
* Permission is hereby granted, free of charge, to any person obtaining
* Permission is hereby granted, free of charge, to any person obtaining
...
@@ -294,12 +294,13 @@ void CpuCustomGBForce::calculateParticlePairValue(int index, ThreadData& data, i
...
@@ -294,12 +294,13 @@ void CpuCustomGBForce::calculateParticlePairValue(int index, ThreadData& data, i
int
blockIndex
=
gmx_atomic_fetch_add
(
reinterpret_cast
<
gmx_atomic_t
*>
(
atomicCounter
),
1
);
int
blockIndex
=
gmx_atomic_fetch_add
(
reinterpret_cast
<
gmx_atomic_t
*>
(
atomicCounter
),
1
);
if
(
blockIndex
>=
neighborList
->
getNumBlocks
())
if
(
blockIndex
>=
neighborList
->
getNumBlocks
())
break
;
break
;
const
int
*
blockAtom
=
&
neighborList
->
getSortedAtoms
()[
4
*
blockIndex
];
const
int
blockSize
=
neighborList
->
getBlockSize
();
const
int
*
blockAtom
=
&
neighborList
->
getSortedAtoms
()[
blockSize
*
blockIndex
];
const
vector
<
int
>&
neighbors
=
neighborList
->
getBlockNeighbors
(
blockIndex
);
const
vector
<
int
>&
neighbors
=
neighborList
->
getBlockNeighbors
(
blockIndex
);
const
vector
<
char
>&
blockExclusions
=
neighborList
->
getBlockExclusions
(
blockIndex
);
const
vector
<
char
>&
blockExclusions
=
neighborList
->
getBlockExclusions
(
blockIndex
);
for
(
int
i
=
0
;
i
<
(
int
)
neighbors
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
neighbors
.
size
();
i
++
)
{
int
first
=
neighbors
[
i
];
int
first
=
neighbors
[
i
];
for
(
int
k
=
0
;
k
<
4
;
k
++
)
{
for
(
int
k
=
0
;
k
<
blockSize
;
k
++
)
{
if
((
blockExclusions
[
i
]
&
(
1
<<
k
))
==
0
)
{
if
((
blockExclusions
[
i
]
&
(
1
<<
k
))
==
0
)
{
int
second
=
blockAtom
[
k
];
int
second
=
blockAtom
[
k
];
if
(
useExclusions
&&
exclusions
[
first
].
find
(
second
)
!=
exclusions
[
first
].
end
())
if
(
useExclusions
&&
exclusions
[
first
].
find
(
second
)
!=
exclusions
[
first
].
end
())
...
@@ -379,12 +380,13 @@ void CpuCustomGBForce::calculateParticlePairEnergyTerm(int index, ThreadData& da
...
@@ -379,12 +380,13 @@ void CpuCustomGBForce::calculateParticlePairEnergyTerm(int index, ThreadData& da
int
blockIndex
=
gmx_atomic_fetch_add
(
reinterpret_cast
<
gmx_atomic_t
*>
(
atomicCounter
),
1
);
int
blockIndex
=
gmx_atomic_fetch_add
(
reinterpret_cast
<
gmx_atomic_t
*>
(
atomicCounter
),
1
);
if
(
blockIndex
>=
neighborList
->
getNumBlocks
())
if
(
blockIndex
>=
neighborList
->
getNumBlocks
())
break
;
break
;
const
int
*
blockAtom
=
&
neighborList
->
getSortedAtoms
()[
4
*
blockIndex
];
const
int
blockSize
=
neighborList
->
getBlockSize
();
const
int
*
blockAtom
=
&
neighborList
->
getSortedAtoms
()[
blockSize
*
blockIndex
];
const
vector
<
int
>&
neighbors
=
neighborList
->
getBlockNeighbors
(
blockIndex
);
const
vector
<
int
>&
neighbors
=
neighborList
->
getBlockNeighbors
(
blockIndex
);
const
vector
<
char
>&
blockExclusions
=
neighborList
->
getBlockExclusions
(
blockIndex
);
const
vector
<
char
>&
blockExclusions
=
neighborList
->
getBlockExclusions
(
blockIndex
);
for
(
int
i
=
0
;
i
<
(
int
)
neighbors
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
neighbors
.
size
();
i
++
)
{
int
first
=
neighbors
[
i
];
int
first
=
neighbors
[
i
];
for
(
int
k
=
0
;
k
<
4
;
k
++
)
{
for
(
int
k
=
0
;
k
<
blockSize
;
k
++
)
{
if
((
blockExclusions
[
i
]
&
(
1
<<
k
))
==
0
)
{
if
((
blockExclusions
[
i
]
&
(
1
<<
k
))
==
0
)
{
int
second
=
blockAtom
[
k
];
int
second
=
blockAtom
[
k
];
if
(
useExclusions
&&
exclusions
[
first
].
find
(
second
)
!=
exclusions
[
first
].
end
())
if
(
useExclusions
&&
exclusions
[
first
].
find
(
second
)
!=
exclusions
[
first
].
end
())
...
@@ -460,12 +462,13 @@ void CpuCustomGBForce::calculateChainRuleForces(ThreadData& data, int numAtoms,
...
@@ -460,12 +462,13 @@ void CpuCustomGBForce::calculateChainRuleForces(ThreadData& data, int numAtoms,
int
blockIndex
=
gmx_atomic_fetch_add
(
reinterpret_cast
<
gmx_atomic_t
*>
(
atomicCounter
),
1
);
int
blockIndex
=
gmx_atomic_fetch_add
(
reinterpret_cast
<
gmx_atomic_t
*>
(
atomicCounter
),
1
);
if
(
blockIndex
>=
neighborList
->
getNumBlocks
())
if
(
blockIndex
>=
neighborList
->
getNumBlocks
())
break
;
break
;
const
int
*
blockAtom
=
&
neighborList
->
getSortedAtoms
()[
4
*
blockIndex
];
const
int
blockSize
=
neighborList
->
getBlockSize
();
const
int
*
blockAtom
=
&
neighborList
->
getSortedAtoms
()[
blockSize
*
blockIndex
];
const
vector
<
int
>&
neighbors
=
neighborList
->
getBlockNeighbors
(
blockIndex
);
const
vector
<
int
>&
neighbors
=
neighborList
->
getBlockNeighbors
(
blockIndex
);
const
vector
<
char
>&
blockExclusions
=
neighborList
->
getBlockExclusions
(
blockIndex
);
const
vector
<
char
>&
blockExclusions
=
neighborList
->
getBlockExclusions
(
blockIndex
);
for
(
int
i
=
0
;
i
<
(
int
)
neighbors
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
neighbors
.
size
();
i
++
)
{
int
first
=
neighbors
[
i
];
int
first
=
neighbors
[
i
];
for
(
int
k
=
0
;
k
<
4
;
k
++
)
{
for
(
int
k
=
0
;
k
<
blockSize
;
k
++
)
{
if
((
blockExclusions
[
i
]
&
(
1
<<
k
))
==
0
)
{
if
((
blockExclusions
[
i
]
&
(
1
<<
k
))
==
0
)
{
int
second
=
blockAtom
[
k
];
int
second
=
blockAtom
[
k
];
bool
isExcluded
=
(
exclusions
[
first
].
find
(
second
)
!=
exclusions
[
first
].
end
());
bool
isExcluded
=
(
exclusions
[
first
].
find
(
second
)
!=
exclusions
[
first
].
end
());
...
...
platforms/cpu/src/CpuCustomNonbondedForce.cpp
View file @
73183c61
/* Portions copyright (c) 2009-201
4
Stanford University and Simbios.
/* Portions copyright (c) 2009-201
6
Stanford University and Simbios.
* Contributors: Peter Eastman
* Contributors: Peter Eastman
*
*
* Permission is hereby granted, free of charge, to any person obtaining
* Permission is hereby granted, free of charge, to any person obtaining
...
@@ -190,7 +190,8 @@ void CpuCustomNonbondedForce::threadComputeForce(ThreadPool& threads, int thread
...
@@ -190,7 +190,8 @@ void CpuCustomNonbondedForce::threadComputeForce(ThreadPool& threads, int thread
int
blockIndex
=
gmx_atomic_fetch_add
(
reinterpret_cast
<
gmx_atomic_t
*>
(
atomicCounter
),
1
);
int
blockIndex
=
gmx_atomic_fetch_add
(
reinterpret_cast
<
gmx_atomic_t
*>
(
atomicCounter
),
1
);
if
(
blockIndex
>=
neighborList
->
getNumBlocks
())
if
(
blockIndex
>=
neighborList
->
getNumBlocks
())
break
;
break
;
const
int
*
blockAtom
=
&
neighborList
->
getSortedAtoms
()[
4
*
blockIndex
];
const
int
blockSize
=
neighborList
->
getBlockSize
();
const
int
*
blockAtom
=
&
neighborList
->
getSortedAtoms
()[
blockSize
*
blockIndex
];
const
vector
<
int
>&
neighbors
=
neighborList
->
getBlockNeighbors
(
blockIndex
);
const
vector
<
int
>&
neighbors
=
neighborList
->
getBlockNeighbors
(
blockIndex
);
const
vector
<
char
>&
exclusions
=
neighborList
->
getBlockExclusions
(
blockIndex
);
const
vector
<
char
>&
exclusions
=
neighborList
->
getBlockExclusions
(
blockIndex
);
for
(
int
i
=
0
;
i
<
(
int
)
neighbors
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
neighbors
.
size
();
i
++
)
{
...
@@ -199,7 +200,7 @@ void CpuCustomNonbondedForce::threadComputeForce(ThreadPool& threads, int thread
...
@@ -199,7 +200,7 @@ void CpuCustomNonbondedForce::threadComputeForce(ThreadPool& threads, int thread
ReferenceForce
::
setVariable
(
data
.
energyParticleParams
[
j
*
2
],
atomParameters
[
first
][
j
]);
ReferenceForce
::
setVariable
(
data
.
energyParticleParams
[
j
*
2
],
atomParameters
[
first
][
j
]);
ReferenceForce
::
setVariable
(
data
.
forceParticleParams
[
j
*
2
],
atomParameters
[
first
][
j
]);
ReferenceForce
::
setVariable
(
data
.
forceParticleParams
[
j
*
2
],
atomParameters
[
first
][
j
]);
}
}
for
(
int
k
=
0
;
k
<
4
;
k
++
)
{
for
(
int
k
=
0
;
k
<
blockSize
;
k
++
)
{
if
((
exclusions
[
i
]
&
(
1
<<
k
))
==
0
)
{
if
((
exclusions
[
i
]
&
(
1
<<
k
))
==
0
)
{
int
second
=
blockAtom
[
k
];
int
second
=
blockAtom
[
k
];
for
(
int
j
=
0
;
j
<
(
int
)
paramNames
.
size
();
j
++
)
{
for
(
int
j
=
0
;
j
<
(
int
)
paramNames
.
size
();
j
++
)
{
...
...
platforms/cpu/src/CpuKernels.cpp
View file @
73183c61
...
@@ -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) 2013-201
5
Stanford University and the Authors. *
* Portions copyright (c) 2013-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -230,6 +230,7 @@ CpuCalcForcesAndEnergyKernel::CpuCalcForcesAndEnergyKernel(std::string name, con
...
@@ -230,6 +230,7 @@ CpuCalcForcesAndEnergyKernel::CpuCalcForcesAndEnergyKernel(std::string name, con
void
CpuCalcForcesAndEnergyKernel
::
initialize
(
const
System
&
system
)
{
void
CpuCalcForcesAndEnergyKernel
::
initialize
(
const
System
&
system
)
{
referenceKernel
.
getAs
<
ReferenceCalcForcesAndEnergyKernel
>
().
initialize
(
system
);
referenceKernel
.
getAs
<
ReferenceCalcForcesAndEnergyKernel
>
().
initialize
(
system
);
lastPositions
.
resize
(
system
.
getNumParticles
(),
Vec3
(
1e10
,
1e10
,
1e10
));
}
}
void
CpuCalcForcesAndEnergyKernel
::
beginComputation
(
ContextImpl
&
context
,
bool
includeForce
,
bool
includeEnergy
,
int
groups
)
{
void
CpuCalcForcesAndEnergyKernel
::
beginComputation
(
ContextImpl
&
context
,
bool
includeForce
,
bool
includeEnergy
,
int
groups
)
{
...
@@ -237,11 +238,60 @@ void CpuCalcForcesAndEnergyKernel::beginComputation(ContextImpl& context, bool i
...
@@ -237,11 +238,60 @@ void CpuCalcForcesAndEnergyKernel::beginComputation(ContextImpl& context, bool i
// Convert positions to single precision and clear the forces.
// Convert positions to single precision and clear the forces.
InitForceTask
task
(
context
.
getSystem
().
getNumParticles
(),
context
,
data
);
int
numParticles
=
context
.
getSystem
().
getNumParticles
();
InitForceTask
task
(
numParticles
,
context
,
data
);
data
.
threads
.
execute
(
task
);
data
.
threads
.
execute
(
task
);
data
.
threads
.
waitForThreads
();
data
.
threads
.
waitForThreads
();
if
(
!
task
.
positionsValid
)
if
(
!
task
.
positionsValid
)
throw
OpenMMException
(
"Particle coordinate is nan"
);
throw
OpenMMException
(
"Particle coordinate is nan"
);
// Determine whether we need to recompute the neighbor list.
if
(
data
.
neighborList
!=
NULL
)
{
double
padding
=
data
.
paddedCutoff
-
data
.
cutoff
;;
bool
needRecompute
=
false
;
double
closeCutoff2
=
0.25
*
padding
*
padding
;
double
farCutoff2
=
0.5
*
padding
*
padding
;
int
maxNumMoved
=
numParticles
/
10
;
vector
<
int
>
moved
;
vector
<
RealVec
>&
posData
=
extractPositions
(
context
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
RealVec
delta
=
posData
[
i
]
-
lastPositions
[
i
];
double
dist2
=
delta
.
dot
(
delta
);
if
(
dist2
>
closeCutoff2
)
{
moved
.
push_back
(
i
);
if
(
dist2
>
farCutoff2
||
moved
.
size
()
>
maxNumMoved
)
{
needRecompute
=
true
;
break
;
}
}
}
if
(
!
needRecompute
&&
moved
.
size
()
>
0
)
{
// Some particles have moved further than half the padding distance. Look for pairs
// that are missing from the neighbor list.
int
numMoved
=
moved
.
size
();
double
cutoff2
=
data
.
cutoff
*
data
.
cutoff
;
double
paddedCutoff2
=
data
.
paddedCutoff
*
data
.
paddedCutoff
;
for
(
int
i
=
1
;
i
<
numMoved
&&
!
needRecompute
;
i
++
)
for
(
int
j
=
0
;
j
<
i
;
j
++
)
{
RealVec
delta
=
posData
[
moved
[
i
]]
-
posData
[
moved
[
j
]];
if
(
delta
.
dot
(
delta
)
<
cutoff2
)
{
// These particles should interact. See if they are in the neighbor list.
RealVec
oldDelta
=
lastPositions
[
moved
[
i
]]
-
lastPositions
[
moved
[
j
]];
if
(
oldDelta
.
dot
(
oldDelta
)
>
paddedCutoff2
)
{
needRecompute
=
true
;
break
;
}
}
}
}
if
(
needRecompute
)
{
data
.
neighborList
->
computeNeighborList
(
numParticles
,
data
.
posq
,
data
.
exclusions
,
extractBoxVectors
(
context
),
data
.
isPeriodic
,
data
.
paddedCutoff
,
data
.
threads
);
lastPositions
=
posData
;
}
}
}
}
double
CpuCalcForcesAndEnergyKernel
::
finishComputation
(
ContextImpl
&
context
,
bool
includeForce
,
bool
includeEnergy
,
int
groups
,
bool
&
valid
)
{
double
CpuCalcForcesAndEnergyKernel
::
finishComputation
(
ContextImpl
&
context
,
bool
includeForce
,
bool
includeEnergy
,
int
groups
,
bool
&
valid
)
{
...
@@ -283,6 +333,7 @@ void CpuCalcHarmonicAngleForceKernel::initialize(const System& system, const Har
...
@@ -283,6 +333,7 @@ void CpuCalcHarmonicAngleForceKernel::initialize(const System& system, const Har
angleParamArray
[
i
][
1
]
=
(
RealOpenMM
)
k
;
angleParamArray
[
i
][
1
]
=
(
RealOpenMM
)
k
;
}
}
bondForce
.
initialize
(
system
.
getNumParticles
(),
numAngles
,
3
,
angleIndexArray
,
data
.
threads
);
bondForce
.
initialize
(
system
.
getNumParticles
(),
numAngles
,
3
,
angleIndexArray
,
data
.
threads
);
usePeriodic
=
force
.
usesPeriodicBoundaryConditions
();
}
}
double
CpuCalcHarmonicAngleForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
double
CpuCalcHarmonicAngleForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
...
@@ -290,6 +341,8 @@ double CpuCalcHarmonicAngleForceKernel::execute(ContextImpl& context, bool inclu
...
@@ -290,6 +341,8 @@ double CpuCalcHarmonicAngleForceKernel::execute(ContextImpl& context, bool inclu
vector
<
RealVec
>&
forceData
=
extractForces
(
context
);
vector
<
RealVec
>&
forceData
=
extractForces
(
context
);
RealOpenMM
energy
=
0
;
RealOpenMM
energy
=
0
;
ReferenceAngleBondIxn
angleBond
;
ReferenceAngleBondIxn
angleBond
;
if
(
usePeriodic
)
angleBond
.
setPeriodic
(
extractBoxVectors
(
context
));
bondForce
.
calculateForce
(
posData
,
angleParamArray
,
forceData
,
includeEnergy
?
&
energy
:
NULL
,
angleBond
);
bondForce
.
calculateForce
(
posData
,
angleParamArray
,
forceData
,
includeEnergy
?
&
energy
:
NULL
,
angleBond
);
return
energy
;
return
energy
;
}
}
...
@@ -343,6 +396,7 @@ void CpuCalcPeriodicTorsionForceKernel::initialize(const System& system, const P
...
@@ -343,6 +396,7 @@ void CpuCalcPeriodicTorsionForceKernel::initialize(const System& system, const P
torsionParamArray
[
i
][
2
]
=
(
RealOpenMM
)
periodicity
;
torsionParamArray
[
i
][
2
]
=
(
RealOpenMM
)
periodicity
;
}
}
bondForce
.
initialize
(
system
.
getNumParticles
(),
numTorsions
,
4
,
torsionIndexArray
,
data
.
threads
);
bondForce
.
initialize
(
system
.
getNumParticles
(),
numTorsions
,
4
,
torsionIndexArray
,
data
.
threads
);
usePeriodic
=
force
.
usesPeriodicBoundaryConditions
();
}
}
double
CpuCalcPeriodicTorsionForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
double
CpuCalcPeriodicTorsionForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
...
@@ -350,6 +404,8 @@ double CpuCalcPeriodicTorsionForceKernel::execute(ContextImpl& context, bool inc
...
@@ -350,6 +404,8 @@ double CpuCalcPeriodicTorsionForceKernel::execute(ContextImpl& context, bool inc
vector
<
RealVec
>&
forceData
=
extractForces
(
context
);
vector
<
RealVec
>&
forceData
=
extractForces
(
context
);
RealOpenMM
energy
=
0
;
RealOpenMM
energy
=
0
;
ReferenceProperDihedralBond
periodicTorsionBond
;
ReferenceProperDihedralBond
periodicTorsionBond
;
if
(
usePeriodic
)
periodicTorsionBond
.
setPeriodic
(
extractBoxVectors
(
context
));
bondForce
.
calculateForce
(
posData
,
torsionParamArray
,
forceData
,
includeEnergy
?
&
energy
:
NULL
,
periodicTorsionBond
);
bondForce
.
calculateForce
(
posData
,
torsionParamArray
,
forceData
,
includeEnergy
?
&
energy
:
NULL
,
periodicTorsionBond
);
return
energy
;
return
energy
;
}
}
...
@@ -407,6 +463,7 @@ void CpuCalcRBTorsionForceKernel::initialize(const System& system, const RBTorsi
...
@@ -407,6 +463,7 @@ void CpuCalcRBTorsionForceKernel::initialize(const System& system, const RBTorsi
torsionParamArray
[
i
][
5
]
=
(
RealOpenMM
)
c5
;
torsionParamArray
[
i
][
5
]
=
(
RealOpenMM
)
c5
;
}
}
bondForce
.
initialize
(
system
.
getNumParticles
(),
numTorsions
,
4
,
torsionIndexArray
,
data
.
threads
);
bondForce
.
initialize
(
system
.
getNumParticles
(),
numTorsions
,
4
,
torsionIndexArray
,
data
.
threads
);
usePeriodic
=
force
.
usesPeriodicBoundaryConditions
();
}
}
double
CpuCalcRBTorsionForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
double
CpuCalcRBTorsionForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
...
@@ -414,6 +471,8 @@ double CpuCalcRBTorsionForceKernel::execute(ContextImpl& context, bool includeFo
...
@@ -414,6 +471,8 @@ double CpuCalcRBTorsionForceKernel::execute(ContextImpl& context, bool includeFo
vector
<
RealVec
>&
forceData
=
extractForces
(
context
);
vector
<
RealVec
>&
forceData
=
extractForces
(
context
);
RealOpenMM
energy
=
0
;
RealOpenMM
energy
=
0
;
ReferenceRbDihedralBond
rbTorsionBond
;
ReferenceRbDihedralBond
rbTorsionBond
;
if
(
usePeriodic
)
rbTorsionBond
.
setPeriodic
(
extractBoxVectors
(
context
));
bondForce
.
calculateForce
(
posData
,
torsionParamArray
,
forceData
,
includeEnergy
?
&
energy
:
NULL
,
rbTorsionBond
);
bondForce
.
calculateForce
(
posData
,
torsionParamArray
,
forceData
,
includeEnergy
?
&
energy
:
NULL
,
rbTorsionBond
);
return
energy
;
return
energy
;
}
}
...
@@ -464,15 +523,11 @@ CpuNonbondedForce* createCpuNonbondedForceVec4();
...
@@ -464,15 +523,11 @@ CpuNonbondedForce* createCpuNonbondedForceVec4();
CpuNonbondedForce
*
createCpuNonbondedForceVec8
();
CpuNonbondedForce
*
createCpuNonbondedForceVec8
();
CpuCalcNonbondedForceKernel
::
CpuCalcNonbondedForceKernel
(
string
name
,
const
Platform
&
platform
,
CpuPlatform
::
PlatformData
&
data
)
:
CalcNonbondedForceKernel
(
name
,
platform
),
CpuCalcNonbondedForceKernel
::
CpuCalcNonbondedForceKernel
(
string
name
,
const
Platform
&
platform
,
CpuPlatform
::
PlatformData
&
data
)
:
CalcNonbondedForceKernel
(
name
,
platform
),
data
(
data
),
bonded14IndexArray
(
NULL
),
bonded14ParamArray
(
NULL
),
hasInitializedPme
(
false
),
neighborList
(
NULL
),
nonbonded
(
NULL
)
{
data
(
data
),
bonded14IndexArray
(
NULL
),
bonded14ParamArray
(
NULL
),
hasInitializedPme
(
false
),
nonbonded
(
NULL
)
{
if
(
isVec8Supported
())
{
if
(
isVec8Supported
())
neighborList
=
new
CpuNeighborList
(
8
);
nonbonded
=
createCpuNonbondedForceVec8
();
nonbonded
=
createCpuNonbondedForceVec8
();
}
else
else
{
neighborList
=
new
CpuNeighborList
(
4
);
nonbonded
=
createCpuNonbondedForceVec4
();
nonbonded
=
createCpuNonbondedForceVec4
();
}
}
}
CpuCalcNonbondedForceKernel
::~
CpuCalcNonbondedForceKernel
()
{
CpuCalcNonbondedForceKernel
::~
CpuCalcNonbondedForceKernel
()
{
...
@@ -486,8 +541,6 @@ CpuCalcNonbondedForceKernel::~CpuCalcNonbondedForceKernel() {
...
@@ -486,8 +541,6 @@ CpuCalcNonbondedForceKernel::~CpuCalcNonbondedForceKernel() {
}
}
if
(
nonbonded
!=
NULL
)
if
(
nonbonded
!=
NULL
)
delete
nonbonded
;
delete
nonbonded
;
if
(
neighborList
!=
NULL
)
delete
neighborList
;
}
}
void
CpuCalcNonbondedForceKernel
::
initialize
(
const
System
&
system
,
const
NonbondedForce
&
force
)
{
void
CpuCalcNonbondedForceKernel
::
initialize
(
const
System
&
system
,
const
NonbondedForce
&
force
)
{
...
@@ -547,6 +600,7 @@ void CpuCalcNonbondedForceKernel::initialize(const System& system, const Nonbond
...
@@ -547,6 +600,7 @@ void CpuCalcNonbondedForceKernel::initialize(const System& system, const Nonbond
if
(
nonbondedMethod
==
NoCutoff
)
if
(
nonbondedMethod
==
NoCutoff
)
useSwitchingFunction
=
false
;
useSwitchingFunction
=
false
;
else
{
else
{
data
.
requestNeighborList
(
nonbondedCutoff
,
0.25
*
nonbondedCutoff
,
true
,
exclusions
);
useSwitchingFunction
=
force
.
getUseSwitchingFunction
();
useSwitchingFunction
=
force
.
getUseSwitchingFunction
();
switchingDistance
=
force
.
getSwitchingDistance
();
switchingDistance
=
force
.
getSwitchingDistance
();
}
}
...
@@ -569,7 +623,6 @@ void CpuCalcNonbondedForceKernel::initialize(const System& system, const Nonbond
...
@@ -569,7 +623,6 @@ void CpuCalcNonbondedForceKernel::initialize(const System& system, const Nonbond
dispersionCoefficient
=
NonbondedForceImpl
::
calcDispersionCorrection
(
system
,
force
);
dispersionCoefficient
=
NonbondedForceImpl
::
calcDispersionCorrection
(
system
,
force
);
else
else
dispersionCoefficient
=
0.0
;
dispersionCoefficient
=
0.0
;
lastPositions
.
resize
(
numParticles
,
Vec3
(
1e10
,
1e10
,
1e10
));
data
.
isPeriodic
=
(
nonbondedMethod
==
CutoffPeriodic
||
nonbondedMethod
==
Ewald
||
nonbondedMethod
==
PME
);
data
.
isPeriodic
=
(
nonbondedMethod
==
CutoffPeriodic
||
nonbondedMethod
==
Ewald
||
nonbondedMethod
==
PME
);
}
}
...
@@ -596,53 +649,8 @@ double CpuCalcNonbondedForceKernel::execute(ContextImpl& context, bool includeFo
...
@@ -596,53 +649,8 @@ double CpuCalcNonbondedForceKernel::execute(ContextImpl& context, bool includeFo
double
energy
=
(
includeReciprocal
?
ewaldSelfEnergy
:
0.0
);
double
energy
=
(
includeReciprocal
?
ewaldSelfEnergy
:
0.0
);
bool
ewald
=
(
nonbondedMethod
==
Ewald
);
bool
ewald
=
(
nonbondedMethod
==
Ewald
);
bool
pme
=
(
nonbondedMethod
==
PME
);
bool
pme
=
(
nonbondedMethod
==
PME
);
if
(
nonbondedMethod
!=
NoCutoff
)
{
if
(
nonbondedMethod
!=
NoCutoff
)
// Determine whether we need to recompute the neighbor list.
nonbonded
->
setUseCutoff
(
nonbondedCutoff
,
*
data
.
neighborList
,
rfDielectric
);
double
padding
=
0.25
*
nonbondedCutoff
;
bool
needRecompute
=
false
;
double
closeCutoff2
=
0.25
*
padding
*
padding
;
double
farCutoff2
=
0.5
*
padding
*
padding
;
int
maxNumMoved
=
numParticles
/
10
;
vector
<
int
>
moved
;
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
RealVec
delta
=
posData
[
i
]
-
lastPositions
[
i
];
double
dist2
=
delta
.
dot
(
delta
);
if
(
dist2
>
closeCutoff2
)
{
moved
.
push_back
(
i
);
if
(
dist2
>
farCutoff2
||
moved
.
size
()
>
maxNumMoved
)
{
needRecompute
=
true
;
break
;
}
}
}
if
(
!
needRecompute
&&
moved
.
size
()
>
0
)
{
// Some particles have moved further than half the padding distance. Look for pairs
// that are missing from the neighbor list.
int
numMoved
=
moved
.
size
();
double
cutoff2
=
nonbondedCutoff
*
nonbondedCutoff
;
double
paddedCutoff2
=
(
nonbondedCutoff
+
padding
)
*
(
nonbondedCutoff
+
padding
);
for
(
int
i
=
1
;
i
<
numMoved
&&
!
needRecompute
;
i
++
)
for
(
int
j
=
0
;
j
<
i
;
j
++
)
{
RealVec
delta
=
posData
[
moved
[
i
]]
-
posData
[
moved
[
j
]];
if
(
delta
.
dot
(
delta
)
<
cutoff2
)
{
// These particles should interact. See if they are in the neighbor list.
RealVec
oldDelta
=
lastPositions
[
moved
[
i
]]
-
lastPositions
[
moved
[
j
]];
if
(
oldDelta
.
dot
(
oldDelta
)
>
paddedCutoff2
)
{
needRecompute
=
true
;
break
;
}
}
}
}
if
(
needRecompute
)
{
neighborList
->
computeNeighborList
(
numParticles
,
posq
,
exclusions
,
boxVectors
,
data
.
isPeriodic
,
nonbondedCutoff
+
padding
,
data
.
threads
);
lastPositions
=
posData
;
}
nonbonded
->
setUseCutoff
(
nonbondedCutoff
,
*
neighborList
,
rfDielectric
);
}
if
(
data
.
isPeriodic
)
{
if
(
data
.
isPeriodic
)
{
RealVec
*
boxVectors
=
extractBoxVectors
(
context
);
RealVec
*
boxVectors
=
extractBoxVectors
(
context
);
double
minAllowedSize
=
1.999999
*
nonbondedCutoff
;
double
minAllowedSize
=
1.999999
*
nonbondedCutoff
;
...
@@ -739,7 +747,7 @@ void CpuCalcNonbondedForceKernel::getPMEParameters(double& alpha, int& nx, int&
...
@@ -739,7 +747,7 @@ void CpuCalcNonbondedForceKernel::getPMEParameters(double& alpha, int& nx, int&
}
}
CpuCalcCustomNonbondedForceKernel
::
CpuCalcCustomNonbondedForceKernel
(
string
name
,
const
Platform
&
platform
,
CpuPlatform
::
PlatformData
&
data
)
:
CpuCalcCustomNonbondedForceKernel
::
CpuCalcCustomNonbondedForceKernel
(
string
name
,
const
Platform
&
platform
,
CpuPlatform
::
PlatformData
&
data
)
:
CalcCustomNonbondedForceKernel
(
name
,
platform
),
data
(
data
),
forceCopy
(
NULL
),
neighborList
(
NULL
),
nonbonded
(
NULL
)
{
CalcCustomNonbondedForceKernel
(
name
,
platform
),
data
(
data
),
forceCopy
(
NULL
),
nonbonded
(
NULL
)
{
}
}
CpuCalcCustomNonbondedForceKernel
::~
CpuCalcCustomNonbondedForceKernel
()
{
CpuCalcCustomNonbondedForceKernel
::~
CpuCalcCustomNonbondedForceKernel
()
{
...
@@ -748,8 +756,6 @@ CpuCalcCustomNonbondedForceKernel::~CpuCalcCustomNonbondedForceKernel() {
...
@@ -748,8 +756,6 @@ CpuCalcCustomNonbondedForceKernel::~CpuCalcCustomNonbondedForceKernel() {
delete
[]
particleParamArray
[
i
];
delete
[]
particleParamArray
[
i
];
delete
[]
particleParamArray
;
delete
[]
particleParamArray
;
}
}
if
(
neighborList
!=
NULL
)
delete
neighborList
;
if
(
nonbonded
!=
NULL
)
if
(
nonbonded
!=
NULL
)
delete
nonbonded
;
delete
nonbonded
;
if
(
forceCopy
!=
NULL
)
if
(
forceCopy
!=
NULL
)
...
@@ -786,7 +792,7 @@ void CpuCalcCustomNonbondedForceKernel::initialize(const System& system, const C
...
@@ -786,7 +792,7 @@ void CpuCalcCustomNonbondedForceKernel::initialize(const System& system, const C
if
(
nonbondedMethod
==
NoCutoff
)
if
(
nonbondedMethod
==
NoCutoff
)
useSwitchingFunction
=
false
;
useSwitchingFunction
=
false
;
else
{
else
{
neighborList
=
new
CpuNeighborList
(
4
);
data
.
requestNeighborList
(
nonbondedCutoff
,
0.25
*
nonbondedCutoff
,
true
,
exclusions
);
useSwitchingFunction
=
force
.
getUseSwitchingFunction
();
useSwitchingFunction
=
force
.
getUseSwitchingFunction
();
switchingDistance
=
force
.
getSwitchingDistance
();
switchingDistance
=
force
.
getSwitchingDistance
();
}
}
...
@@ -852,10 +858,8 @@ double CpuCalcCustomNonbondedForceKernel::execute(ContextImpl& context, bool inc
...
@@ -852,10 +858,8 @@ double CpuCalcCustomNonbondedForceKernel::execute(ContextImpl& context, bool inc
RealVec
*
boxVectors
=
extractBoxVectors
(
context
);
RealVec
*
boxVectors
=
extractBoxVectors
(
context
);
double
energy
=
0
;
double
energy
=
0
;
bool
periodic
=
(
nonbondedMethod
==
CutoffPeriodic
);
bool
periodic
=
(
nonbondedMethod
==
CutoffPeriodic
);
if
(
nonbondedMethod
!=
NoCutoff
)
{
if
(
nonbondedMethod
!=
NoCutoff
)
neighborList
->
computeNeighborList
(
numParticles
,
data
.
posq
,
exclusions
,
boxVectors
,
data
.
isPeriodic
,
nonbondedCutoff
,
data
.
threads
);
nonbonded
->
setUseCutoff
(
nonbondedCutoff
,
*
data
.
neighborList
);
nonbonded
->
setUseCutoff
(
nonbondedCutoff
,
*
neighborList
);
}
if
(
periodic
)
{
if
(
periodic
)
{
double
minAllowedSize
=
2
*
nonbondedCutoff
;
double
minAllowedSize
=
2
*
nonbondedCutoff
;
if
(
boxVectors
[
0
][
0
]
<
minAllowedSize
||
boxVectors
[
1
][
1
]
<
minAllowedSize
||
boxVectors
[
2
][
2
]
<
minAllowedSize
)
if
(
boxVectors
[
0
][
0
]
<
minAllowedSize
||
boxVectors
[
1
][
1
]
<
minAllowedSize
||
boxVectors
[
2
][
2
]
<
minAllowedSize
)
...
@@ -963,8 +967,6 @@ CpuCalcCustomGBForceKernel::~CpuCalcCustomGBForceKernel() {
...
@@ -963,8 +967,6 @@ CpuCalcCustomGBForceKernel::~CpuCalcCustomGBForceKernel() {
delete
[]
particleParamArray
[
i
];
delete
[]
particleParamArray
[
i
];
delete
[]
particleParamArray
;
delete
[]
particleParamArray
;
}
}
if
(
neighborList
!=
NULL
)
delete
neighborList
;
if
(
ixn
!=
NULL
)
if
(
ixn
!=
NULL
)
delete
ixn
;
delete
ixn
;
}
}
...
@@ -1012,10 +1014,8 @@ void CpuCalcCustomGBForceKernel::initialize(const System& system, const CustomGB
...
@@ -1012,10 +1014,8 @@ void CpuCalcCustomGBForceKernel::initialize(const System& system, const CustomGB
globalParameterNames
.
push_back
(
force
.
getGlobalParameterName
(
i
));
globalParameterNames
.
push_back
(
force
.
getGlobalParameterName
(
i
));
nonbondedMethod
=
CalcCustomGBForceKernel
::
NonbondedMethod
(
force
.
getNonbondedMethod
());
nonbondedMethod
=
CalcCustomGBForceKernel
::
NonbondedMethod
(
force
.
getNonbondedMethod
());
nonbondedCutoff
=
(
RealOpenMM
)
force
.
getCutoffDistance
();
nonbondedCutoff
=
(
RealOpenMM
)
force
.
getCutoffDistance
();
if
(
nonbondedMethod
==
NoCutoff
)
if
(
nonbondedMethod
!=
NoCutoff
)
neighborList
=
NULL
;
data
.
requestNeighborList
(
nonbondedCutoff
,
0.25
*
nonbondedCutoff
,
true
,
exclusions
);
else
neighborList
=
new
CpuNeighborList
(
4
);
// Create custom functions for the tabulated functions.
// Create custom functions for the tabulated functions.
...
@@ -1112,8 +1112,7 @@ double CpuCalcCustomGBForceKernel::execute(ContextImpl& context, bool includeFor
...
@@ -1112,8 +1112,7 @@ double CpuCalcCustomGBForceKernel::execute(ContextImpl& context, bool includeFor
ixn
->
setPeriodic
(
extractBoxSize
(
context
));
ixn
->
setPeriodic
(
extractBoxSize
(
context
));
if
(
nonbondedMethod
!=
NoCutoff
)
{
if
(
nonbondedMethod
!=
NoCutoff
)
{
vector
<
set
<
int
>
>
noExclusions
(
numParticles
);
vector
<
set
<
int
>
>
noExclusions
(
numParticles
);
neighborList
->
computeNeighborList
(
numParticles
,
data
.
posq
,
exclusions
,
boxVectors
,
data
.
isPeriodic
,
nonbondedCutoff
,
data
.
threads
);
ixn
->
setUseCutoff
(
nonbondedCutoff
,
*
data
.
neighborList
);
ixn
->
setUseCutoff
(
nonbondedCutoff
,
*
neighborList
);
}
}
map
<
string
,
double
>
globalParameters
;
map
<
string
,
double
>
globalParameters
;
for
(
int
i
=
0
;
i
<
(
int
)
globalParameterNames
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
globalParameterNames
.
size
();
i
++
)
...
...
platforms/cpu/src/CpuNeighborList.cpp
View file @
73183c61
...
@@ -508,6 +508,10 @@ int CpuNeighborList::getNumBlocks() const {
...
@@ -508,6 +508,10 @@ int CpuNeighborList::getNumBlocks() const {
return
sortedAtoms
.
size
()
/
blockSize
;
return
sortedAtoms
.
size
()
/
blockSize
;
}
}
int
CpuNeighborList
::
getBlockSize
()
const
{
return
blockSize
;
}
const
std
::
vector
<
int
>&
CpuNeighborList
::
getSortedAtoms
()
const
{
const
std
::
vector
<
int
>&
CpuNeighborList
::
getSortedAtoms
()
const
{
return
sortedAtoms
;
return
sortedAtoms
;
}
}
...
...
platforms/cpu/src/CpuPlatform.cpp
View file @
73183c61
...
@@ -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) 2013-201
4
Stanford University and the Authors. *
* Portions copyright (c) 2013-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#include "CpuKernels.h"
#include "CpuKernels.h"
#include "CpuSETTLE.h"
#include "CpuSETTLE.h"
#include "ReferenceConstraints.h"
#include "ReferenceConstraints.h"
#include "openmm/OpenMMException.h"
#include "openmm/internal/hardware.h"
#include "openmm/internal/hardware.h"
#include "openmm/internal/vectorize.h"
#include "openmm/internal/vectorize.h"
#include <sstream>
#include <sstream>
...
@@ -59,6 +60,7 @@ extern "C" OPENMM_EXPORT_CPU void registerPlatforms() {
...
@@ -59,6 +60,7 @@ extern "C" OPENMM_EXPORT_CPU void registerPlatforms() {
map
<
const
ContextImpl
*
,
CpuPlatform
::
PlatformData
*>
CpuPlatform
::
contextData
;
map
<
const
ContextImpl
*
,
CpuPlatform
::
PlatformData
*>
CpuPlatform
::
contextData
;
CpuPlatform
::
CpuPlatform
()
{
CpuPlatform
::
CpuPlatform
()
{
deprecatedPropertyReplacements
[
"CpuThreads"
]
=
CpuThreads
();
CpuKernelFactory
*
factory
=
new
CpuKernelFactory
();
CpuKernelFactory
*
factory
=
new
CpuKernelFactory
();
registerKernelFactory
(
CalcForcesAndEnergyKernel
::
Name
(),
factory
);
registerKernelFactory
(
CalcForcesAndEnergyKernel
::
Name
(),
factory
);
registerKernelFactory
(
CalcHarmonicAngleForceKernel
::
Name
(),
factory
);
registerKernelFactory
(
CalcHarmonicAngleForceKernel
::
Name
(),
factory
);
...
@@ -83,7 +85,10 @@ CpuPlatform::CpuPlatform() {
...
@@ -83,7 +85,10 @@ CpuPlatform::CpuPlatform() {
const
string
&
CpuPlatform
::
getPropertyValue
(
const
Context
&
context
,
const
string
&
property
)
const
{
const
string
&
CpuPlatform
::
getPropertyValue
(
const
Context
&
context
,
const
string
&
property
)
const
{
const
ContextImpl
&
impl
=
getContextImpl
(
context
);
const
ContextImpl
&
impl
=
getContextImpl
(
context
);
const
PlatformData
&
data
=
getPlatformData
(
impl
);
const
PlatformData
&
data
=
getPlatformData
(
impl
);
map
<
string
,
string
>::
const_iterator
value
=
data
.
propertyValues
.
find
(
property
);
string
propertyName
=
property
;
if
(
deprecatedPropertyReplacements
.
find
(
property
)
!=
deprecatedPropertyReplacements
.
end
())
propertyName
=
deprecatedPropertyReplacements
.
find
(
property
)
->
second
;
map
<
string
,
string
>::
const_iterator
value
=
data
.
propertyValues
.
find
(
propertyName
);
if
(
value
!=
data
.
propertyValues
.
end
())
if
(
value
!=
data
.
propertyValues
.
end
())
return
value
->
second
;
return
value
->
second
;
return
ReferencePlatform
::
getPropertyValue
(
context
,
property
);
return
ReferencePlatform
::
getPropertyValue
(
context
,
property
);
...
@@ -131,7 +136,8 @@ const CpuPlatform::PlatformData& CpuPlatform::getPlatformData(const ContextImpl&
...
@@ -131,7 +136,8 @@ const CpuPlatform::PlatformData& CpuPlatform::getPlatformData(const ContextImpl&
return
*
contextData
[
&
context
];
return
*
contextData
[
&
context
];
}
}
CpuPlatform
::
PlatformData
::
PlatformData
(
int
numParticles
,
int
numThreads
)
:
posq
(
4
*
numParticles
),
threads
(
numThreads
)
{
CpuPlatform
::
PlatformData
::
PlatformData
(
int
numParticles
,
int
numThreads
)
:
posq
(
4
*
numParticles
),
threads
(
numThreads
),
neighborList
(
NULL
),
cutoff
(
0.0
),
paddedCutoff
(
0.0
),
anyExclusions
(
false
)
{
numThreads
=
threads
.
getNumThreads
();
numThreads
=
threads
.
getNumThreads
();
threadForce
.
resize
(
numThreads
);
threadForce
.
resize
(
numThreads
);
for
(
int
i
=
0
;
i
<
numThreads
;
i
++
)
for
(
int
i
=
0
;
i
<
numThreads
;
i
++
)
...
@@ -141,3 +147,27 @@ CpuPlatform::PlatformData::PlatformData(int numParticles, int numThreads) : posq
...
@@ -141,3 +147,27 @@ CpuPlatform::PlatformData::PlatformData(int numParticles, int numThreads) : posq
threadsProperty
<<
numThreads
;
threadsProperty
<<
numThreads
;
propertyValues
[
CpuThreads
()]
=
threadsProperty
.
str
();
propertyValues
[
CpuThreads
()]
=
threadsProperty
.
str
();
}
}
CpuPlatform
::
PlatformData
::~
PlatformData
()
{
if
(
neighborList
!=
NULL
)
delete
neighborList
;
}
bool
isVec8Supported
();
void
CpuPlatform
::
PlatformData
::
requestNeighborList
(
double
cutoffDistance
,
double
padding
,
bool
useExclusions
,
vector
<
set
<
int
>
>&
exclusionList
)
{
if
(
neighborList
==
NULL
)
neighborList
=
new
CpuNeighborList
(
isVec8Supported
()
?
8
:
4
);
if
(
cutoffDistance
>
cutoff
)
cutoff
=
cutoffDistance
;
if
(
cutoffDistance
+
padding
>
paddedCutoff
)
paddedCutoff
=
cutoffDistance
+
padding
;
if
(
useExclusions
)
{
if
(
anyExclusions
&&
exclusions
!=
exclusionList
)
throw
OpenMMException
(
"All Forces must have identical exclusions"
);
else
{
exclusions
=
exclusionList
;
anyExclusions
=
true
;
}
}
}
platforms/cuda/include/CudaContext.h
View file @
73183c61
...
@@ -326,6 +326,18 @@ public:
...
@@ -326,6 +326,18 @@ public:
void
setStepsSinceReorder
(
int
steps
)
{
void
setStepsSinceReorder
(
int
steps
)
{
stepsSinceReorder
=
steps
;
stepsSinceReorder
=
steps
;
}
}
/**
* Get the flag that marks whether the current force evaluation is valid.
*/
bool
getForcesValid
()
const
{
return
forcesValid
;
}
/**
* Get the flag that marks whether the current force evaluation is valid.
*/
void
setForcesValid
(
bool
valid
)
{
forcesValid
=
valid
;
}
/**
/**
* Get the number of atoms.
* Get the number of atoms.
*/
*/
...
@@ -572,7 +584,7 @@ private:
...
@@ -572,7 +584,7 @@ private:
int
paddedNumAtoms
;
int
paddedNumAtoms
;
int
numAtomBlocks
;
int
numAtomBlocks
;
int
numThreadBlocks
;
int
numThreadBlocks
;
bool
useBlockingSync
,
useDoublePrecision
,
useMixedPrecision
,
contextIsValid
,
atomsWereReordered
,
boxIsTriclinic
,
hasCompilerKernel
;
bool
useBlockingSync
,
useDoublePrecision
,
useMixedPrecision
,
contextIsValid
,
atomsWereReordered
,
boxIsTriclinic
,
hasCompilerKernel
,
forcesValid
;
std
::
string
compiler
,
tempDir
,
cacheDir
,
gpuArchitecture
;
std
::
string
compiler
,
tempDir
,
cacheDir
,
gpuArchitecture
;
float4
periodicBoxVecXFloat
,
periodicBoxVecYFloat
,
periodicBoxVecZFloat
,
periodicBoxSizeFloat
,
invPeriodicBoxSizeFloat
;
float4
periodicBoxVecXFloat
,
periodicBoxVecYFloat
,
periodicBoxVecZFloat
,
periodicBoxSizeFloat
,
invPeriodicBoxSizeFloat
;
double4
periodicBoxVecX
,
periodicBoxVecY
,
periodicBoxVecZ
,
periodicBoxSize
,
invPeriodicBoxSize
;
double4
periodicBoxVecX
,
periodicBoxVecY
,
periodicBoxVecZ
,
periodicBoxSize
,
invPeriodicBoxSize
;
...
...
platforms/cuda/include/CudaKernels.h
View file @
73183c61
...
@@ -178,7 +178,7 @@ public:
...
@@ -178,7 +178,7 @@ public:
* @param b the vector defining the second edge of the periodic box
* @param b the vector defining the second edge of the periodic box
* @param c the vector defining the third edge of the periodic box
* @param c the vector defining the third edge of the periodic box
*/
*/
void
setPeriodicBoxVectors
(
ContextImpl
&
context
,
const
Vec3
&
a
,
const
Vec3
&
b
,
const
Vec3
&
c
)
const
;
void
setPeriodicBoxVectors
(
ContextImpl
&
context
,
const
Vec3
&
a
,
const
Vec3
&
b
,
const
Vec3
&
c
);
/**
/**
* Create a checkpoint recording the current state of the Context.
* Create a checkpoint recording the current state of the Context.
*
*
...
@@ -718,7 +718,7 @@ public:
...
@@ -718,7 +718,7 @@ public:
*/
*/
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomNonbondedForce
&
force
);
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomNonbondedForce
&
force
);
private:
private:
void
initInteractionGroups
(
const
CustomNonbondedForce
&
force
,
const
std
::
string
&
interactionSource
);
void
initInteractionGroups
(
const
CustomNonbondedForce
&
force
,
const
std
::
string
&
interactionSource
,
const
std
::
vector
<
std
::
string
>&
tableTypes
);
CudaContext
&
cu
;
CudaContext
&
cu
;
CudaParameterSet
*
params
;
CudaParameterSet
*
params
;
CudaArray
*
globals
;
CudaArray
*
globals
;
...
...
platforms/cuda/include/CudaNonbondedUtilities.h
View file @
73183c61
...
@@ -269,6 +269,8 @@ private:
...
@@ -269,6 +269,8 @@ private:
CudaArray
*
oldPositions
;
CudaArray
*
oldPositions
;
CudaArray
*
rebuildNeighborList
;
CudaArray
*
rebuildNeighborList
;
CudaSort
*
blockSorter
;
CudaSort
*
blockSorter
;
CUevent
downloadCountEvent
;
int
*
pinnedCountBuffer
;
std
::
vector
<
void
*>
forceArgs
,
findBlockBoundsArgs
,
sortBoxDataArgs
,
findInteractingBlocksArgs
;
std
::
vector
<
void
*>
forceArgs
,
findBlockBoundsArgs
,
sortBoxDataArgs
,
findInteractingBlocksArgs
;
std
::
vector
<
std
::
vector
<
int
>
>
atomExclusions
;
std
::
vector
<
std
::
vector
<
int
>
>
atomExclusions
;
std
::
vector
<
ParameterInfo
>
parameters
;
std
::
vector
<
ParameterInfo
>
parameters
;
...
...
platforms/cuda/include/CudaPlatform.h
View file @
73183c61
...
@@ -58,35 +58,35 @@ public:
...
@@ -58,35 +58,35 @@ public:
* This is the name of the parameter for selecting which CUDA device or devices to use.
* This is the name of the parameter for selecting which CUDA device or devices to use.
*/
*/
static
const
std
::
string
&
CudaDeviceIndex
()
{
static
const
std
::
string
&
CudaDeviceIndex
()
{
static
const
std
::
string
key
=
"
Cuda
DeviceIndex"
;
static
const
std
::
string
key
=
"DeviceIndex"
;
return
key
;
return
key
;
}
}
/**
/**
* This is the name of the parameter that reports the CUDA device or devices being used.
* This is the name of the parameter that reports the CUDA device or devices being used.
*/
*/
static
const
std
::
string
&
CudaDeviceName
()
{
static
const
std
::
string
&
CudaDeviceName
()
{
static
const
std
::
string
key
=
"
Cuda
DeviceName"
;
static
const
std
::
string
key
=
"DeviceName"
;
return
key
;
return
key
;
}
}
/**
/**
* This is the name of the parameter for selecting whether CUDA should sync or spin loop while waiting for results.
* This is the name of the parameter for selecting whether CUDA should sync or spin loop while waiting for results.
*/
*/
static
const
std
::
string
&
CudaUseBlockingSync
()
{
static
const
std
::
string
&
CudaUseBlockingSync
()
{
static
const
std
::
string
key
=
"
Cuda
UseBlockingSync"
;
static
const
std
::
string
key
=
"UseBlockingSync"
;
return
key
;
return
key
;
}
}
/**
/**
* This is the name of the parameter for selecting what numerical precision to use.
* This is the name of the parameter for selecting what numerical precision to use.
*/
*/
static
const
std
::
string
&
CudaPrecision
()
{
static
const
std
::
string
&
CudaPrecision
()
{
static
const
std
::
string
key
=
"
Cuda
Precision"
;
static
const
std
::
string
key
=
"Precision"
;
return
key
;
return
key
;
}
}
/**
/**
* This is the name of the parameter for selecting whether to use the CPU based PME calculation.
* This is the name of the parameter for selecting whether to use the CPU based PME calculation.
*/
*/
static
const
std
::
string
&
CudaUseCpuPme
()
{
static
const
std
::
string
&
CudaUseCpuPme
()
{
static
const
std
::
string
key
=
"
Cuda
UseCpuPme"
;
static
const
std
::
string
key
=
"UseCpuPme"
;
return
key
;
return
key
;
}
}
/**
/**
...
@@ -107,14 +107,21 @@ public:
...
@@ -107,14 +107,21 @@ public:
* This is the name of the parameter for specifying the path to the directory for creating temporary files.
* This is the name of the parameter for specifying the path to the directory for creating temporary files.
*/
*/
static
const
std
::
string
&
CudaTempDirectory
()
{
static
const
std
::
string
&
CudaTempDirectory
()
{
static
const
std
::
string
key
=
"
Cuda
TempDirectory"
;
static
const
std
::
string
key
=
"TempDirectory"
;
return
key
;
return
key
;
}
}
/**
/**
* This is the name of the parameter for selecting whether to disable use of a separate stream for PME.
* This is the name of the parameter for selecting whether to disable use of a separate stream for PME.
*/
*/
static
const
std
::
string
&
CudaDisablePmeStream
()
{
static
const
std
::
string
&
CudaDisablePmeStream
()
{
static
const
std
::
string
key
=
"CudaDisablePmeStream"
;
static
const
std
::
string
key
=
"DisablePmeStream"
;
return
key
;
}
/**
* This is the name of the parameter for requesting that force computations be fully deterministic.
*/
static
const
std
::
string
&
CudaDeterministicForces
()
{
static
const
std
::
string
key
=
"DeterministicForces"
;
return
key
;
return
key
;
}
}
};
};
...
@@ -123,14 +130,14 @@ class OPENMM_EXPORT_CUDA CudaPlatform::PlatformData {
...
@@ -123,14 +130,14 @@ class OPENMM_EXPORT_CUDA CudaPlatform::PlatformData {
public:
public:
PlatformData
(
ContextImpl
*
context
,
const
System
&
system
,
const
std
::
string
&
deviceIndexProperty
,
const
std
::
string
&
blockingProperty
,
const
std
::
string
&
precisionProperty
,
PlatformData
(
ContextImpl
*
context
,
const
System
&
system
,
const
std
::
string
&
deviceIndexProperty
,
const
std
::
string
&
blockingProperty
,
const
std
::
string
&
precisionProperty
,
const
std
::
string
&
cpuPmeProperty
,
const
std
::
string
&
compilerProperty
,
const
std
::
string
&
tempProperty
,
const
std
::
string
&
hostCompilerProperty
,
const
std
::
string
&
cpuPmeProperty
,
const
std
::
string
&
compilerProperty
,
const
std
::
string
&
tempProperty
,
const
std
::
string
&
hostCompilerProperty
,
const
std
::
string
&
pmeStreamProperty
,
int
numThreads
);
const
std
::
string
&
pmeStreamProperty
,
const
std
::
string
&
deterministicForcesProperty
,
int
numThreads
);
~
PlatformData
();
~
PlatformData
();
void
initializeContexts
(
const
System
&
system
);
void
initializeContexts
(
const
System
&
system
);
void
syncContexts
();
void
syncContexts
();
ContextImpl
*
context
;
ContextImpl
*
context
;
std
::
vector
<
CudaContext
*>
contexts
;
std
::
vector
<
CudaContext
*>
contexts
;
std
::
vector
<
double
>
contextEnergy
;
std
::
vector
<
double
>
contextEnergy
;
bool
hasInitializedContexts
,
removeCM
,
peerAccessSupported
,
useCpuPme
,
disablePmeStream
;
bool
hasInitializedContexts
,
removeCM
,
peerAccessSupported
,
useCpuPme
,
disablePmeStream
,
deterministicForces
;
int
cmMotionFrequency
;
int
cmMotionFrequency
;
int
stepCount
,
computeForceCount
;
int
stepCount
,
computeForceCount
;
double
time
;
double
time
;
...
...
Prev
1
2
3
4
5
6
7
…
14
Next
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