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
1945dd6c
Commit
1945dd6c
authored
Feb 20, 2017
by
Andy Simmonett
Browse files
Merge branch 'master' of github.com:pandegroup/openmm into dpme
parents
203e5407
9963e51a
Changes
48
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
325 additions
and
318 deletions
+325
-318
.travis.yml
.travis.yml
+5
-0
CMakeLists.txt
CMakeLists.txt
+10
-23
appveyor.yml
appveyor.yml
+6
-5
docs-source/usersguide/library.rst
docs-source/usersguide/library.rst
+2
-2
libraries/lbfgs/src/lbfgs.cpp
libraries/lbfgs/src/lbfgs.cpp
+192
-171
openmmapi/include/openmm/internal/ThreadPool.h
openmmapi/include/openmm/internal/ThreadPool.h
+8
-1
openmmapi/src/LocalEnergyMinimizer.cpp
openmmapi/src/LocalEnergyMinimizer.cpp
+70
-64
openmmapi/src/ThreadPool.cpp
openmmapi/src/ThreadPool.cpp
+17
-5
platforms/cpu/include/CpuBondForce.h
platforms/cpu/include/CpuBondForce.h
+1
-2
platforms/cpu/include/CpuCustomGBForce.h
platforms/cpu/include/CpuCustomGBForce.h
+1
-2
platforms/cpu/include/CpuCustomManyParticleForce.h
platforms/cpu/include/CpuCustomManyParticleForce.h
+1
-2
platforms/cpu/include/CpuCustomNonbondedForce.h
platforms/cpu/include/CpuCustomNonbondedForce.h
+1
-2
platforms/cpu/include/CpuGBSAOBCForce.h
platforms/cpu/include/CpuGBSAOBCForce.h
+1
-2
platforms/cpu/include/CpuGayBerneForce.h
platforms/cpu/include/CpuGayBerneForce.h
+1
-2
platforms/cpu/include/CpuKernels.h
platforms/cpu/include/CpuKernels.h
+0
-2
platforms/cpu/include/CpuLangevinDynamics.h
platforms/cpu/include/CpuLangevinDynamics.h
+1
-4
platforms/cpu/include/CpuNeighborList.h
platforms/cpu/include/CpuNeighborList.h
+1
-2
platforms/cpu/include/CpuNonbondedForce.h
platforms/cpu/include/CpuNonbondedForce.h
+1
-2
platforms/cpu/include/CpuSETTLE.h
platforms/cpu/include/CpuSETTLE.h
+1
-3
platforms/cpu/src/CpuBondForce.cpp
platforms/cpu/src/CpuBondForce.cpp
+5
-22
No files found.
.travis.yml
View file @
1945dd6c
...
@@ -108,6 +108,11 @@ before_install:
...
@@ -108,6 +108,11 @@ before_install:
brew install doxygen fftw;
brew install doxygen fftw;
sudo easy_install pytest;
sudo easy_install pytest;
fi
fi
-
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
CMAKE_URL="https://cmake.org/files/v3.7/cmake-3.7.2-Linux-x86_64.tar.gz";
mkdir $HOME/cmake && travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C $HOME/cmake;
export PATH=${HOME}/cmake/bin:${PATH};
fi
-
if [[ "$OPENCL" == "true" ]]; then
-
if [[ "$OPENCL" == "true" ]]; then
wget http://s3.amazonaws.com/omnia-ci/AMD-APP-SDKInstaller-v3.0.130.135-GA-linux64.tar.bz2;
wget http://s3.amazonaws.com/omnia-ci/AMD-APP-SDKInstaller-v3.0.130.135-GA-linux64.tar.bz2;
tar -xjf AMD-APP-SDK*.tar.bz2;
tar -xjf AMD-APP-SDK*.tar.bz2;
...
...
CMakeLists.txt
View file @
1945dd6c
...
@@ -21,10 +21,11 @@ IF( NOT PROJECT_NAME )
...
@@ -21,10 +21,11 @@ IF( NOT PROJECT_NAME )
PROJECT
(
OpenMM
)
PROJECT
(
OpenMM
)
ENDIF
(
NOT PROJECT_NAME
)
ENDIF
(
NOT PROJECT_NAME
)
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.8
)
CMAKE_MINIMUM_REQUIRED
(
VERSION 3.1
)
if
(
"
${
CMAKE_VERSION
}
"
VERSION_GREATER
"3.0"
OR
"
${
CMAKE_VERSION
}
"
VERSION_EQUAL
"3.0"
)
CMAKE_POLICY
(
SET CMP0042 OLD
)
CMAKE_POLICY
(
SET CMP0042 OLD
)
CMAKE_POLICY
(
SET CMP0003 NEW
)
endif
()
CMAKE_POLICY
(
SET CMP0005 NEW
)
CMAKE_POLICY
(
SET CMP0011 NEW
)
#SET(CMAKE_VERBOSE_MAKEFILE 1)
#SET(CMAKE_VERBOSE_MAKEFILE 1)
...
@@ -39,21 +40,6 @@ IF(NOT cmv EQUAL "2.4") # This whole file...
...
@@ -39,21 +40,6 @@ IF(NOT cmv EQUAL "2.4") # This whole file...
# We have custom cmake modules for FindOpenMM and running python tests
# We have custom cmake modules for FindOpenMM and running python tests
SET
(
CMAKE_MODULE_PATH
${
CMAKE_MODULE_PATH
}
"
${
CMAKE_SOURCE_DIR
}
/cmake_modules"
)
SET
(
CMAKE_MODULE_PATH
${
CMAKE_MODULE_PATH
}
"
${
CMAKE_SOURCE_DIR
}
/cmake_modules"
)
# Older cmake versions do not have cmake_policy command
# Cmake 2.4.5, the default cmake on red hat linux, has the
# cmake_policy command, but it does not work
# "if(POLICY ..." does not work with cmake 2.4.[56] on red hat
# (cmake 2.4.7 is OK)
if
(
COMMAND cmake_policy
)
if
(
CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 5
)
cmake_policy
(
SET CMP0003 NEW
)
cmake_policy
(
SET CMP0005 NEW
)
endif
(
CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 5
)
if
(
CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 6 OR CMAKE_PATCH_VERSION GREATER 2
)
cmake_policy
(
SET CMP0011 NEW
)
endif
(
CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 6 OR CMAKE_PATCH_VERSION GREATER 2
)
endif
(
COMMAND cmake_policy
)
# Where to install
# Where to install
IF
(
WIN32
)
IF
(
WIN32
)
IF
(
NOT OPENMM_INSTALL_PREFIX
)
IF
(
NOT OPENMM_INSTALL_PREFIX
)
...
@@ -69,6 +55,9 @@ IF(WIN32)
...
@@ -69,6 +55,9 @@ IF(WIN32)
ADD_DEFINITIONS
(
-DWIN32
)
ADD_DEFINITIONS
(
-DWIN32
)
ENDIF
(
WIN32
)
ENDIF
(
WIN32
)
# What type of libraries to build
SET
(
OPENMM_BUILD_SHARED_LIB ON CACHE BOOL
"Whether to build shared OpenMM libraries"
)
SET
(
OPENMM_BUILD_STATIC_LIB OFF CACHE BOOL
"Whether to build static OpenMM libraries"
)
# Include CPU-Features for Android
# Include CPU-Features for Android
IF
(
ANDROID
)
IF
(
ANDROID
)
...
@@ -114,6 +103,7 @@ ELSE( CMAKE_SIZEOF_VOID_P EQUAL 8 )
...
@@ -114,6 +103,7 @@ ELSE( CMAKE_SIZEOF_VOID_P EQUAL 8 )
SET
(
LIB64
)
SET
(
LIB64
)
ENDIF
(
CMAKE_SIZEOF_VOID_P EQUAL 8
)
ENDIF
(
CMAKE_SIZEOF_VOID_P EQUAL 8
)
SET
(
CMAKE_CXX_STANDARD 11
)
IF
(
APPLE
AND
(
NOT PNACL
))
IF
(
APPLE
AND
(
NOT PNACL
))
# Build 64 bit binaries compatible with OS X 10.7
# Build 64 bit binaries compatible with OS X 10.7
...
@@ -283,7 +273,7 @@ IF (ANDROID OR PNACL)
...
@@ -283,7 +273,7 @@ IF (ANDROID OR PNACL)
ELSE
(
ANDROID OR PNACL
)
ELSE
(
ANDROID OR PNACL
)
SET_SOURCE_FILES_PROPERTIES
(
${
CMAKE_SOURCE_DIR
}
/libraries/sfmt/src/SFMT.cpp PROPERTIES COMPILE_FLAGS
"-DHAVE_SSE2=1"
)
SET_SOURCE_FILES_PROPERTIES
(
${
CMAKE_SOURCE_DIR
}
/libraries/sfmt/src/SFMT.cpp PROPERTIES COMPILE_FLAGS
"-DHAVE_SSE2=1"
)
ENDIF
(
ANDROID OR PNACL
)
ENDIF
(
ANDROID OR PNACL
)
IF
(
NOT
(
ANDROID OR PNACL
))
IF
(
NOT
(
ANDROID OR PNACL
OR
(
WIN32 AND OPENMM_BUILD_STATIC_LIB
)
))
FILE
(
GLOB src_files
${
CMAKE_CURRENT_SOURCE_DIR
}
/libraries/asmjit/*/*.cpp
)
FILE
(
GLOB src_files
${
CMAKE_CURRENT_SOURCE_DIR
}
/libraries/asmjit/*/*.cpp
)
FILE
(
GLOB incl_files
${
CMAKE_CURRENT_SOURCE_DIR
}
/libraries/asmjit/*.h
)
FILE
(
GLOB incl_files
${
CMAKE_CURRENT_SOURCE_DIR
}
/libraries/asmjit/*.h
)
SET
(
SOURCE_FILES
${
SOURCE_FILES
}
${
src_files
}
)
SET
(
SOURCE_FILES
${
SOURCE_FILES
}
${
src_files
}
)
...
@@ -302,8 +292,6 @@ ENDIF(OPENMM_BUILD_C_AND_FORTRAN_WRAPPERS)
...
@@ -302,8 +292,6 @@ ENDIF(OPENMM_BUILD_C_AND_FORTRAN_WRAPPERS)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
)
SET
(
OPENMM_BUILD_SHARED_LIB ON CACHE BOOL
"Whether to build shared OpenMM libraries"
)
SET
(
EXTRA_LINK_FLAGS
${
EXTRA_COMPILE_FLAGS
}
)
SET
(
EXTRA_LINK_FLAGS
${
EXTRA_COMPILE_FLAGS
}
)
IF
(
CMAKE_SYSTEM_NAME MATCHES
"Linux"
)
IF
(
CMAKE_SYSTEM_NAME MATCHES
"Linux"
)
IF
(
NOT ANDROID
)
IF
(
NOT ANDROID
)
...
@@ -319,7 +307,6 @@ IF(OPENMM_BUILD_SHARED_LIB)
...
@@ -319,7 +307,6 @@ IF(OPENMM_BUILD_SHARED_LIB)
SET_TARGET_PROPERTIES
(
${
SHARED_TARGET
}
PROPERTIES LINK_FLAGS
"
${
EXTRA_LINK_FLAGS
}
"
COMPILE_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
-DOPENMM_BUILDING_SHARED_LIBRARY -DLEPTON_BUILDING_SHARED_LIBRARY -DPTHREAD_BUILDING_SHARED_LIBRARY"
)
SET_TARGET_PROPERTIES
(
${
SHARED_TARGET
}
PROPERTIES LINK_FLAGS
"
${
EXTRA_LINK_FLAGS
}
"
COMPILE_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
-DOPENMM_BUILDING_SHARED_LIBRARY -DLEPTON_BUILDING_SHARED_LIBRARY -DPTHREAD_BUILDING_SHARED_LIBRARY"
)
ENDIF
(
OPENMM_BUILD_SHARED_LIB
)
ENDIF
(
OPENMM_BUILD_SHARED_LIB
)
SET
(
OPENMM_BUILD_STATIC_LIB OFF CACHE BOOL
"Whether to build static OpenMM libraries"
)
IF
(
OPENMM_BUILD_STATIC_LIB
)
IF
(
OPENMM_BUILD_STATIC_LIB
)
ADD_LIBRARY
(
${
STATIC_TARGET
}
STATIC
${
SOURCE_FILES
}
${
SOURCE_INCLUDE_FILES
}
${
API_ABS_INCLUDE_FILES
}
)
ADD_LIBRARY
(
${
STATIC_TARGET
}
STATIC
${
SOURCE_FILES
}
${
SOURCE_INCLUDE_FILES
}
${
API_ABS_INCLUDE_FILES
}
)
SET
(
EXTRA_COMPILE_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
-DOPENMM_USE_STATIC_LIBRARIES -DLEPTON_USE_STATIC_LIBRARIES -DPTW32_STATIC_LIB"
)
SET
(
EXTRA_COMPILE_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
-DOPENMM_USE_STATIC_LIBRARIES -DLEPTON_USE_STATIC_LIBRARIES -DPTW32_STATIC_LIB"
)
...
...
appveyor.yml
View file @
1945dd6c
os
:
Windows Server 2012 R2
os
:
Visual Studio
2015
platform
:
x64
configuration
:
Release
shallow_clone
:
true
shallow_clone
:
true
install
:
install
:
# Setup shell for VS2010, x64, release mode
# Setup shell for VS2015, x64
-
>
-
call "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
"%ProgramFiles%\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 /release
# Set path to python, git-bash tools.
# Set path to python, git-bash tools.
-
"
set
PATH=C:
\\
Python3
4
-x64;C:
\\
Python3
4
-x64
\\
Scripts;%PATH%"
-
"
set
PATH=C:
\\
Python3
5
-x64;C:
\\
Python3
5
-x64
\\
Scripts;%PATH%"
-
"
set
PATH=C:
\\
Program
Files
(x86)
\\
Git
\\
bin;%PATH%"
-
"
set
PATH=C:
\\
Program
Files
(x86)
\\
Git
\\
bin;%PATH%"
-
pip install pytest
-
pip install pytest
...
...
docs-source/usersguide/library.rst
View file @
1945dd6c
...
@@ -404,7 +404,7 @@ version of Visual Studio.
...
@@ -404,7 +404,7 @@ version of Visual Studio.
Install
CMake
Install
CMake
=============
=============
CMake
is
the
build
system
used
for
OpenMM
.
You
must
install
CMake
version
2.8
CMake
is
the
build
system
used
for
OpenMM
.
You
must
install
CMake
version
3.1
or
higher
before
attempting
to
build
OpenMM
from
source
.
You
can
get
CMake
from
or
higher
before
attempting
to
build
OpenMM
from
source
.
You
can
get
CMake
from
http
://
www
.
cmake
.
org
/.
If
you
choose
to
build
CMake
from
source
on
Linux
,
make
http
://
www
.
cmake
.
org
/.
If
you
choose
to
build
CMake
from
source
on
Linux
,
make
sure
you
have
the
curses
library
installed
beforehand
,
so
that
you
will
be
able
sure
you
have
the
curses
library
installed
beforehand
,
so
that
you
will
be
able
...
@@ -509,7 +509,7 @@ Windows
...
@@ -509,7 +509,7 @@ Windows
On
Windows
,
perform
the
following
steps
:
On
Windows
,
perform
the
following
steps
:
#.
Click
Start
->
All
Programs
->
CMake
2.8
->
CMake
#.
Click
Start
->
All
Programs
->
CMake
3.1
->
CMake
#.
In
the
box
labeled
"Where is the source code:"
browse
to
OpenMM
src
directory
#.
In
the
box
labeled
"Where is the source code:"
browse
to
OpenMM
src
directory
(
containing
top
CMakeLists
.
txt
)
(
containing
top
CMakeLists
.
txt
)
#.
In
the
box
labeled
"Where to build the binaries"
browse
to
your
build_openmm
#.
In
the
box
labeled
"Where to build the binaries"
browse
to
your
build_openmm
...
...
libraries/lbfgs/src/lbfgs.cpp
View file @
1945dd6c
...
@@ -408,210 +408,231 @@ int lbfgs(
...
@@ -408,210 +408,231 @@ int lbfgs(
pf
=
(
lbfgsfloatval_t
*
)
vecalloc
(
param
.
past
*
sizeof
(
lbfgsfloatval_t
));
pf
=
(
lbfgsfloatval_t
*
)
vecalloc
(
param
.
past
*
sizeof
(
lbfgsfloatval_t
));
}
}
/* Evaluate the function value and its gradient. */
try
{
fx
=
cd
.
proc_evaluate
(
cd
.
instance
,
x
,
g
,
cd
.
n
,
0
);
/* Evaluate the function value and its gradient. */
if
(
0.
!=
param
.
orthantwise_c
)
{
fx
=
cd
.
proc_evaluate
(
cd
.
instance
,
x
,
g
,
cd
.
n
,
0
);
/* Compute the L1 norm of the variable and add it to the object value. */
if
(
0.
!=
param
.
orthantwise_c
)
{
xnorm
=
owlqn_x1norm
(
x
,
param
.
orthantwise_start
,
param
.
orthantwise_end
);
/* Compute the L1 norm of the variable and add it to the object value. */
fx
+=
xnorm
*
param
.
orthantwise_c
;
xnorm
=
owlqn_x1norm
(
x
,
param
.
orthantwise_start
,
param
.
orthantwise_end
);
owlqn_pseudo_gradient
(
fx
+=
xnorm
*
param
.
orthantwise_c
;
pg
,
x
,
g
,
n
,
param
.
orthantwise_c
,
param
.
orthantwise_start
,
param
.
orthantwise_end
);
}
/* Store the initial value of the objective function. */
if
(
pf
!=
NULL
)
{
pf
[
0
]
=
fx
;
}
/*
Compute the direction;
we assume the initial hessian matrix H_0 as the identity matrix.
*/
if
(
param
.
orthantwise_c
==
0.
)
{
vecncpy
(
d
,
g
,
n
);
}
else
{
vecncpy
(
d
,
pg
,
n
);
}
/*
Make sure that the initial variables are not a minimizer.
*/
vec2norm
(
&
xnorm
,
x
,
n
);
if
(
param
.
orthantwise_c
==
0.
)
{
vec2norm
(
&
gnorm
,
g
,
n
);
}
else
{
vec2norm
(
&
gnorm
,
pg
,
n
);
}
if
(
xnorm
<
1.0
)
xnorm
=
1.0
;
if
(
gnorm
/
xnorm
<=
param
.
epsilon
)
{
ret
=
LBFGS_ALREADY_MINIMIZED
;
goto
lbfgs_exit
;
}
/* Compute the initial step:
step = 1.0 / sqrt(vecdot(d, d, n))
*/
vec2norminv
(
&
step
,
d
,
n
);
k
=
1
;
end
=
0
;
for
(;;)
{
/* Store the current position and gradient vectors. */
veccpy
(
xp
,
x
,
n
);
veccpy
(
gp
,
g
,
n
);
/* Search for an optimal step. */
if
(
param
.
orthantwise_c
==
0.
)
{
ls
=
linesearch
(
n
,
x
,
&
fx
,
g
,
d
,
&
step
,
xp
,
gp
,
w
,
&
cd
,
&
param
);
}
else
{
ls
=
linesearch
(
n
,
x
,
&
fx
,
g
,
d
,
&
step
,
xp
,
pg
,
w
,
&
cd
,
&
param
);
owlqn_pseudo_gradient
(
owlqn_pseudo_gradient
(
pg
,
x
,
g
,
n
,
pg
,
x
,
g
,
n
,
param
.
orthantwise_c
,
param
.
orthantwise_start
,
param
.
orthantwise_end
param
.
orthantwise_c
,
param
.
orthantwise_start
,
param
.
orthantwise_end
);
);
}
}
if
(
ls
<
0
)
{
/* Revert to the previous point. */
/* Store the initial value of the objective function. */
veccpy
(
x
,
xp
,
n
);
if
(
pf
!=
NULL
)
{
veccpy
(
g
,
gp
,
n
);
pf
[
0
]
=
fx
;
ret
=
ls
;
goto
lbfgs_exit
;
}
}
/* Compute x and g norms. */
/*
vec2norm
(
&
xnorm
,
x
,
n
);
Compute the direction;
we assume the initial hessian matrix H_0 as the identity matrix.
*/
if
(
param
.
orthantwise_c
==
0.
)
{
if
(
param
.
orthantwise_c
==
0.
)
{
vec
2norm
(
&
gnorm
,
g
,
n
);
vec
ncpy
(
d
,
g
,
n
);
}
else
{
}
else
{
vec2norm
(
&
gnorm
,
pg
,
n
);
vecncpy
(
d
,
pg
,
n
);
}
/* Report the progress. */
if
(
cd
.
proc_progress
)
{
if
(
ret
=
cd
.
proc_progress
(
cd
.
instance
,
x
,
g
,
fx
,
xnorm
,
gnorm
,
step
,
cd
.
n
,
k
,
ls
))
{
goto
lbfgs_exit
;
}
}
}
/*
/*
Convergence test.
Make sure that the initial variables are not a minimizer.
The criterion is given by the following formula:
|g(x)| / \max(1, |x|) < \epsilon
*/
*/
vec2norm
(
&
xnorm
,
x
,
n
);
if
(
param
.
orthantwise_c
==
0.
)
{
vec2norm
(
&
gnorm
,
g
,
n
);
}
else
{
vec2norm
(
&
gnorm
,
pg
,
n
);
}
if
(
xnorm
<
1.0
)
xnorm
=
1.0
;
if
(
xnorm
<
1.0
)
xnorm
=
1.0
;
if
(
gnorm
/
xnorm
<=
param
.
epsilon
)
{
if
(
gnorm
/
xnorm
<=
param
.
epsilon
)
{
/* Convergence. */
ret
=
LBFGS_ALREADY_MINIMIZED
;
ret
=
LBFGS_SUCCESS
;
goto
lbfgs_exit
;
break
;
}
}
/*
/* Compute the initial step:
Test for stopping criterion.
step = 1.0 / sqrt(vecdot(d, d, n))
The criterion is given by the following formula:
(f(past_x) - f(x)) / f(x) < \delta
*/
*/
if
(
pf
!=
NULL
)
{
vec2norminv
(
&
step
,
d
,
n
);
/* We don't test the stopping criterion while k < past. */
if
(
param
.
past
<=
k
)
{
k
=
1
;
/* Compute the relative improvement from the past. */
end
=
0
;
rate
=
(
pf
[
k
%
param
.
past
]
-
fx
)
/
fx
;
for
(;;)
{
/* Store the current position and gradient vectors. */
/* The stopping criterion. */
veccpy
(
xp
,
x
,
n
);
if
(
rate
<
param
.
delta
)
{
veccpy
(
gp
,
g
,
n
);
ret
=
LBFGS_STOP
;
break
;
/* Search for an optimal step. */
if
(
param
.
orthantwise_c
==
0.
)
{
ls
=
linesearch
(
n
,
x
,
&
fx
,
g
,
d
,
&
step
,
xp
,
gp
,
w
,
&
cd
,
&
param
);
}
else
{
ls
=
linesearch
(
n
,
x
,
&
fx
,
g
,
d
,
&
step
,
xp
,
pg
,
w
,
&
cd
,
&
param
);
owlqn_pseudo_gradient
(
pg
,
x
,
g
,
n
,
param
.
orthantwise_c
,
param
.
orthantwise_start
,
param
.
orthantwise_end
);
}
if
(
ls
<
0
)
{
/* Revert to the previous point. */
veccpy
(
x
,
xp
,
n
);
veccpy
(
g
,
gp
,
n
);
ret
=
ls
;
goto
lbfgs_exit
;
}
/* Compute x and g norms. */
vec2norm
(
&
xnorm
,
x
,
n
);
if
(
param
.
orthantwise_c
==
0.
)
{
vec2norm
(
&
gnorm
,
g
,
n
);
}
else
{
vec2norm
(
&
gnorm
,
pg
,
n
);
}
/* Report the progress. */
if
(
cd
.
proc_progress
)
{
if
(
ret
=
cd
.
proc_progress
(
cd
.
instance
,
x
,
g
,
fx
,
xnorm
,
gnorm
,
step
,
cd
.
n
,
k
,
ls
))
{
goto
lbfgs_exit
;
}
}
}
}
/* Store the current value of the objective function. */
/*
pf
[
k
%
param
.
past
]
=
fx
;
Convergence test.
}
The criterion is given by the following formula:
|g(x)| / \max(1, |x|) < \epsilon
*/
if
(
xnorm
<
1.0
)
xnorm
=
1.0
;
if
(
gnorm
/
xnorm
<=
param
.
epsilon
)
{
/* Convergence. */
ret
=
LBFGS_SUCCESS
;
break
;
}
if
(
param
.
max_iterations
!=
0
&&
param
.
max_iterations
<
k
+
1
)
{
/*
/* Maximum number of iterations. */
Test for stopping criterion.
ret
=
LBFGSERR_MAXIMUMITERATION
;
The criterion is given by the following formula:
break
;
(f(past_x) - f(x)) / f(x) < \delta
}
*/
if
(
pf
!=
NULL
)
{
/* We don't test the stopping criterion while k < past. */
if
(
param
.
past
<=
k
)
{
/* Compute the relative improvement from the past. */
rate
=
(
pf
[
k
%
param
.
past
]
-
fx
)
/
fx
;
/* The stopping criterion. */
if
(
rate
<
param
.
delta
)
{
ret
=
LBFGS_STOP
;
break
;
}
}
/*
/* Store the current value of the objective function. */
Update vectors s and y:
pf
[
k
%
param
.
past
]
=
fx
;
s_{k+1} = x_{k+1} - x_{k} = \step * d_{k}.
}
y_{k+1} = g_{k+1} - g_{k}.
*/
it
=
&
lm
[
end
];
vecdiff
(
it
->
s
,
x
,
xp
,
n
);
vecdiff
(
it
->
y
,
g
,
gp
,
n
);
/*
if
(
param
.
max_iterations
!=
0
&&
param
.
max_iterations
<
k
+
1
)
{
Compute scalars ys and yy:
/* Maximum number of iterations. */
ys = y^t \cdot s = 1 / \rho.
ret
=
LBFGSERR_MAXIMUMITERATION
;
yy = y^t \cdot y.
break
;
Notice that yy is used for scaling the hessian matrix H_0 (Cholesky factor).
}
*/
vecdot
(
&
ys
,
it
->
y
,
it
->
s
,
n
);
vecdot
(
&
yy
,
it
->
y
,
it
->
y
,
n
);
it
->
ys
=
ys
;
/*
/*
Recursive formula to compute dir = -(H \cdot g).
Update vectors s and y:
This is described in page 779 of:
s_{k+1} = x_{k+1} - x_{k} = \step * d_{k}.
Jorge Nocedal.
y_{k+1} = g_{k+1} - g_{k}.
Updating Quasi-Newton Matrices with Limited Storage.
*/
Mathematics of Computation, Vol. 35, No. 151,
it
=
&
lm
[
end
];
pp. 773--782, 1980.
vecdiff
(
it
->
s
,
x
,
xp
,
n
);
*/
vecdiff
(
it
->
y
,
g
,
gp
,
n
);
bound
=
(
m
<=
k
)
?
m
:
k
;
++
k
;
end
=
(
end
+
1
)
%
m
;
/* Compute the steepest direction. */
/*
if
(
param
.
orthantwise_c
==
0.
)
{
Compute scalars ys and yy:
/* Compute the negative of gradients. */
ys = y^t \cdot s = 1 / \rho.
vecncpy
(
d
,
g
,
n
);
yy = y^t \cdot y.
}
else
{
Notice that yy is used for scaling the hessian matrix H_0 (Cholesky factor).
vecncpy
(
d
,
pg
,
n
);
*/
}
vecdot
(
&
ys
,
it
->
y
,
it
->
s
,
n
);
vecdot
(
&
yy
,
it
->
y
,
it
->
y
,
n
);
it
->
ys
=
ys
;
j
=
end
;
/*
for
(
i
=
0
;
i
<
bound
;
++
i
)
{
Recursive formula to compute dir = -(H \cdot g).
j
=
(
j
+
m
-
1
)
%
m
;
/* if (--j == -1) j = m-1; */
This is described in page 779 of:
it
=
&
lm
[
j
];
Jorge Nocedal.
/* \alpha_{j} = \rho_{j} s^{t}_{j} \cdot q_{k+1}. */
Updating Quasi-Newton Matrices with Limited Storage.
vecdot
(
&
it
->
alpha
,
it
->
s
,
d
,
n
);
Mathematics of Computation, Vol. 35, No. 151,
it
->
alpha
/=
it
->
ys
;
pp. 773--782, 1980.
/* q_{i} = q_{i+1} - \alpha_{i} y_{i}. */
*/
vecadd
(
d
,
it
->
y
,
-
it
->
alpha
,
n
);
bound
=
(
m
<=
k
)
?
m
:
k
;
}
++
k
;
end
=
(
end
+
1
)
%
m
;
/* Compute the steepest direction. */
if
(
param
.
orthantwise_c
==
0.
)
{
/* Compute the negative of gradients. */
vecncpy
(
d
,
g
,
n
);
}
else
{
vecncpy
(
d
,
pg
,
n
);
}
vecscale
(
d
,
ys
/
yy
,
n
);
j
=
end
;
for
(
i
=
0
;
i
<
bound
;
++
i
)
{
j
=
(
j
+
m
-
1
)
%
m
;
/* if (--j == -1) j = m-1; */
it
=
&
lm
[
j
];
/* \alpha_{j} = \rho_{j} s^{t}_{j} \cdot q_{k+1}. */
vecdot
(
&
it
->
alpha
,
it
->
s
,
d
,
n
);
it
->
alpha
/=
it
->
ys
;
/* q_{i} = q_{i+1} - \alpha_{i} y_{i}. */
vecadd
(
d
,
it
->
y
,
-
it
->
alpha
,
n
);
}
for
(
i
=
0
;
i
<
bound
;
++
i
)
{
vecscale
(
d
,
ys
/
yy
,
n
);
it
=
&
lm
[
j
];
/* \beta_{j} = \rho_{j} y^t_{j} \cdot \gamma_{i}. */
vecdot
(
&
beta
,
it
->
y
,
d
,
n
);
beta
/=
it
->
ys
;
/* \gamma_{i+1} = \gamma_{i} + (\alpha_{j} - \beta_{j}) s_{j}. */
vecadd
(
d
,
it
->
s
,
it
->
alpha
-
beta
,
n
);
j
=
(
j
+
1
)
%
m
;
/* if (++j == m) j = 0; */
}
/*
for
(
i
=
0
;
i
<
bound
;
++
i
)
{
Constrain the search direction for orthant-wise updates.
it
=
&
lm
[
j
];
*/
/* \beta_{j} = \rho_{j} y^t_{j} \cdot \gamma_{i}. */
if
(
param
.
orthantwise_c
!=
0.
)
{
vecdot
(
&
beta
,
it
->
y
,
d
,
n
);
for
(
i
=
param
.
orthantwise_start
;
i
<
param
.
orthantwise_end
;
++
i
)
{
beta
/=
it
->
ys
;
if
(
d
[
i
]
*
pg
[
i
]
>=
0
)
{
/* \gamma_{i+1} = \gamma_{i} + (\alpha_{j} - \beta_{j}) s_{j}. */
d
[
i
]
=
0
;
vecadd
(
d
,
it
->
s
,
it
->
alpha
-
beta
,
n
);
j
=
(
j
+
1
)
%
m
;
/* if (++j == m) j = 0; */
}
/*
Constrain the search direction for orthant-wise updates.
*/
if
(
param
.
orthantwise_c
!=
0.
)
{
for
(
i
=
param
.
orthantwise_start
;
i
<
param
.
orthantwise_end
;
++
i
)
{
if
(
d
[
i
]
*
pg
[
i
]
>=
0
)
{
d
[
i
]
=
0
;
}
}
}
}
}
}
/*
/*
Now the search direction d is ready. We try step = 1 first.
Now the search direction d is ready. We try step = 1 first.
*/
*/
step
=
1.0
;
step
=
1.0
;
}
}
catch
(...)
{
vecfree
(
pf
);
/* Free memory blocks used by this function. */
if
(
lm
!=
NULL
)
{
for
(
i
=
0
;
i
<
m
;
++
i
)
{
vecfree
(
lm
[
i
].
s
);
vecfree
(
lm
[
i
].
y
);
}
vecfree
(
lm
);
}
vecfree
(
pg
);
vecfree
(
w
);
vecfree
(
d
);
vecfree
(
gp
);
vecfree
(
g
);
vecfree
(
xp
);
throw
;
}
}
lbfgs_exit:
lbfgs_exit:
...
...
openmmapi/include/openmm/internal/ThreadPool.h
View file @
1945dd6c
...
@@ -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
-2017
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#define NOMINMAX
#define NOMINMAX
#include "windowsExport.h"
#include "windowsExport.h"
#include <functional>
#include <pthread.h>
#include <pthread.h>
#include <vector>
#include <vector>
...
@@ -69,6 +70,10 @@ public:
...
@@ -69,6 +70,10 @@ public:
* Execute a Task in parallel on the worker threads.
* Execute a Task in parallel on the worker threads.
*/
*/
void
execute
(
Task
&
task
);
void
execute
(
Task
&
task
);
/**
* Execute a function in parallel on the worker threads.
*/
void
execute
(
std
::
function
<
void
(
ThreadPool
&
,
int
)
>
task
);
/**
/**
* This is called by the worker threads to block until all threads have reached the same point
* This is called by the worker threads to block until all threads have reached the same point
* and the master thread instructs them to continue by calling resumeThreads().
* and the master thread instructs them to continue by calling resumeThreads().
...
@@ -90,6 +95,8 @@ private:
...
@@ -90,6 +95,8 @@ private:
std
::
vector
<
ThreadData
*>
threadData
;
std
::
vector
<
ThreadData
*>
threadData
;
pthread_cond_t
startCondition
,
endCondition
;
pthread_cond_t
startCondition
,
endCondition
;
pthread_mutex_t
lock
;
pthread_mutex_t
lock
;
Task
*
currentTask
;
std
::
function
<
void
(
ThreadPool
&
pool
,
int
)
>
currentFunction
;
};
};
/**
/**
...
...
openmmapi/src/LocalEnergyMinimizer.cpp
View file @
1945dd6c
...
@@ -105,83 +105,89 @@ static lbfgsfloatval_t evaluate(void *instance, const lbfgsfloatval_t *x, lbfgsf
...
@@ -105,83 +105,89 @@ static lbfgsfloatval_t evaluate(void *instance, const lbfgsfloatval_t *x, lbfgsf
void
LocalEnergyMinimizer
::
minimize
(
Context
&
context
,
double
tolerance
,
int
maxIterations
)
{
void
LocalEnergyMinimizer
::
minimize
(
Context
&
context
,
double
tolerance
,
int
maxIterations
)
{
const
System
&
system
=
context
.
getSystem
();
const
System
&
system
=
context
.
getSystem
();
int
numParticles
=
system
.
getNumParticles
();
int
numParticles
=
system
.
getNumParticles
();
lbfgsfloatval_t
*
x
=
lbfgs_malloc
(
numParticles
*
3
);
if
(
x
==
NULL
)
throw
OpenMMException
(
"LocalEnergyMinimizer: Failed to allocate memory"
);
double
constraintTol
=
context
.
getIntegrator
().
getConstraintTolerance
();
double
constraintTol
=
context
.
getIntegrator
().
getConstraintTolerance
();
double
workingConstraintTol
=
std
::
max
(
1e-4
,
constraintTol
);
double
workingConstraintTol
=
std
::
max
(
1e-4
,
constraintTol
);
double
k
=
tolerance
/
workingConstraintTol
;
double
k
=
tolerance
/
workingConstraintTol
;
lbfgsfloatval_t
*
x
=
lbfgs_malloc
(
numParticles
*
3
);
if
(
x
==
NULL
)
throw
OpenMMException
(
"LocalEnergyMinimizer: Failed to allocate memory"
);
try
{
// Initialize the minimizer.
// Initialize the minimizer.
lbfgs_parameter_t
param
;
lbfgs_parameter_t
param
;
lbfgs_parameter_init
(
&
param
);
lbfgs_parameter_init
(
&
param
);
if
(
!
context
.
getPlatform
().
supportsDoublePrecision
())
if
(
!
context
.
getPlatform
().
supportsDoublePrecision
())
param
.
xtol
=
1e-7
;
param
.
xtol
=
1e-7
;
param
.
max_iterations
=
maxIterations
;
param
.
max_iterations
=
maxIterations
;
param
.
linesearch
=
LBFGS_LINESEARCH_BACKTRACKING_STRONG_WOLFE
;
param
.
linesearch
=
LBFGS_LINESEARCH_BACKTRACKING_STRONG_WOLFE
;
// Make sure the initial configuration satisfies all constraints.
// Make sure the initial configuration satisfies all constraints.
context
.
applyConstraints
(
workingConstraintTol
);
context
.
applyConstraints
(
workingConstraintTol
);
// Record the initial positions and determine a normalization constant for scaling the tolerance.
// Record the initial positions and determine a normalization constant for scaling the tolerance.
vector
<
Vec3
>
initialPos
=
context
.
getState
(
State
::
Positions
).
getPositions
();
vector
<
Vec3
>
initialPos
=
context
.
getState
(
State
::
Positions
).
getPositions
();
double
norm
=
0.0
;
double
norm
=
0.0
;
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
x
[
3
*
i
]
=
initialPos
[
i
][
0
];
x
[
3
*
i
]
=
initialPos
[
i
][
0
];
x
[
3
*
i
+
1
]
=
initialPos
[
i
][
1
];
x
[
3
*
i
+
1
]
=
initialPos
[
i
][
1
];
x
[
3
*
i
+
2
]
=
initialPos
[
i
][
2
];
x
[
3
*
i
+
2
]
=
initialPos
[
i
][
2
];
norm
+=
initialPos
[
i
].
dot
(
initialPos
[
i
]);
norm
+=
initialPos
[
i
].
dot
(
initialPos
[
i
]);
}
norm
/=
numParticles
;
norm
=
(
norm
<
1
?
1
:
sqrt
(
norm
));
param
.
epsilon
=
tolerance
/
norm
;
// Repeatedly minimize, steadily increasing the strength of the springs until all constraints are satisfied.
double
prevMaxError
=
1e10
;
while
(
true
)
{
// Perform the minimization.
lbfgsfloatval_t
fx
;
MinimizerData
data
(
context
,
k
);
lbfgs
(
numParticles
*
3
,
x
,
&
fx
,
evaluate
,
NULL
,
&
data
,
&
param
);
// Check whether all constraints are satisfied.
vector
<
Vec3
>
positions
=
context
.
getState
(
State
::
Positions
).
getPositions
();
int
numConstraints
=
system
.
getNumConstraints
();
double
maxError
=
0.0
;
for
(
int
i
=
0
;
i
<
numConstraints
;
i
++
)
{
int
particle1
,
particle2
;
double
distance
;
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
Vec3
delta
=
positions
[
particle2
]
-
positions
[
particle1
];
double
r
=
sqrt
(
delta
.
dot
(
delta
));
double
error
=
fabs
(
r
-
distance
);
if
(
error
>
maxError
)
maxError
=
error
;
}
}
if
(
maxError
<=
workingConstraintTol
)
norm
/=
numParticles
;
break
;
// All constraints are satisfied.
norm
=
(
norm
<
1
?
1
:
sqrt
(
norm
));
context
.
setPositions
(
initialPos
);
param
.
epsilon
=
tolerance
/
norm
;
if
(
maxError
>=
prevMaxError
)
break
;
// Further tightening the springs doesn't seem to be helping, so just give up.
// Repeatedly minimize, steadily increasing the strength of the springs until all constraints are satisfied.
prevMaxError
=
maxError
;
k
*=
10
;
double
prevMaxError
=
1e10
;
if
(
maxError
>
100
*
workingConstraintTol
)
{
while
(
true
)
{
// We've gotten far enough from a valid state that we might have trouble getting
// Perform the minimization.
// back, so reset to the original positions.
lbfgsfloatval_t
fx
;
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
MinimizerData
data
(
context
,
k
);
x
[
3
*
i
]
=
initialPos
[
i
][
0
];
lbfgs
(
numParticles
*
3
,
x
,
&
fx
,
evaluate
,
NULL
,
&
data
,
&
param
);
x
[
3
*
i
+
1
]
=
initialPos
[
i
][
1
];
x
[
3
*
i
+
2
]
=
initialPos
[
i
][
2
];
// Check whether all constraints are satisfied.
vector
<
Vec3
>
positions
=
context
.
getState
(
State
::
Positions
).
getPositions
();
int
numConstraints
=
system
.
getNumConstraints
();
double
maxError
=
0.0
;
for
(
int
i
=
0
;
i
<
numConstraints
;
i
++
)
{
int
particle1
,
particle2
;
double
distance
;
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
Vec3
delta
=
positions
[
particle2
]
-
positions
[
particle1
];
double
r
=
sqrt
(
delta
.
dot
(
delta
));
double
error
=
fabs
(
r
-
distance
);
if
(
error
>
maxError
)
maxError
=
error
;
}
if
(
maxError
<=
workingConstraintTol
)
break
;
// All constraints are satisfied.
context
.
setPositions
(
initialPos
);
if
(
maxError
>=
prevMaxError
)
break
;
// Further tightening the springs doesn't seem to be helping, so just give up.
prevMaxError
=
maxError
;
k
*=
10
;
if
(
maxError
>
100
*
workingConstraintTol
)
{
// We've gotten far enough from a valid state that we might have trouble getting
// back, so reset to the original positions.
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
x
[
3
*
i
]
=
initialPos
[
i
][
0
];
x
[
3
*
i
+
1
]
=
initialPos
[
i
][
1
];
x
[
3
*
i
+
2
]
=
initialPos
[
i
][
2
];
}
}
}
}
}
}
}
catch
(...)
{
lbfgs_free
(
x
);
throw
;
}
lbfgs_free
(
x
);
lbfgs_free
(
x
);
// If necessary, do a final constraint projection to make sure they are satisfied
// If necessary, do a final constraint projection to make sure they are satisfied
...
...
openmmapi/src/ThreadPool.cpp
View file @
1945dd6c
...
@@ -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
7
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -40,10 +40,17 @@ class ThreadPool::ThreadData {
...
@@ -40,10 +40,17 @@ class ThreadPool::ThreadData {
public:
public:
ThreadData
(
ThreadPool
&
owner
,
int
index
)
:
owner
(
owner
),
index
(
index
),
isDeleted
(
false
)
{
ThreadData
(
ThreadPool
&
owner
,
int
index
)
:
owner
(
owner
),
index
(
index
),
isDeleted
(
false
)
{
}
}
void
executeTask
()
{
if
(
owner
.
currentTask
!=
NULL
)
owner
.
currentTask
->
execute
(
owner
,
index
);
else
owner
.
currentFunction
(
owner
,
index
);
}
ThreadPool
&
owner
;
ThreadPool
&
owner
;
int
index
;
int
index
;
bool
isDeleted
;
bool
isDeleted
;
Task
*
currentTask
;
Task
*
currentTask
;
function
<
void
(
ThreadPool
&
pool
,
int
)
>
currentFunction
;
};
};
static
void
*
threadBody
(
void
*
args
)
{
static
void
*
threadBody
(
void
*
args
)
{
...
@@ -54,13 +61,13 @@ static void* threadBody(void* args) {
...
@@ -54,13 +61,13 @@ static void* threadBody(void* args) {
data
.
owner
.
syncThreads
();
data
.
owner
.
syncThreads
();
if
(
data
.
isDeleted
)
if
(
data
.
isDeleted
)
break
;
break
;
data
.
currentTask
->
execute
(
data
.
owner
,
data
.
index
);
data
.
executeTask
(
);
}
}
delete
&
data
;
delete
&
data
;
return
0
;
return
0
;
}
}
ThreadPool
::
ThreadPool
(
int
numThreads
)
{
ThreadPool
::
ThreadPool
(
int
numThreads
)
:
currentTask
(
NULL
)
{
if
(
numThreads
<=
0
)
if
(
numThreads
<=
0
)
numThreads
=
getNumProcessors
();
numThreads
=
getNumProcessors
();
this
->
numThreads
=
numThreads
;
this
->
numThreads
=
numThreads
;
...
@@ -99,8 +106,13 @@ int ThreadPool::getNumThreads() const {
...
@@ -99,8 +106,13 @@ int ThreadPool::getNumThreads() const {
}
}
void
ThreadPool
::
execute
(
Task
&
task
)
{
void
ThreadPool
::
execute
(
Task
&
task
)
{
for
(
int
i
=
0
;
i
<
(
int
)
threadData
.
size
();
i
++
)
currentTask
=
&
task
;
threadData
[
i
]
->
currentTask
=
&
task
;
resumeThreads
();
}
void
ThreadPool
::
execute
(
function
<
void
(
ThreadPool
&
,
int
)
>
task
)
{
currentTask
=
NULL
;
currentFunction
=
task
;
resumeThreads
();
resumeThreads
();
}
}
...
...
platforms/cpu/include/CpuBondForce.h
View file @
1945dd6c
...
@@ -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) 2014 Stanford University and the Authors.
*
* Portions copyright (c) 2014
-2017
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -46,7 +46,6 @@ namespace OpenMM {
...
@@ -46,7 +46,6 @@ namespace OpenMM {
*/
*/
class
OPENMM_EXPORT_CPU
CpuBondForce
{
class
OPENMM_EXPORT_CPU
CpuBondForce
{
public:
public:
class
ComputeForceTask
;
CpuBondForce
();
CpuBondForce
();
/**
/**
* Analyze the set of bonds and decide which to compute with each thread.
* Analyze the set of bonds and decide which to compute with each thread.
...
...
platforms/cpu/include/CpuCustomGBForce.h
View file @
1945dd6c
/* Portions copyright (c) 2009-201
6
Stanford University and Simbios.
/* Portions copyright (c) 2009-201
7
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
...
@@ -39,7 +39,6 @@ namespace OpenMM {
...
@@ -39,7 +39,6 @@ namespace OpenMM {
class
CpuCustomGBForce
{
class
CpuCustomGBForce
{
private:
private:
class
ComputeForceTask
;
class
ThreadData
;
class
ThreadData
;
bool
cutoff
;
bool
cutoff
;
...
...
platforms/cpu/include/CpuCustomManyParticleForce.h
View file @
1945dd6c
/* Portions copyright (c) 2009-201
4
Stanford University and Simbios.
/* Portions copyright (c) 2009-201
7
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
...
@@ -48,7 +48,6 @@ private:
...
@@ -48,7 +48,6 @@ private:
class
DistanceTermInfo
;
class
DistanceTermInfo
;
class
AngleTermInfo
;
class
AngleTermInfo
;
class
DihedralTermInfo
;
class
DihedralTermInfo
;
class
ComputeForceTask
;
class
ThreadData
;
class
ThreadData
;
int
numParticles
,
numParticlesPerSet
,
numPerParticleParameters
,
numTypes
;
int
numParticles
,
numParticlesPerSet
,
numPerParticleParameters
,
numTypes
;
bool
useCutoff
,
usePeriodic
,
triclinic
,
centralParticleMode
;
bool
useCutoff
,
usePeriodic
,
triclinic
,
centralParticleMode
;
...
...
platforms/cpu/include/CpuCustomNonbondedForce.h
View file @
1945dd6c
/* Portions copyright (c) 2009-201
6
Stanford University and Simbios.
/* Portions copyright (c) 2009-201
7
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
...
@@ -122,7 +122,6 @@ class CpuCustomNonbondedForce {
...
@@ -122,7 +122,6 @@ class CpuCustomNonbondedForce {
RealOpenMM
*
fixedParameters
,
const
std
::
map
<
std
::
string
,
double
>&
globalParameters
,
RealOpenMM
*
fixedParameters
,
const
std
::
map
<
std
::
string
,
double
>&
globalParameters
,
std
::
vector
<
AlignedArray
<
float
>
>&
threadForce
,
bool
includeForce
,
bool
includeEnergy
,
double
&
totalEnergy
,
double
*
energyParamDerivs
);
std
::
vector
<
AlignedArray
<
float
>
>&
threadForce
,
bool
includeForce
,
bool
includeEnergy
,
double
&
totalEnergy
,
double
*
energyParamDerivs
);
private:
private:
class
ComputeForceTask
;
class
ThreadData
;
class
ThreadData
;
bool
cutoff
;
bool
cutoff
;
...
...
platforms/cpu/include/CpuGBSAOBCForce.h
View file @
1945dd6c
/* Portions copyright (c) 2006-201
3
Stanford University and Simbios.
/* Portions copyright (c) 2006-201
7
Stanford University and Simbios.
* Contributors: Pande Group
* Contributors: Pande Group
*
*
* Permission is hereby granted, free of charge, to any person obtaining
* Permission is hereby granted, free of charge, to any person obtaining
...
@@ -36,7 +36,6 @@ namespace OpenMM {
...
@@ -36,7 +36,6 @@ namespace OpenMM {
class
CpuGBSAOBCForce
{
class
CpuGBSAOBCForce
{
public:
public:
class
ComputeTask
;
CpuGBSAOBCForce
();
CpuGBSAOBCForce
();
/**
/**
...
...
platforms/cpu/include/CpuGayBerneForce.h
View file @
1945dd6c
...
@@ -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) 2016 Stanford University and the Authors.
*
* Portions copyright (c) 2016
-2017
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -45,7 +45,6 @@ namespace OpenMM {
...
@@ -45,7 +45,6 @@ namespace OpenMM {
class
CpuGayBerneForce
{
class
CpuGayBerneForce
{
public:
public:
struct
Matrix
;
struct
Matrix
;
class
ComputeTask
;
/**
/**
* Constructor.
* Constructor.
...
...
platforms/cpu/include/CpuKernels.h
View file @
1945dd6c
...
@@ -54,8 +54,6 @@ namespace OpenMM {
...
@@ -54,8 +54,6 @@ namespace OpenMM {
*/
*/
class
CpuCalcForcesAndEnergyKernel
:
public
CalcForcesAndEnergyKernel
{
class
CpuCalcForcesAndEnergyKernel
:
public
CalcForcesAndEnergyKernel
{
public:
public:
class
InitForceTask
;
class
SumForceTask
;
CpuCalcForcesAndEnergyKernel
(
std
::
string
name
,
const
Platform
&
platform
,
CpuPlatform
::
PlatformData
&
data
,
ContextImpl
&
context
);
CpuCalcForcesAndEnergyKernel
(
std
::
string
name
,
const
Platform
&
platform
,
CpuPlatform
::
PlatformData
&
data
,
ContextImpl
&
context
);
/**
/**
* Initialize the kernel.
* Initialize the kernel.
...
...
platforms/cpu/include/CpuLangevinDynamics.h
View file @
1945dd6c
/* Portions copyright (c) 2013-201
6
Stanford University and Simbios.
/* Portions copyright (c) 2013-201
7
Stanford University and Simbios.
* Authors: Peter Eastman
* Authors: Peter Eastman
* Contributors:
* Contributors:
*
*
...
@@ -35,9 +35,6 @@ namespace OpenMM {
...
@@ -35,9 +35,6 @@ namespace OpenMM {
class
CpuLangevinDynamics
:
public
ReferenceStochasticDynamics
{
class
CpuLangevinDynamics
:
public
ReferenceStochasticDynamics
{
public:
public:
class
Update1Task
;
class
Update2Task
;
class
Update3Task
;
/**
/**
* Constructor.
* Constructor.
*
*
...
...
platforms/cpu/include/CpuNeighborList.h
View file @
1945dd6c
...
@@ -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
6
Stanford University and the Authors. *
* Portions copyright (c) 2013-201
7
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -45,7 +45,6 @@ namespace OpenMM {
...
@@ -45,7 +45,6 @@ namespace OpenMM {
class
OPENMM_EXPORT_CPU
CpuNeighborList
{
class
OPENMM_EXPORT_CPU
CpuNeighborList
{
public:
public:
class
ThreadTask
;
class
Voxels
;
class
Voxels
;
CpuNeighborList
(
int
blockSize
);
CpuNeighborList
(
int
blockSize
);
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
,
...
...
platforms/cpu/include/CpuNonbondedForce.h
View file @
1945dd6c
/* Portions copyright (c) 2006-201
5
Stanford University and Simbios.
/* Portions copyright (c) 2006-201
7
Stanford University and Simbios.
* Contributors: Pande Group
* Contributors: Pande Group
*
*
* Permission is hereby granted, free of charge, to any person obtaining
* Permission is hereby granted, free of charge, to any person obtaining
...
@@ -39,7 +39,6 @@ namespace OpenMM {
...
@@ -39,7 +39,6 @@ namespace OpenMM {
class
CpuNonbondedForce
{
class
CpuNonbondedForce
{
public:
public:
class
ComputeDirectTask
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
...
platforms/cpu/include/CpuSETTLE.h
View file @
1945dd6c
...
@@ -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
-2017
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -45,8 +45,6 @@ namespace OpenMM {
...
@@ -45,8 +45,6 @@ namespace OpenMM {
*/
*/
class
OPENMM_EXPORT_CPU
CpuSETTLE
:
public
ReferenceConstraintAlgorithm
{
class
OPENMM_EXPORT_CPU
CpuSETTLE
:
public
ReferenceConstraintAlgorithm
{
public:
public:
class
ApplyToPositionsTask
;
class
ApplyToVelocitiesTask
;
CpuSETTLE
(
const
System
&
system
,
const
ReferenceSETTLEAlgorithm
&
settle
,
ThreadPool
&
threads
);
CpuSETTLE
(
const
System
&
system
,
const
ReferenceSETTLEAlgorithm
&
settle
,
ThreadPool
&
threads
);
~
CpuSETTLE
();
~
CpuSETTLE
();
...
...
platforms/cpu/src/CpuBondForce.cpp
View file @
1945dd6c
...
@@ -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) 2014-201
6
Stanford University and the Authors. *
* Portions copyright (c) 2014-201
7
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -35,25 +35,6 @@
...
@@ -35,25 +35,6 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
class
CpuBondForce
::
ComputeForceTask
:
public
ThreadPool
::
Task
{
public:
ComputeForceTask
(
CpuBondForce
&
owner
,
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
**
parameters
,
vector
<
RealVec
>&
forces
,
vector
<
RealOpenMM
>&
threadEnergy
,
RealOpenMM
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
)
:
owner
(
owner
),
atomCoordinates
(
atomCoordinates
),
parameters
(
parameters
),
forces
(
forces
),
threadEnergy
(
threadEnergy
),
totalEnergy
(
totalEnergy
),
referenceBondIxn
(
referenceBondIxn
)
{
}
void
execute
(
ThreadPool
&
threads
,
int
threadIndex
)
{
RealOpenMM
*
energy
=
(
totalEnergy
==
NULL
?
NULL
:
&
threadEnergy
[
threadIndex
]);
owner
.
threadComputeForce
(
threads
,
threadIndex
,
atomCoordinates
,
parameters
,
forces
,
energy
,
referenceBondIxn
);
}
CpuBondForce
&
owner
;
vector
<
RealVec
>&
atomCoordinates
;
RealOpenMM
**
parameters
;
vector
<
RealVec
>&
forces
;
vector
<
RealOpenMM
>&
threadEnergy
;
RealOpenMM
*
totalEnergy
;
ReferenceBondIxn
&
referenceBondIxn
;
};
CpuBondForce
::
CpuBondForce
()
{
CpuBondForce
::
CpuBondForce
()
{
}
}
...
@@ -188,8 +169,10 @@ void CpuBondForce::calculateForce(vector<RealVec>& atomCoordinates, RealOpenMM**
...
@@ -188,8 +169,10 @@ void CpuBondForce::calculateForce(vector<RealVec>& atomCoordinates, RealOpenMM**
// Have the worker threads compute their forces.
// Have the worker threads compute their forces.
vector
<
RealOpenMM
>
threadEnergy
(
threads
->
getNumThreads
(),
0
);
vector
<
RealOpenMM
>
threadEnergy
(
threads
->
getNumThreads
(),
0
);
ComputeForceTask
task
(
*
this
,
atomCoordinates
,
parameters
,
forces
,
threadEnergy
,
totalEnergy
,
referenceBondIxn
);
threads
->
execute
([
&
]
(
ThreadPool
&
threads
,
int
threadIndex
)
{
threads
->
execute
(
task
);
RealOpenMM
*
energy
=
(
totalEnergy
==
NULL
?
NULL
:
&
threadEnergy
[
threadIndex
]);
threadComputeForce
(
threads
,
threadIndex
,
atomCoordinates
,
parameters
,
forces
,
energy
,
referenceBondIxn
);
});
threads
->
waitForThreads
();
threads
->
waitForThreads
();
// Compute any "extra" bonds.
// Compute any "extra" bonds.
...
...
Prev
1
2
3
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