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
cf7a8bcb
Commit
cf7a8bcb
authored
Feb 10, 2012
by
Peter Eastman
Browse files
ApplyConstraintsKernel did not work correctly
parent
d51a7a5c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
3 deletions
+25
-3
platforms/opencl/src/OpenCLKernels.cpp
platforms/opencl/src/OpenCLKernels.cpp
+14
-2
platforms/opencl/src/OpenCLKernels.h
platforms/opencl/src/OpenCLKernels.h
+4
-1
platforms/opencl/src/kernels/constraints.cl
platforms/opencl/src/kernels/constraints.cl
+7
-0
No files found.
platforms/opencl/src/OpenCLKernels.cpp
View file @
cf7a8bcb
...
@@ -221,8 +221,20 @@ void OpenCLApplyConstraintsKernel::initialize(const System& system) {
...
@@ -221,8 +221,20 @@ void OpenCLApplyConstraintsKernel::initialize(const System& system) {
}
}
void
OpenCLApplyConstraintsKernel
::
apply
(
ContextImpl
&
context
,
double
tol
)
{
void
OpenCLApplyConstraintsKernel
::
apply
(
ContextImpl
&
context
,
double
tol
)
{
cl
.
getIntegrationUtilities
().
applyConstraints
(
tol
);
if
(
!
hasInitializedKernel
)
{
cl
.
getIntegrationUtilities
().
computeVirtualSites
();
hasInitializedKernel
=
true
;
map
<
string
,
string
>
defines
;
defines
[
"NUM_ATOMS"
]
=
intToString
(
cl
.
getNumAtoms
());
cl
::
Program
program
=
cl
.
createProgram
(
OpenCLKernelSources
::
constraints
,
defines
);
applyDeltasKernel
=
cl
::
Kernel
(
program
,
"applyPositionDeltas"
);
applyDeltasKernel
.
setArg
<
cl
::
Buffer
>
(
0
,
cl
.
getPosq
().
getDeviceBuffer
());
applyDeltasKernel
.
setArg
<
cl
::
Buffer
>
(
1
,
cl
.
getIntegrationUtilities
().
getPosDelta
().
getDeviceBuffer
());
}
OpenCLIntegrationUtilities
&
integration
=
cl
.
getIntegrationUtilities
();
cl
.
clearBuffer
(
integration
.
getPosDelta
());
integration
.
applyConstraints
(
tol
);
cl
.
executeKernel
(
applyDeltasKernel
,
cl
.
getNumAtoms
());
integration
.
computeVirtualSites
();
}
}
void
OpenCLVirtualSitesKernel
::
initialize
(
const
System
&
system
)
{
void
OpenCLVirtualSitesKernel
::
initialize
(
const
System
&
system
)
{
...
...
platforms/opencl/src/OpenCLKernels.h
View file @
cf7a8bcb
...
@@ -159,7 +159,8 @@ private:
...
@@ -159,7 +159,8 @@ private:
*/
*/
class
OpenCLApplyConstraintsKernel
:
public
ApplyConstraintsKernel
{
class
OpenCLApplyConstraintsKernel
:
public
ApplyConstraintsKernel
{
public:
public:
OpenCLApplyConstraintsKernel
(
std
::
string
name
,
const
Platform
&
platform
,
OpenCLContext
&
cl
)
:
ApplyConstraintsKernel
(
name
,
platform
),
cl
(
cl
)
{
OpenCLApplyConstraintsKernel
(
std
::
string
name
,
const
Platform
&
platform
,
OpenCLContext
&
cl
)
:
ApplyConstraintsKernel
(
name
,
platform
),
cl
(
cl
),
hasInitializedKernel
(
false
)
{
}
}
/**
/**
* Initialize the kernel.
* Initialize the kernel.
...
@@ -176,6 +177,8 @@ public:
...
@@ -176,6 +177,8 @@ public:
void
apply
(
ContextImpl
&
context
,
double
tol
);
void
apply
(
ContextImpl
&
context
,
double
tol
);
private:
private:
OpenCLContext
&
cl
;
OpenCLContext
&
cl
;
bool
hasInitializedKernel
;
cl
::
Kernel
applyDeltasKernel
;
};
};
/**
/**
...
...
platforms/opencl/src/kernels/constraints.cl
0 → 100644
View file @
cf7a8bcb
__kernel
void
applyPositionDeltas
(
__global
float4*
restrict
posq,
__global
float4*
restrict
posDelta
)
{
for
(
unsigned
int
index
=
get_global_id
(
0
)
; index < NUM_ATOMS; index += get_global_size(0)) {
float4
position
=
posq[index]
;
position.xyz
+=
posDelta[index].xyz
;
posq[index]
=
position
;
}
}
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