Commit 5301b9cc authored by Peter Eastman's avatar Peter Eastman
Browse files

Fixed bug in writing forces to global memory (see bug 1080)

parent fac4150f
...@@ -123,22 +123,17 @@ __global__ void METHOD_NAME(kCalculateCustomNonbonded, Forces_kernel)(unsigned i ...@@ -123,22 +123,17 @@ __global__ void METHOD_NAME(kCalculateCustomNonbonded, Forces_kernel)(unsigned i
} }
// Write results // Write results
float4 of;
#ifdef USE_OUTPUT_BUFFER_PER_WARP #ifdef USE_OUTPUT_BUFFER_PER_WARP
unsigned int offset = x + tgx + warp*cSim.stride; unsigned int offset = x + tgx + warp*cSim.stride;
of = cSim.pForce4[offset]; #else
unsigned int offset = x + tgx + (x >> GRIDBITS) * cSim.stride;
#endif
float4 of = cSim.pForce4[offset];
of.x += af.x; of.x += af.x;
of.y += af.y; of.y += af.y;
of.z += af.z; of.z += af.z;
cSim.pForce4[offset] = of; cSim.pForce4[offset] = of;
#else
of.x = af.x;
of.y = af.y;
of.z = af.z;
of.w = 0.0f;
unsigned int offset = x + tgx + (x >> GRIDBITS) * cSim.stride;
cSim.pForce4[offset] = of;
#endif
} }
else // 100% utilization else // 100% utilization
{ {
...@@ -370,30 +365,24 @@ __global__ void METHOD_NAME(kCalculateCustomNonbonded, Forces_kernel)(unsigned i ...@@ -370,30 +365,24 @@ __global__ void METHOD_NAME(kCalculateCustomNonbonded, Forces_kernel)(unsigned i
float4 of; float4 of;
#ifdef USE_OUTPUT_BUFFER_PER_WARP #ifdef USE_OUTPUT_BUFFER_PER_WARP
unsigned int offset = x + tgx + warp*cSim.stride; unsigned int offset = x + tgx + warp*cSim.stride;
#else
unsigned int offset = x + tgx + (y >> GRIDBITS) * cSim.stride;
#endif
of = cSim.pForce4[offset]; of = cSim.pForce4[offset];
of.x += af.x; of.x += af.x;
of.y += af.y; of.y += af.y;
of.z += af.z; of.z += af.z;
cSim.pForce4[offset] = of; cSim.pForce4[offset] = of;
#ifdef USE_OUTPUT_BUFFER_PER_WARP
offset = y + tgx + warp*cSim.stride; offset = y + tgx + warp*cSim.stride;
#else
offset = y + tgx + (x >> GRIDBITS) * cSim.stride;
#endif
of = cSim.pForce4[offset]; of = cSim.pForce4[offset];
of.x += sA[threadIdx.x].fx; of.x += sA[threadIdx.x].fx;
of.y += sA[threadIdx.x].fy; of.y += sA[threadIdx.x].fy;
of.z += sA[threadIdx.x].fz; of.z += sA[threadIdx.x].fz;
cSim.pForce4[offset] = of; cSim.pForce4[offset] = of;
#else
of.x = af.x;
of.y = af.y;
of.z = af.z;
of.w = 0.0f;
unsigned int offset = x + tgx + (y >> GRIDBITS) * cSim.stride;
cSim.pForce4[offset] = of;
of.x = sA[threadIdx.x].fx;
of.y = sA[threadIdx.x].fy;
of.z = sA[threadIdx.x].fz;
offset = y + tgx + (x >> GRIDBITS) * cSim.stride;
cSim.pForce4[offset] = of;
#endif
lasty = y; lasty = 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