Bug Summary

File:gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_single/nb_kernel_ElecCSTab_VdwLJ_GeomP1P1_sse4_1_single.c
Location:line 128, column 5
Description:Value stored to 'j_coord_offsetA' is never read

Annotated Source Code

1/*
2 * This file is part of the GROMACS molecular simulation package.
3 *
4 * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
8 *
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
13 *
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 *
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
31 *
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
34 */
35/*
36 * Note: this file was generated by the GROMACS sse4_1_single kernel generator.
37 */
38#ifdef HAVE_CONFIG_H1
39#include <config.h>
40#endif
41
42#include <math.h>
43
44#include "../nb_kernel.h"
45#include "types/simple.h"
46#include "gromacs/math/vec.h"
47#include "nrnb.h"
48
49#include "gromacs/simd/math_x86_sse4_1_single.h"
50#include "kernelutil_x86_sse4_1_single.h"
51
52/*
53 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwLJ_GeomP1P1_VF_sse4_1_single
54 * Electrostatics interaction: CubicSplineTable
55 * VdW interaction: LennardJones
56 * Geometry: Particle-Particle
57 * Calculate force/pot: PotentialAndForce
58 */
59void
60nb_kernel_ElecCSTab_VdwLJ_GeomP1P1_VF_sse4_1_single
61 (t_nblist * gmx_restrict nlist,
62 rvec * gmx_restrict xx,
63 rvec * gmx_restrict ff,
64 t_forcerec * gmx_restrict fr,
65 t_mdatoms * gmx_restrict mdatoms,
66 nb_kernel_data_t gmx_unused__attribute__ ((unused)) * gmx_restrict kernel_data,
67 t_nrnb * gmx_restrict nrnb)
68{
69 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
70 * just 0 for non-waters.
71 * Suffixes A,B,C,D refer to j loop unrolling done with SSE, e.g. for the four different
72 * jnr indices corresponding to data put in the four positions in the SIMD register.
73 */
74 int i_shift_offset,i_coord_offset,outeriter,inneriter;
75 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
76 int jnrA,jnrB,jnrC,jnrD;
77 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
78 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
79 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
80 real rcutoff_scalar;
81 real *shiftvec,*fshift,*x,*f;
82 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
83 real scratch[4*DIM3];
84 __m128 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
85 int vdwioffset0;
86 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
87 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
88 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
89 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
90 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
91 real *charge;
92 int nvdwtype;
93 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
94 int *vdwtype;
95 real *vdwparam;
96 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
97 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
98 __m128i vfitab;
99 __m128i ifour = _mm_set1_epi32(4);
100 __m128 rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
101 real *vftab;
102 __m128 dummy_mask,cutoff_mask;
103 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
104 __m128 one = _mm_set1_ps(1.0);
105 __m128 two = _mm_set1_ps(2.0);
106 x = xx[0];
107 f = ff[0];
108
109 nri = nlist->nri;
110 iinr = nlist->iinr;
111 jindex = nlist->jindex;
112 jjnr = nlist->jjnr;
113 shiftidx = nlist->shift;
114 gid = nlist->gid;
115 shiftvec = fr->shift_vec[0];
116 fshift = fr->fshift[0];
117 facel = _mm_set1_ps(fr->epsfac);
118 charge = mdatoms->chargeA;
119 nvdwtype = fr->ntype;
120 vdwparam = fr->nbfp;
121 vdwtype = mdatoms->typeA;
122
123 vftab = kernel_data->table_elec->data;
124 vftabscale = _mm_set1_ps(kernel_data->table_elec->scale);
125
126 /* Avoid stupid compiler warnings */
127 jnrA = jnrB = jnrC = jnrD = 0;
128 j_coord_offsetA = 0;
Value stored to 'j_coord_offsetA' is never read
129 j_coord_offsetB = 0;
130 j_coord_offsetC = 0;
131 j_coord_offsetD = 0;
132
133 outeriter = 0;
134 inneriter = 0;
135
136 for(iidx=0;iidx<4*DIM3;iidx++)
137 {
138 scratch[iidx] = 0.0;
139 }
140
141 /* Start outer loop over neighborlists */
142 for(iidx=0; iidx<nri; iidx++)
143 {
144 /* Load shift vector for this list */
145 i_shift_offset = DIM3*shiftidx[iidx];
146
147 /* Load limits for loop over neighbors */
148 j_index_start = jindex[iidx];
149 j_index_end = jindex[iidx+1];
150
151 /* Get outer coordinate index */
152 inr = iinr[iidx];
153 i_coord_offset = DIM3*inr;
154
155 /* Load i particle coords and add shift vector */
156 gmx_mm_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
157
158 fix0 = _mm_setzero_ps();
159 fiy0 = _mm_setzero_ps();
160 fiz0 = _mm_setzero_ps();
161
162 /* Load parameters for i particles */
163 iq0 = _mm_mul_ps(facel,_mm_load1_ps(charge+inr+0));
164 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
165
166 /* Reset potential sums */
167 velecsum = _mm_setzero_ps();
168 vvdwsum = _mm_setzero_ps();
169
170 /* Start inner kernel loop */
171 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
172 {
173
174 /* Get j neighbor index, and coordinate index */
175 jnrA = jjnr[jidx];
176 jnrB = jjnr[jidx+1];
177 jnrC = jjnr[jidx+2];
178 jnrD = jjnr[jidx+3];
179 j_coord_offsetA = DIM3*jnrA;
180 j_coord_offsetB = DIM3*jnrB;
181 j_coord_offsetC = DIM3*jnrC;
182 j_coord_offsetD = DIM3*jnrD;
183
184 /* load j atom coordinates */
185 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
186 x+j_coord_offsetC,x+j_coord_offsetD,
187 &jx0,&jy0,&jz0);
188
189 /* Calculate displacement vector */
190 dx00 = _mm_sub_ps(ix0,jx0);
191 dy00 = _mm_sub_ps(iy0,jy0);
192 dz00 = _mm_sub_ps(iz0,jz0);
193
194 /* Calculate squared distance and things based on it */
195 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
196
197 rinv00 = gmx_mm_invsqrt_psgmx_simd_invsqrt_f(rsq00);
198
199 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
200
201 /* Load parameters for j particles */
202 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
203 charge+jnrC+0,charge+jnrD+0);
204 vdwjidx0A = 2*vdwtype[jnrA+0];
205 vdwjidx0B = 2*vdwtype[jnrB+0];
206 vdwjidx0C = 2*vdwtype[jnrC+0];
207 vdwjidx0D = 2*vdwtype[jnrD+0];
208
209 /**************************
210 * CALCULATE INTERACTIONS *
211 **************************/
212
213 r00 = _mm_mul_ps(rsq00,rinv00);
214
215 /* Compute parameters for interactions between i and j atoms */
216 qq00 = _mm_mul_ps(iq0,jq0);
217 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
218 vdwparam+vdwioffset0+vdwjidx0B,
219 vdwparam+vdwioffset0+vdwjidx0C,
220 vdwparam+vdwioffset0+vdwjidx0D,
221 &c6_00,&c12_00);
222
223 /* Calculate table index by multiplying r with table scale and truncate to integer */
224 rt = _mm_mul_ps(r00,vftabscale);
225 vfitab = _mm_cvttps_epi32(rt);
226 vfeps = _mm_sub_ps(rt,_mm_round_ps(rt, _MM_FROUND_FLOOR)__extension__ ({ __m128 __X = (rt); (__m128) __builtin_ia32_roundps
((__v4sf)__X, ((0x00 | 0x01))); })
);
227 vfitab = _mm_slli_epi32(vfitab,2);
228
229 /* CUBIC SPLINE TABLE ELECTROSTATICS */
230 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0)(__extension__ ({ __v4si __a = (__v4si)(vfitab); __a[(0) &
3];}))
);
231 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1)(__extension__ ({ __v4si __a = (__v4si)(vfitab); __a[(1) &
3];}))
);
232 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2)(__extension__ ({ __v4si __a = (__v4si)(vfitab); __a[(2) &
3];}))
);
233 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3)(__extension__ ({ __v4si __a = (__v4si)(vfitab); __a[(3) &
3];}))
);
234 _MM_TRANSPOSE4_PS(Y,F,G,H)do { __m128 tmp3, tmp2, tmp1, tmp0; tmp0 = _mm_unpacklo_ps((Y
), (F)); tmp2 = _mm_unpacklo_ps((G), (H)); tmp1 = _mm_unpackhi_ps
((Y), (F)); tmp3 = _mm_unpackhi_ps((G), (H)); (Y) = _mm_movelh_ps
(tmp0, tmp2); (F) = _mm_movehl_ps(tmp2, tmp0); (G) = _mm_movelh_ps
(tmp1, tmp3); (H) = _mm_movehl_ps(tmp3, tmp1); } while (0)
;
235 Heps = _mm_mul_ps(vfeps,H);
236 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
237 VV = _mm_add_ps(Y,_mm_mul_ps(vfeps,Fp));
238 velec = _mm_mul_ps(qq00,VV);
239 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
240 felec = _mm_xor_ps(signbit,_mm_mul_ps(_mm_mul_ps(qq00,FF),_mm_mul_ps(vftabscale,rinv00)));
241
242 /* LENNARD-JONES DISPERSION/REPULSION */
243
244 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
245 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
246 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
247 vvdw = _mm_sub_ps( _mm_mul_ps(vvdw12,one_twelfth) , _mm_mul_ps(vvdw6,one_sixth) );
248 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
249
250 /* Update potential sum for this i atom from the interaction with this j atom. */
251 velecsum = _mm_add_ps(velecsum,velec);
252 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
253
254 fscal = _mm_add_ps(felec,fvdw);
255
256 /* Calculate temporary vectorial force */
257 tx = _mm_mul_ps(fscal,dx00);
258 ty = _mm_mul_ps(fscal,dy00);
259 tz = _mm_mul_ps(fscal,dz00);
260
261 /* Update vectorial force */
262 fix0 = _mm_add_ps(fix0,tx);
263 fiy0 = _mm_add_ps(fiy0,ty);
264 fiz0 = _mm_add_ps(fiz0,tz);
265
266 fjptrA = f+j_coord_offsetA;
267 fjptrB = f+j_coord_offsetB;
268 fjptrC = f+j_coord_offsetC;
269 fjptrD = f+j_coord_offsetD;
270 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
271
272 /* Inner loop uses 56 flops */
273 }
274
275 if(jidx<j_index_end)
276 {
277
278 /* Get j neighbor index, and coordinate index */
279 jnrlistA = jjnr[jidx];
280 jnrlistB = jjnr[jidx+1];
281 jnrlistC = jjnr[jidx+2];
282 jnrlistD = jjnr[jidx+3];
283 /* Sign of each element will be negative for non-real atoms.
284 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
285 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
286 */
287 dummy_mask = gmx_mm_castsi128_ps_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
288 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
289 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
290 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
291 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
292 j_coord_offsetA = DIM3*jnrA;
293 j_coord_offsetB = DIM3*jnrB;
294 j_coord_offsetC = DIM3*jnrC;
295 j_coord_offsetD = DIM3*jnrD;
296
297 /* load j atom coordinates */
298 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
299 x+j_coord_offsetC,x+j_coord_offsetD,
300 &jx0,&jy0,&jz0);
301
302 /* Calculate displacement vector */
303 dx00 = _mm_sub_ps(ix0,jx0);
304 dy00 = _mm_sub_ps(iy0,jy0);
305 dz00 = _mm_sub_ps(iz0,jz0);
306
307 /* Calculate squared distance and things based on it */
308 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
309
310 rinv00 = gmx_mm_invsqrt_psgmx_simd_invsqrt_f(rsq00);
311
312 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
313
314 /* Load parameters for j particles */
315 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
316 charge+jnrC+0,charge+jnrD+0);
317 vdwjidx0A = 2*vdwtype[jnrA+0];
318 vdwjidx0B = 2*vdwtype[jnrB+0];
319 vdwjidx0C = 2*vdwtype[jnrC+0];
320 vdwjidx0D = 2*vdwtype[jnrD+0];
321
322 /**************************
323 * CALCULATE INTERACTIONS *
324 **************************/
325
326 r00 = _mm_mul_ps(rsq00,rinv00);
327 r00 = _mm_andnot_ps(dummy_mask,r00);
328
329 /* Compute parameters for interactions between i and j atoms */
330 qq00 = _mm_mul_ps(iq0,jq0);
331 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
332 vdwparam+vdwioffset0+vdwjidx0B,
333 vdwparam+vdwioffset0+vdwjidx0C,
334 vdwparam+vdwioffset0+vdwjidx0D,
335 &c6_00,&c12_00);
336
337 /* Calculate table index by multiplying r with table scale and truncate to integer */
338 rt = _mm_mul_ps(r00,vftabscale);
339 vfitab = _mm_cvttps_epi32(rt);
340 vfeps = _mm_sub_ps(rt,_mm_round_ps(rt, _MM_FROUND_FLOOR)__extension__ ({ __m128 __X = (rt); (__m128) __builtin_ia32_roundps
((__v4sf)__X, ((0x00 | 0x01))); })
);
341 vfitab = _mm_slli_epi32(vfitab,2);
342
343 /* CUBIC SPLINE TABLE ELECTROSTATICS */
344 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0)(__extension__ ({ __v4si __a = (__v4si)(vfitab); __a[(0) &
3];}))
);
345 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1)(__extension__ ({ __v4si __a = (__v4si)(vfitab); __a[(1) &
3];}))
);
346 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2)(__extension__ ({ __v4si __a = (__v4si)(vfitab); __a[(2) &
3];}))
);
347 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3)(__extension__ ({ __v4si __a = (__v4si)(vfitab); __a[(3) &
3];}))
);
348 _MM_TRANSPOSE4_PS(Y,F,G,H)do { __m128 tmp3, tmp2, tmp1, tmp0; tmp0 = _mm_unpacklo_ps((Y
), (F)); tmp2 = _mm_unpacklo_ps((G), (H)); tmp1 = _mm_unpackhi_ps
((Y), (F)); tmp3 = _mm_unpackhi_ps((G), (H)); (Y) = _mm_movelh_ps
(tmp0, tmp2); (F) = _mm_movehl_ps(tmp2, tmp0); (G) = _mm_movelh_ps
(tmp1, tmp3); (H) = _mm_movehl_ps(tmp3, tmp1); } while (0)
;
349 Heps = _mm_mul_ps(vfeps,H);
350 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
351 VV = _mm_add_ps(Y,_mm_mul_ps(vfeps,Fp));
352 velec = _mm_mul_ps(qq00,VV);
353 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
354 felec = _mm_xor_ps(signbit,_mm_mul_ps(_mm_mul_ps(qq00,FF),_mm_mul_ps(vftabscale,rinv00)));
355
356 /* LENNARD-JONES DISPERSION/REPULSION */
357
358 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
359 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
360 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
361 vvdw = _mm_sub_ps( _mm_mul_ps(vvdw12,one_twelfth) , _mm_mul_ps(vvdw6,one_sixth) );
362 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
363
364 /* Update potential sum for this i atom from the interaction with this j atom. */
365 velec = _mm_andnot_ps(dummy_mask,velec);
366 velecsum = _mm_add_ps(velecsum,velec);
367 vvdw = _mm_andnot_ps(dummy_mask,vvdw);
368 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
369
370 fscal = _mm_add_ps(felec,fvdw);
371
372 fscal = _mm_andnot_ps(dummy_mask,fscal);
373
374 /* Calculate temporary vectorial force */
375 tx = _mm_mul_ps(fscal,dx00);
376 ty = _mm_mul_ps(fscal,dy00);
377 tz = _mm_mul_ps(fscal,dz00);
378
379 /* Update vectorial force */
380 fix0 = _mm_add_ps(fix0,tx);
381 fiy0 = _mm_add_ps(fiy0,ty);
382 fiz0 = _mm_add_ps(fiz0,tz);
383
384 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
385 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
386 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
387 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
388 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
389
390 /* Inner loop uses 57 flops */
391 }
392
393 /* End of innermost loop */
394
395 gmx_mm_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0,
396 f+i_coord_offset,fshift+i_shift_offset);
397
398 ggid = gid[iidx];
399 /* Update potential energies */
400 gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
401 gmx_mm_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
402
403 /* Increment number of inner iterations */
404 inneriter += j_index_end - j_index_start;
405
406 /* Outer loop uses 9 flops */
407 }
408
409 /* Increment number of outer iterations */
410 outeriter += nri;
411
412 /* Update outer/inner flops */
413
414 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_VF,outeriter*9 + inneriter*57)(nrnb)->n[eNR_NBKERNEL_ELEC_VDW_VF] += outeriter*9 + inneriter
*57
;
415}
416/*
417 * Gromacs nonbonded kernel: nb_kernel_ElecCSTab_VdwLJ_GeomP1P1_F_sse4_1_single
418 * Electrostatics interaction: CubicSplineTable
419 * VdW interaction: LennardJones
420 * Geometry: Particle-Particle
421 * Calculate force/pot: Force
422 */
423void
424nb_kernel_ElecCSTab_VdwLJ_GeomP1P1_F_sse4_1_single
425 (t_nblist * gmx_restrict nlist,
426 rvec * gmx_restrict xx,
427 rvec * gmx_restrict ff,
428 t_forcerec * gmx_restrict fr,
429 t_mdatoms * gmx_restrict mdatoms,
430 nb_kernel_data_t gmx_unused__attribute__ ((unused)) * gmx_restrict kernel_data,
431 t_nrnb * gmx_restrict nrnb)
432{
433 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
434 * just 0 for non-waters.
435 * Suffixes A,B,C,D refer to j loop unrolling done with SSE, e.g. for the four different
436 * jnr indices corresponding to data put in the four positions in the SIMD register.
437 */
438 int i_shift_offset,i_coord_offset,outeriter,inneriter;
439 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
440 int jnrA,jnrB,jnrC,jnrD;
441 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
442 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
443 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
444 real rcutoff_scalar;
445 real *shiftvec,*fshift,*x,*f;
446 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
447 real scratch[4*DIM3];
448 __m128 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
449 int vdwioffset0;
450 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
451 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
452 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
453 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
454 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
455 real *charge;
456 int nvdwtype;
457 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
458 int *vdwtype;
459 real *vdwparam;
460 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
461 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
462 __m128i vfitab;
463 __m128i ifour = _mm_set1_epi32(4);
464 __m128 rt,vfeps,vftabscale,Y,F,G,H,Heps,Fp,VV,FF;
465 real *vftab;
466 __m128 dummy_mask,cutoff_mask;
467 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
468 __m128 one = _mm_set1_ps(1.0);
469 __m128 two = _mm_set1_ps(2.0);
470 x = xx[0];
471 f = ff[0];
472
473 nri = nlist->nri;
474 iinr = nlist->iinr;
475 jindex = nlist->jindex;
476 jjnr = nlist->jjnr;
477 shiftidx = nlist->shift;
478 gid = nlist->gid;
479 shiftvec = fr->shift_vec[0];
480 fshift = fr->fshift[0];
481 facel = _mm_set1_ps(fr->epsfac);
482 charge = mdatoms->chargeA;
483 nvdwtype = fr->ntype;
484 vdwparam = fr->nbfp;
485 vdwtype = mdatoms->typeA;
486
487 vftab = kernel_data->table_elec->data;
488 vftabscale = _mm_set1_ps(kernel_data->table_elec->scale);
489
490 /* Avoid stupid compiler warnings */
491 jnrA = jnrB = jnrC = jnrD = 0;
492 j_coord_offsetA = 0;
493 j_coord_offsetB = 0;
494 j_coord_offsetC = 0;
495 j_coord_offsetD = 0;
496
497 outeriter = 0;
498 inneriter = 0;
499
500 for(iidx=0;iidx<4*DIM3;iidx++)
501 {
502 scratch[iidx] = 0.0;
503 }
504
505 /* Start outer loop over neighborlists */
506 for(iidx=0; iidx<nri; iidx++)
507 {
508 /* Load shift vector for this list */
509 i_shift_offset = DIM3*shiftidx[iidx];
510
511 /* Load limits for loop over neighbors */
512 j_index_start = jindex[iidx];
513 j_index_end = jindex[iidx+1];
514
515 /* Get outer coordinate index */
516 inr = iinr[iidx];
517 i_coord_offset = DIM3*inr;
518
519 /* Load i particle coords and add shift vector */
520 gmx_mm_load_shift_and_1rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,&ix0,&iy0,&iz0);
521
522 fix0 = _mm_setzero_ps();
523 fiy0 = _mm_setzero_ps();
524 fiz0 = _mm_setzero_ps();
525
526 /* Load parameters for i particles */
527 iq0 = _mm_mul_ps(facel,_mm_load1_ps(charge+inr+0));
528 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
529
530 /* Start inner kernel loop */
531 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
532 {
533
534 /* Get j neighbor index, and coordinate index */
535 jnrA = jjnr[jidx];
536 jnrB = jjnr[jidx+1];
537 jnrC = jjnr[jidx+2];
538 jnrD = jjnr[jidx+3];
539 j_coord_offsetA = DIM3*jnrA;
540 j_coord_offsetB = DIM3*jnrB;
541 j_coord_offsetC = DIM3*jnrC;
542 j_coord_offsetD = DIM3*jnrD;
543
544 /* load j atom coordinates */
545 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
546 x+j_coord_offsetC,x+j_coord_offsetD,
547 &jx0,&jy0,&jz0);
548
549 /* Calculate displacement vector */
550 dx00 = _mm_sub_ps(ix0,jx0);
551 dy00 = _mm_sub_ps(iy0,jy0);
552 dz00 = _mm_sub_ps(iz0,jz0);
553
554 /* Calculate squared distance and things based on it */
555 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
556
557 rinv00 = gmx_mm_invsqrt_psgmx_simd_invsqrt_f(rsq00);
558
559 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
560
561 /* Load parameters for j particles */
562 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
563 charge+jnrC+0,charge+jnrD+0);
564 vdwjidx0A = 2*vdwtype[jnrA+0];
565 vdwjidx0B = 2*vdwtype[jnrB+0];
566 vdwjidx0C = 2*vdwtype[jnrC+0];
567 vdwjidx0D = 2*vdwtype[jnrD+0];
568
569 /**************************
570 * CALCULATE INTERACTIONS *
571 **************************/
572
573 r00 = _mm_mul_ps(rsq00,rinv00);
574
575 /* Compute parameters for interactions between i and j atoms */
576 qq00 = _mm_mul_ps(iq0,jq0);
577 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
578 vdwparam+vdwioffset0+vdwjidx0B,
579 vdwparam+vdwioffset0+vdwjidx0C,
580 vdwparam+vdwioffset0+vdwjidx0D,
581 &c6_00,&c12_00);
582
583 /* Calculate table index by multiplying r with table scale and truncate to integer */
584 rt = _mm_mul_ps(r00,vftabscale);
585 vfitab = _mm_cvttps_epi32(rt);
586 vfeps = _mm_sub_ps(rt,_mm_round_ps(rt, _MM_FROUND_FLOOR)__extension__ ({ __m128 __X = (rt); (__m128) __builtin_ia32_roundps
((__v4sf)__X, ((0x00 | 0x01))); })
);
587 vfitab = _mm_slli_epi32(vfitab,2);
588
589 /* CUBIC SPLINE TABLE ELECTROSTATICS */
590 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0)(__extension__ ({ __v4si __a = (__v4si)(vfitab); __a[(0) &
3];}))
);
591 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1)(__extension__ ({ __v4si __a = (__v4si)(vfitab); __a[(1) &
3];}))
);
592 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2)(__extension__ ({ __v4si __a = (__v4si)(vfitab); __a[(2) &
3];}))
);
593 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3)(__extension__ ({ __v4si __a = (__v4si)(vfitab); __a[(3) &
3];}))
);
594 _MM_TRANSPOSE4_PS(Y,F,G,H)do { __m128 tmp3, tmp2, tmp1, tmp0; tmp0 = _mm_unpacklo_ps((Y
), (F)); tmp2 = _mm_unpacklo_ps((G), (H)); tmp1 = _mm_unpackhi_ps
((Y), (F)); tmp3 = _mm_unpackhi_ps((G), (H)); (Y) = _mm_movelh_ps
(tmp0, tmp2); (F) = _mm_movehl_ps(tmp2, tmp0); (G) = _mm_movelh_ps
(tmp1, tmp3); (H) = _mm_movehl_ps(tmp3, tmp1); } while (0)
;
595 Heps = _mm_mul_ps(vfeps,H);
596 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
597 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
598 felec = _mm_xor_ps(signbit,_mm_mul_ps(_mm_mul_ps(qq00,FF),_mm_mul_ps(vftabscale,rinv00)));
599
600 /* LENNARD-JONES DISPERSION/REPULSION */
601
602 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
603 fvdw = _mm_mul_ps(_mm_sub_ps(_mm_mul_ps(c12_00,rinvsix),c6_00),_mm_mul_ps(rinvsix,rinvsq00));
604
605 fscal = _mm_add_ps(felec,fvdw);
606
607 /* Calculate temporary vectorial force */
608 tx = _mm_mul_ps(fscal,dx00);
609 ty = _mm_mul_ps(fscal,dy00);
610 tz = _mm_mul_ps(fscal,dz00);
611
612 /* Update vectorial force */
613 fix0 = _mm_add_ps(fix0,tx);
614 fiy0 = _mm_add_ps(fiy0,ty);
615 fiz0 = _mm_add_ps(fiz0,tz);
616
617 fjptrA = f+j_coord_offsetA;
618 fjptrB = f+j_coord_offsetB;
619 fjptrC = f+j_coord_offsetC;
620 fjptrD = f+j_coord_offsetD;
621 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
622
623 /* Inner loop uses 47 flops */
624 }
625
626 if(jidx<j_index_end)
627 {
628
629 /* Get j neighbor index, and coordinate index */
630 jnrlistA = jjnr[jidx];
631 jnrlistB = jjnr[jidx+1];
632 jnrlistC = jjnr[jidx+2];
633 jnrlistD = jjnr[jidx+3];
634 /* Sign of each element will be negative for non-real atoms.
635 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
636 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
637 */
638 dummy_mask = gmx_mm_castsi128_ps_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
639 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
640 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
641 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
642 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
643 j_coord_offsetA = DIM3*jnrA;
644 j_coord_offsetB = DIM3*jnrB;
645 j_coord_offsetC = DIM3*jnrC;
646 j_coord_offsetD = DIM3*jnrD;
647
648 /* load j atom coordinates */
649 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
650 x+j_coord_offsetC,x+j_coord_offsetD,
651 &jx0,&jy0,&jz0);
652
653 /* Calculate displacement vector */
654 dx00 = _mm_sub_ps(ix0,jx0);
655 dy00 = _mm_sub_ps(iy0,jy0);
656 dz00 = _mm_sub_ps(iz0,jz0);
657
658 /* Calculate squared distance and things based on it */
659 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
660
661 rinv00 = gmx_mm_invsqrt_psgmx_simd_invsqrt_f(rsq00);
662
663 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
664
665 /* Load parameters for j particles */
666 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
667 charge+jnrC+0,charge+jnrD+0);
668 vdwjidx0A = 2*vdwtype[jnrA+0];
669 vdwjidx0B = 2*vdwtype[jnrB+0];
670 vdwjidx0C = 2*vdwtype[jnrC+0];
671 vdwjidx0D = 2*vdwtype[jnrD+0];
672
673 /**************************
674 * CALCULATE INTERACTIONS *
675 **************************/
676
677 r00 = _mm_mul_ps(rsq00,rinv00);
678 r00 = _mm_andnot_ps(dummy_mask,r00);
679
680 /* Compute parameters for interactions between i and j atoms */
681 qq00 = _mm_mul_ps(iq0,jq0);
682 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
683 vdwparam+vdwioffset0+vdwjidx0B,
684 vdwparam+vdwioffset0+vdwjidx0C,
685 vdwparam+vdwioffset0+vdwjidx0D,
686 &c6_00,&c12_00);
687
688 /* Calculate table index by multiplying r with table scale and truncate to integer */
689 rt = _mm_mul_ps(r00,vftabscale);
690 vfitab = _mm_cvttps_epi32(rt);
691 vfeps = _mm_sub_ps(rt,_mm_round_ps(rt, _MM_FROUND_FLOOR)__extension__ ({ __m128 __X = (rt); (__m128) __builtin_ia32_roundps
((__v4sf)__X, ((0x00 | 0x01))); })
);
692 vfitab = _mm_slli_epi32(vfitab,2);
693
694 /* CUBIC SPLINE TABLE ELECTROSTATICS */
695 Y = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,0)(__extension__ ({ __v4si __a = (__v4si)(vfitab); __a[(0) &
3];}))
);
696 F = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,1)(__extension__ ({ __v4si __a = (__v4si)(vfitab); __a[(1) &
3];}))
);
697 G = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,2)(__extension__ ({ __v4si __a = (__v4si)(vfitab); __a[(2) &
3];}))
);
698 H = _mm_load_ps( vftab + gmx_mm_extract_epi32(vfitab,3)(__extension__ ({ __v4si __a = (__v4si)(vfitab); __a[(3) &
3];}))
);
699 _MM_TRANSPOSE4_PS(Y,F,G,H)do { __m128 tmp3, tmp2, tmp1, tmp0; tmp0 = _mm_unpacklo_ps((Y
), (F)); tmp2 = _mm_unpacklo_ps((G), (H)); tmp1 = _mm_unpackhi_ps
((Y), (F)); tmp3 = _mm_unpackhi_ps((G), (H)); (Y) = _mm_movelh_ps
(tmp0, tmp2); (F) = _mm_movehl_ps(tmp2, tmp0); (G) = _mm_movelh_ps
(tmp1, tmp3); (H) = _mm_movehl_ps(tmp3, tmp1); } while (0)
;
700 Heps = _mm_mul_ps(vfeps,H);
701 Fp = _mm_add_ps(F,_mm_mul_ps(vfeps,_mm_add_ps(G,Heps)));
702 FF = _mm_add_ps(Fp,_mm_mul_ps(vfeps,_mm_add_ps(G,_mm_add_ps(Heps,Heps))));
703 felec = _mm_xor_ps(signbit,_mm_mul_ps(_mm_mul_ps(qq00,FF),_mm_mul_ps(vftabscale,rinv00)));
704
705 /* LENNARD-JONES DISPERSION/REPULSION */
706
707 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
708 fvdw = _mm_mul_ps(_mm_sub_ps(_mm_mul_ps(c12_00,rinvsix),c6_00),_mm_mul_ps(rinvsix,rinvsq00));
709
710 fscal = _mm_add_ps(felec,fvdw);
711
712 fscal = _mm_andnot_ps(dummy_mask,fscal);
713
714 /* Calculate temporary vectorial force */
715 tx = _mm_mul_ps(fscal,dx00);
716 ty = _mm_mul_ps(fscal,dy00);
717 tz = _mm_mul_ps(fscal,dz00);
718
719 /* Update vectorial force */
720 fix0 = _mm_add_ps(fix0,tx);
721 fiy0 = _mm_add_ps(fiy0,ty);
722 fiz0 = _mm_add_ps(fiz0,tz);
723
724 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
725 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
726 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
727 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
728 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,tx,ty,tz);
729
730 /* Inner loop uses 48 flops */
731 }
732
733 /* End of innermost loop */
734
735 gmx_mm_update_iforce_1atom_swizzle_ps(fix0,fiy0,fiz0,
736 f+i_coord_offset,fshift+i_shift_offset);
737
738 /* Increment number of inner iterations */
739 inneriter += j_index_end - j_index_start;
740
741 /* Outer loop uses 7 flops */
742 }
743
744 /* Increment number of outer iterations */
745 outeriter += nri;
746
747 /* Update outer/inner flops */
748
749 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_F,outeriter*7 + inneriter*48)(nrnb)->n[eNR_NBKERNEL_ELEC_VDW_F] += outeriter*7 + inneriter
*48
;
750}