2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014,2015,2017, 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.
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.
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.
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.
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.
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.
36 * Note: this file was generated by the GROMACS avx_128_fma_single kernel generator.
44 #include "../nb_kernel.h"
45 #include "gromacs/gmxlib/nrnb.h"
47 #include "kernelutil_x86_avx_128_fma_single.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJSh_GeomW4W4_VF_avx_128_fma_single
51 * Electrostatics interaction: Ewald
52 * VdW interaction: LennardJones
53 * Geometry: Water4-Water4
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecEwSh_VdwLJSh_GeomW4W4_VF_avx_128_fma_single
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 struct t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
67 * just 0 for non-waters.
68 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
69 * jnr indices corresponding to data put in the four positions in the SIMD register.
71 int i_shift_offset,i_coord_offset,outeriter,inneriter;
72 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
73 int jnrA,jnrB,jnrC,jnrD;
74 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
75 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
76 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
78 real *shiftvec,*fshift,*x,*f;
79 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
81 __m128 fscal,rcutoff,rcutoff2,jidxall;
83 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
85 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
87 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
89 __m128 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
90 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
91 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
92 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D;
93 __m128 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
94 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D;
95 __m128 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
96 int vdwjidx3A,vdwjidx3B,vdwjidx3C,vdwjidx3D;
97 __m128 jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
98 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
99 __m128 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
100 __m128 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
101 __m128 dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
102 __m128 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
103 __m128 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
104 __m128 dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
105 __m128 dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
106 __m128 dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
107 __m128 dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
108 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
111 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
114 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
115 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
117 __m128 ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
118 __m128 beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
120 __m128 dummy_mask,cutoff_mask;
121 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
122 __m128 one = _mm_set1_ps(1.0);
123 __m128 two = _mm_set1_ps(2.0);
129 jindex = nlist->jindex;
131 shiftidx = nlist->shift;
133 shiftvec = fr->shift_vec[0];
134 fshift = fr->fshift[0];
135 facel = _mm_set1_ps(fr->ic->epsfac);
136 charge = mdatoms->chargeA;
137 nvdwtype = fr->ntype;
139 vdwtype = mdatoms->typeA;
141 sh_ewald = _mm_set1_ps(fr->ic->sh_ewald);
142 beta = _mm_set1_ps(fr->ic->ewaldcoeff_q);
143 beta2 = _mm_mul_ps(beta,beta);
144 beta3 = _mm_mul_ps(beta,beta2);
145 ewtab = fr->ic->tabq_coul_FDV0;
146 ewtabscale = _mm_set1_ps(fr->ic->tabq_scale);
147 ewtabhalfspace = _mm_set1_ps(0.5/fr->ic->tabq_scale);
149 /* Setup water-specific parameters */
150 inr = nlist->iinr[0];
151 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
152 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
153 iq3 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
154 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
156 jq1 = _mm_set1_ps(charge[inr+1]);
157 jq2 = _mm_set1_ps(charge[inr+2]);
158 jq3 = _mm_set1_ps(charge[inr+3]);
159 vdwjidx0A = 2*vdwtype[inr+0];
160 c6_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A]);
161 c12_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A+1]);
162 qq11 = _mm_mul_ps(iq1,jq1);
163 qq12 = _mm_mul_ps(iq1,jq2);
164 qq13 = _mm_mul_ps(iq1,jq3);
165 qq21 = _mm_mul_ps(iq2,jq1);
166 qq22 = _mm_mul_ps(iq2,jq2);
167 qq23 = _mm_mul_ps(iq2,jq3);
168 qq31 = _mm_mul_ps(iq3,jq1);
169 qq32 = _mm_mul_ps(iq3,jq2);
170 qq33 = _mm_mul_ps(iq3,jq3);
172 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
173 rcutoff_scalar = fr->ic->rcoulomb;
174 rcutoff = _mm_set1_ps(rcutoff_scalar);
175 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
177 sh_vdw_invrcut6 = _mm_set1_ps(fr->ic->sh_invrc6);
178 rvdw = _mm_set1_ps(fr->ic->rvdw);
180 /* Avoid stupid compiler warnings */
181 jnrA = jnrB = jnrC = jnrD = 0;
190 for(iidx=0;iidx<4*DIM;iidx++)
195 /* Start outer loop over neighborlists */
196 for(iidx=0; iidx<nri; iidx++)
198 /* Load shift vector for this list */
199 i_shift_offset = DIM*shiftidx[iidx];
201 /* Load limits for loop over neighbors */
202 j_index_start = jindex[iidx];
203 j_index_end = jindex[iidx+1];
205 /* Get outer coordinate index */
207 i_coord_offset = DIM*inr;
209 /* Load i particle coords and add shift vector */
210 gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
211 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
213 fix0 = _mm_setzero_ps();
214 fiy0 = _mm_setzero_ps();
215 fiz0 = _mm_setzero_ps();
216 fix1 = _mm_setzero_ps();
217 fiy1 = _mm_setzero_ps();
218 fiz1 = _mm_setzero_ps();
219 fix2 = _mm_setzero_ps();
220 fiy2 = _mm_setzero_ps();
221 fiz2 = _mm_setzero_ps();
222 fix3 = _mm_setzero_ps();
223 fiy3 = _mm_setzero_ps();
224 fiz3 = _mm_setzero_ps();
226 /* Reset potential sums */
227 velecsum = _mm_setzero_ps();
228 vvdwsum = _mm_setzero_ps();
230 /* Start inner kernel loop */
231 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
234 /* Get j neighbor index, and coordinate index */
239 j_coord_offsetA = DIM*jnrA;
240 j_coord_offsetB = DIM*jnrB;
241 j_coord_offsetC = DIM*jnrC;
242 j_coord_offsetD = DIM*jnrD;
244 /* load j atom coordinates */
245 gmx_mm_load_4rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
246 x+j_coord_offsetC,x+j_coord_offsetD,
247 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
248 &jy2,&jz2,&jx3,&jy3,&jz3);
250 /* Calculate displacement vector */
251 dx00 = _mm_sub_ps(ix0,jx0);
252 dy00 = _mm_sub_ps(iy0,jy0);
253 dz00 = _mm_sub_ps(iz0,jz0);
254 dx11 = _mm_sub_ps(ix1,jx1);
255 dy11 = _mm_sub_ps(iy1,jy1);
256 dz11 = _mm_sub_ps(iz1,jz1);
257 dx12 = _mm_sub_ps(ix1,jx2);
258 dy12 = _mm_sub_ps(iy1,jy2);
259 dz12 = _mm_sub_ps(iz1,jz2);
260 dx13 = _mm_sub_ps(ix1,jx3);
261 dy13 = _mm_sub_ps(iy1,jy3);
262 dz13 = _mm_sub_ps(iz1,jz3);
263 dx21 = _mm_sub_ps(ix2,jx1);
264 dy21 = _mm_sub_ps(iy2,jy1);
265 dz21 = _mm_sub_ps(iz2,jz1);
266 dx22 = _mm_sub_ps(ix2,jx2);
267 dy22 = _mm_sub_ps(iy2,jy2);
268 dz22 = _mm_sub_ps(iz2,jz2);
269 dx23 = _mm_sub_ps(ix2,jx3);
270 dy23 = _mm_sub_ps(iy2,jy3);
271 dz23 = _mm_sub_ps(iz2,jz3);
272 dx31 = _mm_sub_ps(ix3,jx1);
273 dy31 = _mm_sub_ps(iy3,jy1);
274 dz31 = _mm_sub_ps(iz3,jz1);
275 dx32 = _mm_sub_ps(ix3,jx2);
276 dy32 = _mm_sub_ps(iy3,jy2);
277 dz32 = _mm_sub_ps(iz3,jz2);
278 dx33 = _mm_sub_ps(ix3,jx3);
279 dy33 = _mm_sub_ps(iy3,jy3);
280 dz33 = _mm_sub_ps(iz3,jz3);
282 /* Calculate squared distance and things based on it */
283 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
284 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
285 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
286 rsq13 = gmx_mm_calc_rsq_ps(dx13,dy13,dz13);
287 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
288 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
289 rsq23 = gmx_mm_calc_rsq_ps(dx23,dy23,dz23);
290 rsq31 = gmx_mm_calc_rsq_ps(dx31,dy31,dz31);
291 rsq32 = gmx_mm_calc_rsq_ps(dx32,dy32,dz32);
292 rsq33 = gmx_mm_calc_rsq_ps(dx33,dy33,dz33);
294 rinv11 = avx128fma_invsqrt_f(rsq11);
295 rinv12 = avx128fma_invsqrt_f(rsq12);
296 rinv13 = avx128fma_invsqrt_f(rsq13);
297 rinv21 = avx128fma_invsqrt_f(rsq21);
298 rinv22 = avx128fma_invsqrt_f(rsq22);
299 rinv23 = avx128fma_invsqrt_f(rsq23);
300 rinv31 = avx128fma_invsqrt_f(rsq31);
301 rinv32 = avx128fma_invsqrt_f(rsq32);
302 rinv33 = avx128fma_invsqrt_f(rsq33);
304 rinvsq00 = avx128fma_inv_f(rsq00);
305 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
306 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
307 rinvsq13 = _mm_mul_ps(rinv13,rinv13);
308 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
309 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
310 rinvsq23 = _mm_mul_ps(rinv23,rinv23);
311 rinvsq31 = _mm_mul_ps(rinv31,rinv31);
312 rinvsq32 = _mm_mul_ps(rinv32,rinv32);
313 rinvsq33 = _mm_mul_ps(rinv33,rinv33);
315 fjx0 = _mm_setzero_ps();
316 fjy0 = _mm_setzero_ps();
317 fjz0 = _mm_setzero_ps();
318 fjx1 = _mm_setzero_ps();
319 fjy1 = _mm_setzero_ps();
320 fjz1 = _mm_setzero_ps();
321 fjx2 = _mm_setzero_ps();
322 fjy2 = _mm_setzero_ps();
323 fjz2 = _mm_setzero_ps();
324 fjx3 = _mm_setzero_ps();
325 fjy3 = _mm_setzero_ps();
326 fjz3 = _mm_setzero_ps();
328 /**************************
329 * CALCULATE INTERACTIONS *
330 **************************/
332 if (gmx_mm_any_lt(rsq00,rcutoff2))
335 /* LENNARD-JONES DISPERSION/REPULSION */
337 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
338 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
339 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
340 vvdw = _mm_msub_ps(_mm_nmacc_ps(c12_00,_mm_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
341 _mm_mul_ps( _mm_nmacc_ps(c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
342 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
344 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
346 /* Update potential sum for this i atom from the interaction with this j atom. */
347 vvdw = _mm_and_ps(vvdw,cutoff_mask);
348 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
352 fscal = _mm_and_ps(fscal,cutoff_mask);
354 /* Update vectorial force */
355 fix0 = _mm_macc_ps(dx00,fscal,fix0);
356 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
357 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
359 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
360 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
361 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
365 /**************************
366 * CALCULATE INTERACTIONS *
367 **************************/
369 if (gmx_mm_any_lt(rsq11,rcutoff2))
372 r11 = _mm_mul_ps(rsq11,rinv11);
374 /* EWALD ELECTROSTATICS */
376 /* Analytical PME correction */
377 zeta2 = _mm_mul_ps(beta2,rsq11);
378 rinv3 = _mm_mul_ps(rinvsq11,rinv11);
379 pmecorrF = avx128fma_pmecorrF_f(zeta2);
380 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
381 felec = _mm_mul_ps(qq11,felec);
382 pmecorrV = avx128fma_pmecorrV_f(zeta2);
383 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv11,sh_ewald));
384 velec = _mm_mul_ps(qq11,velec);
386 cutoff_mask = _mm_cmplt_ps(rsq11,rcutoff2);
388 /* Update potential sum for this i atom from the interaction with this j atom. */
389 velec = _mm_and_ps(velec,cutoff_mask);
390 velecsum = _mm_add_ps(velecsum,velec);
394 fscal = _mm_and_ps(fscal,cutoff_mask);
396 /* Update vectorial force */
397 fix1 = _mm_macc_ps(dx11,fscal,fix1);
398 fiy1 = _mm_macc_ps(dy11,fscal,fiy1);
399 fiz1 = _mm_macc_ps(dz11,fscal,fiz1);
401 fjx1 = _mm_macc_ps(dx11,fscal,fjx1);
402 fjy1 = _mm_macc_ps(dy11,fscal,fjy1);
403 fjz1 = _mm_macc_ps(dz11,fscal,fjz1);
407 /**************************
408 * CALCULATE INTERACTIONS *
409 **************************/
411 if (gmx_mm_any_lt(rsq12,rcutoff2))
414 r12 = _mm_mul_ps(rsq12,rinv12);
416 /* EWALD ELECTROSTATICS */
418 /* Analytical PME correction */
419 zeta2 = _mm_mul_ps(beta2,rsq12);
420 rinv3 = _mm_mul_ps(rinvsq12,rinv12);
421 pmecorrF = avx128fma_pmecorrF_f(zeta2);
422 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
423 felec = _mm_mul_ps(qq12,felec);
424 pmecorrV = avx128fma_pmecorrV_f(zeta2);
425 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv12,sh_ewald));
426 velec = _mm_mul_ps(qq12,velec);
428 cutoff_mask = _mm_cmplt_ps(rsq12,rcutoff2);
430 /* Update potential sum for this i atom from the interaction with this j atom. */
431 velec = _mm_and_ps(velec,cutoff_mask);
432 velecsum = _mm_add_ps(velecsum,velec);
436 fscal = _mm_and_ps(fscal,cutoff_mask);
438 /* Update vectorial force */
439 fix1 = _mm_macc_ps(dx12,fscal,fix1);
440 fiy1 = _mm_macc_ps(dy12,fscal,fiy1);
441 fiz1 = _mm_macc_ps(dz12,fscal,fiz1);
443 fjx2 = _mm_macc_ps(dx12,fscal,fjx2);
444 fjy2 = _mm_macc_ps(dy12,fscal,fjy2);
445 fjz2 = _mm_macc_ps(dz12,fscal,fjz2);
449 /**************************
450 * CALCULATE INTERACTIONS *
451 **************************/
453 if (gmx_mm_any_lt(rsq13,rcutoff2))
456 r13 = _mm_mul_ps(rsq13,rinv13);
458 /* EWALD ELECTROSTATICS */
460 /* Analytical PME correction */
461 zeta2 = _mm_mul_ps(beta2,rsq13);
462 rinv3 = _mm_mul_ps(rinvsq13,rinv13);
463 pmecorrF = avx128fma_pmecorrF_f(zeta2);
464 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
465 felec = _mm_mul_ps(qq13,felec);
466 pmecorrV = avx128fma_pmecorrV_f(zeta2);
467 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv13,sh_ewald));
468 velec = _mm_mul_ps(qq13,velec);
470 cutoff_mask = _mm_cmplt_ps(rsq13,rcutoff2);
472 /* Update potential sum for this i atom from the interaction with this j atom. */
473 velec = _mm_and_ps(velec,cutoff_mask);
474 velecsum = _mm_add_ps(velecsum,velec);
478 fscal = _mm_and_ps(fscal,cutoff_mask);
480 /* Update vectorial force */
481 fix1 = _mm_macc_ps(dx13,fscal,fix1);
482 fiy1 = _mm_macc_ps(dy13,fscal,fiy1);
483 fiz1 = _mm_macc_ps(dz13,fscal,fiz1);
485 fjx3 = _mm_macc_ps(dx13,fscal,fjx3);
486 fjy3 = _mm_macc_ps(dy13,fscal,fjy3);
487 fjz3 = _mm_macc_ps(dz13,fscal,fjz3);
491 /**************************
492 * CALCULATE INTERACTIONS *
493 **************************/
495 if (gmx_mm_any_lt(rsq21,rcutoff2))
498 r21 = _mm_mul_ps(rsq21,rinv21);
500 /* EWALD ELECTROSTATICS */
502 /* Analytical PME correction */
503 zeta2 = _mm_mul_ps(beta2,rsq21);
504 rinv3 = _mm_mul_ps(rinvsq21,rinv21);
505 pmecorrF = avx128fma_pmecorrF_f(zeta2);
506 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
507 felec = _mm_mul_ps(qq21,felec);
508 pmecorrV = avx128fma_pmecorrV_f(zeta2);
509 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv21,sh_ewald));
510 velec = _mm_mul_ps(qq21,velec);
512 cutoff_mask = _mm_cmplt_ps(rsq21,rcutoff2);
514 /* Update potential sum for this i atom from the interaction with this j atom. */
515 velec = _mm_and_ps(velec,cutoff_mask);
516 velecsum = _mm_add_ps(velecsum,velec);
520 fscal = _mm_and_ps(fscal,cutoff_mask);
522 /* Update vectorial force */
523 fix2 = _mm_macc_ps(dx21,fscal,fix2);
524 fiy2 = _mm_macc_ps(dy21,fscal,fiy2);
525 fiz2 = _mm_macc_ps(dz21,fscal,fiz2);
527 fjx1 = _mm_macc_ps(dx21,fscal,fjx1);
528 fjy1 = _mm_macc_ps(dy21,fscal,fjy1);
529 fjz1 = _mm_macc_ps(dz21,fscal,fjz1);
533 /**************************
534 * CALCULATE INTERACTIONS *
535 **************************/
537 if (gmx_mm_any_lt(rsq22,rcutoff2))
540 r22 = _mm_mul_ps(rsq22,rinv22);
542 /* EWALD ELECTROSTATICS */
544 /* Analytical PME correction */
545 zeta2 = _mm_mul_ps(beta2,rsq22);
546 rinv3 = _mm_mul_ps(rinvsq22,rinv22);
547 pmecorrF = avx128fma_pmecorrF_f(zeta2);
548 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
549 felec = _mm_mul_ps(qq22,felec);
550 pmecorrV = avx128fma_pmecorrV_f(zeta2);
551 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv22,sh_ewald));
552 velec = _mm_mul_ps(qq22,velec);
554 cutoff_mask = _mm_cmplt_ps(rsq22,rcutoff2);
556 /* Update potential sum for this i atom from the interaction with this j atom. */
557 velec = _mm_and_ps(velec,cutoff_mask);
558 velecsum = _mm_add_ps(velecsum,velec);
562 fscal = _mm_and_ps(fscal,cutoff_mask);
564 /* Update vectorial force */
565 fix2 = _mm_macc_ps(dx22,fscal,fix2);
566 fiy2 = _mm_macc_ps(dy22,fscal,fiy2);
567 fiz2 = _mm_macc_ps(dz22,fscal,fiz2);
569 fjx2 = _mm_macc_ps(dx22,fscal,fjx2);
570 fjy2 = _mm_macc_ps(dy22,fscal,fjy2);
571 fjz2 = _mm_macc_ps(dz22,fscal,fjz2);
575 /**************************
576 * CALCULATE INTERACTIONS *
577 **************************/
579 if (gmx_mm_any_lt(rsq23,rcutoff2))
582 r23 = _mm_mul_ps(rsq23,rinv23);
584 /* EWALD ELECTROSTATICS */
586 /* Analytical PME correction */
587 zeta2 = _mm_mul_ps(beta2,rsq23);
588 rinv3 = _mm_mul_ps(rinvsq23,rinv23);
589 pmecorrF = avx128fma_pmecorrF_f(zeta2);
590 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
591 felec = _mm_mul_ps(qq23,felec);
592 pmecorrV = avx128fma_pmecorrV_f(zeta2);
593 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv23,sh_ewald));
594 velec = _mm_mul_ps(qq23,velec);
596 cutoff_mask = _mm_cmplt_ps(rsq23,rcutoff2);
598 /* Update potential sum for this i atom from the interaction with this j atom. */
599 velec = _mm_and_ps(velec,cutoff_mask);
600 velecsum = _mm_add_ps(velecsum,velec);
604 fscal = _mm_and_ps(fscal,cutoff_mask);
606 /* Update vectorial force */
607 fix2 = _mm_macc_ps(dx23,fscal,fix2);
608 fiy2 = _mm_macc_ps(dy23,fscal,fiy2);
609 fiz2 = _mm_macc_ps(dz23,fscal,fiz2);
611 fjx3 = _mm_macc_ps(dx23,fscal,fjx3);
612 fjy3 = _mm_macc_ps(dy23,fscal,fjy3);
613 fjz3 = _mm_macc_ps(dz23,fscal,fjz3);
617 /**************************
618 * CALCULATE INTERACTIONS *
619 **************************/
621 if (gmx_mm_any_lt(rsq31,rcutoff2))
624 r31 = _mm_mul_ps(rsq31,rinv31);
626 /* EWALD ELECTROSTATICS */
628 /* Analytical PME correction */
629 zeta2 = _mm_mul_ps(beta2,rsq31);
630 rinv3 = _mm_mul_ps(rinvsq31,rinv31);
631 pmecorrF = avx128fma_pmecorrF_f(zeta2);
632 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
633 felec = _mm_mul_ps(qq31,felec);
634 pmecorrV = avx128fma_pmecorrV_f(zeta2);
635 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv31,sh_ewald));
636 velec = _mm_mul_ps(qq31,velec);
638 cutoff_mask = _mm_cmplt_ps(rsq31,rcutoff2);
640 /* Update potential sum for this i atom from the interaction with this j atom. */
641 velec = _mm_and_ps(velec,cutoff_mask);
642 velecsum = _mm_add_ps(velecsum,velec);
646 fscal = _mm_and_ps(fscal,cutoff_mask);
648 /* Update vectorial force */
649 fix3 = _mm_macc_ps(dx31,fscal,fix3);
650 fiy3 = _mm_macc_ps(dy31,fscal,fiy3);
651 fiz3 = _mm_macc_ps(dz31,fscal,fiz3);
653 fjx1 = _mm_macc_ps(dx31,fscal,fjx1);
654 fjy1 = _mm_macc_ps(dy31,fscal,fjy1);
655 fjz1 = _mm_macc_ps(dz31,fscal,fjz1);
659 /**************************
660 * CALCULATE INTERACTIONS *
661 **************************/
663 if (gmx_mm_any_lt(rsq32,rcutoff2))
666 r32 = _mm_mul_ps(rsq32,rinv32);
668 /* EWALD ELECTROSTATICS */
670 /* Analytical PME correction */
671 zeta2 = _mm_mul_ps(beta2,rsq32);
672 rinv3 = _mm_mul_ps(rinvsq32,rinv32);
673 pmecorrF = avx128fma_pmecorrF_f(zeta2);
674 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
675 felec = _mm_mul_ps(qq32,felec);
676 pmecorrV = avx128fma_pmecorrV_f(zeta2);
677 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv32,sh_ewald));
678 velec = _mm_mul_ps(qq32,velec);
680 cutoff_mask = _mm_cmplt_ps(rsq32,rcutoff2);
682 /* Update potential sum for this i atom from the interaction with this j atom. */
683 velec = _mm_and_ps(velec,cutoff_mask);
684 velecsum = _mm_add_ps(velecsum,velec);
688 fscal = _mm_and_ps(fscal,cutoff_mask);
690 /* Update vectorial force */
691 fix3 = _mm_macc_ps(dx32,fscal,fix3);
692 fiy3 = _mm_macc_ps(dy32,fscal,fiy3);
693 fiz3 = _mm_macc_ps(dz32,fscal,fiz3);
695 fjx2 = _mm_macc_ps(dx32,fscal,fjx2);
696 fjy2 = _mm_macc_ps(dy32,fscal,fjy2);
697 fjz2 = _mm_macc_ps(dz32,fscal,fjz2);
701 /**************************
702 * CALCULATE INTERACTIONS *
703 **************************/
705 if (gmx_mm_any_lt(rsq33,rcutoff2))
708 r33 = _mm_mul_ps(rsq33,rinv33);
710 /* EWALD ELECTROSTATICS */
712 /* Analytical PME correction */
713 zeta2 = _mm_mul_ps(beta2,rsq33);
714 rinv3 = _mm_mul_ps(rinvsq33,rinv33);
715 pmecorrF = avx128fma_pmecorrF_f(zeta2);
716 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
717 felec = _mm_mul_ps(qq33,felec);
718 pmecorrV = avx128fma_pmecorrV_f(zeta2);
719 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv33,sh_ewald));
720 velec = _mm_mul_ps(qq33,velec);
722 cutoff_mask = _mm_cmplt_ps(rsq33,rcutoff2);
724 /* Update potential sum for this i atom from the interaction with this j atom. */
725 velec = _mm_and_ps(velec,cutoff_mask);
726 velecsum = _mm_add_ps(velecsum,velec);
730 fscal = _mm_and_ps(fscal,cutoff_mask);
732 /* Update vectorial force */
733 fix3 = _mm_macc_ps(dx33,fscal,fix3);
734 fiy3 = _mm_macc_ps(dy33,fscal,fiy3);
735 fiz3 = _mm_macc_ps(dz33,fscal,fiz3);
737 fjx3 = _mm_macc_ps(dx33,fscal,fjx3);
738 fjy3 = _mm_macc_ps(dy33,fscal,fjy3);
739 fjz3 = _mm_macc_ps(dz33,fscal,fjz3);
743 fjptrA = f+j_coord_offsetA;
744 fjptrB = f+j_coord_offsetB;
745 fjptrC = f+j_coord_offsetC;
746 fjptrD = f+j_coord_offsetD;
748 gmx_mm_decrement_4rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
749 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
750 fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
752 /* Inner loop uses 344 flops */
758 /* Get j neighbor index, and coordinate index */
759 jnrlistA = jjnr[jidx];
760 jnrlistB = jjnr[jidx+1];
761 jnrlistC = jjnr[jidx+2];
762 jnrlistD = jjnr[jidx+3];
763 /* Sign of each element will be negative for non-real atoms.
764 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
765 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
767 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
768 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
769 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
770 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
771 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
772 j_coord_offsetA = DIM*jnrA;
773 j_coord_offsetB = DIM*jnrB;
774 j_coord_offsetC = DIM*jnrC;
775 j_coord_offsetD = DIM*jnrD;
777 /* load j atom coordinates */
778 gmx_mm_load_4rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
779 x+j_coord_offsetC,x+j_coord_offsetD,
780 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
781 &jy2,&jz2,&jx3,&jy3,&jz3);
783 /* Calculate displacement vector */
784 dx00 = _mm_sub_ps(ix0,jx0);
785 dy00 = _mm_sub_ps(iy0,jy0);
786 dz00 = _mm_sub_ps(iz0,jz0);
787 dx11 = _mm_sub_ps(ix1,jx1);
788 dy11 = _mm_sub_ps(iy1,jy1);
789 dz11 = _mm_sub_ps(iz1,jz1);
790 dx12 = _mm_sub_ps(ix1,jx2);
791 dy12 = _mm_sub_ps(iy1,jy2);
792 dz12 = _mm_sub_ps(iz1,jz2);
793 dx13 = _mm_sub_ps(ix1,jx3);
794 dy13 = _mm_sub_ps(iy1,jy3);
795 dz13 = _mm_sub_ps(iz1,jz3);
796 dx21 = _mm_sub_ps(ix2,jx1);
797 dy21 = _mm_sub_ps(iy2,jy1);
798 dz21 = _mm_sub_ps(iz2,jz1);
799 dx22 = _mm_sub_ps(ix2,jx2);
800 dy22 = _mm_sub_ps(iy2,jy2);
801 dz22 = _mm_sub_ps(iz2,jz2);
802 dx23 = _mm_sub_ps(ix2,jx3);
803 dy23 = _mm_sub_ps(iy2,jy3);
804 dz23 = _mm_sub_ps(iz2,jz3);
805 dx31 = _mm_sub_ps(ix3,jx1);
806 dy31 = _mm_sub_ps(iy3,jy1);
807 dz31 = _mm_sub_ps(iz3,jz1);
808 dx32 = _mm_sub_ps(ix3,jx2);
809 dy32 = _mm_sub_ps(iy3,jy2);
810 dz32 = _mm_sub_ps(iz3,jz2);
811 dx33 = _mm_sub_ps(ix3,jx3);
812 dy33 = _mm_sub_ps(iy3,jy3);
813 dz33 = _mm_sub_ps(iz3,jz3);
815 /* Calculate squared distance and things based on it */
816 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
817 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
818 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
819 rsq13 = gmx_mm_calc_rsq_ps(dx13,dy13,dz13);
820 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
821 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
822 rsq23 = gmx_mm_calc_rsq_ps(dx23,dy23,dz23);
823 rsq31 = gmx_mm_calc_rsq_ps(dx31,dy31,dz31);
824 rsq32 = gmx_mm_calc_rsq_ps(dx32,dy32,dz32);
825 rsq33 = gmx_mm_calc_rsq_ps(dx33,dy33,dz33);
827 rinv11 = avx128fma_invsqrt_f(rsq11);
828 rinv12 = avx128fma_invsqrt_f(rsq12);
829 rinv13 = avx128fma_invsqrt_f(rsq13);
830 rinv21 = avx128fma_invsqrt_f(rsq21);
831 rinv22 = avx128fma_invsqrt_f(rsq22);
832 rinv23 = avx128fma_invsqrt_f(rsq23);
833 rinv31 = avx128fma_invsqrt_f(rsq31);
834 rinv32 = avx128fma_invsqrt_f(rsq32);
835 rinv33 = avx128fma_invsqrt_f(rsq33);
837 rinvsq00 = avx128fma_inv_f(rsq00);
838 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
839 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
840 rinvsq13 = _mm_mul_ps(rinv13,rinv13);
841 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
842 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
843 rinvsq23 = _mm_mul_ps(rinv23,rinv23);
844 rinvsq31 = _mm_mul_ps(rinv31,rinv31);
845 rinvsq32 = _mm_mul_ps(rinv32,rinv32);
846 rinvsq33 = _mm_mul_ps(rinv33,rinv33);
848 fjx0 = _mm_setzero_ps();
849 fjy0 = _mm_setzero_ps();
850 fjz0 = _mm_setzero_ps();
851 fjx1 = _mm_setzero_ps();
852 fjy1 = _mm_setzero_ps();
853 fjz1 = _mm_setzero_ps();
854 fjx2 = _mm_setzero_ps();
855 fjy2 = _mm_setzero_ps();
856 fjz2 = _mm_setzero_ps();
857 fjx3 = _mm_setzero_ps();
858 fjy3 = _mm_setzero_ps();
859 fjz3 = _mm_setzero_ps();
861 /**************************
862 * CALCULATE INTERACTIONS *
863 **************************/
865 if (gmx_mm_any_lt(rsq00,rcutoff2))
868 /* LENNARD-JONES DISPERSION/REPULSION */
870 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
871 vvdw6 = _mm_mul_ps(c6_00,rinvsix);
872 vvdw12 = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
873 vvdw = _mm_msub_ps(_mm_nmacc_ps(c12_00,_mm_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
874 _mm_mul_ps( _mm_nmacc_ps(c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
875 fvdw = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
877 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
879 /* Update potential sum for this i atom from the interaction with this j atom. */
880 vvdw = _mm_and_ps(vvdw,cutoff_mask);
881 vvdw = _mm_andnot_ps(dummy_mask,vvdw);
882 vvdwsum = _mm_add_ps(vvdwsum,vvdw);
886 fscal = _mm_and_ps(fscal,cutoff_mask);
888 fscal = _mm_andnot_ps(dummy_mask,fscal);
890 /* Update vectorial force */
891 fix0 = _mm_macc_ps(dx00,fscal,fix0);
892 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
893 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
895 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
896 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
897 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
901 /**************************
902 * CALCULATE INTERACTIONS *
903 **************************/
905 if (gmx_mm_any_lt(rsq11,rcutoff2))
908 r11 = _mm_mul_ps(rsq11,rinv11);
909 r11 = _mm_andnot_ps(dummy_mask,r11);
911 /* EWALD ELECTROSTATICS */
913 /* Analytical PME correction */
914 zeta2 = _mm_mul_ps(beta2,rsq11);
915 rinv3 = _mm_mul_ps(rinvsq11,rinv11);
916 pmecorrF = avx128fma_pmecorrF_f(zeta2);
917 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
918 felec = _mm_mul_ps(qq11,felec);
919 pmecorrV = avx128fma_pmecorrV_f(zeta2);
920 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv11,sh_ewald));
921 velec = _mm_mul_ps(qq11,velec);
923 cutoff_mask = _mm_cmplt_ps(rsq11,rcutoff2);
925 /* Update potential sum for this i atom from the interaction with this j atom. */
926 velec = _mm_and_ps(velec,cutoff_mask);
927 velec = _mm_andnot_ps(dummy_mask,velec);
928 velecsum = _mm_add_ps(velecsum,velec);
932 fscal = _mm_and_ps(fscal,cutoff_mask);
934 fscal = _mm_andnot_ps(dummy_mask,fscal);
936 /* Update vectorial force */
937 fix1 = _mm_macc_ps(dx11,fscal,fix1);
938 fiy1 = _mm_macc_ps(dy11,fscal,fiy1);
939 fiz1 = _mm_macc_ps(dz11,fscal,fiz1);
941 fjx1 = _mm_macc_ps(dx11,fscal,fjx1);
942 fjy1 = _mm_macc_ps(dy11,fscal,fjy1);
943 fjz1 = _mm_macc_ps(dz11,fscal,fjz1);
947 /**************************
948 * CALCULATE INTERACTIONS *
949 **************************/
951 if (gmx_mm_any_lt(rsq12,rcutoff2))
954 r12 = _mm_mul_ps(rsq12,rinv12);
955 r12 = _mm_andnot_ps(dummy_mask,r12);
957 /* EWALD ELECTROSTATICS */
959 /* Analytical PME correction */
960 zeta2 = _mm_mul_ps(beta2,rsq12);
961 rinv3 = _mm_mul_ps(rinvsq12,rinv12);
962 pmecorrF = avx128fma_pmecorrF_f(zeta2);
963 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
964 felec = _mm_mul_ps(qq12,felec);
965 pmecorrV = avx128fma_pmecorrV_f(zeta2);
966 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv12,sh_ewald));
967 velec = _mm_mul_ps(qq12,velec);
969 cutoff_mask = _mm_cmplt_ps(rsq12,rcutoff2);
971 /* Update potential sum for this i atom from the interaction with this j atom. */
972 velec = _mm_and_ps(velec,cutoff_mask);
973 velec = _mm_andnot_ps(dummy_mask,velec);
974 velecsum = _mm_add_ps(velecsum,velec);
978 fscal = _mm_and_ps(fscal,cutoff_mask);
980 fscal = _mm_andnot_ps(dummy_mask,fscal);
982 /* Update vectorial force */
983 fix1 = _mm_macc_ps(dx12,fscal,fix1);
984 fiy1 = _mm_macc_ps(dy12,fscal,fiy1);
985 fiz1 = _mm_macc_ps(dz12,fscal,fiz1);
987 fjx2 = _mm_macc_ps(dx12,fscal,fjx2);
988 fjy2 = _mm_macc_ps(dy12,fscal,fjy2);
989 fjz2 = _mm_macc_ps(dz12,fscal,fjz2);
993 /**************************
994 * CALCULATE INTERACTIONS *
995 **************************/
997 if (gmx_mm_any_lt(rsq13,rcutoff2))
1000 r13 = _mm_mul_ps(rsq13,rinv13);
1001 r13 = _mm_andnot_ps(dummy_mask,r13);
1003 /* EWALD ELECTROSTATICS */
1005 /* Analytical PME correction */
1006 zeta2 = _mm_mul_ps(beta2,rsq13);
1007 rinv3 = _mm_mul_ps(rinvsq13,rinv13);
1008 pmecorrF = avx128fma_pmecorrF_f(zeta2);
1009 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1010 felec = _mm_mul_ps(qq13,felec);
1011 pmecorrV = avx128fma_pmecorrV_f(zeta2);
1012 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv13,sh_ewald));
1013 velec = _mm_mul_ps(qq13,velec);
1015 cutoff_mask = _mm_cmplt_ps(rsq13,rcutoff2);
1017 /* Update potential sum for this i atom from the interaction with this j atom. */
1018 velec = _mm_and_ps(velec,cutoff_mask);
1019 velec = _mm_andnot_ps(dummy_mask,velec);
1020 velecsum = _mm_add_ps(velecsum,velec);
1024 fscal = _mm_and_ps(fscal,cutoff_mask);
1026 fscal = _mm_andnot_ps(dummy_mask,fscal);
1028 /* Update vectorial force */
1029 fix1 = _mm_macc_ps(dx13,fscal,fix1);
1030 fiy1 = _mm_macc_ps(dy13,fscal,fiy1);
1031 fiz1 = _mm_macc_ps(dz13,fscal,fiz1);
1033 fjx3 = _mm_macc_ps(dx13,fscal,fjx3);
1034 fjy3 = _mm_macc_ps(dy13,fscal,fjy3);
1035 fjz3 = _mm_macc_ps(dz13,fscal,fjz3);
1039 /**************************
1040 * CALCULATE INTERACTIONS *
1041 **************************/
1043 if (gmx_mm_any_lt(rsq21,rcutoff2))
1046 r21 = _mm_mul_ps(rsq21,rinv21);
1047 r21 = _mm_andnot_ps(dummy_mask,r21);
1049 /* EWALD ELECTROSTATICS */
1051 /* Analytical PME correction */
1052 zeta2 = _mm_mul_ps(beta2,rsq21);
1053 rinv3 = _mm_mul_ps(rinvsq21,rinv21);
1054 pmecorrF = avx128fma_pmecorrF_f(zeta2);
1055 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1056 felec = _mm_mul_ps(qq21,felec);
1057 pmecorrV = avx128fma_pmecorrV_f(zeta2);
1058 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv21,sh_ewald));
1059 velec = _mm_mul_ps(qq21,velec);
1061 cutoff_mask = _mm_cmplt_ps(rsq21,rcutoff2);
1063 /* Update potential sum for this i atom from the interaction with this j atom. */
1064 velec = _mm_and_ps(velec,cutoff_mask);
1065 velec = _mm_andnot_ps(dummy_mask,velec);
1066 velecsum = _mm_add_ps(velecsum,velec);
1070 fscal = _mm_and_ps(fscal,cutoff_mask);
1072 fscal = _mm_andnot_ps(dummy_mask,fscal);
1074 /* Update vectorial force */
1075 fix2 = _mm_macc_ps(dx21,fscal,fix2);
1076 fiy2 = _mm_macc_ps(dy21,fscal,fiy2);
1077 fiz2 = _mm_macc_ps(dz21,fscal,fiz2);
1079 fjx1 = _mm_macc_ps(dx21,fscal,fjx1);
1080 fjy1 = _mm_macc_ps(dy21,fscal,fjy1);
1081 fjz1 = _mm_macc_ps(dz21,fscal,fjz1);
1085 /**************************
1086 * CALCULATE INTERACTIONS *
1087 **************************/
1089 if (gmx_mm_any_lt(rsq22,rcutoff2))
1092 r22 = _mm_mul_ps(rsq22,rinv22);
1093 r22 = _mm_andnot_ps(dummy_mask,r22);
1095 /* EWALD ELECTROSTATICS */
1097 /* Analytical PME correction */
1098 zeta2 = _mm_mul_ps(beta2,rsq22);
1099 rinv3 = _mm_mul_ps(rinvsq22,rinv22);
1100 pmecorrF = avx128fma_pmecorrF_f(zeta2);
1101 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1102 felec = _mm_mul_ps(qq22,felec);
1103 pmecorrV = avx128fma_pmecorrV_f(zeta2);
1104 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv22,sh_ewald));
1105 velec = _mm_mul_ps(qq22,velec);
1107 cutoff_mask = _mm_cmplt_ps(rsq22,rcutoff2);
1109 /* Update potential sum for this i atom from the interaction with this j atom. */
1110 velec = _mm_and_ps(velec,cutoff_mask);
1111 velec = _mm_andnot_ps(dummy_mask,velec);
1112 velecsum = _mm_add_ps(velecsum,velec);
1116 fscal = _mm_and_ps(fscal,cutoff_mask);
1118 fscal = _mm_andnot_ps(dummy_mask,fscal);
1120 /* Update vectorial force */
1121 fix2 = _mm_macc_ps(dx22,fscal,fix2);
1122 fiy2 = _mm_macc_ps(dy22,fscal,fiy2);
1123 fiz2 = _mm_macc_ps(dz22,fscal,fiz2);
1125 fjx2 = _mm_macc_ps(dx22,fscal,fjx2);
1126 fjy2 = _mm_macc_ps(dy22,fscal,fjy2);
1127 fjz2 = _mm_macc_ps(dz22,fscal,fjz2);
1131 /**************************
1132 * CALCULATE INTERACTIONS *
1133 **************************/
1135 if (gmx_mm_any_lt(rsq23,rcutoff2))
1138 r23 = _mm_mul_ps(rsq23,rinv23);
1139 r23 = _mm_andnot_ps(dummy_mask,r23);
1141 /* EWALD ELECTROSTATICS */
1143 /* Analytical PME correction */
1144 zeta2 = _mm_mul_ps(beta2,rsq23);
1145 rinv3 = _mm_mul_ps(rinvsq23,rinv23);
1146 pmecorrF = avx128fma_pmecorrF_f(zeta2);
1147 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1148 felec = _mm_mul_ps(qq23,felec);
1149 pmecorrV = avx128fma_pmecorrV_f(zeta2);
1150 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv23,sh_ewald));
1151 velec = _mm_mul_ps(qq23,velec);
1153 cutoff_mask = _mm_cmplt_ps(rsq23,rcutoff2);
1155 /* Update potential sum for this i atom from the interaction with this j atom. */
1156 velec = _mm_and_ps(velec,cutoff_mask);
1157 velec = _mm_andnot_ps(dummy_mask,velec);
1158 velecsum = _mm_add_ps(velecsum,velec);
1162 fscal = _mm_and_ps(fscal,cutoff_mask);
1164 fscal = _mm_andnot_ps(dummy_mask,fscal);
1166 /* Update vectorial force */
1167 fix2 = _mm_macc_ps(dx23,fscal,fix2);
1168 fiy2 = _mm_macc_ps(dy23,fscal,fiy2);
1169 fiz2 = _mm_macc_ps(dz23,fscal,fiz2);
1171 fjx3 = _mm_macc_ps(dx23,fscal,fjx3);
1172 fjy3 = _mm_macc_ps(dy23,fscal,fjy3);
1173 fjz3 = _mm_macc_ps(dz23,fscal,fjz3);
1177 /**************************
1178 * CALCULATE INTERACTIONS *
1179 **************************/
1181 if (gmx_mm_any_lt(rsq31,rcutoff2))
1184 r31 = _mm_mul_ps(rsq31,rinv31);
1185 r31 = _mm_andnot_ps(dummy_mask,r31);
1187 /* EWALD ELECTROSTATICS */
1189 /* Analytical PME correction */
1190 zeta2 = _mm_mul_ps(beta2,rsq31);
1191 rinv3 = _mm_mul_ps(rinvsq31,rinv31);
1192 pmecorrF = avx128fma_pmecorrF_f(zeta2);
1193 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1194 felec = _mm_mul_ps(qq31,felec);
1195 pmecorrV = avx128fma_pmecorrV_f(zeta2);
1196 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv31,sh_ewald));
1197 velec = _mm_mul_ps(qq31,velec);
1199 cutoff_mask = _mm_cmplt_ps(rsq31,rcutoff2);
1201 /* Update potential sum for this i atom from the interaction with this j atom. */
1202 velec = _mm_and_ps(velec,cutoff_mask);
1203 velec = _mm_andnot_ps(dummy_mask,velec);
1204 velecsum = _mm_add_ps(velecsum,velec);
1208 fscal = _mm_and_ps(fscal,cutoff_mask);
1210 fscal = _mm_andnot_ps(dummy_mask,fscal);
1212 /* Update vectorial force */
1213 fix3 = _mm_macc_ps(dx31,fscal,fix3);
1214 fiy3 = _mm_macc_ps(dy31,fscal,fiy3);
1215 fiz3 = _mm_macc_ps(dz31,fscal,fiz3);
1217 fjx1 = _mm_macc_ps(dx31,fscal,fjx1);
1218 fjy1 = _mm_macc_ps(dy31,fscal,fjy1);
1219 fjz1 = _mm_macc_ps(dz31,fscal,fjz1);
1223 /**************************
1224 * CALCULATE INTERACTIONS *
1225 **************************/
1227 if (gmx_mm_any_lt(rsq32,rcutoff2))
1230 r32 = _mm_mul_ps(rsq32,rinv32);
1231 r32 = _mm_andnot_ps(dummy_mask,r32);
1233 /* EWALD ELECTROSTATICS */
1235 /* Analytical PME correction */
1236 zeta2 = _mm_mul_ps(beta2,rsq32);
1237 rinv3 = _mm_mul_ps(rinvsq32,rinv32);
1238 pmecorrF = avx128fma_pmecorrF_f(zeta2);
1239 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1240 felec = _mm_mul_ps(qq32,felec);
1241 pmecorrV = avx128fma_pmecorrV_f(zeta2);
1242 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv32,sh_ewald));
1243 velec = _mm_mul_ps(qq32,velec);
1245 cutoff_mask = _mm_cmplt_ps(rsq32,rcutoff2);
1247 /* Update potential sum for this i atom from the interaction with this j atom. */
1248 velec = _mm_and_ps(velec,cutoff_mask);
1249 velec = _mm_andnot_ps(dummy_mask,velec);
1250 velecsum = _mm_add_ps(velecsum,velec);
1254 fscal = _mm_and_ps(fscal,cutoff_mask);
1256 fscal = _mm_andnot_ps(dummy_mask,fscal);
1258 /* Update vectorial force */
1259 fix3 = _mm_macc_ps(dx32,fscal,fix3);
1260 fiy3 = _mm_macc_ps(dy32,fscal,fiy3);
1261 fiz3 = _mm_macc_ps(dz32,fscal,fiz3);
1263 fjx2 = _mm_macc_ps(dx32,fscal,fjx2);
1264 fjy2 = _mm_macc_ps(dy32,fscal,fjy2);
1265 fjz2 = _mm_macc_ps(dz32,fscal,fjz2);
1269 /**************************
1270 * CALCULATE INTERACTIONS *
1271 **************************/
1273 if (gmx_mm_any_lt(rsq33,rcutoff2))
1276 r33 = _mm_mul_ps(rsq33,rinv33);
1277 r33 = _mm_andnot_ps(dummy_mask,r33);
1279 /* EWALD ELECTROSTATICS */
1281 /* Analytical PME correction */
1282 zeta2 = _mm_mul_ps(beta2,rsq33);
1283 rinv3 = _mm_mul_ps(rinvsq33,rinv33);
1284 pmecorrF = avx128fma_pmecorrF_f(zeta2);
1285 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1286 felec = _mm_mul_ps(qq33,felec);
1287 pmecorrV = avx128fma_pmecorrV_f(zeta2);
1288 velec = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv33,sh_ewald));
1289 velec = _mm_mul_ps(qq33,velec);
1291 cutoff_mask = _mm_cmplt_ps(rsq33,rcutoff2);
1293 /* Update potential sum for this i atom from the interaction with this j atom. */
1294 velec = _mm_and_ps(velec,cutoff_mask);
1295 velec = _mm_andnot_ps(dummy_mask,velec);
1296 velecsum = _mm_add_ps(velecsum,velec);
1300 fscal = _mm_and_ps(fscal,cutoff_mask);
1302 fscal = _mm_andnot_ps(dummy_mask,fscal);
1304 /* Update vectorial force */
1305 fix3 = _mm_macc_ps(dx33,fscal,fix3);
1306 fiy3 = _mm_macc_ps(dy33,fscal,fiy3);
1307 fiz3 = _mm_macc_ps(dz33,fscal,fiz3);
1309 fjx3 = _mm_macc_ps(dx33,fscal,fjx3);
1310 fjy3 = _mm_macc_ps(dy33,fscal,fjy3);
1311 fjz3 = _mm_macc_ps(dz33,fscal,fjz3);
1315 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1316 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1317 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1318 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1320 gmx_mm_decrement_4rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
1321 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
1322 fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1324 /* Inner loop uses 353 flops */
1327 /* End of innermost loop */
1329 gmx_mm_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1330 f+i_coord_offset,fshift+i_shift_offset);
1333 /* Update potential energies */
1334 gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
1335 gmx_mm_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
1337 /* Increment number of inner iterations */
1338 inneriter += j_index_end - j_index_start;
1340 /* Outer loop uses 26 flops */
1343 /* Increment number of outer iterations */
1346 /* Update outer/inner flops */
1348 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*26 + inneriter*353);
1351 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJSh_GeomW4W4_F_avx_128_fma_single
1352 * Electrostatics interaction: Ewald
1353 * VdW interaction: LennardJones
1354 * Geometry: Water4-Water4
1355 * Calculate force/pot: Force
1358 nb_kernel_ElecEwSh_VdwLJSh_GeomW4W4_F_avx_128_fma_single
1359 (t_nblist * gmx_restrict nlist,
1360 rvec * gmx_restrict xx,
1361 rvec * gmx_restrict ff,
1362 struct t_forcerec * gmx_restrict fr,
1363 t_mdatoms * gmx_restrict mdatoms,
1364 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
1365 t_nrnb * gmx_restrict nrnb)
1367 /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
1368 * just 0 for non-waters.
1369 * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
1370 * jnr indices corresponding to data put in the four positions in the SIMD register.
1372 int i_shift_offset,i_coord_offset,outeriter,inneriter;
1373 int j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
1374 int jnrA,jnrB,jnrC,jnrD;
1375 int jnrlistA,jnrlistB,jnrlistC,jnrlistD;
1376 int j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
1377 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
1378 real rcutoff_scalar;
1379 real *shiftvec,*fshift,*x,*f;
1380 real *fjptrA,*fjptrB,*fjptrC,*fjptrD;
1381 real scratch[4*DIM];
1382 __m128 fscal,rcutoff,rcutoff2,jidxall;
1384 __m128 ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
1386 __m128 ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
1388 __m128 ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
1390 __m128 ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
1391 int vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
1392 __m128 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
1393 int vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D;
1394 __m128 jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
1395 int vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D;
1396 __m128 jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
1397 int vdwjidx3A,vdwjidx3B,vdwjidx3C,vdwjidx3D;
1398 __m128 jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
1399 __m128 dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
1400 __m128 dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
1401 __m128 dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
1402 __m128 dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
1403 __m128 dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
1404 __m128 dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
1405 __m128 dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
1406 __m128 dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
1407 __m128 dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
1408 __m128 dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
1409 __m128 velec,felec,velecsum,facel,crf,krf,krf2;
1412 __m128 rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
1415 __m128 one_sixth = _mm_set1_ps(1.0/6.0);
1416 __m128 one_twelfth = _mm_set1_ps(1.0/12.0);
1418 __m128 ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
1419 __m128 beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
1421 __m128 dummy_mask,cutoff_mask;
1422 __m128 signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
1423 __m128 one = _mm_set1_ps(1.0);
1424 __m128 two = _mm_set1_ps(2.0);
1430 jindex = nlist->jindex;
1432 shiftidx = nlist->shift;
1434 shiftvec = fr->shift_vec[0];
1435 fshift = fr->fshift[0];
1436 facel = _mm_set1_ps(fr->ic->epsfac);
1437 charge = mdatoms->chargeA;
1438 nvdwtype = fr->ntype;
1439 vdwparam = fr->nbfp;
1440 vdwtype = mdatoms->typeA;
1442 sh_ewald = _mm_set1_ps(fr->ic->sh_ewald);
1443 beta = _mm_set1_ps(fr->ic->ewaldcoeff_q);
1444 beta2 = _mm_mul_ps(beta,beta);
1445 beta3 = _mm_mul_ps(beta,beta2);
1446 ewtab = fr->ic->tabq_coul_F;
1447 ewtabscale = _mm_set1_ps(fr->ic->tabq_scale);
1448 ewtabhalfspace = _mm_set1_ps(0.5/fr->ic->tabq_scale);
1450 /* Setup water-specific parameters */
1451 inr = nlist->iinr[0];
1452 iq1 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
1453 iq2 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
1454 iq3 = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
1455 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
1457 jq1 = _mm_set1_ps(charge[inr+1]);
1458 jq2 = _mm_set1_ps(charge[inr+2]);
1459 jq3 = _mm_set1_ps(charge[inr+3]);
1460 vdwjidx0A = 2*vdwtype[inr+0];
1461 c6_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A]);
1462 c12_00 = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A+1]);
1463 qq11 = _mm_mul_ps(iq1,jq1);
1464 qq12 = _mm_mul_ps(iq1,jq2);
1465 qq13 = _mm_mul_ps(iq1,jq3);
1466 qq21 = _mm_mul_ps(iq2,jq1);
1467 qq22 = _mm_mul_ps(iq2,jq2);
1468 qq23 = _mm_mul_ps(iq2,jq3);
1469 qq31 = _mm_mul_ps(iq3,jq1);
1470 qq32 = _mm_mul_ps(iq3,jq2);
1471 qq33 = _mm_mul_ps(iq3,jq3);
1473 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
1474 rcutoff_scalar = fr->ic->rcoulomb;
1475 rcutoff = _mm_set1_ps(rcutoff_scalar);
1476 rcutoff2 = _mm_mul_ps(rcutoff,rcutoff);
1478 sh_vdw_invrcut6 = _mm_set1_ps(fr->ic->sh_invrc6);
1479 rvdw = _mm_set1_ps(fr->ic->rvdw);
1481 /* Avoid stupid compiler warnings */
1482 jnrA = jnrB = jnrC = jnrD = 0;
1483 j_coord_offsetA = 0;
1484 j_coord_offsetB = 0;
1485 j_coord_offsetC = 0;
1486 j_coord_offsetD = 0;
1491 for(iidx=0;iidx<4*DIM;iidx++)
1493 scratch[iidx] = 0.0;
1496 /* Start outer loop over neighborlists */
1497 for(iidx=0; iidx<nri; iidx++)
1499 /* Load shift vector for this list */
1500 i_shift_offset = DIM*shiftidx[iidx];
1502 /* Load limits for loop over neighbors */
1503 j_index_start = jindex[iidx];
1504 j_index_end = jindex[iidx+1];
1506 /* Get outer coordinate index */
1508 i_coord_offset = DIM*inr;
1510 /* Load i particle coords and add shift vector */
1511 gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
1512 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
1514 fix0 = _mm_setzero_ps();
1515 fiy0 = _mm_setzero_ps();
1516 fiz0 = _mm_setzero_ps();
1517 fix1 = _mm_setzero_ps();
1518 fiy1 = _mm_setzero_ps();
1519 fiz1 = _mm_setzero_ps();
1520 fix2 = _mm_setzero_ps();
1521 fiy2 = _mm_setzero_ps();
1522 fiz2 = _mm_setzero_ps();
1523 fix3 = _mm_setzero_ps();
1524 fiy3 = _mm_setzero_ps();
1525 fiz3 = _mm_setzero_ps();
1527 /* Start inner kernel loop */
1528 for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
1531 /* Get j neighbor index, and coordinate index */
1533 jnrB = jjnr[jidx+1];
1534 jnrC = jjnr[jidx+2];
1535 jnrD = jjnr[jidx+3];
1536 j_coord_offsetA = DIM*jnrA;
1537 j_coord_offsetB = DIM*jnrB;
1538 j_coord_offsetC = DIM*jnrC;
1539 j_coord_offsetD = DIM*jnrD;
1541 /* load j atom coordinates */
1542 gmx_mm_load_4rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1543 x+j_coord_offsetC,x+j_coord_offsetD,
1544 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
1545 &jy2,&jz2,&jx3,&jy3,&jz3);
1547 /* Calculate displacement vector */
1548 dx00 = _mm_sub_ps(ix0,jx0);
1549 dy00 = _mm_sub_ps(iy0,jy0);
1550 dz00 = _mm_sub_ps(iz0,jz0);
1551 dx11 = _mm_sub_ps(ix1,jx1);
1552 dy11 = _mm_sub_ps(iy1,jy1);
1553 dz11 = _mm_sub_ps(iz1,jz1);
1554 dx12 = _mm_sub_ps(ix1,jx2);
1555 dy12 = _mm_sub_ps(iy1,jy2);
1556 dz12 = _mm_sub_ps(iz1,jz2);
1557 dx13 = _mm_sub_ps(ix1,jx3);
1558 dy13 = _mm_sub_ps(iy1,jy3);
1559 dz13 = _mm_sub_ps(iz1,jz3);
1560 dx21 = _mm_sub_ps(ix2,jx1);
1561 dy21 = _mm_sub_ps(iy2,jy1);
1562 dz21 = _mm_sub_ps(iz2,jz1);
1563 dx22 = _mm_sub_ps(ix2,jx2);
1564 dy22 = _mm_sub_ps(iy2,jy2);
1565 dz22 = _mm_sub_ps(iz2,jz2);
1566 dx23 = _mm_sub_ps(ix2,jx3);
1567 dy23 = _mm_sub_ps(iy2,jy3);
1568 dz23 = _mm_sub_ps(iz2,jz3);
1569 dx31 = _mm_sub_ps(ix3,jx1);
1570 dy31 = _mm_sub_ps(iy3,jy1);
1571 dz31 = _mm_sub_ps(iz3,jz1);
1572 dx32 = _mm_sub_ps(ix3,jx2);
1573 dy32 = _mm_sub_ps(iy3,jy2);
1574 dz32 = _mm_sub_ps(iz3,jz2);
1575 dx33 = _mm_sub_ps(ix3,jx3);
1576 dy33 = _mm_sub_ps(iy3,jy3);
1577 dz33 = _mm_sub_ps(iz3,jz3);
1579 /* Calculate squared distance and things based on it */
1580 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1581 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
1582 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
1583 rsq13 = gmx_mm_calc_rsq_ps(dx13,dy13,dz13);
1584 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
1585 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
1586 rsq23 = gmx_mm_calc_rsq_ps(dx23,dy23,dz23);
1587 rsq31 = gmx_mm_calc_rsq_ps(dx31,dy31,dz31);
1588 rsq32 = gmx_mm_calc_rsq_ps(dx32,dy32,dz32);
1589 rsq33 = gmx_mm_calc_rsq_ps(dx33,dy33,dz33);
1591 rinv11 = avx128fma_invsqrt_f(rsq11);
1592 rinv12 = avx128fma_invsqrt_f(rsq12);
1593 rinv13 = avx128fma_invsqrt_f(rsq13);
1594 rinv21 = avx128fma_invsqrt_f(rsq21);
1595 rinv22 = avx128fma_invsqrt_f(rsq22);
1596 rinv23 = avx128fma_invsqrt_f(rsq23);
1597 rinv31 = avx128fma_invsqrt_f(rsq31);
1598 rinv32 = avx128fma_invsqrt_f(rsq32);
1599 rinv33 = avx128fma_invsqrt_f(rsq33);
1601 rinvsq00 = avx128fma_inv_f(rsq00);
1602 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
1603 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
1604 rinvsq13 = _mm_mul_ps(rinv13,rinv13);
1605 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
1606 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
1607 rinvsq23 = _mm_mul_ps(rinv23,rinv23);
1608 rinvsq31 = _mm_mul_ps(rinv31,rinv31);
1609 rinvsq32 = _mm_mul_ps(rinv32,rinv32);
1610 rinvsq33 = _mm_mul_ps(rinv33,rinv33);
1612 fjx0 = _mm_setzero_ps();
1613 fjy0 = _mm_setzero_ps();
1614 fjz0 = _mm_setzero_ps();
1615 fjx1 = _mm_setzero_ps();
1616 fjy1 = _mm_setzero_ps();
1617 fjz1 = _mm_setzero_ps();
1618 fjx2 = _mm_setzero_ps();
1619 fjy2 = _mm_setzero_ps();
1620 fjz2 = _mm_setzero_ps();
1621 fjx3 = _mm_setzero_ps();
1622 fjy3 = _mm_setzero_ps();
1623 fjz3 = _mm_setzero_ps();
1625 /**************************
1626 * CALCULATE INTERACTIONS *
1627 **************************/
1629 if (gmx_mm_any_lt(rsq00,rcutoff2))
1632 /* LENNARD-JONES DISPERSION/REPULSION */
1634 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
1635 fvdw = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
1637 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
1641 fscal = _mm_and_ps(fscal,cutoff_mask);
1643 /* Update vectorial force */
1644 fix0 = _mm_macc_ps(dx00,fscal,fix0);
1645 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
1646 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
1648 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
1649 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
1650 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
1654 /**************************
1655 * CALCULATE INTERACTIONS *
1656 **************************/
1658 if (gmx_mm_any_lt(rsq11,rcutoff2))
1661 r11 = _mm_mul_ps(rsq11,rinv11);
1663 /* EWALD ELECTROSTATICS */
1665 /* Analytical PME correction */
1666 zeta2 = _mm_mul_ps(beta2,rsq11);
1667 rinv3 = _mm_mul_ps(rinvsq11,rinv11);
1668 pmecorrF = avx128fma_pmecorrF_f(zeta2);
1669 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1670 felec = _mm_mul_ps(qq11,felec);
1672 cutoff_mask = _mm_cmplt_ps(rsq11,rcutoff2);
1676 fscal = _mm_and_ps(fscal,cutoff_mask);
1678 /* Update vectorial force */
1679 fix1 = _mm_macc_ps(dx11,fscal,fix1);
1680 fiy1 = _mm_macc_ps(dy11,fscal,fiy1);
1681 fiz1 = _mm_macc_ps(dz11,fscal,fiz1);
1683 fjx1 = _mm_macc_ps(dx11,fscal,fjx1);
1684 fjy1 = _mm_macc_ps(dy11,fscal,fjy1);
1685 fjz1 = _mm_macc_ps(dz11,fscal,fjz1);
1689 /**************************
1690 * CALCULATE INTERACTIONS *
1691 **************************/
1693 if (gmx_mm_any_lt(rsq12,rcutoff2))
1696 r12 = _mm_mul_ps(rsq12,rinv12);
1698 /* EWALD ELECTROSTATICS */
1700 /* Analytical PME correction */
1701 zeta2 = _mm_mul_ps(beta2,rsq12);
1702 rinv3 = _mm_mul_ps(rinvsq12,rinv12);
1703 pmecorrF = avx128fma_pmecorrF_f(zeta2);
1704 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1705 felec = _mm_mul_ps(qq12,felec);
1707 cutoff_mask = _mm_cmplt_ps(rsq12,rcutoff2);
1711 fscal = _mm_and_ps(fscal,cutoff_mask);
1713 /* Update vectorial force */
1714 fix1 = _mm_macc_ps(dx12,fscal,fix1);
1715 fiy1 = _mm_macc_ps(dy12,fscal,fiy1);
1716 fiz1 = _mm_macc_ps(dz12,fscal,fiz1);
1718 fjx2 = _mm_macc_ps(dx12,fscal,fjx2);
1719 fjy2 = _mm_macc_ps(dy12,fscal,fjy2);
1720 fjz2 = _mm_macc_ps(dz12,fscal,fjz2);
1724 /**************************
1725 * CALCULATE INTERACTIONS *
1726 **************************/
1728 if (gmx_mm_any_lt(rsq13,rcutoff2))
1731 r13 = _mm_mul_ps(rsq13,rinv13);
1733 /* EWALD ELECTROSTATICS */
1735 /* Analytical PME correction */
1736 zeta2 = _mm_mul_ps(beta2,rsq13);
1737 rinv3 = _mm_mul_ps(rinvsq13,rinv13);
1738 pmecorrF = avx128fma_pmecorrF_f(zeta2);
1739 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1740 felec = _mm_mul_ps(qq13,felec);
1742 cutoff_mask = _mm_cmplt_ps(rsq13,rcutoff2);
1746 fscal = _mm_and_ps(fscal,cutoff_mask);
1748 /* Update vectorial force */
1749 fix1 = _mm_macc_ps(dx13,fscal,fix1);
1750 fiy1 = _mm_macc_ps(dy13,fscal,fiy1);
1751 fiz1 = _mm_macc_ps(dz13,fscal,fiz1);
1753 fjx3 = _mm_macc_ps(dx13,fscal,fjx3);
1754 fjy3 = _mm_macc_ps(dy13,fscal,fjy3);
1755 fjz3 = _mm_macc_ps(dz13,fscal,fjz3);
1759 /**************************
1760 * CALCULATE INTERACTIONS *
1761 **************************/
1763 if (gmx_mm_any_lt(rsq21,rcutoff2))
1766 r21 = _mm_mul_ps(rsq21,rinv21);
1768 /* EWALD ELECTROSTATICS */
1770 /* Analytical PME correction */
1771 zeta2 = _mm_mul_ps(beta2,rsq21);
1772 rinv3 = _mm_mul_ps(rinvsq21,rinv21);
1773 pmecorrF = avx128fma_pmecorrF_f(zeta2);
1774 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1775 felec = _mm_mul_ps(qq21,felec);
1777 cutoff_mask = _mm_cmplt_ps(rsq21,rcutoff2);
1781 fscal = _mm_and_ps(fscal,cutoff_mask);
1783 /* Update vectorial force */
1784 fix2 = _mm_macc_ps(dx21,fscal,fix2);
1785 fiy2 = _mm_macc_ps(dy21,fscal,fiy2);
1786 fiz2 = _mm_macc_ps(dz21,fscal,fiz2);
1788 fjx1 = _mm_macc_ps(dx21,fscal,fjx1);
1789 fjy1 = _mm_macc_ps(dy21,fscal,fjy1);
1790 fjz1 = _mm_macc_ps(dz21,fscal,fjz1);
1794 /**************************
1795 * CALCULATE INTERACTIONS *
1796 **************************/
1798 if (gmx_mm_any_lt(rsq22,rcutoff2))
1801 r22 = _mm_mul_ps(rsq22,rinv22);
1803 /* EWALD ELECTROSTATICS */
1805 /* Analytical PME correction */
1806 zeta2 = _mm_mul_ps(beta2,rsq22);
1807 rinv3 = _mm_mul_ps(rinvsq22,rinv22);
1808 pmecorrF = avx128fma_pmecorrF_f(zeta2);
1809 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1810 felec = _mm_mul_ps(qq22,felec);
1812 cutoff_mask = _mm_cmplt_ps(rsq22,rcutoff2);
1816 fscal = _mm_and_ps(fscal,cutoff_mask);
1818 /* Update vectorial force */
1819 fix2 = _mm_macc_ps(dx22,fscal,fix2);
1820 fiy2 = _mm_macc_ps(dy22,fscal,fiy2);
1821 fiz2 = _mm_macc_ps(dz22,fscal,fiz2);
1823 fjx2 = _mm_macc_ps(dx22,fscal,fjx2);
1824 fjy2 = _mm_macc_ps(dy22,fscal,fjy2);
1825 fjz2 = _mm_macc_ps(dz22,fscal,fjz2);
1829 /**************************
1830 * CALCULATE INTERACTIONS *
1831 **************************/
1833 if (gmx_mm_any_lt(rsq23,rcutoff2))
1836 r23 = _mm_mul_ps(rsq23,rinv23);
1838 /* EWALD ELECTROSTATICS */
1840 /* Analytical PME correction */
1841 zeta2 = _mm_mul_ps(beta2,rsq23);
1842 rinv3 = _mm_mul_ps(rinvsq23,rinv23);
1843 pmecorrF = avx128fma_pmecorrF_f(zeta2);
1844 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1845 felec = _mm_mul_ps(qq23,felec);
1847 cutoff_mask = _mm_cmplt_ps(rsq23,rcutoff2);
1851 fscal = _mm_and_ps(fscal,cutoff_mask);
1853 /* Update vectorial force */
1854 fix2 = _mm_macc_ps(dx23,fscal,fix2);
1855 fiy2 = _mm_macc_ps(dy23,fscal,fiy2);
1856 fiz2 = _mm_macc_ps(dz23,fscal,fiz2);
1858 fjx3 = _mm_macc_ps(dx23,fscal,fjx3);
1859 fjy3 = _mm_macc_ps(dy23,fscal,fjy3);
1860 fjz3 = _mm_macc_ps(dz23,fscal,fjz3);
1864 /**************************
1865 * CALCULATE INTERACTIONS *
1866 **************************/
1868 if (gmx_mm_any_lt(rsq31,rcutoff2))
1871 r31 = _mm_mul_ps(rsq31,rinv31);
1873 /* EWALD ELECTROSTATICS */
1875 /* Analytical PME correction */
1876 zeta2 = _mm_mul_ps(beta2,rsq31);
1877 rinv3 = _mm_mul_ps(rinvsq31,rinv31);
1878 pmecorrF = avx128fma_pmecorrF_f(zeta2);
1879 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1880 felec = _mm_mul_ps(qq31,felec);
1882 cutoff_mask = _mm_cmplt_ps(rsq31,rcutoff2);
1886 fscal = _mm_and_ps(fscal,cutoff_mask);
1888 /* Update vectorial force */
1889 fix3 = _mm_macc_ps(dx31,fscal,fix3);
1890 fiy3 = _mm_macc_ps(dy31,fscal,fiy3);
1891 fiz3 = _mm_macc_ps(dz31,fscal,fiz3);
1893 fjx1 = _mm_macc_ps(dx31,fscal,fjx1);
1894 fjy1 = _mm_macc_ps(dy31,fscal,fjy1);
1895 fjz1 = _mm_macc_ps(dz31,fscal,fjz1);
1899 /**************************
1900 * CALCULATE INTERACTIONS *
1901 **************************/
1903 if (gmx_mm_any_lt(rsq32,rcutoff2))
1906 r32 = _mm_mul_ps(rsq32,rinv32);
1908 /* EWALD ELECTROSTATICS */
1910 /* Analytical PME correction */
1911 zeta2 = _mm_mul_ps(beta2,rsq32);
1912 rinv3 = _mm_mul_ps(rinvsq32,rinv32);
1913 pmecorrF = avx128fma_pmecorrF_f(zeta2);
1914 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1915 felec = _mm_mul_ps(qq32,felec);
1917 cutoff_mask = _mm_cmplt_ps(rsq32,rcutoff2);
1921 fscal = _mm_and_ps(fscal,cutoff_mask);
1923 /* Update vectorial force */
1924 fix3 = _mm_macc_ps(dx32,fscal,fix3);
1925 fiy3 = _mm_macc_ps(dy32,fscal,fiy3);
1926 fiz3 = _mm_macc_ps(dz32,fscal,fiz3);
1928 fjx2 = _mm_macc_ps(dx32,fscal,fjx2);
1929 fjy2 = _mm_macc_ps(dy32,fscal,fjy2);
1930 fjz2 = _mm_macc_ps(dz32,fscal,fjz2);
1934 /**************************
1935 * CALCULATE INTERACTIONS *
1936 **************************/
1938 if (gmx_mm_any_lt(rsq33,rcutoff2))
1941 r33 = _mm_mul_ps(rsq33,rinv33);
1943 /* EWALD ELECTROSTATICS */
1945 /* Analytical PME correction */
1946 zeta2 = _mm_mul_ps(beta2,rsq33);
1947 rinv3 = _mm_mul_ps(rinvsq33,rinv33);
1948 pmecorrF = avx128fma_pmecorrF_f(zeta2);
1949 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
1950 felec = _mm_mul_ps(qq33,felec);
1952 cutoff_mask = _mm_cmplt_ps(rsq33,rcutoff2);
1956 fscal = _mm_and_ps(fscal,cutoff_mask);
1958 /* Update vectorial force */
1959 fix3 = _mm_macc_ps(dx33,fscal,fix3);
1960 fiy3 = _mm_macc_ps(dy33,fscal,fiy3);
1961 fiz3 = _mm_macc_ps(dz33,fscal,fiz3);
1963 fjx3 = _mm_macc_ps(dx33,fscal,fjx3);
1964 fjy3 = _mm_macc_ps(dy33,fscal,fjy3);
1965 fjz3 = _mm_macc_ps(dz33,fscal,fjz3);
1969 fjptrA = f+j_coord_offsetA;
1970 fjptrB = f+j_coord_offsetB;
1971 fjptrC = f+j_coord_offsetC;
1972 fjptrD = f+j_coord_offsetD;
1974 gmx_mm_decrement_4rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
1975 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
1976 fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1978 /* Inner loop uses 315 flops */
1981 if(jidx<j_index_end)
1984 /* Get j neighbor index, and coordinate index */
1985 jnrlistA = jjnr[jidx];
1986 jnrlistB = jjnr[jidx+1];
1987 jnrlistC = jjnr[jidx+2];
1988 jnrlistD = jjnr[jidx+3];
1989 /* Sign of each element will be negative for non-real atoms.
1990 * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1991 * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1993 dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
1994 jnrA = (jnrlistA>=0) ? jnrlistA : 0;
1995 jnrB = (jnrlistB>=0) ? jnrlistB : 0;
1996 jnrC = (jnrlistC>=0) ? jnrlistC : 0;
1997 jnrD = (jnrlistD>=0) ? jnrlistD : 0;
1998 j_coord_offsetA = DIM*jnrA;
1999 j_coord_offsetB = DIM*jnrB;
2000 j_coord_offsetC = DIM*jnrC;
2001 j_coord_offsetD = DIM*jnrD;
2003 /* load j atom coordinates */
2004 gmx_mm_load_4rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
2005 x+j_coord_offsetC,x+j_coord_offsetD,
2006 &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
2007 &jy2,&jz2,&jx3,&jy3,&jz3);
2009 /* Calculate displacement vector */
2010 dx00 = _mm_sub_ps(ix0,jx0);
2011 dy00 = _mm_sub_ps(iy0,jy0);
2012 dz00 = _mm_sub_ps(iz0,jz0);
2013 dx11 = _mm_sub_ps(ix1,jx1);
2014 dy11 = _mm_sub_ps(iy1,jy1);
2015 dz11 = _mm_sub_ps(iz1,jz1);
2016 dx12 = _mm_sub_ps(ix1,jx2);
2017 dy12 = _mm_sub_ps(iy1,jy2);
2018 dz12 = _mm_sub_ps(iz1,jz2);
2019 dx13 = _mm_sub_ps(ix1,jx3);
2020 dy13 = _mm_sub_ps(iy1,jy3);
2021 dz13 = _mm_sub_ps(iz1,jz3);
2022 dx21 = _mm_sub_ps(ix2,jx1);
2023 dy21 = _mm_sub_ps(iy2,jy1);
2024 dz21 = _mm_sub_ps(iz2,jz1);
2025 dx22 = _mm_sub_ps(ix2,jx2);
2026 dy22 = _mm_sub_ps(iy2,jy2);
2027 dz22 = _mm_sub_ps(iz2,jz2);
2028 dx23 = _mm_sub_ps(ix2,jx3);
2029 dy23 = _mm_sub_ps(iy2,jy3);
2030 dz23 = _mm_sub_ps(iz2,jz3);
2031 dx31 = _mm_sub_ps(ix3,jx1);
2032 dy31 = _mm_sub_ps(iy3,jy1);
2033 dz31 = _mm_sub_ps(iz3,jz1);
2034 dx32 = _mm_sub_ps(ix3,jx2);
2035 dy32 = _mm_sub_ps(iy3,jy2);
2036 dz32 = _mm_sub_ps(iz3,jz2);
2037 dx33 = _mm_sub_ps(ix3,jx3);
2038 dy33 = _mm_sub_ps(iy3,jy3);
2039 dz33 = _mm_sub_ps(iz3,jz3);
2041 /* Calculate squared distance and things based on it */
2042 rsq00 = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
2043 rsq11 = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
2044 rsq12 = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
2045 rsq13 = gmx_mm_calc_rsq_ps(dx13,dy13,dz13);
2046 rsq21 = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
2047 rsq22 = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
2048 rsq23 = gmx_mm_calc_rsq_ps(dx23,dy23,dz23);
2049 rsq31 = gmx_mm_calc_rsq_ps(dx31,dy31,dz31);
2050 rsq32 = gmx_mm_calc_rsq_ps(dx32,dy32,dz32);
2051 rsq33 = gmx_mm_calc_rsq_ps(dx33,dy33,dz33);
2053 rinv11 = avx128fma_invsqrt_f(rsq11);
2054 rinv12 = avx128fma_invsqrt_f(rsq12);
2055 rinv13 = avx128fma_invsqrt_f(rsq13);
2056 rinv21 = avx128fma_invsqrt_f(rsq21);
2057 rinv22 = avx128fma_invsqrt_f(rsq22);
2058 rinv23 = avx128fma_invsqrt_f(rsq23);
2059 rinv31 = avx128fma_invsqrt_f(rsq31);
2060 rinv32 = avx128fma_invsqrt_f(rsq32);
2061 rinv33 = avx128fma_invsqrt_f(rsq33);
2063 rinvsq00 = avx128fma_inv_f(rsq00);
2064 rinvsq11 = _mm_mul_ps(rinv11,rinv11);
2065 rinvsq12 = _mm_mul_ps(rinv12,rinv12);
2066 rinvsq13 = _mm_mul_ps(rinv13,rinv13);
2067 rinvsq21 = _mm_mul_ps(rinv21,rinv21);
2068 rinvsq22 = _mm_mul_ps(rinv22,rinv22);
2069 rinvsq23 = _mm_mul_ps(rinv23,rinv23);
2070 rinvsq31 = _mm_mul_ps(rinv31,rinv31);
2071 rinvsq32 = _mm_mul_ps(rinv32,rinv32);
2072 rinvsq33 = _mm_mul_ps(rinv33,rinv33);
2074 fjx0 = _mm_setzero_ps();
2075 fjy0 = _mm_setzero_ps();
2076 fjz0 = _mm_setzero_ps();
2077 fjx1 = _mm_setzero_ps();
2078 fjy1 = _mm_setzero_ps();
2079 fjz1 = _mm_setzero_ps();
2080 fjx2 = _mm_setzero_ps();
2081 fjy2 = _mm_setzero_ps();
2082 fjz2 = _mm_setzero_ps();
2083 fjx3 = _mm_setzero_ps();
2084 fjy3 = _mm_setzero_ps();
2085 fjz3 = _mm_setzero_ps();
2087 /**************************
2088 * CALCULATE INTERACTIONS *
2089 **************************/
2091 if (gmx_mm_any_lt(rsq00,rcutoff2))
2094 /* LENNARD-JONES DISPERSION/REPULSION */
2096 rinvsix = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
2097 fvdw = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
2099 cutoff_mask = _mm_cmplt_ps(rsq00,rcutoff2);
2103 fscal = _mm_and_ps(fscal,cutoff_mask);
2105 fscal = _mm_andnot_ps(dummy_mask,fscal);
2107 /* Update vectorial force */
2108 fix0 = _mm_macc_ps(dx00,fscal,fix0);
2109 fiy0 = _mm_macc_ps(dy00,fscal,fiy0);
2110 fiz0 = _mm_macc_ps(dz00,fscal,fiz0);
2112 fjx0 = _mm_macc_ps(dx00,fscal,fjx0);
2113 fjy0 = _mm_macc_ps(dy00,fscal,fjy0);
2114 fjz0 = _mm_macc_ps(dz00,fscal,fjz0);
2118 /**************************
2119 * CALCULATE INTERACTIONS *
2120 **************************/
2122 if (gmx_mm_any_lt(rsq11,rcutoff2))
2125 r11 = _mm_mul_ps(rsq11,rinv11);
2126 r11 = _mm_andnot_ps(dummy_mask,r11);
2128 /* EWALD ELECTROSTATICS */
2130 /* Analytical PME correction */
2131 zeta2 = _mm_mul_ps(beta2,rsq11);
2132 rinv3 = _mm_mul_ps(rinvsq11,rinv11);
2133 pmecorrF = avx128fma_pmecorrF_f(zeta2);
2134 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
2135 felec = _mm_mul_ps(qq11,felec);
2137 cutoff_mask = _mm_cmplt_ps(rsq11,rcutoff2);
2141 fscal = _mm_and_ps(fscal,cutoff_mask);
2143 fscal = _mm_andnot_ps(dummy_mask,fscal);
2145 /* Update vectorial force */
2146 fix1 = _mm_macc_ps(dx11,fscal,fix1);
2147 fiy1 = _mm_macc_ps(dy11,fscal,fiy1);
2148 fiz1 = _mm_macc_ps(dz11,fscal,fiz1);
2150 fjx1 = _mm_macc_ps(dx11,fscal,fjx1);
2151 fjy1 = _mm_macc_ps(dy11,fscal,fjy1);
2152 fjz1 = _mm_macc_ps(dz11,fscal,fjz1);
2156 /**************************
2157 * CALCULATE INTERACTIONS *
2158 **************************/
2160 if (gmx_mm_any_lt(rsq12,rcutoff2))
2163 r12 = _mm_mul_ps(rsq12,rinv12);
2164 r12 = _mm_andnot_ps(dummy_mask,r12);
2166 /* EWALD ELECTROSTATICS */
2168 /* Analytical PME correction */
2169 zeta2 = _mm_mul_ps(beta2,rsq12);
2170 rinv3 = _mm_mul_ps(rinvsq12,rinv12);
2171 pmecorrF = avx128fma_pmecorrF_f(zeta2);
2172 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
2173 felec = _mm_mul_ps(qq12,felec);
2175 cutoff_mask = _mm_cmplt_ps(rsq12,rcutoff2);
2179 fscal = _mm_and_ps(fscal,cutoff_mask);
2181 fscal = _mm_andnot_ps(dummy_mask,fscal);
2183 /* Update vectorial force */
2184 fix1 = _mm_macc_ps(dx12,fscal,fix1);
2185 fiy1 = _mm_macc_ps(dy12,fscal,fiy1);
2186 fiz1 = _mm_macc_ps(dz12,fscal,fiz1);
2188 fjx2 = _mm_macc_ps(dx12,fscal,fjx2);
2189 fjy2 = _mm_macc_ps(dy12,fscal,fjy2);
2190 fjz2 = _mm_macc_ps(dz12,fscal,fjz2);
2194 /**************************
2195 * CALCULATE INTERACTIONS *
2196 **************************/
2198 if (gmx_mm_any_lt(rsq13,rcutoff2))
2201 r13 = _mm_mul_ps(rsq13,rinv13);
2202 r13 = _mm_andnot_ps(dummy_mask,r13);
2204 /* EWALD ELECTROSTATICS */
2206 /* Analytical PME correction */
2207 zeta2 = _mm_mul_ps(beta2,rsq13);
2208 rinv3 = _mm_mul_ps(rinvsq13,rinv13);
2209 pmecorrF = avx128fma_pmecorrF_f(zeta2);
2210 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
2211 felec = _mm_mul_ps(qq13,felec);
2213 cutoff_mask = _mm_cmplt_ps(rsq13,rcutoff2);
2217 fscal = _mm_and_ps(fscal,cutoff_mask);
2219 fscal = _mm_andnot_ps(dummy_mask,fscal);
2221 /* Update vectorial force */
2222 fix1 = _mm_macc_ps(dx13,fscal,fix1);
2223 fiy1 = _mm_macc_ps(dy13,fscal,fiy1);
2224 fiz1 = _mm_macc_ps(dz13,fscal,fiz1);
2226 fjx3 = _mm_macc_ps(dx13,fscal,fjx3);
2227 fjy3 = _mm_macc_ps(dy13,fscal,fjy3);
2228 fjz3 = _mm_macc_ps(dz13,fscal,fjz3);
2232 /**************************
2233 * CALCULATE INTERACTIONS *
2234 **************************/
2236 if (gmx_mm_any_lt(rsq21,rcutoff2))
2239 r21 = _mm_mul_ps(rsq21,rinv21);
2240 r21 = _mm_andnot_ps(dummy_mask,r21);
2242 /* EWALD ELECTROSTATICS */
2244 /* Analytical PME correction */
2245 zeta2 = _mm_mul_ps(beta2,rsq21);
2246 rinv3 = _mm_mul_ps(rinvsq21,rinv21);
2247 pmecorrF = avx128fma_pmecorrF_f(zeta2);
2248 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
2249 felec = _mm_mul_ps(qq21,felec);
2251 cutoff_mask = _mm_cmplt_ps(rsq21,rcutoff2);
2255 fscal = _mm_and_ps(fscal,cutoff_mask);
2257 fscal = _mm_andnot_ps(dummy_mask,fscal);
2259 /* Update vectorial force */
2260 fix2 = _mm_macc_ps(dx21,fscal,fix2);
2261 fiy2 = _mm_macc_ps(dy21,fscal,fiy2);
2262 fiz2 = _mm_macc_ps(dz21,fscal,fiz2);
2264 fjx1 = _mm_macc_ps(dx21,fscal,fjx1);
2265 fjy1 = _mm_macc_ps(dy21,fscal,fjy1);
2266 fjz1 = _mm_macc_ps(dz21,fscal,fjz1);
2270 /**************************
2271 * CALCULATE INTERACTIONS *
2272 **************************/
2274 if (gmx_mm_any_lt(rsq22,rcutoff2))
2277 r22 = _mm_mul_ps(rsq22,rinv22);
2278 r22 = _mm_andnot_ps(dummy_mask,r22);
2280 /* EWALD ELECTROSTATICS */
2282 /* Analytical PME correction */
2283 zeta2 = _mm_mul_ps(beta2,rsq22);
2284 rinv3 = _mm_mul_ps(rinvsq22,rinv22);
2285 pmecorrF = avx128fma_pmecorrF_f(zeta2);
2286 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
2287 felec = _mm_mul_ps(qq22,felec);
2289 cutoff_mask = _mm_cmplt_ps(rsq22,rcutoff2);
2293 fscal = _mm_and_ps(fscal,cutoff_mask);
2295 fscal = _mm_andnot_ps(dummy_mask,fscal);
2297 /* Update vectorial force */
2298 fix2 = _mm_macc_ps(dx22,fscal,fix2);
2299 fiy2 = _mm_macc_ps(dy22,fscal,fiy2);
2300 fiz2 = _mm_macc_ps(dz22,fscal,fiz2);
2302 fjx2 = _mm_macc_ps(dx22,fscal,fjx2);
2303 fjy2 = _mm_macc_ps(dy22,fscal,fjy2);
2304 fjz2 = _mm_macc_ps(dz22,fscal,fjz2);
2308 /**************************
2309 * CALCULATE INTERACTIONS *
2310 **************************/
2312 if (gmx_mm_any_lt(rsq23,rcutoff2))
2315 r23 = _mm_mul_ps(rsq23,rinv23);
2316 r23 = _mm_andnot_ps(dummy_mask,r23);
2318 /* EWALD ELECTROSTATICS */
2320 /* Analytical PME correction */
2321 zeta2 = _mm_mul_ps(beta2,rsq23);
2322 rinv3 = _mm_mul_ps(rinvsq23,rinv23);
2323 pmecorrF = avx128fma_pmecorrF_f(zeta2);
2324 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
2325 felec = _mm_mul_ps(qq23,felec);
2327 cutoff_mask = _mm_cmplt_ps(rsq23,rcutoff2);
2331 fscal = _mm_and_ps(fscal,cutoff_mask);
2333 fscal = _mm_andnot_ps(dummy_mask,fscal);
2335 /* Update vectorial force */
2336 fix2 = _mm_macc_ps(dx23,fscal,fix2);
2337 fiy2 = _mm_macc_ps(dy23,fscal,fiy2);
2338 fiz2 = _mm_macc_ps(dz23,fscal,fiz2);
2340 fjx3 = _mm_macc_ps(dx23,fscal,fjx3);
2341 fjy3 = _mm_macc_ps(dy23,fscal,fjy3);
2342 fjz3 = _mm_macc_ps(dz23,fscal,fjz3);
2346 /**************************
2347 * CALCULATE INTERACTIONS *
2348 **************************/
2350 if (gmx_mm_any_lt(rsq31,rcutoff2))
2353 r31 = _mm_mul_ps(rsq31,rinv31);
2354 r31 = _mm_andnot_ps(dummy_mask,r31);
2356 /* EWALD ELECTROSTATICS */
2358 /* Analytical PME correction */
2359 zeta2 = _mm_mul_ps(beta2,rsq31);
2360 rinv3 = _mm_mul_ps(rinvsq31,rinv31);
2361 pmecorrF = avx128fma_pmecorrF_f(zeta2);
2362 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
2363 felec = _mm_mul_ps(qq31,felec);
2365 cutoff_mask = _mm_cmplt_ps(rsq31,rcutoff2);
2369 fscal = _mm_and_ps(fscal,cutoff_mask);
2371 fscal = _mm_andnot_ps(dummy_mask,fscal);
2373 /* Update vectorial force */
2374 fix3 = _mm_macc_ps(dx31,fscal,fix3);
2375 fiy3 = _mm_macc_ps(dy31,fscal,fiy3);
2376 fiz3 = _mm_macc_ps(dz31,fscal,fiz3);
2378 fjx1 = _mm_macc_ps(dx31,fscal,fjx1);
2379 fjy1 = _mm_macc_ps(dy31,fscal,fjy1);
2380 fjz1 = _mm_macc_ps(dz31,fscal,fjz1);
2384 /**************************
2385 * CALCULATE INTERACTIONS *
2386 **************************/
2388 if (gmx_mm_any_lt(rsq32,rcutoff2))
2391 r32 = _mm_mul_ps(rsq32,rinv32);
2392 r32 = _mm_andnot_ps(dummy_mask,r32);
2394 /* EWALD ELECTROSTATICS */
2396 /* Analytical PME correction */
2397 zeta2 = _mm_mul_ps(beta2,rsq32);
2398 rinv3 = _mm_mul_ps(rinvsq32,rinv32);
2399 pmecorrF = avx128fma_pmecorrF_f(zeta2);
2400 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
2401 felec = _mm_mul_ps(qq32,felec);
2403 cutoff_mask = _mm_cmplt_ps(rsq32,rcutoff2);
2407 fscal = _mm_and_ps(fscal,cutoff_mask);
2409 fscal = _mm_andnot_ps(dummy_mask,fscal);
2411 /* Update vectorial force */
2412 fix3 = _mm_macc_ps(dx32,fscal,fix3);
2413 fiy3 = _mm_macc_ps(dy32,fscal,fiy3);
2414 fiz3 = _mm_macc_ps(dz32,fscal,fiz3);
2416 fjx2 = _mm_macc_ps(dx32,fscal,fjx2);
2417 fjy2 = _mm_macc_ps(dy32,fscal,fjy2);
2418 fjz2 = _mm_macc_ps(dz32,fscal,fjz2);
2422 /**************************
2423 * CALCULATE INTERACTIONS *
2424 **************************/
2426 if (gmx_mm_any_lt(rsq33,rcutoff2))
2429 r33 = _mm_mul_ps(rsq33,rinv33);
2430 r33 = _mm_andnot_ps(dummy_mask,r33);
2432 /* EWALD ELECTROSTATICS */
2434 /* Analytical PME correction */
2435 zeta2 = _mm_mul_ps(beta2,rsq33);
2436 rinv3 = _mm_mul_ps(rinvsq33,rinv33);
2437 pmecorrF = avx128fma_pmecorrF_f(zeta2);
2438 felec = _mm_macc_ps(pmecorrF,beta3,rinv3);
2439 felec = _mm_mul_ps(qq33,felec);
2441 cutoff_mask = _mm_cmplt_ps(rsq33,rcutoff2);
2445 fscal = _mm_and_ps(fscal,cutoff_mask);
2447 fscal = _mm_andnot_ps(dummy_mask,fscal);
2449 /* Update vectorial force */
2450 fix3 = _mm_macc_ps(dx33,fscal,fix3);
2451 fiy3 = _mm_macc_ps(dy33,fscal,fiy3);
2452 fiz3 = _mm_macc_ps(dz33,fscal,fiz3);
2454 fjx3 = _mm_macc_ps(dx33,fscal,fjx3);
2455 fjy3 = _mm_macc_ps(dy33,fscal,fjy3);
2456 fjz3 = _mm_macc_ps(dz33,fscal,fjz3);
2460 fjptrA = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
2461 fjptrB = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
2462 fjptrC = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
2463 fjptrD = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
2465 gmx_mm_decrement_4rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
2466 fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
2467 fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
2469 /* Inner loop uses 324 flops */
2472 /* End of innermost loop */
2474 gmx_mm_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
2475 f+i_coord_offset,fshift+i_shift_offset);
2477 /* Increment number of inner iterations */
2478 inneriter += j_index_end - j_index_start;
2480 /* Outer loop uses 24 flops */
2483 /* Increment number of outer iterations */
2486 /* Update outer/inner flops */
2488 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*24 + inneriter*324);