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
18c9ba59
Commit
18c9ba59
authored
Feb 16, 2012
by
Peter Eastman
Browse files
CustomIntegrator computed energy incorrectly
parent
663a8db0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
4 deletions
+6
-4
platforms/opencl/src/OpenCLKernels.cpp
platforms/opencl/src/OpenCLKernels.cpp
+4
-2
platforms/opencl/src/kernels/customIntegrator.cl
platforms/opencl/src/kernels/customIntegrator.cl
+2
-2
No files found.
platforms/opencl/src/OpenCLKernels.cpp
View file @
18c9ba59
...
@@ -3895,6 +3895,7 @@ void OpenCLIntegrateCustomStepKernel::execute(ContextImpl& context, CustomIntegr
...
@@ -3895,6 +3895,7 @@ void OpenCLIntegrateCustomStepKernel::execute(ContextImpl& context, CustomIntegr
}
}
if
(
!
found
)
if
(
!
found
)
throw
OpenMMException
(
"Unknown global variable: "
+
variable
[
step
]);
throw
OpenMMException
(
"Unknown global variable: "
+
variable
[
step
]);
kernel
.
setArg
<
cl_int
>
(
index
++
,
3
*
numAtoms
);
}
}
}
}
else
if
(
stepType
[
step
]
==
CustomIntegrator
::
ComputeGlobal
&&
!
merged
[
step
])
{
else
if
(
stepType
[
step
]
==
CustomIntegrator
::
ComputeGlobal
&&
!
merged
[
step
])
{
...
@@ -3935,7 +3936,8 @@ void OpenCLIntegrateCustomStepKernel::execute(ContextImpl& context, CustomIntegr
...
@@ -3935,7 +3936,8 @@ void OpenCLIntegrateCustomStepKernel::execute(ContextImpl& context, CustomIntegr
int
index
=
0
;
int
index
=
0
;
sumEnergyKernel
.
setArg
<
cl
::
Buffer
>
(
index
++
,
cl
.
getEnergyBuffer
().
getDeviceBuffer
());
sumEnergyKernel
.
setArg
<
cl
::
Buffer
>
(
index
++
,
cl
.
getEnergyBuffer
().
getDeviceBuffer
());
sumEnergyKernel
.
setArg
<
cl
::
Buffer
>
(
index
++
,
energy
->
getDeviceBuffer
());
sumEnergyKernel
.
setArg
<
cl
::
Buffer
>
(
index
++
,
energy
->
getDeviceBuffer
());
sumEnergyKernel
.
setArg
<
cl_float
>
(
index
++
,
0
);
sumEnergyKernel
.
setArg
<
cl_int
>
(
index
++
,
0
);
sumEnergyKernel
.
setArg
<
cl_int
>
(
index
++
,
cl
.
getEnergyBuffer
().
getSize
());
}
}
// Make sure all values (variables, parameters, etc.) stored on the device are up to date.
// Make sure all values (variables, parameters, etc.) stored on the device are up to date.
...
@@ -3983,7 +3985,7 @@ void OpenCLIntegrateCustomStepKernel::execute(ContextImpl& context, CustomIntegr
...
@@ -3983,7 +3985,7 @@ void OpenCLIntegrateCustomStepKernel::execute(ContextImpl& context, CustomIntegr
break
;
break
;
}
}
recordChangedParameters
(
context
);
recordChangedParameters
(
context
);
context
.
calcForcesAndEnergy
(
computeForce
,
false
,
forceGroup
[
i
]);
context
.
calcForcesAndEnergy
(
computeForce
,
computeEnergy
,
forceGroup
[
i
]);
if
(
computeEnergy
)
if
(
computeEnergy
)
cl
.
executeKernel
(
sumEnergyKernel
,
OpenCLContext
::
ThreadBlockSize
,
OpenCLContext
::
ThreadBlockSize
);
cl
.
executeKernel
(
sumEnergyKernel
,
OpenCLContext
::
ThreadBlockSize
,
OpenCLContext
::
ThreadBlockSize
);
forcesAreValid
=
true
;
forcesAreValid
=
true
;
...
...
platforms/opencl/src/kernels/customIntegrator.cl
View file @
18c9ba59
__kernel
void
computeSum
(
__global
const
float*
restrict
sumBuffer,
__global
float*
result,
unsigned
int
outputIndex
)
{
__kernel
void
computeSum
(
__global
const
float*
restrict
sumBuffer,
__global
float*
result,
unsigned
int
outputIndex
,
int
bufferSize
)
{
__local
float
tempBuffer[WORK_GROUP_SIZE]
;
__local
float
tempBuffer[WORK_GROUP_SIZE]
;
const
unsigned
int
thread
=
get_local_id
(
0
)
;
const
unsigned
int
thread
=
get_local_id
(
0
)
;
float
sum
=
0.0f
;
float
sum
=
0.0f
;
for
(
unsigned
int
index
=
thread
; index <
3*NUM_ATOMS
; index += get_local_size(0))
for
(
unsigned
int
index
=
thread
; index <
bufferSize
; index += get_local_size(0))
sum
+=
sumBuffer[index]
;
sum
+=
sumBuffer[index]
;
tempBuffer[thread]
=
sum
;
tempBuffer[thread]
=
sum
;
for
(
int
i
=
1
; i < WORK_GROUP_SIZE; i *= 2) {
for
(
int
i
=
1
; i < WORK_GROUP_SIZE; i *= 2) {
...
...
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