Commit 21804e95 authored by Peter Eastman's avatar Peter Eastman
Browse files

Fixed illegal memory access

parent c306d802
...@@ -83,7 +83,7 @@ __kernel void computeDonorForces(__global float4* restrict forceBuffers, __globa ...@@ -83,7 +83,7 @@ __kernel void computeDonorForces(__global float4* restrict forceBuffers, __globa
// Load the next block of acceptors into local memory. // Load the next block of acceptors into local memory.
int blockSize = min((int) get_local_size(0), NUM_ACCEPTORS-acceptorStart); int blockSize = min((int) get_local_size(0), NUM_ACCEPTORS-acceptorStart);
if (get_local_id(0) < blockSize) { if (get_local_id(0) < blockSize && acceptorStart+get_local_id(0) < NUM_ACCEPTORS) {
int4 atoms2 = acceptorAtoms[acceptorStart+get_local_id(0)]; int4 atoms2 = acceptorAtoms[acceptorStart+get_local_id(0)];
posBuffer[3*get_local_id(0)] = posq[atoms2.x]; posBuffer[3*get_local_id(0)] = posq[atoms2.x];
posBuffer[3*get_local_id(0)+1] = posq[atoms2.y]; posBuffer[3*get_local_id(0)+1] = posq[atoms2.y];
...@@ -168,7 +168,7 @@ __kernel void computeAcceptorForces(__global float4* restrict forceBuffers, __gl ...@@ -168,7 +168,7 @@ __kernel void computeAcceptorForces(__global float4* restrict forceBuffers, __gl
// Load the next block of donors into local memory. // Load the next block of donors into local memory.
int blockSize = min((int) get_local_size(0), NUM_DONORS-donorStart); int blockSize = min((int) get_local_size(0), NUM_DONORS-donorStart);
if (get_local_id(0) < blockSize) { if (get_local_id(0) < blockSize && donorStart+get_local_id(0) < NUM_DONORS) {
int4 atoms2 = donorAtoms[donorStart+get_local_id(0)]; int4 atoms2 = donorAtoms[donorStart+get_local_id(0)];
posBuffer[3*get_local_id(0)] = posq[atoms2.x]; posBuffer[3*get_local_id(0)] = posq[atoms2.x];
posBuffer[3*get_local_id(0)+1] = posq[atoms2.y]; posBuffer[3*get_local_id(0)+1] = posq[atoms2.y];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment