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
325fead1
Unverified
Commit
325fead1
authored
Jun 15, 2019
by
peastman
Committed by
GitHub
Jun 15, 2019
Browse files
Merge pull request #2322 from peastman/cv
CustomCVForce applies ForceInfos from inner context to the outer one
parents
0a4867a9
ab92c8ed
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
78 additions
and
10 deletions
+78
-10
platforms/cuda/include/CudaContext.h
platforms/cuda/include/CudaContext.h
+6
-2
platforms/cuda/include/CudaKernels.h
platforms/cuda/include/CudaKernels.h
+2
-1
platforms/cuda/src/CudaContext.cpp
platforms/cuda/src/CudaContext.cpp
+5
-1
platforms/cuda/src/CudaKernels.cpp
platforms/cuda/src/CudaKernels.cpp
+26
-1
platforms/opencl/include/OpenCLContext.h
platforms/opencl/include/OpenCLContext.h
+6
-2
platforms/opencl/include/OpenCLKernels.h
platforms/opencl/include/OpenCLKernels.h
+2
-1
platforms/opencl/src/OpenCLContext.cpp
platforms/opencl/src/OpenCLContext.cpp
+5
-1
platforms/opencl/src/OpenCLKernels.cpp
platforms/opencl/src/OpenCLKernels.cpp
+26
-1
No files found.
platforms/cuda/include/CudaContext.h
View file @
325fead1
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* *
* Portions copyright (c) 2009-201
8
Stanford University and the Authors. *
* Portions copyright (c) 2009-201
9
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -86,9 +86,13 @@ public:
...
@@ -86,9 +86,13 @@ public:
*/
*/
void
initialize
();
void
initialize
();
/**
/**
* Add a CudaForce to this context.
* Add a CudaForce
Info
to this context.
*/
*/
void
addForce
(
CudaForceInfo
*
force
);
void
addForce
(
CudaForceInfo
*
force
);
/**
* Get all CudaForceInfos that have been added to this context.
*/
std
::
vector
<
CudaForceInfo
*>&
getForceInfos
();
/**
/**
* Get the CUcontext associated with this object.
* Get the CUcontext associated with this object.
*/
*/
...
...
platforms/cuda/include/CudaKernels.h
View file @
325fead1
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* *
* Portions copyright (c) 2008-201
8
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
9
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -1268,6 +1268,7 @@ public:
...
@@ -1268,6 +1268,7 @@ public:
*/
*/
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomCVForce
&
force
);
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomCVForce
&
force
);
private:
private:
class
ForceInfo
;
class
ReorderListener
;
class
ReorderListener
;
CudaContext
&
cu
;
CudaContext
&
cu
;
bool
hasInitializedListeners
;
bool
hasInitializedListeners
;
...
...
platforms/cuda/src/CudaContext.cpp
View file @
325fead1
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* *
* Portions copyright (c) 2009-201
8
Stanford University and the Authors. *
* Portions copyright (c) 2009-201
9
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -488,6 +488,10 @@ void CudaContext::addForce(CudaForceInfo* force) {
...
@@ -488,6 +488,10 @@ void CudaContext::addForce(CudaForceInfo* force) {
forces
.
push_back
(
force
);
forces
.
push_back
(
force
);
}
}
vector
<
CudaForceInfo
*>&
CudaContext
::
getForceInfos
()
{
return
forces
;
}
void
CudaContext
::
setAsCurrent
()
{
void
CudaContext
::
setAsCurrent
()
{
if
(
contextIsValid
)
if
(
contextIsValid
)
cuCtxSetCurrent
(
context
);
cuCtxSetCurrent
(
context
);
...
...
platforms/cuda/src/CudaKernels.cpp
View file @
325fead1
...
@@ -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
8
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
9
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -6646,6 +6646,26 @@ void CudaCalcGayBerneForceKernel::sortAtoms() {
...
@@ -6646,6 +6646,26 @@ void CudaCalcGayBerneForceKernel::sortAtoms() {
exclusionStartIndex.upload(startIndexVec);
exclusionStartIndex.upload(startIndexVec);
}
}
class CudaCalcCustomCVForceKernel::ForceInfo : public CudaForceInfo {
public:
ForceInfo(CudaForceInfo& force) : force(force) {
}
bool areParticlesIdentical(int particle1, int particle2) {
return force.areParticlesIdentical(particle1, particle2);
}
int getNumParticleGroups() {
return force.getNumParticleGroups();
}
void getParticlesInGroup(int index, std::vector<int>& particles) {
force.getParticlesInGroup(index, particles);
}
bool areGroupsIdentical(int group1, int group2) {
return force.areGroupsIdentical(group1, group2);
}
private:
CudaForceInfo& force;
};
class CudaCalcCustomCVForceKernel::ReorderListener : public CudaContext::ReorderListener {
class CudaCalcCustomCVForceKernel::ReorderListener : public CudaContext::ReorderListener {
public:
public:
ReorderListener(CudaContext& cu, CudaArray& invAtomOrder) : cu(cu), invAtomOrder(invAtomOrder) {
ReorderListener(CudaContext& cu, CudaArray& invAtomOrder) : cu(cu), invAtomOrder(invAtomOrder) {
...
@@ -6725,6 +6745,11 @@ void CudaCalcCustomCVForceKernel::initialize(const System& system, const CustomC
...
@@ -6725,6 +6745,11 @@ void CudaCalcCustomCVForceKernel::initialize(const System& system, const CustomC
copyStateKernel = cu.getKernel(module, "copyState");
copyStateKernel = cu.getKernel(module, "copyState");
copyForcesKernel = cu.getKernel(module, "copyForces");
copyForcesKernel = cu.getKernel(module, "copyForces");
addForcesKernel = cu.getKernel(module, "addForces");
addForcesKernel = cu.getKernel(module, "addForces");
// This context needs to respect all forces in the inner context when reordering atoms.
for (CudaForceInfo* info : cu2.getForceInfos())
cu.addForce(new ForceInfo(*info));
}
}
double CudaCalcCustomCVForceKernel::execute(ContextImpl& context, ContextImpl& innerContext, bool includeForces, bool includeEnergy) {
double CudaCalcCustomCVForceKernel::execute(ContextImpl& context, ContextImpl& innerContext, bool includeForces, bool includeEnergy) {
...
...
platforms/opencl/include/OpenCLContext.h
View file @
325fead1
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* *
* Portions copyright (c) 2009-201
8
Stanford University and the Authors. *
* Portions copyright (c) 2009-201
9
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -172,9 +172,13 @@ public:
...
@@ -172,9 +172,13 @@ public:
*/
*/
void
initialize
();
void
initialize
();
/**
/**
* Add an OpenCLForce to this context.
* Add an OpenCLForce
Info
to this context.
*/
*/
void
addForce
(
OpenCLForceInfo
*
force
);
void
addForce
(
OpenCLForceInfo
*
force
);
/**
* Get all OpenCLForceInfos that have been added to this context.
*/
std
::
vector
<
OpenCLForceInfo
*>&
getForceInfos
();
/**
/**
* Get the cl::Context associated with this object.
* Get the cl::Context associated with this object.
*/
*/
...
...
platforms/opencl/include/OpenCLKernels.h
View file @
325fead1
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* *
* Portions copyright (c) 2008-201
8
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
9
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -1245,6 +1245,7 @@ public:
...
@@ -1245,6 +1245,7 @@ public:
*/
*/
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomCVForce
&
force
);
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomCVForce
&
force
);
private:
private:
class
ForceInfo
;
class
ReorderListener
;
class
ReorderListener
;
OpenCLContext
&
cl
;
OpenCLContext
&
cl
;
bool
hasInitializedKernels
;
bool
hasInitializedKernels
;
...
...
platforms/opencl/src/OpenCLContext.cpp
View file @
325fead1
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* *
* Portions copyright (c) 2009-201
8
Stanford University and the Authors. *
* Portions copyright (c) 2009-201
9
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -507,6 +507,10 @@ void OpenCLContext::addForce(OpenCLForceInfo* force) {
...
@@ -507,6 +507,10 @@ void OpenCLContext::addForce(OpenCLForceInfo* force) {
forces
.
push_back
(
force
);
forces
.
push_back
(
force
);
}
}
vector
<
OpenCLForceInfo
*>&
OpenCLContext
::
getForceInfos
()
{
return
forces
;
}
string
OpenCLContext
::
replaceStrings
(
const
string
&
input
,
const
std
::
map
<
std
::
string
,
std
::
string
>&
replacements
)
const
{
string
OpenCLContext
::
replaceStrings
(
const
string
&
input
,
const
std
::
map
<
std
::
string
,
std
::
string
>&
replacements
)
const
{
static
set
<
char
>
symbolChars
;
static
set
<
char
>
symbolChars
;
if
(
symbolChars
.
size
()
==
0
)
{
if
(
symbolChars
.
size
()
==
0
)
{
...
...
platforms/opencl/src/OpenCLKernels.cpp
View file @
325fead1
...
@@ -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
8
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
9
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -6925,6 +6925,26 @@ void OpenCLCalcGayBerneForceKernel::sortAtoms() {
...
@@ -6925,6 +6925,26 @@ void OpenCLCalcGayBerneForceKernel::sortAtoms() {
exclusionStartIndex.upload(startIndexVec);
exclusionStartIndex.upload(startIndexVec);
}
}
class OpenCLCalcCustomCVForceKernel::ForceInfo : public OpenCLForceInfo {
public:
ForceInfo(OpenCLForceInfo& force) : OpenCLForceInfo(0), force(force) {
}
bool areParticlesIdentical(int particle1, int particle2) {
return force.areParticlesIdentical(particle1, particle2);
}
int getNumParticleGroups() {
return force.getNumParticleGroups();
}
void getParticlesInGroup(int index, std::vector<int>& particles) {
force.getParticlesInGroup(index, particles);
}
bool areGroupsIdentical(int group1, int group2) {
return force.areGroupsIdentical(group1, group2);
}
private:
OpenCLForceInfo& force;
};
class OpenCLCalcCustomCVForceKernel::ReorderListener : public OpenCLContext::ReorderListener {
class OpenCLCalcCustomCVForceKernel::ReorderListener : public OpenCLContext::ReorderListener {
public:
public:
ReorderListener(OpenCLContext& cl, OpenCLArray& invAtomOrder) : cl(cl), invAtomOrder(invAtomOrder) {
ReorderListener(OpenCLContext& cl, OpenCLArray& invAtomOrder) : cl(cl), invAtomOrder(invAtomOrder) {
...
@@ -7005,6 +7025,11 @@ void OpenCLCalcCustomCVForceKernel::initialize(const System& system, const Custo
...
@@ -7005,6 +7025,11 @@ void OpenCLCalcCustomCVForceKernel::initialize(const System& system, const Custo
copyStateKernel = cl::Kernel(program, "copyState");
copyStateKernel = cl::Kernel(program, "copyState");
copyForcesKernel = cl::Kernel(program, "copyForces");
copyForcesKernel = cl::Kernel(program, "copyForces");
addForcesKernel = cl::Kernel(program, "addForces");
addForcesKernel = cl::Kernel(program, "addForces");
// This context needs to respect all forces in the inner context when reordering atoms.
for (OpenCLForceInfo* info : cl2.getForceInfos())
cl.addForce(new ForceInfo(*info));
}
}
double OpenCLCalcCustomCVForceKernel::execute(ContextImpl& context, ContextImpl& innerContext, bool includeForces, bool includeEnergy) {
double OpenCLCalcCustomCVForceKernel::execute(ContextImpl& context, ContextImpl& innerContext, bool includeForces, bool includeEnergy) {
...
...
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