Bug Summary

File:gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_single/nb_kernel_ElecEwSw_VdwLJSw_GeomW3P1_sse4_1_single.c
Location:line 151, column 5
Description:Value stored to 'd' 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_ElecEwSw_VdwLJSw_GeomW3P1_VF_sse4_1_single
54 * Electrostatics interaction: Ewald
55 * VdW interaction: LennardJones
56 * Geometry: Water3-Particle
57 * Calculate force/pot: PotentialAndForce
58 */
59void
60nb_kernel_ElecEwSw_VdwLJSw_GeomW3P1_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 vdwioffset1;
88 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
89 int vdwioffset2;
90 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
91 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
92 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
93 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
94 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
95 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
96 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
97 real *charge;
98 int nvdwtype;
99 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
100 int *vdwtype;
101 real *vdwparam;
102 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
103 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
104 __m128i ewitab;
105 __m128 ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
106 real *ewtab;
107 __m128 rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
108 real rswitch_scalar,d_scalar;
109 __m128 dummy_mask,cutoff_mask;
110 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
111 __m128 one = _mm_set1_ps(1.0);
112 __m128 two = _mm_set1_ps(2.0);
113 x = xx[0];
114 f = ff[0];
115
116 nri = nlist->nri;
117 iinr = nlist->iinr;
118 jindex = nlist->jindex;
119 jjnr = nlist->jjnr;
120 shiftidx = nlist->shift;
121 gid = nlist->gid;
122 shiftvec = fr->shift_vec[0];
123 fshift = fr->fshift[0];
124 facel = _mm_set1_ps(fr->epsfac);
125 charge = mdatoms->chargeA;
126 nvdwtype = fr->ntype;
127 vdwparam = fr->nbfp;
128 vdwtype = mdatoms->typeA;
129
130 sh_ewald = _mm_set1_ps(fr->ic->sh_ewald);
131 ewtab = fr->ic->tabq_coul_FDV0;
132 ewtabscale = _mm_set1_ps(fr->ic->tabq_scale);
133 ewtabhalfspace = _mm_set1_ps(0.5/fr->ic->tabq_scale);
134
135 /* Setup water-specific parameters */
136 inr = nlist->iinr[0];
137 iq0 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
138 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
139 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
140 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
141
142 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
143 rcutoff_scalar = fr->rcoulomb;
144 rcutoff = _mm_set1_ps(rcutoff_scalar);
145 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
146
147 rswitch_scalar = fr->rcoulomb_switch;
148 rswitch = _mm_set1_ps(rswitch_scalar);
149 /* Setup switch parameters */
150 d_scalar = rcutoff_scalar-rswitch_scalar;
151 d = _mm_set1_ps(d_scalar);
Value stored to 'd' is never read
152 swV3 = _mm_set1_ps(-10.0/(d_scalar*d_scalar*d_scalar));
153 swV4 = _mm_set1_ps( 15.0/(d_scalar*d_scalar*d_scalar*d_scalar));
154 swV5 = _mm_set1_ps( -6.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
155 swF2 = _mm_set1_ps(-30.0/(d_scalar*d_scalar*d_scalar));
156 swF3 = _mm_set1_ps( 60.0/(d_scalar*d_scalar*d_scalar*d_scalar));
157 swF4 = _mm_set1_ps(-30.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
158
159 /* Avoid stupid compiler warnings */
160 jnrA = jnrB = jnrC = jnrD = 0;
161 j_coord_offsetA = 0;
162 j_coord_offsetB = 0;
163 j_coord_offsetC = 0;
164 j_coord_offsetD = 0;
165
166 outeriter = 0;
167 inneriter = 0;
168
169 for(iidx=0;iidx<4*DIM3;iidx++)
170 {
171 scratch[iidx] = 0.0;
172 }
173
174 /* Start outer loop over neighborlists */
175 for(iidx=0; iidx<nri; iidx++)
176 {
177 /* Load shift vector for this list */
178 i_shift_offset = DIM3*shiftidx[iidx];
179
180 /* Load limits for loop over neighbors */
181 j_index_start = jindex[iidx];
182 j_index_end = jindex[iidx+1];
183
184 /* Get outer coordinate index */
185 inr = iinr[iidx];
186 i_coord_offset = DIM3*inr;
187
188 /* Load i particle coords and add shift vector */
189 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
190 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
191
192 fix0 = _mm_setzero_ps();
193 fiy0 = _mm_setzero_ps();
194 fiz0 = _mm_setzero_ps();
195 fix1 = _mm_setzero_ps();
196 fiy1 = _mm_setzero_ps();
197 fiz1 = _mm_setzero_ps();
198 fix2 = _mm_setzero_ps();
199 fiy2 = _mm_setzero_ps();
200 fiz2 = _mm_setzero_ps();
201
202 /* Reset potential sums */
203 velecsum = _mm_setzero_ps();
204 vvdwsum = _mm_setzero_ps();
205
206 /* Start inner kernel loop */
207 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
208 {
209
210 /* Get j neighbor index, and coordinate index */
211 jnrA = jjnr[jidx];
212 jnrB = jjnr[jidx+1];
213 jnrC = jjnr[jidx+2];
214 jnrD = jjnr[jidx+3];
215 j_coord_offsetA = DIM3*jnrA;
216 j_coord_offsetB = DIM3*jnrB;
217 j_coord_offsetC = DIM3*jnrC;
218 j_coord_offsetD = DIM3*jnrD;
219
220 /* load j atom coordinates */
221 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
222 x+j_coord_offsetC,x+j_coord_offsetD,
223 &jx0,&jy0,&jz0);
224
225 /* Calculate displacement vector */
226 dx00 = _mm_sub_ps(ix0,jx0);
227 dy00 = _mm_sub_ps(iy0,jy0);
228 dz00 = _mm_sub_ps(iz0,jz0);
229 dx10 = _mm_sub_ps(ix1,jx0);
230 dy10 = _mm_sub_ps(iy1,jy0);
231 dz10 = _mm_sub_ps(iz1,jz0);
232 dx20 = _mm_sub_ps(ix2,jx0);
233 dy20 = _mm_sub_ps(iy2,jy0);
234 dz20 = _mm_sub_ps(iz2,jz0);
235
236 /* Calculate squared distance and things based on it */
237 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
238 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
239 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
240
241 rinv00 = gmx_mm_invsqrt_psgmx_simd_invsqrt_f(rsq00);
242 rinv10 = gmx_mm_invsqrt_psgmx_simd_invsqrt_f(rsq10);
243 rinv20 = gmx_mm_invsqrt_psgmx_simd_invsqrt_f(rsq20);
244
245 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
246 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
247 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
248
249 /* Load parameters for j particles */
250 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
251 charge+jnrC+0,charge+jnrD+0);
252 vdwjidx0A = 2*vdwtype[jnrA+0];
253 vdwjidx0B = 2*vdwtype[jnrB+0];
254 vdwjidx0C = 2*vdwtype[jnrC+0];
255 vdwjidx0D = 2*vdwtype[jnrD+0];
256
257 fjx0 = _mm_setzero_ps();
258 fjy0 = _mm_setzero_ps();
259 fjz0 = _mm_setzero_ps();
260
261 /**************************
262 * CALCULATE INTERACTIONS *
263 **************************/
264
265 if (gmx_mm_any_lt(rsq00,rcutoff2))
266 {
267
268 r00 = _mm_mul_ps(rsq00,rinv00);
269
270 /* Compute parameters for interactions between i and j atoms */
271 qq00 = _mm_mul_ps(iq0,jq0);
272 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
273 vdwparam+vdwioffset0+vdwjidx0B,
274 vdwparam+vdwioffset0+vdwjidx0C,
275 vdwparam+vdwioffset0+vdwjidx0D,
276 &c6_00,&c12_00);
277
278 /* EWALD ELECTROSTATICS */
279
280 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
281 ewrt = _mm_mul_ps(r00,ewtabscale);
282 ewitab = _mm_cvttps_epi32(ewrt);
283 eweps = _mm_sub_ps(ewrt,_mm_round_ps(ewrt, _MM_FROUND_FLOOR)__extension__ ({ __m128 __X = (ewrt); (__m128) __builtin_ia32_roundps
((__v4sf)__X, ((0x00 | 0x01))); })
);
284 ewitab = _mm_slli_epi32(ewitab,2);
285 ewtabF = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,0)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(0) &
3];}))
);
286 ewtabD = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,1)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(1) &
3];}))
);
287 ewtabV = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,2)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(2) &
3];}))
);
288 ewtabFn = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,3)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(3) &
3];}))
);
289 _MM_TRANSPOSE4_PS(ewtabF,ewtabD,ewtabV,ewtabFn)do { __m128 tmp3, tmp2, tmp1, tmp0; tmp0 = _mm_unpacklo_ps((ewtabF
), (ewtabD)); tmp2 = _mm_unpacklo_ps((ewtabV), (ewtabFn)); tmp1
= _mm_unpackhi_ps((ewtabF), (ewtabD)); tmp3 = _mm_unpackhi_ps
((ewtabV), (ewtabFn)); (ewtabF) = _mm_movelh_ps(tmp0, tmp2); (
ewtabD) = _mm_movehl_ps(tmp2, tmp0); (ewtabV) = _mm_movelh_ps
(tmp1, tmp3); (ewtabFn) = _mm_movehl_ps(tmp3, tmp1); } while (
0)
;
290 felec = _mm_add_ps(ewtabF,_mm_mul_ps(eweps,ewtabD));
291 velec = _mm_sub_ps(ewtabV,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace,eweps),_mm_add_ps(ewtabF,felec)));
292 velec = _mm_mul_ps(qq00,_mm_sub_ps(rinv00,velec));
293 felec = _mm_mul_ps(_mm_mul_ps(qq00,rinv00),_mm_sub_ps(rinvsq00,felec));
294
295 /* LENNARD-JONES DISPERSION/REPULSION */
296
297 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
298 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
299 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
300 vvdw = _mm_sub_ps( _mm_mul_ps(vvdw12,one_twelfth) , _mm_mul_ps(vvdw6,one_sixth) );
301 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
302
303 d = _mm_sub_ps(r00,rswitch);
304 d = _mm_max_ps(d,_mm_setzero_ps());
305 d2 = _mm_mul_ps(d,d);
306 sw = _mm_add_ps(one,_mm_mul_ps(d2,_mm_mul_ps(d,_mm_add_ps(swV3,_mm_mul_ps(d,_mm_add_ps(swV4,_mm_mul_ps(d,swV5)))))));
307
308 dsw = _mm_mul_ps(d2,_mm_add_ps(swF2,_mm_mul_ps(d,_mm_add_ps(swF3,_mm_mul_ps(d,swF4)))));
309
310 /* Evaluate switch function */
311 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
312 felec = _mm_sub_ps( _mm_mul_ps(felec,sw) , _mm_mul_ps(rinv00,_mm_mul_ps(velec,dsw)) );
313 fvdw = _mm_sub_ps( _mm_mul_ps(fvdw,sw) , _mm_mul_ps(rinv00,_mm_mul_ps(vvdw,dsw)) );
314 velec = _mm_mul_ps(velec,sw);
315 vvdw = _mm_mul_ps(vvdw,sw);
316 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
317
318 /* Update potential sum for this i atom from the interaction with this j atom. */
319 velec = _mm_and_ps(velec,cutoff_mask);
320 velecsum = _mm_add_ps(velecsum,velec);
321 vvdw = _mm_and_ps(vvdw,cutoff_mask);
322 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
323
324 fscal = _mm_add_ps(felec,fvdw);
325
326 fscal = _mm_and_ps(fscal,cutoff_mask);
327
328 /* Calculate temporary vectorial force */
329 tx = _mm_mul_ps(fscal,dx00);
330 ty = _mm_mul_ps(fscal,dy00);
331 tz = _mm_mul_ps(fscal,dz00);
332
333 /* Update vectorial force */
334 fix0 = _mm_add_ps(fix0,tx);
335 fiy0 = _mm_add_ps(fiy0,ty);
336 fiz0 = _mm_add_ps(fiz0,tz);
337
338 fjx0 = _mm_add_ps(fjx0,tx);
339 fjy0 = _mm_add_ps(fjy0,ty);
340 fjz0 = _mm_add_ps(fjz0,tz);
341
342 }
343
344 /**************************
345 * CALCULATE INTERACTIONS *
346 **************************/
347
348 if (gmx_mm_any_lt(rsq10,rcutoff2))
349 {
350
351 r10 = _mm_mul_ps(rsq10,rinv10);
352
353 /* Compute parameters for interactions between i and j atoms */
354 qq10 = _mm_mul_ps(iq1,jq0);
355
356 /* EWALD ELECTROSTATICS */
357
358 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
359 ewrt = _mm_mul_ps(r10,ewtabscale);
360 ewitab = _mm_cvttps_epi32(ewrt);
361 eweps = _mm_sub_ps(ewrt,_mm_round_ps(ewrt, _MM_FROUND_FLOOR)__extension__ ({ __m128 __X = (ewrt); (__m128) __builtin_ia32_roundps
((__v4sf)__X, ((0x00 | 0x01))); })
);
362 ewitab = _mm_slli_epi32(ewitab,2);
363 ewtabF = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,0)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(0) &
3];}))
);
364 ewtabD = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,1)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(1) &
3];}))
);
365 ewtabV = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,2)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(2) &
3];}))
);
366 ewtabFn = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,3)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(3) &
3];}))
);
367 _MM_TRANSPOSE4_PS(ewtabF,ewtabD,ewtabV,ewtabFn)do { __m128 tmp3, tmp2, tmp1, tmp0; tmp0 = _mm_unpacklo_ps((ewtabF
), (ewtabD)); tmp2 = _mm_unpacklo_ps((ewtabV), (ewtabFn)); tmp1
= _mm_unpackhi_ps((ewtabF), (ewtabD)); tmp3 = _mm_unpackhi_ps
((ewtabV), (ewtabFn)); (ewtabF) = _mm_movelh_ps(tmp0, tmp2); (
ewtabD) = _mm_movehl_ps(tmp2, tmp0); (ewtabV) = _mm_movelh_ps
(tmp1, tmp3); (ewtabFn) = _mm_movehl_ps(tmp3, tmp1); } while (
0)
;
368 felec = _mm_add_ps(ewtabF,_mm_mul_ps(eweps,ewtabD));
369 velec = _mm_sub_ps(ewtabV,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace,eweps),_mm_add_ps(ewtabF,felec)));
370 velec = _mm_mul_ps(qq10,_mm_sub_ps(rinv10,velec));
371 felec = _mm_mul_ps(_mm_mul_ps(qq10,rinv10),_mm_sub_ps(rinvsq10,felec));
372
373 d = _mm_sub_ps(r10,rswitch);
374 d = _mm_max_ps(d,_mm_setzero_ps());
375 d2 = _mm_mul_ps(d,d);
376 sw = _mm_add_ps(one,_mm_mul_ps(d2,_mm_mul_ps(d,_mm_add_ps(swV3,_mm_mul_ps(d,_mm_add_ps(swV4,_mm_mul_ps(d,swV5)))))));
377
378 dsw = _mm_mul_ps(d2,_mm_add_ps(swF2,_mm_mul_ps(d,_mm_add_ps(swF3,_mm_mul_ps(d,swF4)))));
379
380 /* Evaluate switch function */
381 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
382 felec = _mm_sub_ps( _mm_mul_ps(felec,sw) , _mm_mul_ps(rinv10,_mm_mul_ps(velec,dsw)) );
383 velec = _mm_mul_ps(velec,sw);
384 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
385
386 /* Update potential sum for this i atom from the interaction with this j atom. */
387 velec = _mm_and_ps(velec,cutoff_mask);
388 velecsum = _mm_add_ps(velecsum,velec);
389
390 fscal = felec;
391
392 fscal = _mm_and_ps(fscal,cutoff_mask);
393
394 /* Calculate temporary vectorial force */
395 tx = _mm_mul_ps(fscal,dx10);
396 ty = _mm_mul_ps(fscal,dy10);
397 tz = _mm_mul_ps(fscal,dz10);
398
399 /* Update vectorial force */
400 fix1 = _mm_add_ps(fix1,tx);
401 fiy1 = _mm_add_ps(fiy1,ty);
402 fiz1 = _mm_add_ps(fiz1,tz);
403
404 fjx0 = _mm_add_ps(fjx0,tx);
405 fjy0 = _mm_add_ps(fjy0,ty);
406 fjz0 = _mm_add_ps(fjz0,tz);
407
408 }
409
410 /**************************
411 * CALCULATE INTERACTIONS *
412 **************************/
413
414 if (gmx_mm_any_lt(rsq20,rcutoff2))
415 {
416
417 r20 = _mm_mul_ps(rsq20,rinv20);
418
419 /* Compute parameters for interactions between i and j atoms */
420 qq20 = _mm_mul_ps(iq2,jq0);
421
422 /* EWALD ELECTROSTATICS */
423
424 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
425 ewrt = _mm_mul_ps(r20,ewtabscale);
426 ewitab = _mm_cvttps_epi32(ewrt);
427 eweps = _mm_sub_ps(ewrt,_mm_round_ps(ewrt, _MM_FROUND_FLOOR)__extension__ ({ __m128 __X = (ewrt); (__m128) __builtin_ia32_roundps
((__v4sf)__X, ((0x00 | 0x01))); })
);
428 ewitab = _mm_slli_epi32(ewitab,2);
429 ewtabF = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,0)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(0) &
3];}))
);
430 ewtabD = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,1)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(1) &
3];}))
);
431 ewtabV = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,2)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(2) &
3];}))
);
432 ewtabFn = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,3)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(3) &
3];}))
);
433 _MM_TRANSPOSE4_PS(ewtabF,ewtabD,ewtabV,ewtabFn)do { __m128 tmp3, tmp2, tmp1, tmp0; tmp0 = _mm_unpacklo_ps((ewtabF
), (ewtabD)); tmp2 = _mm_unpacklo_ps((ewtabV), (ewtabFn)); tmp1
= _mm_unpackhi_ps((ewtabF), (ewtabD)); tmp3 = _mm_unpackhi_ps
((ewtabV), (ewtabFn)); (ewtabF) = _mm_movelh_ps(tmp0, tmp2); (
ewtabD) = _mm_movehl_ps(tmp2, tmp0); (ewtabV) = _mm_movelh_ps
(tmp1, tmp3); (ewtabFn) = _mm_movehl_ps(tmp3, tmp1); } while (
0)
;
434 felec = _mm_add_ps(ewtabF,_mm_mul_ps(eweps,ewtabD));
435 velec = _mm_sub_ps(ewtabV,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace,eweps),_mm_add_ps(ewtabF,felec)));
436 velec = _mm_mul_ps(qq20,_mm_sub_ps(rinv20,velec));
437 felec = _mm_mul_ps(_mm_mul_ps(qq20,rinv20),_mm_sub_ps(rinvsq20,felec));
438
439 d = _mm_sub_ps(r20,rswitch);
440 d = _mm_max_ps(d,_mm_setzero_ps());
441 d2 = _mm_mul_ps(d,d);
442 sw = _mm_add_ps(one,_mm_mul_ps(d2,_mm_mul_ps(d,_mm_add_ps(swV3,_mm_mul_ps(d,_mm_add_ps(swV4,_mm_mul_ps(d,swV5)))))));
443
444 dsw = _mm_mul_ps(d2,_mm_add_ps(swF2,_mm_mul_ps(d,_mm_add_ps(swF3,_mm_mul_ps(d,swF4)))));
445
446 /* Evaluate switch function */
447 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
448 felec = _mm_sub_ps( _mm_mul_ps(felec,sw) , _mm_mul_ps(rinv20,_mm_mul_ps(velec,dsw)) );
449 velec = _mm_mul_ps(velec,sw);
450 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
451
452 /* Update potential sum for this i atom from the interaction with this j atom. */
453 velec = _mm_and_ps(velec,cutoff_mask);
454 velecsum = _mm_add_ps(velecsum,velec);
455
456 fscal = felec;
457
458 fscal = _mm_and_ps(fscal,cutoff_mask);
459
460 /* Calculate temporary vectorial force */
461 tx = _mm_mul_ps(fscal,dx20);
462 ty = _mm_mul_ps(fscal,dy20);
463 tz = _mm_mul_ps(fscal,dz20);
464
465 /* Update vectorial force */
466 fix2 = _mm_add_ps(fix2,tx);
467 fiy2 = _mm_add_ps(fiy2,ty);
468 fiz2 = _mm_add_ps(fiz2,tz);
469
470 fjx0 = _mm_add_ps(fjx0,tx);
471 fjy0 = _mm_add_ps(fjy0,ty);
472 fjz0 = _mm_add_ps(fjz0,tz);
473
474 }
475
476 fjptrA = f+j_coord_offsetA;
477 fjptrB = f+j_coord_offsetB;
478 fjptrC = f+j_coord_offsetC;
479 fjptrD = f+j_coord_offsetD;
480
481 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
482
483 /* Inner loop uses 213 flops */
484 }
485
486 if(jidx<j_index_end)
487 {
488
489 /* Get j neighbor index, and coordinate index */
490 jnrlistA = jjnr[jidx];
491 jnrlistB = jjnr[jidx+1];
492 jnrlistC = jjnr[jidx+2];
493 jnrlistD = jjnr[jidx+3];
494 /* Sign of each element will be negative for non-real atoms.
495 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
496 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
497 */
498 dummy_mask = gmx_mm_castsi128_ps_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
499 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
500 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
501 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
502 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
503 j_coord_offsetA = DIM3*jnrA;
504 j_coord_offsetB = DIM3*jnrB;
505 j_coord_offsetC = DIM3*jnrC;
506 j_coord_offsetD = DIM3*jnrD;
507
508 /* load j atom coordinates */
509 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
510 x+j_coord_offsetC,x+j_coord_offsetD,
511 &jx0,&jy0,&jz0);
512
513 /* Calculate displacement vector */
514 dx00 = _mm_sub_ps(ix0,jx0);
515 dy00 = _mm_sub_ps(iy0,jy0);
516 dz00 = _mm_sub_ps(iz0,jz0);
517 dx10 = _mm_sub_ps(ix1,jx0);
518 dy10 = _mm_sub_ps(iy1,jy0);
519 dz10 = _mm_sub_ps(iz1,jz0);
520 dx20 = _mm_sub_ps(ix2,jx0);
521 dy20 = _mm_sub_ps(iy2,jy0);
522 dz20 = _mm_sub_ps(iz2,jz0);
523
524 /* Calculate squared distance and things based on it */
525 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
526 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
527 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
528
529 rinv00 = gmx_mm_invsqrt_psgmx_simd_invsqrt_f(rsq00);
530 rinv10 = gmx_mm_invsqrt_psgmx_simd_invsqrt_f(rsq10);
531 rinv20 = gmx_mm_invsqrt_psgmx_simd_invsqrt_f(rsq20);
532
533 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
534 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
535 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
536
537 /* Load parameters for j particles */
538 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
539 charge+jnrC+0,charge+jnrD+0);
540 vdwjidx0A = 2*vdwtype[jnrA+0];
541 vdwjidx0B = 2*vdwtype[jnrB+0];
542 vdwjidx0C = 2*vdwtype[jnrC+0];
543 vdwjidx0D = 2*vdwtype[jnrD+0];
544
545 fjx0 = _mm_setzero_ps();
546 fjy0 = _mm_setzero_ps();
547 fjz0 = _mm_setzero_ps();
548
549 /**************************
550 * CALCULATE INTERACTIONS *
551 **************************/
552
553 if (gmx_mm_any_lt(rsq00,rcutoff2))
554 {
555
556 r00 = _mm_mul_ps(rsq00,rinv00);
557 r00 = _mm_andnot_ps(dummy_mask,r00);
558
559 /* Compute parameters for interactions between i and j atoms */
560 qq00 = _mm_mul_ps(iq0,jq0);
561 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
562 vdwparam+vdwioffset0+vdwjidx0B,
563 vdwparam+vdwioffset0+vdwjidx0C,
564 vdwparam+vdwioffset0+vdwjidx0D,
565 &c6_00,&c12_00);
566
567 /* EWALD ELECTROSTATICS */
568
569 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
570 ewrt = _mm_mul_ps(r00,ewtabscale);
571 ewitab = _mm_cvttps_epi32(ewrt);
572 eweps = _mm_sub_ps(ewrt,_mm_round_ps(ewrt, _MM_FROUND_FLOOR)__extension__ ({ __m128 __X = (ewrt); (__m128) __builtin_ia32_roundps
((__v4sf)__X, ((0x00 | 0x01))); })
);
573 ewitab = _mm_slli_epi32(ewitab,2);
574 ewtabF = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,0)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(0) &
3];}))
);
575 ewtabD = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,1)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(1) &
3];}))
);
576 ewtabV = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,2)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(2) &
3];}))
);
577 ewtabFn = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,3)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(3) &
3];}))
);
578 _MM_TRANSPOSE4_PS(ewtabF,ewtabD,ewtabV,ewtabFn)do { __m128 tmp3, tmp2, tmp1, tmp0; tmp0 = _mm_unpacklo_ps((ewtabF
), (ewtabD)); tmp2 = _mm_unpacklo_ps((ewtabV), (ewtabFn)); tmp1
= _mm_unpackhi_ps((ewtabF), (ewtabD)); tmp3 = _mm_unpackhi_ps
((ewtabV), (ewtabFn)); (ewtabF) = _mm_movelh_ps(tmp0, tmp2); (
ewtabD) = _mm_movehl_ps(tmp2, tmp0); (ewtabV) = _mm_movelh_ps
(tmp1, tmp3); (ewtabFn) = _mm_movehl_ps(tmp3, tmp1); } while (
0)
;
579 felec = _mm_add_ps(ewtabF,_mm_mul_ps(eweps,ewtabD));
580 velec = _mm_sub_ps(ewtabV,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace,eweps),_mm_add_ps(ewtabF,felec)));
581 velec = _mm_mul_ps(qq00,_mm_sub_ps(rinv00,velec));
582 felec = _mm_mul_ps(_mm_mul_ps(qq00,rinv00),_mm_sub_ps(rinvsq00,felec));
583
584 /* LENNARD-JONES DISPERSION/REPULSION */
585
586 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
587 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
588 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
589 vvdw = _mm_sub_ps( _mm_mul_ps(vvdw12,one_twelfth) , _mm_mul_ps(vvdw6,one_sixth) );
590 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
591
592 d = _mm_sub_ps(r00,rswitch);
593 d = _mm_max_ps(d,_mm_setzero_ps());
594 d2 = _mm_mul_ps(d,d);
595 sw = _mm_add_ps(one,_mm_mul_ps(d2,_mm_mul_ps(d,_mm_add_ps(swV3,_mm_mul_ps(d,_mm_add_ps(swV4,_mm_mul_ps(d,swV5)))))));
596
597 dsw = _mm_mul_ps(d2,_mm_add_ps(swF2,_mm_mul_ps(d,_mm_add_ps(swF3,_mm_mul_ps(d,swF4)))));
598
599 /* Evaluate switch function */
600 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
601 felec = _mm_sub_ps( _mm_mul_ps(felec,sw) , _mm_mul_ps(rinv00,_mm_mul_ps(velec,dsw)) );
602 fvdw = _mm_sub_ps( _mm_mul_ps(fvdw,sw) , _mm_mul_ps(rinv00,_mm_mul_ps(vvdw,dsw)) );
603 velec = _mm_mul_ps(velec,sw);
604 vvdw = _mm_mul_ps(vvdw,sw);
605 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
606
607 /* Update potential sum for this i atom from the interaction with this j atom. */
608 velec = _mm_and_ps(velec,cutoff_mask);
609 velec = _mm_andnot_ps(dummy_mask,velec);
610 velecsum = _mm_add_ps(velecsum,velec);
611 vvdw = _mm_and_ps(vvdw,cutoff_mask);
612 vvdw = _mm_andnot_ps(dummy_mask,vvdw);
613 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
614
615 fscal = _mm_add_ps(felec,fvdw);
616
617 fscal = _mm_and_ps(fscal,cutoff_mask);
618
619 fscal = _mm_andnot_ps(dummy_mask,fscal);
620
621 /* Calculate temporary vectorial force */
622 tx = _mm_mul_ps(fscal,dx00);
623 ty = _mm_mul_ps(fscal,dy00);
624 tz = _mm_mul_ps(fscal,dz00);
625
626 /* Update vectorial force */
627 fix0 = _mm_add_ps(fix0,tx);
628 fiy0 = _mm_add_ps(fiy0,ty);
629 fiz0 = _mm_add_ps(fiz0,tz);
630
631 fjx0 = _mm_add_ps(fjx0,tx);
632 fjy0 = _mm_add_ps(fjy0,ty);
633 fjz0 = _mm_add_ps(fjz0,tz);
634
635 }
636
637 /**************************
638 * CALCULATE INTERACTIONS *
639 **************************/
640
641 if (gmx_mm_any_lt(rsq10,rcutoff2))
642 {
643
644 r10 = _mm_mul_ps(rsq10,rinv10);
645 r10 = _mm_andnot_ps(dummy_mask,r10);
646
647 /* Compute parameters for interactions between i and j atoms */
648 qq10 = _mm_mul_ps(iq1,jq0);
649
650 /* EWALD ELECTROSTATICS */
651
652 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
653 ewrt = _mm_mul_ps(r10,ewtabscale);
654 ewitab = _mm_cvttps_epi32(ewrt);
655 eweps = _mm_sub_ps(ewrt,_mm_round_ps(ewrt, _MM_FROUND_FLOOR)__extension__ ({ __m128 __X = (ewrt); (__m128) __builtin_ia32_roundps
((__v4sf)__X, ((0x00 | 0x01))); })
);
656 ewitab = _mm_slli_epi32(ewitab,2);
657 ewtabF = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,0)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(0) &
3];}))
);
658 ewtabD = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,1)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(1) &
3];}))
);
659 ewtabV = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,2)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(2) &
3];}))
);
660 ewtabFn = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,3)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(3) &
3];}))
);
661 _MM_TRANSPOSE4_PS(ewtabF,ewtabD,ewtabV,ewtabFn)do { __m128 tmp3, tmp2, tmp1, tmp0; tmp0 = _mm_unpacklo_ps((ewtabF
), (ewtabD)); tmp2 = _mm_unpacklo_ps((ewtabV), (ewtabFn)); tmp1
= _mm_unpackhi_ps((ewtabF), (ewtabD)); tmp3 = _mm_unpackhi_ps
((ewtabV), (ewtabFn)); (ewtabF) = _mm_movelh_ps(tmp0, tmp2); (
ewtabD) = _mm_movehl_ps(tmp2, tmp0); (ewtabV) = _mm_movelh_ps
(tmp1, tmp3); (ewtabFn) = _mm_movehl_ps(tmp3, tmp1); } while (
0)
;
662 felec = _mm_add_ps(ewtabF,_mm_mul_ps(eweps,ewtabD));
663 velec = _mm_sub_ps(ewtabV,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace,eweps),_mm_add_ps(ewtabF,felec)));
664 velec = _mm_mul_ps(qq10,_mm_sub_ps(rinv10,velec));
665 felec = _mm_mul_ps(_mm_mul_ps(qq10,rinv10),_mm_sub_ps(rinvsq10,felec));
666
667 d = _mm_sub_ps(r10,rswitch);
668 d = _mm_max_ps(d,_mm_setzero_ps());
669 d2 = _mm_mul_ps(d,d);
670 sw = _mm_add_ps(one,_mm_mul_ps(d2,_mm_mul_ps(d,_mm_add_ps(swV3,_mm_mul_ps(d,_mm_add_ps(swV4,_mm_mul_ps(d,swV5)))))));
671
672 dsw = _mm_mul_ps(d2,_mm_add_ps(swF2,_mm_mul_ps(d,_mm_add_ps(swF3,_mm_mul_ps(d,swF4)))));
673
674 /* Evaluate switch function */
675 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
676 felec = _mm_sub_ps( _mm_mul_ps(felec,sw) , _mm_mul_ps(rinv10,_mm_mul_ps(velec,dsw)) );
677 velec = _mm_mul_ps(velec,sw);
678 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
679
680 /* Update potential sum for this i atom from the interaction with this j atom. */
681 velec = _mm_and_ps(velec,cutoff_mask);
682 velec = _mm_andnot_ps(dummy_mask,velec);
683 velecsum = _mm_add_ps(velecsum,velec);
684
685 fscal = felec;
686
687 fscal = _mm_and_ps(fscal,cutoff_mask);
688
689 fscal = _mm_andnot_ps(dummy_mask,fscal);
690
691 /* Calculate temporary vectorial force */
692 tx = _mm_mul_ps(fscal,dx10);
693 ty = _mm_mul_ps(fscal,dy10);
694 tz = _mm_mul_ps(fscal,dz10);
695
696 /* Update vectorial force */
697 fix1 = _mm_add_ps(fix1,tx);
698 fiy1 = _mm_add_ps(fiy1,ty);
699 fiz1 = _mm_add_ps(fiz1,tz);
700
701 fjx0 = _mm_add_ps(fjx0,tx);
702 fjy0 = _mm_add_ps(fjy0,ty);
703 fjz0 = _mm_add_ps(fjz0,tz);
704
705 }
706
707 /**************************
708 * CALCULATE INTERACTIONS *
709 **************************/
710
711 if (gmx_mm_any_lt(rsq20,rcutoff2))
712 {
713
714 r20 = _mm_mul_ps(rsq20,rinv20);
715 r20 = _mm_andnot_ps(dummy_mask,r20);
716
717 /* Compute parameters for interactions between i and j atoms */
718 qq20 = _mm_mul_ps(iq2,jq0);
719
720 /* EWALD ELECTROSTATICS */
721
722 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
723 ewrt = _mm_mul_ps(r20,ewtabscale);
724 ewitab = _mm_cvttps_epi32(ewrt);
725 eweps = _mm_sub_ps(ewrt,_mm_round_ps(ewrt, _MM_FROUND_FLOOR)__extension__ ({ __m128 __X = (ewrt); (__m128) __builtin_ia32_roundps
((__v4sf)__X, ((0x00 | 0x01))); })
);
726 ewitab = _mm_slli_epi32(ewitab,2);
727 ewtabF = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,0)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(0) &
3];}))
);
728 ewtabD = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,1)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(1) &
3];}))
);
729 ewtabV = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,2)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(2) &
3];}))
);
730 ewtabFn = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,3)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(3) &
3];}))
);
731 _MM_TRANSPOSE4_PS(ewtabF,ewtabD,ewtabV,ewtabFn)do { __m128 tmp3, tmp2, tmp1, tmp0; tmp0 = _mm_unpacklo_ps((ewtabF
), (ewtabD)); tmp2 = _mm_unpacklo_ps((ewtabV), (ewtabFn)); tmp1
= _mm_unpackhi_ps((ewtabF), (ewtabD)); tmp3 = _mm_unpackhi_ps
((ewtabV), (ewtabFn)); (ewtabF) = _mm_movelh_ps(tmp0, tmp2); (
ewtabD) = _mm_movehl_ps(tmp2, tmp0); (ewtabV) = _mm_movelh_ps
(tmp1, tmp3); (ewtabFn) = _mm_movehl_ps(tmp3, tmp1); } while (
0)
;
732 felec = _mm_add_ps(ewtabF,_mm_mul_ps(eweps,ewtabD));
733 velec = _mm_sub_ps(ewtabV,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace,eweps),_mm_add_ps(ewtabF,felec)));
734 velec = _mm_mul_ps(qq20,_mm_sub_ps(rinv20,velec));
735 felec = _mm_mul_ps(_mm_mul_ps(qq20,rinv20),_mm_sub_ps(rinvsq20,felec));
736
737 d = _mm_sub_ps(r20,rswitch);
738 d = _mm_max_ps(d,_mm_setzero_ps());
739 d2 = _mm_mul_ps(d,d);
740 sw = _mm_add_ps(one,_mm_mul_ps(d2,_mm_mul_ps(d,_mm_add_ps(swV3,_mm_mul_ps(d,_mm_add_ps(swV4,_mm_mul_ps(d,swV5)))))));
741
742 dsw = _mm_mul_ps(d2,_mm_add_ps(swF2,_mm_mul_ps(d,_mm_add_ps(swF3,_mm_mul_ps(d,swF4)))));
743
744 /* Evaluate switch function */
745 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
746 felec = _mm_sub_ps( _mm_mul_ps(felec,sw) , _mm_mul_ps(rinv20,_mm_mul_ps(velec,dsw)) );
747 velec = _mm_mul_ps(velec,sw);
748 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
749
750 /* Update potential sum for this i atom from the interaction with this j atom. */
751 velec = _mm_and_ps(velec,cutoff_mask);
752 velec = _mm_andnot_ps(dummy_mask,velec);
753 velecsum = _mm_add_ps(velecsum,velec);
754
755 fscal = felec;
756
757 fscal = _mm_and_ps(fscal,cutoff_mask);
758
759 fscal = _mm_andnot_ps(dummy_mask,fscal);
760
761 /* Calculate temporary vectorial force */
762 tx = _mm_mul_ps(fscal,dx20);
763 ty = _mm_mul_ps(fscal,dy20);
764 tz = _mm_mul_ps(fscal,dz20);
765
766 /* Update vectorial force */
767 fix2 = _mm_add_ps(fix2,tx);
768 fiy2 = _mm_add_ps(fiy2,ty);
769 fiz2 = _mm_add_ps(fiz2,tz);
770
771 fjx0 = _mm_add_ps(fjx0,tx);
772 fjy0 = _mm_add_ps(fjy0,ty);
773 fjz0 = _mm_add_ps(fjz0,tz);
774
775 }
776
777 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
778 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
779 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
780 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
781
782 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
783
784 /* Inner loop uses 216 flops */
785 }
786
787 /* End of innermost loop */
788
789 gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
790 f+i_coord_offset,fshift+i_shift_offset);
791
792 ggid = gid[iidx];
793 /* Update potential energies */
794 gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
795 gmx_mm_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
796
797 /* Increment number of inner iterations */
798 inneriter += j_index_end - j_index_start;
799
800 /* Outer loop uses 20 flops */
801 }
802
803 /* Increment number of outer iterations */
804 outeriter += nri;
805
806 /* Update outer/inner flops */
807
808 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*20 + inneriter*216)(nrnb)->n[eNR_NBKERNEL_ELEC_VDW_W3_VF] += outeriter*20 + inneriter
*216
;
809}
810/*
811 * Gromacs nonbonded kernel: nb_kernel_ElecEwSw_VdwLJSw_GeomW3P1_F_sse4_1_single
812 * Electrostatics interaction: Ewald
813 * VdW interaction: LennardJones
814 * Geometry: Water3-Particle
815 * Calculate force/pot: Force
816 */
817void
818nb_kernel_ElecEwSw_VdwLJSw_GeomW3P1_F_sse4_1_single
819 (t_nblist * gmx_restrict nlist,
820 rvec * gmx_restrict xx,
821 rvec * gmx_restrict ff,
822 t_forcerec * gmx_restrict fr,
823 t_mdatoms * gmx_restrict mdatoms,
824 nb_kernel_data_t gmx_unused__attribute__ ((unused)) * gmx_restrict kernel_data,
825 t_nrnb * gmx_restrict nrnb)
826{
827 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
828 * just 0 for non-waters.
829 * Suffixes A,B,C,D refer to j loop unrolling done with SSE, e.g. for the four different
830 * jnr indices corresponding to data put in the four positions in the SIMD register.
831 */
832 int i_shift_offset,i_coord_offset,outeriter,inneriter;
833 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
834 int jnrA,jnrB,jnrC,jnrD;
835 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
836 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
837 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
838 real rcutoff_scalar;
839 real *shiftvec,*fshift,*x,*f;
840 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
841 real scratch[4*DIM3];
842 __m128 tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
843 int vdwioffset0;
844 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
845 int vdwioffset1;
846 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
847 int vdwioffset2;
848 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
849 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
850 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
851 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
852 __m128 dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
853 __m128 dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
854 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
855 real *charge;
856 int nvdwtype;
857 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
858 int *vdwtype;
859 real *vdwparam;
860 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
861 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
862 __m128i ewitab;
863 __m128 ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
864 real *ewtab;
865 __m128 rswitch,swV3,swV4,swV5,swF2,swF3,swF4,d,d2,sw,dsw;
866 real rswitch_scalar,d_scalar;
867 __m128 dummy_mask,cutoff_mask;
868 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
869 __m128 one = _mm_set1_ps(1.0);
870 __m128 two = _mm_set1_ps(2.0);
871 x = xx[0];
872 f = ff[0];
873
874 nri = nlist->nri;
875 iinr = nlist->iinr;
876 jindex = nlist->jindex;
877 jjnr = nlist->jjnr;
878 shiftidx = nlist->shift;
879 gid = nlist->gid;
880 shiftvec = fr->shift_vec[0];
881 fshift = fr->fshift[0];
882 facel = _mm_set1_ps(fr->epsfac);
883 charge = mdatoms->chargeA;
884 nvdwtype = fr->ntype;
885 vdwparam = fr->nbfp;
886 vdwtype = mdatoms->typeA;
887
888 sh_ewald = _mm_set1_ps(fr->ic->sh_ewald);
889 ewtab = fr->ic->tabq_coul_FDV0;
890 ewtabscale = _mm_set1_ps(fr->ic->tabq_scale);
891 ewtabhalfspace = _mm_set1_ps(0.5/fr->ic->tabq_scale);
892
893 /* Setup water-specific parameters */
894 inr = nlist->iinr[0];
895 iq0 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
896 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
897 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
898 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
899
900 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
901 rcutoff_scalar = fr->rcoulomb;
902 rcutoff = _mm_set1_ps(rcutoff_scalar);
903 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
904
905 rswitch_scalar = fr->rcoulomb_switch;
906 rswitch = _mm_set1_ps(rswitch_scalar);
907 /* Setup switch parameters */
908 d_scalar = rcutoff_scalar-rswitch_scalar;
909 d = _mm_set1_ps(d_scalar);
910 swV3 = _mm_set1_ps(-10.0/(d_scalar*d_scalar*d_scalar));
911 swV4 = _mm_set1_ps( 15.0/(d_scalar*d_scalar*d_scalar*d_scalar));
912 swV5 = _mm_set1_ps( -6.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
913 swF2 = _mm_set1_ps(-30.0/(d_scalar*d_scalar*d_scalar));
914 swF3 = _mm_set1_ps( 60.0/(d_scalar*d_scalar*d_scalar*d_scalar));
915 swF4 = _mm_set1_ps(-30.0/(d_scalar*d_scalar*d_scalar*d_scalar*d_scalar));
916
917 /* Avoid stupid compiler warnings */
918 jnrA = jnrB = jnrC = jnrD = 0;
919 j_coord_offsetA = 0;
920 j_coord_offsetB = 0;
921 j_coord_offsetC = 0;
922 j_coord_offsetD = 0;
923
924 outeriter = 0;
925 inneriter = 0;
926
927 for(iidx=0;iidx<4*DIM3;iidx++)
928 {
929 scratch[iidx] = 0.0;
930 }
931
932 /* Start outer loop over neighborlists */
933 for(iidx=0; iidx<nri; iidx++)
934 {
935 /* Load shift vector for this list */
936 i_shift_offset = DIM3*shiftidx[iidx];
937
938 /* Load limits for loop over neighbors */
939 j_index_start = jindex[iidx];
940 j_index_end = jindex[iidx+1];
941
942 /* Get outer coordinate index */
943 inr = iinr[iidx];
944 i_coord_offset = DIM3*inr;
945
946 /* Load i particle coords and add shift vector */
947 gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
948 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
949
950 fix0 = _mm_setzero_ps();
951 fiy0 = _mm_setzero_ps();
952 fiz0 = _mm_setzero_ps();
953 fix1 = _mm_setzero_ps();
954 fiy1 = _mm_setzero_ps();
955 fiz1 = _mm_setzero_ps();
956 fix2 = _mm_setzero_ps();
957 fiy2 = _mm_setzero_ps();
958 fiz2 = _mm_setzero_ps();
959
960 /* Start inner kernel loop */
961 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
962 {
963
964 /* Get j neighbor index, and coordinate index */
965 jnrA = jjnr[jidx];
966 jnrB = jjnr[jidx+1];
967 jnrC = jjnr[jidx+2];
968 jnrD = jjnr[jidx+3];
969 j_coord_offsetA = DIM3*jnrA;
970 j_coord_offsetB = DIM3*jnrB;
971 j_coord_offsetC = DIM3*jnrC;
972 j_coord_offsetD = DIM3*jnrD;
973
974 /* load j atom coordinates */
975 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
976 x+j_coord_offsetC,x+j_coord_offsetD,
977 &jx0,&jy0,&jz0);
978
979 /* Calculate displacement vector */
980 dx00 = _mm_sub_ps(ix0,jx0);
981 dy00 = _mm_sub_ps(iy0,jy0);
982 dz00 = _mm_sub_ps(iz0,jz0);
983 dx10 = _mm_sub_ps(ix1,jx0);
984 dy10 = _mm_sub_ps(iy1,jy0);
985 dz10 = _mm_sub_ps(iz1,jz0);
986 dx20 = _mm_sub_ps(ix2,jx0);
987 dy20 = _mm_sub_ps(iy2,jy0);
988 dz20 = _mm_sub_ps(iz2,jz0);
989
990 /* Calculate squared distance and things based on it */
991 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
992 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
993 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
994
995 rinv00 = gmx_mm_invsqrt_psgmx_simd_invsqrt_f(rsq00);
996 rinv10 = gmx_mm_invsqrt_psgmx_simd_invsqrt_f(rsq10);
997 rinv20 = gmx_mm_invsqrt_psgmx_simd_invsqrt_f(rsq20);
998
999 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
1000 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
1001 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
1002
1003 /* Load parameters for j particles */
1004 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
1005 charge+jnrC+0,charge+jnrD+0);
1006 vdwjidx0A = 2*vdwtype[jnrA+0];
1007 vdwjidx0B = 2*vdwtype[jnrB+0];
1008 vdwjidx0C = 2*vdwtype[jnrC+0];
1009 vdwjidx0D = 2*vdwtype[jnrD+0];
1010
1011 fjx0 = _mm_setzero_ps();
1012 fjy0 = _mm_setzero_ps();
1013 fjz0 = _mm_setzero_ps();
1014
1015 /**************************
1016 * CALCULATE INTERACTIONS *
1017 **************************/
1018
1019 if (gmx_mm_any_lt(rsq00,rcutoff2))
1020 {
1021
1022 r00 = _mm_mul_ps(rsq00,rinv00);
1023
1024 /* Compute parameters for interactions between i and j atoms */
1025 qq00 = _mm_mul_ps(iq0,jq0);
1026 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
1027 vdwparam+vdwioffset0+vdwjidx0B,
1028 vdwparam+vdwioffset0+vdwjidx0C,
1029 vdwparam+vdwioffset0+vdwjidx0D,
1030 &c6_00,&c12_00);
1031
1032 /* EWALD ELECTROSTATICS */
1033
1034 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1035 ewrt = _mm_mul_ps(r00,ewtabscale);
1036 ewitab = _mm_cvttps_epi32(ewrt);
1037 eweps = _mm_sub_ps(ewrt,_mm_round_ps(ewrt, _MM_FROUND_FLOOR)__extension__ ({ __m128 __X = (ewrt); (__m128) __builtin_ia32_roundps
((__v4sf)__X, ((0x00 | 0x01))); })
);
1038 ewitab = _mm_slli_epi32(ewitab,2);
1039 ewtabF = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,0)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(0) &
3];}))
);
1040 ewtabD = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,1)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(1) &
3];}))
);
1041 ewtabV = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,2)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(2) &
3];}))
);
1042 ewtabFn = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,3)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(3) &
3];}))
);
1043 _MM_TRANSPOSE4_PS(ewtabF,ewtabD,ewtabV,ewtabFn)do { __m128 tmp3, tmp2, tmp1, tmp0; tmp0 = _mm_unpacklo_ps((ewtabF
), (ewtabD)); tmp2 = _mm_unpacklo_ps((ewtabV), (ewtabFn)); tmp1
= _mm_unpackhi_ps((ewtabF), (ewtabD)); tmp3 = _mm_unpackhi_ps
((ewtabV), (ewtabFn)); (ewtabF) = _mm_movelh_ps(tmp0, tmp2); (
ewtabD) = _mm_movehl_ps(tmp2, tmp0); (ewtabV) = _mm_movelh_ps
(tmp1, tmp3); (ewtabFn) = _mm_movehl_ps(tmp3, tmp1); } while (
0)
;
1044 felec = _mm_add_ps(ewtabF,_mm_mul_ps(eweps,ewtabD));
1045 velec = _mm_sub_ps(ewtabV,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace,eweps),_mm_add_ps(ewtabF,felec)));
1046 velec = _mm_mul_ps(qq00,_mm_sub_ps(rinv00,velec));
1047 felec = _mm_mul_ps(_mm_mul_ps(qq00,rinv00),_mm_sub_ps(rinvsq00,felec));
1048
1049 /* LENNARD-JONES DISPERSION/REPULSION */
1050
1051 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
1052 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
1053 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
1054 vvdw = _mm_sub_ps( _mm_mul_ps(vvdw12,one_twelfth) , _mm_mul_ps(vvdw6,one_sixth) );
1055 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
1056
1057 d = _mm_sub_ps(r00,rswitch);
1058 d = _mm_max_ps(d,_mm_setzero_ps());
1059 d2 = _mm_mul_ps(d,d);
1060 sw = _mm_add_ps(one,_mm_mul_ps(d2,_mm_mul_ps(d,_mm_add_ps(swV3,_mm_mul_ps(d,_mm_add_ps(swV4,_mm_mul_ps(d,swV5)))))));
1061
1062 dsw = _mm_mul_ps(d2,_mm_add_ps(swF2,_mm_mul_ps(d,_mm_add_ps(swF3,_mm_mul_ps(d,swF4)))));
1063
1064 /* Evaluate switch function */
1065 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
1066 felec = _mm_sub_ps( _mm_mul_ps(felec,sw) , _mm_mul_ps(rinv00,_mm_mul_ps(velec,dsw)) );
1067 fvdw = _mm_sub_ps( _mm_mul_ps(fvdw,sw) , _mm_mul_ps(rinv00,_mm_mul_ps(vvdw,dsw)) );
1068 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
1069
1070 fscal = _mm_add_ps(felec,fvdw);
1071
1072 fscal = _mm_and_ps(fscal,cutoff_mask);
1073
1074 /* Calculate temporary vectorial force */
1075 tx = _mm_mul_ps(fscal,dx00);
1076 ty = _mm_mul_ps(fscal,dy00);
1077 tz = _mm_mul_ps(fscal,dz00);
1078
1079 /* Update vectorial force */
1080 fix0 = _mm_add_ps(fix0,tx);
1081 fiy0 = _mm_add_ps(fiy0,ty);
1082 fiz0 = _mm_add_ps(fiz0,tz);
1083
1084 fjx0 = _mm_add_ps(fjx0,tx);
1085 fjy0 = _mm_add_ps(fjy0,ty);
1086 fjz0 = _mm_add_ps(fjz0,tz);
1087
1088 }
1089
1090 /**************************
1091 * CALCULATE INTERACTIONS *
1092 **************************/
1093
1094 if (gmx_mm_any_lt(rsq10,rcutoff2))
1095 {
1096
1097 r10 = _mm_mul_ps(rsq10,rinv10);
1098
1099 /* Compute parameters for interactions between i and j atoms */
1100 qq10 = _mm_mul_ps(iq1,jq0);
1101
1102 /* EWALD ELECTROSTATICS */
1103
1104 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1105 ewrt = _mm_mul_ps(r10,ewtabscale);
1106 ewitab = _mm_cvttps_epi32(ewrt);
1107 eweps = _mm_sub_ps(ewrt,_mm_round_ps(ewrt, _MM_FROUND_FLOOR)__extension__ ({ __m128 __X = (ewrt); (__m128) __builtin_ia32_roundps
((__v4sf)__X, ((0x00 | 0x01))); })
);
1108 ewitab = _mm_slli_epi32(ewitab,2);
1109 ewtabF = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,0)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(0) &
3];}))
);
1110 ewtabD = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,1)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(1) &
3];}))
);
1111 ewtabV = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,2)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(2) &
3];}))
);
1112 ewtabFn = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,3)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(3) &
3];}))
);
1113 _MM_TRANSPOSE4_PS(ewtabF,ewtabD,ewtabV,ewtabFn)do { __m128 tmp3, tmp2, tmp1, tmp0; tmp0 = _mm_unpacklo_ps((ewtabF
), (ewtabD)); tmp2 = _mm_unpacklo_ps((ewtabV), (ewtabFn)); tmp1
= _mm_unpackhi_ps((ewtabF), (ewtabD)); tmp3 = _mm_unpackhi_ps
((ewtabV), (ewtabFn)); (ewtabF) = _mm_movelh_ps(tmp0, tmp2); (
ewtabD) = _mm_movehl_ps(tmp2, tmp0); (ewtabV) = _mm_movelh_ps
(tmp1, tmp3); (ewtabFn) = _mm_movehl_ps(tmp3, tmp1); } while (
0)
;
1114 felec = _mm_add_ps(ewtabF,_mm_mul_ps(eweps,ewtabD));
1115 velec = _mm_sub_ps(ewtabV,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace,eweps),_mm_add_ps(ewtabF,felec)));
1116 velec = _mm_mul_ps(qq10,_mm_sub_ps(rinv10,velec));
1117 felec = _mm_mul_ps(_mm_mul_ps(qq10,rinv10),_mm_sub_ps(rinvsq10,felec));
1118
1119 d = _mm_sub_ps(r10,rswitch);
1120 d = _mm_max_ps(d,_mm_setzero_ps());
1121 d2 = _mm_mul_ps(d,d);
1122 sw = _mm_add_ps(one,_mm_mul_ps(d2,_mm_mul_ps(d,_mm_add_ps(swV3,_mm_mul_ps(d,_mm_add_ps(swV4,_mm_mul_ps(d,swV5)))))));
1123
1124 dsw = _mm_mul_ps(d2,_mm_add_ps(swF2,_mm_mul_ps(d,_mm_add_ps(swF3,_mm_mul_ps(d,swF4)))));
1125
1126 /* Evaluate switch function */
1127 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
1128 felec = _mm_sub_ps( _mm_mul_ps(felec,sw) , _mm_mul_ps(rinv10,_mm_mul_ps(velec,dsw)) );
1129 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
1130
1131 fscal = felec;
1132
1133 fscal = _mm_and_ps(fscal,cutoff_mask);
1134
1135 /* Calculate temporary vectorial force */
1136 tx = _mm_mul_ps(fscal,dx10);
1137 ty = _mm_mul_ps(fscal,dy10);
1138 tz = _mm_mul_ps(fscal,dz10);
1139
1140 /* Update vectorial force */
1141 fix1 = _mm_add_ps(fix1,tx);
1142 fiy1 = _mm_add_ps(fiy1,ty);
1143 fiz1 = _mm_add_ps(fiz1,tz);
1144
1145 fjx0 = _mm_add_ps(fjx0,tx);
1146 fjy0 = _mm_add_ps(fjy0,ty);
1147 fjz0 = _mm_add_ps(fjz0,tz);
1148
1149 }
1150
1151 /**************************
1152 * CALCULATE INTERACTIONS *
1153 **************************/
1154
1155 if (gmx_mm_any_lt(rsq20,rcutoff2))
1156 {
1157
1158 r20 = _mm_mul_ps(rsq20,rinv20);
1159
1160 /* Compute parameters for interactions between i and j atoms */
1161 qq20 = _mm_mul_ps(iq2,jq0);
1162
1163 /* EWALD ELECTROSTATICS */
1164
1165 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1166 ewrt = _mm_mul_ps(r20,ewtabscale);
1167 ewitab = _mm_cvttps_epi32(ewrt);
1168 eweps = _mm_sub_ps(ewrt,_mm_round_ps(ewrt, _MM_FROUND_FLOOR)__extension__ ({ __m128 __X = (ewrt); (__m128) __builtin_ia32_roundps
((__v4sf)__X, ((0x00 | 0x01))); })
);
1169 ewitab = _mm_slli_epi32(ewitab,2);
1170 ewtabF = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,0)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(0) &
3];}))
);
1171 ewtabD = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,1)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(1) &
3];}))
);
1172 ewtabV = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,2)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(2) &
3];}))
);
1173 ewtabFn = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,3)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(3) &
3];}))
);
1174 _MM_TRANSPOSE4_PS(ewtabF,ewtabD,ewtabV,ewtabFn)do { __m128 tmp3, tmp2, tmp1, tmp0; tmp0 = _mm_unpacklo_ps((ewtabF
), (ewtabD)); tmp2 = _mm_unpacklo_ps((ewtabV), (ewtabFn)); tmp1
= _mm_unpackhi_ps((ewtabF), (ewtabD)); tmp3 = _mm_unpackhi_ps
((ewtabV), (ewtabFn)); (ewtabF) = _mm_movelh_ps(tmp0, tmp2); (
ewtabD) = _mm_movehl_ps(tmp2, tmp0); (ewtabV) = _mm_movelh_ps
(tmp1, tmp3); (ewtabFn) = _mm_movehl_ps(tmp3, tmp1); } while (
0)
;
1175 felec = _mm_add_ps(ewtabF,_mm_mul_ps(eweps,ewtabD));
1176 velec = _mm_sub_ps(ewtabV,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace,eweps),_mm_add_ps(ewtabF,felec)));
1177 velec = _mm_mul_ps(qq20,_mm_sub_ps(rinv20,velec));
1178 felec = _mm_mul_ps(_mm_mul_ps(qq20,rinv20),_mm_sub_ps(rinvsq20,felec));
1179
1180 d = _mm_sub_ps(r20,rswitch);
1181 d = _mm_max_ps(d,_mm_setzero_ps());
1182 d2 = _mm_mul_ps(d,d);
1183 sw = _mm_add_ps(one,_mm_mul_ps(d2,_mm_mul_ps(d,_mm_add_ps(swV3,_mm_mul_ps(d,_mm_add_ps(swV4,_mm_mul_ps(d,swV5)))))));
1184
1185 dsw = _mm_mul_ps(d2,_mm_add_ps(swF2,_mm_mul_ps(d,_mm_add_ps(swF3,_mm_mul_ps(d,swF4)))));
1186
1187 /* Evaluate switch function */
1188 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
1189 felec = _mm_sub_ps( _mm_mul_ps(felec,sw) , _mm_mul_ps(rinv20,_mm_mul_ps(velec,dsw)) );
1190 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
1191
1192 fscal = felec;
1193
1194 fscal = _mm_and_ps(fscal,cutoff_mask);
1195
1196 /* Calculate temporary vectorial force */
1197 tx = _mm_mul_ps(fscal,dx20);
1198 ty = _mm_mul_ps(fscal,dy20);
1199 tz = _mm_mul_ps(fscal,dz20);
1200
1201 /* Update vectorial force */
1202 fix2 = _mm_add_ps(fix2,tx);
1203 fiy2 = _mm_add_ps(fiy2,ty);
1204 fiz2 = _mm_add_ps(fiz2,tz);
1205
1206 fjx0 = _mm_add_ps(fjx0,tx);
1207 fjy0 = _mm_add_ps(fjy0,ty);
1208 fjz0 = _mm_add_ps(fjz0,tz);
1209
1210 }
1211
1212 fjptrA = f+j_coord_offsetA;
1213 fjptrB = f+j_coord_offsetB;
1214 fjptrC = f+j_coord_offsetC;
1215 fjptrD = f+j_coord_offsetD;
1216
1217 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
1218
1219 /* Inner loop uses 201 flops */
1220 }
1221
1222 if(jidx<j_index_end)
1223 {
1224
1225 /* Get j neighbor index, and coordinate index */
1226 jnrlistA = jjnr[jidx];
1227 jnrlistB = jjnr[jidx+1];
1228 jnrlistC = jjnr[jidx+2];
1229 jnrlistD = jjnr[jidx+3];
1230 /* Sign of each element will be negative for non-real atoms.
1231 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1232 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1233 */
1234 dummy_mask = gmx_mm_castsi128_ps_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
1235 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
1236 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
1237 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
1238 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
1239 j_coord_offsetA = DIM3*jnrA;
1240 j_coord_offsetB = DIM3*jnrB;
1241 j_coord_offsetC = DIM3*jnrC;
1242 j_coord_offsetD = DIM3*jnrD;
1243
1244 /* load j atom coordinates */
1245 gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1246 x+j_coord_offsetC,x+j_coord_offsetD,
1247 &jx0,&jy0,&jz0);
1248
1249 /* Calculate displacement vector */
1250 dx00 = _mm_sub_ps(ix0,jx0);
1251 dy00 = _mm_sub_ps(iy0,jy0);
1252 dz00 = _mm_sub_ps(iz0,jz0);
1253 dx10 = _mm_sub_ps(ix1,jx0);
1254 dy10 = _mm_sub_ps(iy1,jy0);
1255 dz10 = _mm_sub_ps(iz1,jz0);
1256 dx20 = _mm_sub_ps(ix2,jx0);
1257 dy20 = _mm_sub_ps(iy2,jy0);
1258 dz20 = _mm_sub_ps(iz2,jz0);
1259
1260 /* Calculate squared distance and things based on it */
1261 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1262 rsq10 = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
1263 rsq20 = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
1264
1265 rinv00 = gmx_mm_invsqrt_psgmx_simd_invsqrt_f(rsq00);
1266 rinv10 = gmx_mm_invsqrt_psgmx_simd_invsqrt_f(rsq10);
1267 rinv20 = gmx_mm_invsqrt_psgmx_simd_invsqrt_f(rsq20);
1268
1269 rinvsq00 = _mm_mul_ps(rinv00,rinv00);
1270 rinvsq10 = _mm_mul_ps(rinv10,rinv10);
1271 rinvsq20 = _mm_mul_ps(rinv20,rinv20);
1272
1273 /* Load parameters for j particles */
1274 jq0 = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
1275 charge+jnrC+0,charge+jnrD+0);
1276 vdwjidx0A = 2*vdwtype[jnrA+0];
1277 vdwjidx0B = 2*vdwtype[jnrB+0];
1278 vdwjidx0C = 2*vdwtype[jnrC+0];
1279 vdwjidx0D = 2*vdwtype[jnrD+0];
1280
1281 fjx0 = _mm_setzero_ps();
1282 fjy0 = _mm_setzero_ps();
1283 fjz0 = _mm_setzero_ps();
1284
1285 /**************************
1286 * CALCULATE INTERACTIONS *
1287 **************************/
1288
1289 if (gmx_mm_any_lt(rsq00,rcutoff2))
1290 {
1291
1292 r00 = _mm_mul_ps(rsq00,rinv00);
1293 r00 = _mm_andnot_ps(dummy_mask,r00);
1294
1295 /* Compute parameters for interactions between i and j atoms */
1296 qq00 = _mm_mul_ps(iq0,jq0);
1297 gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
1298 vdwparam+vdwioffset0+vdwjidx0B,
1299 vdwparam+vdwioffset0+vdwjidx0C,
1300 vdwparam+vdwioffset0+vdwjidx0D,
1301 &c6_00,&c12_00);
1302
1303 /* EWALD ELECTROSTATICS */
1304
1305 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1306 ewrt = _mm_mul_ps(r00,ewtabscale);
1307 ewitab = _mm_cvttps_epi32(ewrt);
1308 eweps = _mm_sub_ps(ewrt,_mm_round_ps(ewrt, _MM_FROUND_FLOOR)__extension__ ({ __m128 __X = (ewrt); (__m128) __builtin_ia32_roundps
((__v4sf)__X, ((0x00 | 0x01))); })
);
1309 ewitab = _mm_slli_epi32(ewitab,2);
1310 ewtabF = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,0)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(0) &
3];}))
);
1311 ewtabD = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,1)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(1) &
3];}))
);
1312 ewtabV = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,2)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(2) &
3];}))
);
1313 ewtabFn = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,3)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(3) &
3];}))
);
1314 _MM_TRANSPOSE4_PS(ewtabF,ewtabD,ewtabV,ewtabFn)do { __m128 tmp3, tmp2, tmp1, tmp0; tmp0 = _mm_unpacklo_ps((ewtabF
), (ewtabD)); tmp2 = _mm_unpacklo_ps((ewtabV), (ewtabFn)); tmp1
= _mm_unpackhi_ps((ewtabF), (ewtabD)); tmp3 = _mm_unpackhi_ps
((ewtabV), (ewtabFn)); (ewtabF) = _mm_movelh_ps(tmp0, tmp2); (
ewtabD) = _mm_movehl_ps(tmp2, tmp0); (ewtabV) = _mm_movelh_ps
(tmp1, tmp3); (ewtabFn) = _mm_movehl_ps(tmp3, tmp1); } while (
0)
;
1315 felec = _mm_add_ps(ewtabF,_mm_mul_ps(eweps,ewtabD));
1316 velec = _mm_sub_ps(ewtabV,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace,eweps),_mm_add_ps(ewtabF,felec)));
1317 velec = _mm_mul_ps(qq00,_mm_sub_ps(rinv00,velec));
1318 felec = _mm_mul_ps(_mm_mul_ps(qq00,rinv00),_mm_sub_ps(rinvsq00,felec));
1319
1320 /* LENNARD-JONES DISPERSION/REPULSION */
1321
1322 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
1323 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
1324 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
1325 vvdw = _mm_sub_ps( _mm_mul_ps(vvdw12,one_twelfth) , _mm_mul_ps(vvdw6,one_sixth) );
1326 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
1327
1328 d = _mm_sub_ps(r00,rswitch);
1329 d = _mm_max_ps(d,_mm_setzero_ps());
1330 d2 = _mm_mul_ps(d,d);
1331 sw = _mm_add_ps(one,_mm_mul_ps(d2,_mm_mul_ps(d,_mm_add_ps(swV3,_mm_mul_ps(d,_mm_add_ps(swV4,_mm_mul_ps(d,swV5)))))));
1332
1333 dsw = _mm_mul_ps(d2,_mm_add_ps(swF2,_mm_mul_ps(d,_mm_add_ps(swF3,_mm_mul_ps(d,swF4)))));
1334
1335 /* Evaluate switch function */
1336 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
1337 felec = _mm_sub_ps( _mm_mul_ps(felec,sw) , _mm_mul_ps(rinv00,_mm_mul_ps(velec,dsw)) );
1338 fvdw = _mm_sub_ps( _mm_mul_ps(fvdw,sw) , _mm_mul_ps(rinv00,_mm_mul_ps(vvdw,dsw)) );
1339 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
1340
1341 fscal = _mm_add_ps(felec,fvdw);
1342
1343 fscal = _mm_and_ps(fscal,cutoff_mask);
1344
1345 fscal = _mm_andnot_ps(dummy_mask,fscal);
1346
1347 /* Calculate temporary vectorial force */
1348 tx = _mm_mul_ps(fscal,dx00);
1349 ty = _mm_mul_ps(fscal,dy00);
1350 tz = _mm_mul_ps(fscal,dz00);
1351
1352 /* Update vectorial force */
1353 fix0 = _mm_add_ps(fix0,tx);
1354 fiy0 = _mm_add_ps(fiy0,ty);
1355 fiz0 = _mm_add_ps(fiz0,tz);
1356
1357 fjx0 = _mm_add_ps(fjx0,tx);
1358 fjy0 = _mm_add_ps(fjy0,ty);
1359 fjz0 = _mm_add_ps(fjz0,tz);
1360
1361 }
1362
1363 /**************************
1364 * CALCULATE INTERACTIONS *
1365 **************************/
1366
1367 if (gmx_mm_any_lt(rsq10,rcutoff2))
1368 {
1369
1370 r10 = _mm_mul_ps(rsq10,rinv10);
1371 r10 = _mm_andnot_ps(dummy_mask,r10);
1372
1373 /* Compute parameters for interactions between i and j atoms */
1374 qq10 = _mm_mul_ps(iq1,jq0);
1375
1376 /* EWALD ELECTROSTATICS */
1377
1378 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1379 ewrt = _mm_mul_ps(r10,ewtabscale);
1380 ewitab = _mm_cvttps_epi32(ewrt);
1381 eweps = _mm_sub_ps(ewrt,_mm_round_ps(ewrt, _MM_FROUND_FLOOR)__extension__ ({ __m128 __X = (ewrt); (__m128) __builtin_ia32_roundps
((__v4sf)__X, ((0x00 | 0x01))); })
);
1382 ewitab = _mm_slli_epi32(ewitab,2);
1383 ewtabF = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,0)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(0) &
3];}))
);
1384 ewtabD = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,1)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(1) &
3];}))
);
1385 ewtabV = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,2)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(2) &
3];}))
);
1386 ewtabFn = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,3)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(3) &
3];}))
);
1387 _MM_TRANSPOSE4_PS(ewtabF,ewtabD,ewtabV,ewtabFn)do { __m128 tmp3, tmp2, tmp1, tmp0; tmp0 = _mm_unpacklo_ps((ewtabF
), (ewtabD)); tmp2 = _mm_unpacklo_ps((ewtabV), (ewtabFn)); tmp1
= _mm_unpackhi_ps((ewtabF), (ewtabD)); tmp3 = _mm_unpackhi_ps
((ewtabV), (ewtabFn)); (ewtabF) = _mm_movelh_ps(tmp0, tmp2); (
ewtabD) = _mm_movehl_ps(tmp2, tmp0); (ewtabV) = _mm_movelh_ps
(tmp1, tmp3); (ewtabFn) = _mm_movehl_ps(tmp3, tmp1); } while (
0)
;
1388 felec = _mm_add_ps(ewtabF,_mm_mul_ps(eweps,ewtabD));
1389 velec = _mm_sub_ps(ewtabV,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace,eweps),_mm_add_ps(ewtabF,felec)));
1390 velec = _mm_mul_ps(qq10,_mm_sub_ps(rinv10,velec));
1391 felec = _mm_mul_ps(_mm_mul_ps(qq10,rinv10),_mm_sub_ps(rinvsq10,felec));
1392
1393 d = _mm_sub_ps(r10,rswitch);
1394 d = _mm_max_ps(d,_mm_setzero_ps());
1395 d2 = _mm_mul_ps(d,d);
1396 sw = _mm_add_ps(one,_mm_mul_ps(d2,_mm_mul_ps(d,_mm_add_ps(swV3,_mm_mul_ps(d,_mm_add_ps(swV4,_mm_mul_ps(d,swV5)))))));
1397
1398 dsw = _mm_mul_ps(d2,_mm_add_ps(swF2,_mm_mul_ps(d,_mm_add_ps(swF3,_mm_mul_ps(d,swF4)))));
1399
1400 /* Evaluate switch function */
1401 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
1402 felec = _mm_sub_ps( _mm_mul_ps(felec,sw) , _mm_mul_ps(rinv10,_mm_mul_ps(velec,dsw)) );
1403 cutoff_mask = _mm_cmplt_ps(rsq10,rcutoff2);
1404
1405 fscal = felec;
1406
1407 fscal = _mm_and_ps(fscal,cutoff_mask);
1408
1409 fscal = _mm_andnot_ps(dummy_mask,fscal);
1410
1411 /* Calculate temporary vectorial force */
1412 tx = _mm_mul_ps(fscal,dx10);
1413 ty = _mm_mul_ps(fscal,dy10);
1414 tz = _mm_mul_ps(fscal,dz10);
1415
1416 /* Update vectorial force */
1417 fix1 = _mm_add_ps(fix1,tx);
1418 fiy1 = _mm_add_ps(fiy1,ty);
1419 fiz1 = _mm_add_ps(fiz1,tz);
1420
1421 fjx0 = _mm_add_ps(fjx0,tx);
1422 fjy0 = _mm_add_ps(fjy0,ty);
1423 fjz0 = _mm_add_ps(fjz0,tz);
1424
1425 }
1426
1427 /**************************
1428 * CALCULATE INTERACTIONS *
1429 **************************/
1430
1431 if (gmx_mm_any_lt(rsq20,rcutoff2))
1432 {
1433
1434 r20 = _mm_mul_ps(rsq20,rinv20);
1435 r20 = _mm_andnot_ps(dummy_mask,r20);
1436
1437 /* Compute parameters for interactions between i and j atoms */
1438 qq20 = _mm_mul_ps(iq2,jq0);
1439
1440 /* EWALD ELECTROSTATICS */
1441
1442 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1443 ewrt = _mm_mul_ps(r20,ewtabscale);
1444 ewitab = _mm_cvttps_epi32(ewrt);
1445 eweps = _mm_sub_ps(ewrt,_mm_round_ps(ewrt, _MM_FROUND_FLOOR)__extension__ ({ __m128 __X = (ewrt); (__m128) __builtin_ia32_roundps
((__v4sf)__X, ((0x00 | 0x01))); })
);
1446 ewitab = _mm_slli_epi32(ewitab,2);
1447 ewtabF = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,0)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(0) &
3];}))
);
1448 ewtabD = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,1)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(1) &
3];}))
);
1449 ewtabV = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,2)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(2) &
3];}))
);
1450 ewtabFn = _mm_load_ps( ewtab + gmx_mm_extract_epi32(ewitab,3)(__extension__ ({ __v4si __a = (__v4si)(ewitab); __a[(3) &
3];}))
);
1451 _MM_TRANSPOSE4_PS(ewtabF,ewtabD,ewtabV,ewtabFn)do { __m128 tmp3, tmp2, tmp1, tmp0; tmp0 = _mm_unpacklo_ps((ewtabF
), (ewtabD)); tmp2 = _mm_unpacklo_ps((ewtabV), (ewtabFn)); tmp1
= _mm_unpackhi_ps((ewtabF), (ewtabD)); tmp3 = _mm_unpackhi_ps
((ewtabV), (ewtabFn)); (ewtabF) = _mm_movelh_ps(tmp0, tmp2); (
ewtabD) = _mm_movehl_ps(tmp2, tmp0); (ewtabV) = _mm_movelh_ps
(tmp1, tmp3); (ewtabFn) = _mm_movehl_ps(tmp3, tmp1); } while (
0)
;
1452 felec = _mm_add_ps(ewtabF,_mm_mul_ps(eweps,ewtabD));
1453 velec = _mm_sub_ps(ewtabV,_mm_mul_ps(_mm_mul_ps(ewtabhalfspace,eweps),_mm_add_ps(ewtabF,felec)));
1454 velec = _mm_mul_ps(qq20,_mm_sub_ps(rinv20,velec));
1455 felec = _mm_mul_ps(_mm_mul_ps(qq20,rinv20),_mm_sub_ps(rinvsq20,felec));
1456
1457 d = _mm_sub_ps(r20,rswitch);
1458 d = _mm_max_ps(d,_mm_setzero_ps());
1459 d2 = _mm_mul_ps(d,d);
1460 sw = _mm_add_ps(one,_mm_mul_ps(d2,_mm_mul_ps(d,_mm_add_ps(swV3,_mm_mul_ps(d,_mm_add_ps(swV4,_mm_mul_ps(d,swV5)))))));
1461
1462 dsw = _mm_mul_ps(d2,_mm_add_ps(swF2,_mm_mul_ps(d,_mm_add_ps(swF3,_mm_mul_ps(d,swF4)))));
1463
1464 /* Evaluate switch function */
1465 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
1466 felec = _mm_sub_ps( _mm_mul_ps(felec,sw) , _mm_mul_ps(rinv20,_mm_mul_ps(velec,dsw)) );
1467 cutoff_mask = _mm_cmplt_ps(rsq20,rcutoff2);
1468
1469 fscal = felec;
1470
1471 fscal = _mm_and_ps(fscal,cutoff_mask);
1472
1473 fscal = _mm_andnot_ps(dummy_mask,fscal);
1474
1475 /* Calculate temporary vectorial force */
1476 tx = _mm_mul_ps(fscal,dx20);
1477 ty = _mm_mul_ps(fscal,dy20);
1478 tz = _mm_mul_ps(fscal,dz20);
1479
1480 /* Update vectorial force */
1481 fix2 = _mm_add_ps(fix2,tx);
1482 fiy2 = _mm_add_ps(fiy2,ty);
1483 fiz2 = _mm_add_ps(fiz2,tz);
1484
1485 fjx0 = _mm_add_ps(fjx0,tx);
1486 fjy0 = _mm_add_ps(fjy0,ty);
1487 fjz0 = _mm_add_ps(fjz0,tz);
1488
1489 }
1490
1491 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1492 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1493 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1494 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1495
1496 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
1497
1498 /* Inner loop uses 204 flops */
1499 }
1500
1501 /* End of innermost loop */
1502
1503 gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
1504 f+i_coord_offset,fshift+i_shift_offset);
1505
1506 /* Increment number of inner iterations */
1507 inneriter += j_index_end - j_index_start;
1508
1509 /* Outer loop uses 18 flops */
1510 }
1511
1512 /* Increment number of outer iterations */
1513 outeriter += nri;
1514
1515 /* Update outer/inner flops */
1516
1517 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*18 + inneriter*204)(nrnb)->n[eNR_NBKERNEL_ELEC_VDW_W3_F] += outeriter*18 + inneriter
*204
;
1518}