gbsaObc_default.cl 19.3 KB
Newer Older
1
2
#define TILE_SIZE 32

3
4
5
6
7
8
9
10
11
12
typedef struct {
    float x, y, z;
    float q;
    float fx, fy, fz, fw;
    float radius, scaledRadius;
    float bornSum;
    float bornRadius;
    float bornForce;
} AtomData;

13
14
15
16
/**
 * Compute the Born sum.
 */

17
__kernel __attribute__((reqd_work_group_size(WORK_GROUP_SIZE, 1, 1)))
18
void computeBornSum(__global float* global_bornSum, __global float4* posq, __global float2* global_params,
19
        __local AtomData* localData, __local float* tempBuffer,
20
#ifdef USE_CUTOFF
21
        __global ushort2* tiles, __global unsigned int* interactionCount, float4 periodicBoxSize, float4 invPeriodicBoxSize, unsigned int maxTiles) {
22
23
24
25
26
#else
        unsigned int numTiles) {
#endif
#ifdef USE_CUTOFF
    unsigned int numTiles = interactionCount[0];
27
28
    unsigned int pos = get_group_id(0)*(numTiles > maxTiles ? NUM_BLOCKS*(NUM_BLOCKS+1)/2 : numTiles)/get_num_groups(0);
    unsigned int end = (get_group_id(0)+1)*(numTiles > maxTiles ? NUM_BLOCKS*(NUM_BLOCKS+1)/2 : numTiles)/get_num_groups(0);
29
#else
30
31
    unsigned int pos = get_group_id(0)*numTiles/get_num_groups(0);
    unsigned int end = (get_group_id(0)+1)*numTiles/get_num_groups(0);
32
#endif
33
34
35
36
    unsigned int lasty = 0xFFFFFFFF;

    while (pos < end) {
        // Extract the coordinates of this tile
37
        unsigned int x, y;
38
#ifdef USE_CUTOFF
39
        if (numTiles <= maxTiles) {
40
41
42
            ushort2 tileIndices = tiles[pos];
            x = tileIndices.x;
            y = tileIndices.y;
43
        }
44
        else
45
#endif
46
47
48
        {
            y = (unsigned int) floor(NUM_BLOCKS+0.5f-sqrt((NUM_BLOCKS+0.5f)*(NUM_BLOCKS+0.5f)-2*pos));
            x = (pos-y*NUM_BLOCKS+y*(y+1)/2);
49
50
            if (x < y || x >= NUM_BLOCKS) { // Occasionally happens due to roundoff error.
                y += (x < y ? -1 : 1);
51
52
53
                x = (pos-y*NUM_BLOCKS+y*(y+1)/2);
            }
        }
54
55
56
        unsigned int baseLocalAtom = (get_local_id(0) < TILE_SIZE ? 0 : TILE_SIZE/2);
        unsigned int tgx = get_local_id(0) & (TILE_SIZE-1);
        unsigned int forceBufferOffset = (tgx < TILE_SIZE/2 ? 0 : TILE_SIZE);
57
        unsigned int atom1 = x*TILE_SIZE + tgx;
58
59
60
61
62
63
        float bornSum = 0.0f;
        float4 posq1 = posq[atom1];
        float2 params1 = global_params[atom1];
        if (x == y) {
            // This tile is on the diagonal.

64
65
66
67
68
69
            localData[get_local_id(0)].x = posq1.x;
            localData[get_local_id(0)].y = posq1.y;
            localData[get_local_id(0)].z = posq1.z;
            localData[get_local_id(0)].q = posq1.w;
            localData[get_local_id(0)].radius = params1.x;
            localData[get_local_id(0)].scaledRadius = params1.y;
70
71
            barrier(CLK_LOCAL_MEM_FENCE);
            for (unsigned int j = 0; j < TILE_SIZE/2; j++) {
72
                float4 delta = (float4) (localData[baseLocalAtom+j].x-posq1.x, localData[baseLocalAtom+j].y-posq1.y, localData[baseLocalAtom+j].z-posq1.z, 0.0f);
73
#ifdef USE_PERIODIC
74
75
76
                delta.x -= floor(delta.x*invPeriodicBoxSize.x+0.5f)*periodicBoxSize.x;
                delta.y -= floor(delta.y*invPeriodicBoxSize.y+0.5f)*periodicBoxSize.y;
                delta.z -= floor(delta.z*invPeriodicBoxSize.z+0.5f)*periodicBoxSize.z;
77
78
#endif
                float r2 = delta.x*delta.x + delta.y*delta.y + delta.z*delta.z;
79
80
81
82
                float invR = RSQRT(r2);
                float r = RECIP(invR);
                float2 params2 = (float2) (localData[baseLocalAtom+j].radius, localData[baseLocalAtom+j].scaledRadius);
                float rScaledRadiusJ = r+params2.y;
83
#ifdef USE_CUTOFF
84
                unsigned int includeInteraction = (atom1 < NUM_ATOMS && y*TILE_SIZE+baseLocalAtom+j < NUM_ATOMS && r2 < CUTOFF_SQUARED && (j+baseLocalAtom != tgx) && (params1.x < rScaledRadiusJ));
85
#else
86
                unsigned int includeInteraction = (atom1 < NUM_ATOMS && y*TILE_SIZE+baseLocalAtom+j < NUM_ATOMS && (j+baseLocalAtom != tgx) && (params1.x < rScaledRadiusJ));
87
#endif
88
89
90
91
92
93
94
95
                float l_ij = RECIP(max(params1.x, fabs(r-params2.y)));
                float u_ij = RECIP(rScaledRadiusJ);
                float l_ij2 = l_ij*l_ij;
                float u_ij2 = u_ij*u_ij;
                float ratio = LOG(u_ij * RECIP(l_ij));
                bornSum += select(0.0f, l_ij - u_ij + 0.25f*r*(u_ij2-l_ij2) + (0.50f*invR*ratio) +
                                 (0.25f*params2.y*params2.y*invR)*(l_ij2-u_ij2), includeInteraction);
                bornSum += select(0.0f, 2.0f*(RECIP(params1.x)-l_ij), includeInteraction && params1.x < params2.x-r);
96
97
98
99
            }

            // Sum the forces and write results.

100

101
102
103
104
105
            if (get_local_id(0) >= TILE_SIZE)
                tempBuffer[get_local_id(0)] = bornSum;
            barrier(CLK_LOCAL_MEM_FENCE);
            if (get_local_id(0) < TILE_SIZE) {
#ifdef USE_OUTPUT_BUFFER_PER_BLOCK
106
                unsigned int offset = x*TILE_SIZE + tgx + x*PADDED_NUM_ATOMS;
107
#else
108
                unsigned int offset = x*TILE_SIZE + tgx + get_group_id(0)*PADDED_NUM_ATOMS;
109
110
111
112
113
114
115
116
#endif
                global_bornSum[offset] += bornSum+tempBuffer[get_local_id(0)+TILE_SIZE];
            }
        }
        else {
            // This is an off-diagonal tile.

            if (lasty != y && get_local_id(0) < TILE_SIZE) {
117
                unsigned int j = y*TILE_SIZE + tgx;
118
119
120
121
122
123
124
125
                float4 tempPosq = posq[j];
                localData[get_local_id(0)].x = tempPosq.x;
                localData[get_local_id(0)].y = tempPosq.y;
                localData[get_local_id(0)].z = tempPosq.z;
                localData[get_local_id(0)].q = tempPosq.w;
                float2 tempParams = global_params[j];
                localData[get_local_id(0)].radius = tempParams.x;
                localData[get_local_id(0)].scaledRadius = tempParams.y;
126
            }
127
            localData[get_local_id(0)].bornSum = 0.0f;
128
129
130
131
132
133
            barrier(CLK_LOCAL_MEM_FENCE);

            // Compute the full set of interactions in this tile.

            unsigned int tj = tgx%(TILE_SIZE/2);
            for (unsigned int j = 0; j < TILE_SIZE/2; j++) {
134
                float4 delta = (float4) (localData[baseLocalAtom+tj].x-posq1.x, localData[baseLocalAtom+tj].y-posq1.y, localData[baseLocalAtom+tj].z-posq1.z, 0.0f);
135
#ifdef USE_PERIODIC
136
137
138
                delta.x -= floor(delta.x*invPeriodicBoxSize.x+0.5f)*periodicBoxSize.x;
                delta.y -= floor(delta.y*invPeriodicBoxSize.y+0.5f)*periodicBoxSize.y;
                delta.z -= floor(delta.z*invPeriodicBoxSize.z+0.5f)*periodicBoxSize.z;
139
140
141
#endif
                float r2 = delta.x*delta.x + delta.y*delta.y + delta.z*delta.z;
#ifdef USE_CUTOFF
142
                unsigned int includeInteraction = (atom1 < NUM_ATOMS && y*TILE_SIZE+baseLocalAtom+tj < NUM_ATOMS && r2 < CUTOFF_SQUARED);
143
#else
144
                unsigned int includeInteraction = (atom1 < NUM_ATOMS && y*TILE_SIZE+baseLocalAtom+tj < NUM_ATOMS);
145
#endif
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
                float invR = RSQRT(r2);
                float r = RECIP(invR);
                float2 params2 = (float2) (localData[baseLocalAtom+tj].radius, localData[baseLocalAtom+tj].scaledRadius);
                float rScaledRadiusJ = r+params2.y;
                {
                    float l_ij = RECIP(max(params1.x, fabs(r-params2.y)));
                    float u_ij = RECIP(rScaledRadiusJ);
                    float l_ij2 = l_ij*l_ij;
                    float u_ij2 = u_ij*u_ij;
                    float ratio = LOG(u_ij * RECIP(l_ij));
                    unsigned int includeTerm = (includeInteraction && params1.x < rScaledRadiusJ);
                    bornSum += select(0.0f, l_ij - u_ij + 0.25f*r*(u_ij2-l_ij2) + (0.50f*invR*ratio) +
                                     (0.25f*params2.y*params2.y*invR)*(l_ij2-u_ij2), includeTerm);
                    bornSum += select(0.0f, 2.0f*(RECIP(params1.x)-l_ij), includeTerm && params1.x < params2.x-r);
                }
                float rScaledRadiusI = r+params1.y;
                {
                    float l_ij = RECIP(max(params2.x, fabs(r-params1.y)));
                    float u_ij = RECIP(rScaledRadiusI);
                    float l_ij2 = l_ij*l_ij;
                    float u_ij2 = u_ij*u_ij;
                    float ratio = LOG(u_ij * RECIP(l_ij));
                    float term = l_ij - u_ij + 0.25f*r*(u_ij2-l_ij2) + (0.50f*invR*ratio) +
                                     (0.25f*params1.y*params1.y*invR)*(l_ij2-u_ij2);
                    term += select(0.0f, 2.0f*(RECIP(params2.x)-l_ij), params2.x < params1.x-r);
                    localData[baseLocalAtom+tj+forceBufferOffset].bornSum += select(0.0f, term, includeInteraction && params2.x < rScaledRadiusI);
172
173
174
175
176
177
178
179
180
181
182
183
                }
                barrier(CLK_LOCAL_MEM_FENCE);
                tj = (tj+1)%(TILE_SIZE/2);
            }

            // Sum the forces and write results.

            if (get_local_id(0) >= TILE_SIZE)
                tempBuffer[get_local_id(0)] = bornSum;
            barrier(CLK_LOCAL_MEM_FENCE);
            if (get_local_id(0) < TILE_SIZE) {
#ifdef USE_OUTPUT_BUFFER_PER_BLOCK
184
185
                unsigned int offset1 = x*TILE_SIZE + tgx + y*PADDED_NUM_ATOMS;
                unsigned int offset2 = y*TILE_SIZE + tgx + x*PADDED_NUM_ATOMS;
186
#else
187
188
                unsigned int offset1 = x*TILE_SIZE + tgx + get_group_id(0)*PADDED_NUM_ATOMS;
                unsigned int offset2 = y*TILE_SIZE + tgx + get_group_id(0)*PADDED_NUM_ATOMS;
189
190
#endif
                global_bornSum[offset1] += bornSum+tempBuffer[get_local_id(0)+TILE_SIZE];
191
                global_bornSum[offset2] += localData[get_local_id(0)].bornSum+localData[get_local_id(0)+TILE_SIZE].bornSum;
192
193
            }
        }
194
        lasty = y;
195
196
197
198
199
200
201
202
        pos++;
    }
}

/**
 * First part of computing the GBSA interaction.
 */

203
204
__kernel __attribute__((reqd_work_group_size(WORK_GROUP_SIZE, 1, 1)))
void computeGBSAForce1(__global float4* forceBuffers, __global float* energyBuffer,
205
        __global float4* posq, __global float* global_bornRadii, __global float* global_bornForce,
206
        __local AtomData* localData, __local float4* tempBuffer,
207
#ifdef USE_CUTOFF
208
        __global ushort2* tiles, __global unsigned int* interactionCount, float4 periodicBoxSize, float4 invPeriodicBoxSize, unsigned int maxTiles) {
209
210
211
212
213
#else
        unsigned int numTiles) {
#endif
#ifdef USE_CUTOFF
    unsigned int numTiles = interactionCount[0];
214
215
    unsigned int pos = get_group_id(0)*(numTiles > maxTiles ? NUM_BLOCKS*(NUM_BLOCKS+1)/2 : numTiles)/get_num_groups(0);
    unsigned int end = (get_group_id(0)+1)*(numTiles > maxTiles ? NUM_BLOCKS*(NUM_BLOCKS+1)/2 : numTiles)/get_num_groups(0);
216
#else
217
218
    unsigned int pos = get_group_id(0)*numTiles/get_num_groups(0);
    unsigned int end = (get_group_id(0)+1)*numTiles/get_num_groups(0);
219
#endif
220
221
222
223
224
    float energy = 0.0f;
    unsigned int lasty = 0xFFFFFFFF;

    while (pos < end) {
        // Extract the coordinates of this tile
225
        unsigned int x, y;
226
#ifdef USE_CUTOFF
227
        if (numTiles <= maxTiles) {
228
229
230
            ushort2 tileIndices = tiles[pos];
            x = tileIndices.x;
            y = tileIndices.y;
231
        }
232
        else
233
#endif
234
235
236
        {
            y = (unsigned int) floor(NUM_BLOCKS+0.5f-sqrt((NUM_BLOCKS+0.5f)*(NUM_BLOCKS+0.5f)-2*pos));
            x = (pos-y*NUM_BLOCKS+y*(y+1)/2);
237
238
            if (x < y || x >= NUM_BLOCKS) { // Occasionally happens due to roundoff error.
                y += (x < y ? -1 : 1);
239
240
241
                x = (pos-y*NUM_BLOCKS+y*(y+1)/2);
            }
        }
242
243
244
        unsigned int baseLocalAtom = (get_local_id(0) < TILE_SIZE ? 0 : TILE_SIZE/2);
        unsigned int tgx = get_local_id(0) & (TILE_SIZE-1);
        unsigned int forceBufferOffset = (tgx < TILE_SIZE/2 ? 0 : TILE_SIZE);
245
        unsigned int atom1 = x*TILE_SIZE + tgx;
246
247
248
249
250
251
        float4 force = 0.0f;
        float4 posq1 = posq[atom1];
        float bornRadius1 = global_bornRadii[atom1];
        if (x == y) {
            // This tile is on the diagonal.

252
253
254
255
256
            localData[get_local_id(0)].x = posq1.x;
            localData[get_local_id(0)].y = posq1.y;
            localData[get_local_id(0)].z = posq1.z;
            localData[get_local_id(0)].q = posq1.w;
            localData[get_local_id(0)].bornRadius = bornRadius1;
257
258
            barrier(CLK_LOCAL_MEM_FENCE);
            for (unsigned int j = 0; j < TILE_SIZE/2; j++) {
259
                unsigned int includeInteraction = (atom1 < NUM_ATOMS && y*TILE_SIZE+baseLocalAtom+j < NUM_ATOMS);
260
261
                float4 posq2 = (float4) (localData[baseLocalAtom+j].x, localData[baseLocalAtom+j].y, localData[baseLocalAtom+j].z, localData[baseLocalAtom+j].q);
                float4 delta = (float4) (posq2.xyz - posq1.xyz, 0.0f);
262
#ifdef USE_PERIODIC
263
264
265
                delta.x -= floor(delta.x*invPeriodicBoxSize.x+0.5f)*periodicBoxSize.x;
                delta.y -= floor(delta.y*invPeriodicBoxSize.y+0.5f)*periodicBoxSize.y;
                delta.z -= floor(delta.z*invPeriodicBoxSize.z+0.5f)*periodicBoxSize.z;
266
#endif
267
268
269
270
271
272
273
274
275
276
277
278
279
                float r2 = delta.x*delta.x + delta.y*delta.y + delta.z*delta.z;
                float invR = RSQRT(r2);
                float r = RECIP(invR);
                float bornRadius2 = localData[baseLocalAtom+j].bornRadius;
                float alpha2_ij = bornRadius1*bornRadius2;
                float D_ij = r2*RECIP(4.0f*alpha2_ij);
                float expTerm = EXP(-D_ij);
                float denominator2 = r2 + alpha2_ij*expTerm;
                float denominator = SQRT(denominator2);
                float tempEnergy = (PREFACTOR*posq1.w*posq2.w)*RECIP(denominator);
                float Gpol = tempEnergy*RECIP(denominator2);
                float dGpol_dalpha2_ij = -0.5f*Gpol*expTerm*(1.0f+D_ij);
                float dEdR = Gpol*(1.0f - 0.25f*expTerm);
280
#ifdef USE_CUTOFF
281
282
                dEdR = select(dEdR, 0.0f, r2 > CUTOFF_SQUARED);
                tempEnergy = select(tempEnergy, 0.0f, r2 > CUTOFF_SQUARED);
283
                dGpol_dalpha2_ij = select(dGpol_dalpha2_ij, 0.0f, r2 > CUTOFF_SQUARED);
284
#endif
285
                force.w += select(0.0f, dGpol_dalpha2_ij*bornRadius2, includeInteraction);
286
287
288
                energy += select(0.0f, 0.5f*tempEnergy, includeInteraction);
                delta.xyz *= select(0.0f, dEdR, includeInteraction);
                force.xyz -= delta.xyz;
289
290
291
292
293
294
295
296
297
            }

            // Sum the forces and write results.

            if (get_local_id(0) >= TILE_SIZE)
                tempBuffer[get_local_id(0)] = force;
            barrier(CLK_LOCAL_MEM_FENCE);
            if (get_local_id(0) < TILE_SIZE) {
#ifdef USE_OUTPUT_BUFFER_PER_BLOCK
298
                unsigned int offset = x*TILE_SIZE + tgx + x*PADDED_NUM_ATOMS;
299
#else
300
                unsigned int offset = x*TILE_SIZE + tgx + get_group_id(0)*PADDED_NUM_ATOMS;
301
302
303
304
305
306
307
308
309
#endif
                forceBuffers[offset].xyz = forceBuffers[offset].xyz+force.xyz+tempBuffer[get_local_id(0)+TILE_SIZE].xyz;
                global_bornForce[offset] += force.w+tempBuffer[get_local_id(0)+TILE_SIZE].w;
            }
        }
        else {
            // This is an off-diagonal tile.

            if (lasty != y && get_local_id(0) < TILE_SIZE) {
310
                unsigned int j = y*TILE_SIZE + tgx;
311
312
313
314
315
316
                float4 tempPosq = posq[j];
                localData[get_local_id(0)].x = tempPosq.x;
                localData[get_local_id(0)].y = tempPosq.y;
                localData[get_local_id(0)].z = tempPosq.z;
                localData[get_local_id(0)].q = tempPosq.w;
                localData[get_local_id(0)].bornRadius = global_bornRadii[j];
317
            }
318
319
320
321
            localData[get_local_id(0)].fx = 0.0f;
            localData[get_local_id(0)].fy = 0.0f;
            localData[get_local_id(0)].fz = 0.0f;
            localData[get_local_id(0)].fw = 0.0f;
322
323
324
325
326
327
            barrier(CLK_LOCAL_MEM_FENCE);

            // Compute the full set of interactions in this tile.

            unsigned int tj = tgx%(TILE_SIZE/2);
            for (unsigned int j = 0; j < TILE_SIZE/2; j++) {
328
                unsigned int includeInteraction = (atom1 < NUM_ATOMS && y*TILE_SIZE+baseLocalAtom+tj < NUM_ATOMS);
329
330
                float4 posq2 = (float4) (localData[baseLocalAtom+tj].x, localData[baseLocalAtom+tj].y, localData[baseLocalAtom+tj].z, localData[baseLocalAtom+tj].q);
                float4 delta = (float4) (posq2.xyz - posq1.xyz, 0.0f);
331
#ifdef USE_PERIODIC
332
333
334
                delta.x -= floor(delta.x*invPeriodicBoxSize.x+0.5f)*periodicBoxSize.x;
                delta.y -= floor(delta.y*invPeriodicBoxSize.y+0.5f)*periodicBoxSize.y;
                delta.z -= floor(delta.z*invPeriodicBoxSize.z+0.5f)*periodicBoxSize.z;
335
#endif
336
337
338
339
340
341
342
343
344
345
346
347
348
                float r2 = delta.x*delta.x + delta.y*delta.y + delta.z*delta.z;
                float invR = RSQRT(r2);
                float r = RECIP(invR);
                float bornRadius2 = localData[baseLocalAtom+tj].bornRadius;
                float alpha2_ij = bornRadius1*bornRadius2;
                float D_ij = r2*RECIP(4.0f*alpha2_ij);
                float expTerm = EXP(-D_ij);
                float denominator2 = r2 + alpha2_ij*expTerm;
                float denominator = SQRT(denominator2);
                float tempEnergy = (PREFACTOR*posq1.w*posq2.w)*RECIP(denominator);
                float Gpol = tempEnergy*RECIP(denominator2);
                float dGpol_dalpha2_ij = -0.5f*Gpol*expTerm*(1.0f+D_ij);
                float dEdR = Gpol*(1.0f - 0.25f*expTerm);
349
#ifdef USE_CUTOFF
350
351
                dEdR = select(dEdR, 0.0f, r2 > CUTOFF_SQUARED);
                tempEnergy = select(tempEnergy, 0.0f, r2 > CUTOFF_SQUARED);
352
                dGpol_dalpha2_ij = select(dGpol_dalpha2_ij, 0.0f, r2 > CUTOFF_SQUARED);
353
#endif
354
                force.w += select(0.0f, dGpol_dalpha2_ij*bornRadius2, includeInteraction);
355
356
357
358
359
360
361
                energy += select(0.0f, tempEnergy, includeInteraction);
                delta.xyz *= select(0.0f, dEdR, includeInteraction);
                force.xyz -= delta.xyz;
                localData[baseLocalAtom+tj+forceBufferOffset].fx += delta.x;
                localData[baseLocalAtom+tj+forceBufferOffset].fy += delta.y;
                localData[baseLocalAtom+tj+forceBufferOffset].fz += delta.z;
                localData[baseLocalAtom+tj+forceBufferOffset].fw += select(0.0f, dGpol_dalpha2_ij*bornRadius1, includeInteraction);
362
363
364
365
366
367
368
369
370
371
372
                barrier(CLK_LOCAL_MEM_FENCE);
                tj = (tj+1)%(TILE_SIZE/2);
            }

            // Sum the forces and write results.

            if (get_local_id(0) >= TILE_SIZE)
                tempBuffer[get_local_id(0)] = force;
            barrier(CLK_LOCAL_MEM_FENCE);
            if (get_local_id(0) < TILE_SIZE) {
#ifdef USE_OUTPUT_BUFFER_PER_BLOCK
373
374
                unsigned int offset1 = x*TILE_SIZE + tgx + y*PADDED_NUM_ATOMS;
                unsigned int offset2 = y*TILE_SIZE + tgx + x*PADDED_NUM_ATOMS;
375
#else
376
377
                unsigned int offset1 = x*TILE_SIZE + tgx + get_group_id(0)*PADDED_NUM_ATOMS;
                unsigned int offset2 = y*TILE_SIZE + tgx + get_group_id(0)*PADDED_NUM_ATOMS;
378
379
#endif
                forceBuffers[offset1].xyz = forceBuffers[offset1].xyz+force.xyz+tempBuffer[get_local_id(0)+TILE_SIZE].xyz;
380
381
382
383
384
                float4 sum = (float4) (localData[get_local_id(0)].fx+localData[get_local_id(0)+TILE_SIZE].fx,
                                       localData[get_local_id(0)].fy+localData[get_local_id(0)+TILE_SIZE].fy,
                                       localData[get_local_id(0)].fz+localData[get_local_id(0)+TILE_SIZE].fz,
                                       localData[get_local_id(0)].fw+localData[get_local_id(0)+TILE_SIZE].fw);
                forceBuffers[offset2].xyz = forceBuffers[offset2].xyz+sum.xyz;
385
                global_bornForce[offset1] += force.w+tempBuffer[get_local_id(0)+TILE_SIZE].w;
386
                global_bornForce[offset2] += sum.w;
387
388
            }
        }
389
        lasty = y;
390
391
392
393
        pos++;
    }
    energyBuffer[get_global_id(0)] += energy;
}