Added option to gmx nmeig to print ZPE.
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_avx_128_fma_single / nb_kernel_ElecEwSh_VdwLJSh_GeomW4W4_avx_128_fma_single.c
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
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.
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 avx_128_fma_single kernel generator.
37  */
38 #include "gmxpre.h"
39
40 #include "config.h"
41
42 #include <math.h>
43
44 #include "../nb_kernel.h"
45 #include "gromacs/gmxlib/nrnb.h"
46
47 #include "kernelutil_x86_avx_128_fma_single.h"
48
49 /*
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
55  */
56 void
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)
65 {
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.
70      */
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;
77     real             rcutoff_scalar;
78     real             *shiftvec,*fshift,*x,*f;
79     real             *fjptrA,*fjptrB,*fjptrC,*fjptrD;
80     real             scratch[4*DIM];
81     __m128           fscal,rcutoff,rcutoff2,jidxall;
82     int              vdwioffset0;
83     __m128           ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
84     int              vdwioffset1;
85     __m128           ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
86     int              vdwioffset2;
87     __m128           ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
88     int              vdwioffset3;
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;
109     real             *charge;
110     int              nvdwtype;
111     __m128           rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
112     int              *vdwtype;
113     real             *vdwparam;
114     __m128           one_sixth   = _mm_set1_ps(1.0/6.0);
115     __m128           one_twelfth = _mm_set1_ps(1.0/12.0);
116     __m128i          ewitab;
117     __m128           ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
118     __m128           beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
119     real             *ewtab;
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);
124     x                = xx[0];
125     f                = ff[0];
126
127     nri              = nlist->nri;
128     iinr             = nlist->iinr;
129     jindex           = nlist->jindex;
130     jjnr             = nlist->jjnr;
131     shiftidx         = nlist->shift;
132     gid              = nlist->gid;
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;
138     vdwparam         = fr->nbfp;
139     vdwtype          = mdatoms->typeA;
140
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);
148
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];
155
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);
171
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);
176
177     sh_vdw_invrcut6  = _mm_set1_ps(fr->ic->sh_invrc6);
178     rvdw             = _mm_set1_ps(fr->ic->rvdw);
179
180     /* Avoid stupid compiler warnings */
181     jnrA = jnrB = jnrC = jnrD = 0;
182     j_coord_offsetA = 0;
183     j_coord_offsetB = 0;
184     j_coord_offsetC = 0;
185     j_coord_offsetD = 0;
186
187     outeriter        = 0;
188     inneriter        = 0;
189
190     for(iidx=0;iidx<4*DIM;iidx++)
191     {
192         scratch[iidx] = 0.0;
193     }
194
195     /* Start outer loop over neighborlists */
196     for(iidx=0; iidx<nri; iidx++)
197     {
198         /* Load shift vector for this list */
199         i_shift_offset   = DIM*shiftidx[iidx];
200
201         /* Load limits for loop over neighbors */
202         j_index_start    = jindex[iidx];
203         j_index_end      = jindex[iidx+1];
204
205         /* Get outer coordinate index */
206         inr              = iinr[iidx];
207         i_coord_offset   = DIM*inr;
208
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);
212
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();
225
226         /* Reset potential sums */
227         velecsum         = _mm_setzero_ps();
228         vvdwsum          = _mm_setzero_ps();
229
230         /* Start inner kernel loop */
231         for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
232         {
233
234             /* Get j neighbor index, and coordinate index */
235             jnrA             = jjnr[jidx];
236             jnrB             = jjnr[jidx+1];
237             jnrC             = jjnr[jidx+2];
238             jnrD             = jjnr[jidx+3];
239             j_coord_offsetA  = DIM*jnrA;
240             j_coord_offsetB  = DIM*jnrB;
241             j_coord_offsetC  = DIM*jnrC;
242             j_coord_offsetD  = DIM*jnrD;
243
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);
249
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);
281
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);
293
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);
303
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);
314
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();
327
328             /**************************
329              * CALCULATE INTERACTIONS *
330              **************************/
331
332             if (gmx_mm_any_lt(rsq00,rcutoff2))
333             {
334
335             /* LENNARD-JONES DISPERSION/REPULSION */
336
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);
343
344             cutoff_mask      = _mm_cmplt_ps(rsq00,rcutoff2);
345
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);
349
350             fscal            = fvdw;
351
352             fscal            = _mm_and_ps(fscal,cutoff_mask);
353
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);
358
359             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
360             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
361             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
362
363             }
364
365             /**************************
366              * CALCULATE INTERACTIONS *
367              **************************/
368
369             if (gmx_mm_any_lt(rsq11,rcutoff2))
370             {
371
372             r11              = _mm_mul_ps(rsq11,rinv11);
373
374             /* EWALD ELECTROSTATICS */
375
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);
385
386             cutoff_mask      = _mm_cmplt_ps(rsq11,rcutoff2);
387
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);
391
392             fscal            = felec;
393
394             fscal            = _mm_and_ps(fscal,cutoff_mask);
395
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);
400
401             fjx1             = _mm_macc_ps(dx11,fscal,fjx1);
402             fjy1             = _mm_macc_ps(dy11,fscal,fjy1);
403             fjz1             = _mm_macc_ps(dz11,fscal,fjz1);
404
405             }
406
407             /**************************
408              * CALCULATE INTERACTIONS *
409              **************************/
410
411             if (gmx_mm_any_lt(rsq12,rcutoff2))
412             {
413
414             r12              = _mm_mul_ps(rsq12,rinv12);
415
416             /* EWALD ELECTROSTATICS */
417
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);
427
428             cutoff_mask      = _mm_cmplt_ps(rsq12,rcutoff2);
429
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);
433
434             fscal            = felec;
435
436             fscal            = _mm_and_ps(fscal,cutoff_mask);
437
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);
442
443             fjx2             = _mm_macc_ps(dx12,fscal,fjx2);
444             fjy2             = _mm_macc_ps(dy12,fscal,fjy2);
445             fjz2             = _mm_macc_ps(dz12,fscal,fjz2);
446
447             }
448
449             /**************************
450              * CALCULATE INTERACTIONS *
451              **************************/
452
453             if (gmx_mm_any_lt(rsq13,rcutoff2))
454             {
455
456             r13              = _mm_mul_ps(rsq13,rinv13);
457
458             /* EWALD ELECTROSTATICS */
459
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);
469
470             cutoff_mask      = _mm_cmplt_ps(rsq13,rcutoff2);
471
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);
475
476             fscal            = felec;
477
478             fscal            = _mm_and_ps(fscal,cutoff_mask);
479
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);
484
485             fjx3             = _mm_macc_ps(dx13,fscal,fjx3);
486             fjy3             = _mm_macc_ps(dy13,fscal,fjy3);
487             fjz3             = _mm_macc_ps(dz13,fscal,fjz3);
488
489             }
490
491             /**************************
492              * CALCULATE INTERACTIONS *
493              **************************/
494
495             if (gmx_mm_any_lt(rsq21,rcutoff2))
496             {
497
498             r21              = _mm_mul_ps(rsq21,rinv21);
499
500             /* EWALD ELECTROSTATICS */
501
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);
511
512             cutoff_mask      = _mm_cmplt_ps(rsq21,rcutoff2);
513
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);
517
518             fscal            = felec;
519
520             fscal            = _mm_and_ps(fscal,cutoff_mask);
521
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);
526
527             fjx1             = _mm_macc_ps(dx21,fscal,fjx1);
528             fjy1             = _mm_macc_ps(dy21,fscal,fjy1);
529             fjz1             = _mm_macc_ps(dz21,fscal,fjz1);
530
531             }
532
533             /**************************
534              * CALCULATE INTERACTIONS *
535              **************************/
536
537             if (gmx_mm_any_lt(rsq22,rcutoff2))
538             {
539
540             r22              = _mm_mul_ps(rsq22,rinv22);
541
542             /* EWALD ELECTROSTATICS */
543
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);
553
554             cutoff_mask      = _mm_cmplt_ps(rsq22,rcutoff2);
555
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);
559
560             fscal            = felec;
561
562             fscal            = _mm_and_ps(fscal,cutoff_mask);
563
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);
568
569             fjx2             = _mm_macc_ps(dx22,fscal,fjx2);
570             fjy2             = _mm_macc_ps(dy22,fscal,fjy2);
571             fjz2             = _mm_macc_ps(dz22,fscal,fjz2);
572
573             }
574
575             /**************************
576              * CALCULATE INTERACTIONS *
577              **************************/
578
579             if (gmx_mm_any_lt(rsq23,rcutoff2))
580             {
581
582             r23              = _mm_mul_ps(rsq23,rinv23);
583
584             /* EWALD ELECTROSTATICS */
585
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);
595
596             cutoff_mask      = _mm_cmplt_ps(rsq23,rcutoff2);
597
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);
601
602             fscal            = felec;
603
604             fscal            = _mm_and_ps(fscal,cutoff_mask);
605
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);
610
611             fjx3             = _mm_macc_ps(dx23,fscal,fjx3);
612             fjy3             = _mm_macc_ps(dy23,fscal,fjy3);
613             fjz3             = _mm_macc_ps(dz23,fscal,fjz3);
614
615             }
616
617             /**************************
618              * CALCULATE INTERACTIONS *
619              **************************/
620
621             if (gmx_mm_any_lt(rsq31,rcutoff2))
622             {
623
624             r31              = _mm_mul_ps(rsq31,rinv31);
625
626             /* EWALD ELECTROSTATICS */
627
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);
637
638             cutoff_mask      = _mm_cmplt_ps(rsq31,rcutoff2);
639
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);
643
644             fscal            = felec;
645
646             fscal            = _mm_and_ps(fscal,cutoff_mask);
647
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);
652
653             fjx1             = _mm_macc_ps(dx31,fscal,fjx1);
654             fjy1             = _mm_macc_ps(dy31,fscal,fjy1);
655             fjz1             = _mm_macc_ps(dz31,fscal,fjz1);
656
657             }
658
659             /**************************
660              * CALCULATE INTERACTIONS *
661              **************************/
662
663             if (gmx_mm_any_lt(rsq32,rcutoff2))
664             {
665
666             r32              = _mm_mul_ps(rsq32,rinv32);
667
668             /* EWALD ELECTROSTATICS */
669
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);
679
680             cutoff_mask      = _mm_cmplt_ps(rsq32,rcutoff2);
681
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);
685
686             fscal            = felec;
687
688             fscal            = _mm_and_ps(fscal,cutoff_mask);
689
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);
694
695             fjx2             = _mm_macc_ps(dx32,fscal,fjx2);
696             fjy2             = _mm_macc_ps(dy32,fscal,fjy2);
697             fjz2             = _mm_macc_ps(dz32,fscal,fjz2);
698
699             }
700
701             /**************************
702              * CALCULATE INTERACTIONS *
703              **************************/
704
705             if (gmx_mm_any_lt(rsq33,rcutoff2))
706             {
707
708             r33              = _mm_mul_ps(rsq33,rinv33);
709
710             /* EWALD ELECTROSTATICS */
711
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);
721
722             cutoff_mask      = _mm_cmplt_ps(rsq33,rcutoff2);
723
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);
727
728             fscal            = felec;
729
730             fscal            = _mm_and_ps(fscal,cutoff_mask);
731
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);
736
737             fjx3             = _mm_macc_ps(dx33,fscal,fjx3);
738             fjy3             = _mm_macc_ps(dy33,fscal,fjy3);
739             fjz3             = _mm_macc_ps(dz33,fscal,fjz3);
740
741             }
742
743             fjptrA             = f+j_coord_offsetA;
744             fjptrB             = f+j_coord_offsetB;
745             fjptrC             = f+j_coord_offsetC;
746             fjptrD             = f+j_coord_offsetD;
747
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);
751
752             /* Inner loop uses 344 flops */
753         }
754
755         if(jidx<j_index_end)
756         {
757
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.
766              */
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;
776
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);
782
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);
814
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);
826
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);
836
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);
847
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();
860
861             /**************************
862              * CALCULATE INTERACTIONS *
863              **************************/
864
865             if (gmx_mm_any_lt(rsq00,rcutoff2))
866             {
867
868             /* LENNARD-JONES DISPERSION/REPULSION */
869
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);
876
877             cutoff_mask      = _mm_cmplt_ps(rsq00,rcutoff2);
878
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);
883
884             fscal            = fvdw;
885
886             fscal            = _mm_and_ps(fscal,cutoff_mask);
887
888             fscal            = _mm_andnot_ps(dummy_mask,fscal);
889
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);
894
895             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
896             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
897             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
898
899             }
900
901             /**************************
902              * CALCULATE INTERACTIONS *
903              **************************/
904
905             if (gmx_mm_any_lt(rsq11,rcutoff2))
906             {
907
908             r11              = _mm_mul_ps(rsq11,rinv11);
909             r11              = _mm_andnot_ps(dummy_mask,r11);
910
911             /* EWALD ELECTROSTATICS */
912
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);
922
923             cutoff_mask      = _mm_cmplt_ps(rsq11,rcutoff2);
924
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);
929
930             fscal            = felec;
931
932             fscal            = _mm_and_ps(fscal,cutoff_mask);
933
934             fscal            = _mm_andnot_ps(dummy_mask,fscal);
935
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);
940
941             fjx1             = _mm_macc_ps(dx11,fscal,fjx1);
942             fjy1             = _mm_macc_ps(dy11,fscal,fjy1);
943             fjz1             = _mm_macc_ps(dz11,fscal,fjz1);
944
945             }
946
947             /**************************
948              * CALCULATE INTERACTIONS *
949              **************************/
950
951             if (gmx_mm_any_lt(rsq12,rcutoff2))
952             {
953
954             r12              = _mm_mul_ps(rsq12,rinv12);
955             r12              = _mm_andnot_ps(dummy_mask,r12);
956
957             /* EWALD ELECTROSTATICS */
958
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);
968
969             cutoff_mask      = _mm_cmplt_ps(rsq12,rcutoff2);
970
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);
975
976             fscal            = felec;
977
978             fscal            = _mm_and_ps(fscal,cutoff_mask);
979
980             fscal            = _mm_andnot_ps(dummy_mask,fscal);
981
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);
986
987             fjx2             = _mm_macc_ps(dx12,fscal,fjx2);
988             fjy2             = _mm_macc_ps(dy12,fscal,fjy2);
989             fjz2             = _mm_macc_ps(dz12,fscal,fjz2);
990
991             }
992
993             /**************************
994              * CALCULATE INTERACTIONS *
995              **************************/
996
997             if (gmx_mm_any_lt(rsq13,rcutoff2))
998             {
999
1000             r13              = _mm_mul_ps(rsq13,rinv13);
1001             r13              = _mm_andnot_ps(dummy_mask,r13);
1002
1003             /* EWALD ELECTROSTATICS */
1004
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);
1014
1015             cutoff_mask      = _mm_cmplt_ps(rsq13,rcutoff2);
1016
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);
1021
1022             fscal            = felec;
1023
1024             fscal            = _mm_and_ps(fscal,cutoff_mask);
1025
1026             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1027
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);
1032
1033             fjx3             = _mm_macc_ps(dx13,fscal,fjx3);
1034             fjy3             = _mm_macc_ps(dy13,fscal,fjy3);
1035             fjz3             = _mm_macc_ps(dz13,fscal,fjz3);
1036
1037             }
1038
1039             /**************************
1040              * CALCULATE INTERACTIONS *
1041              **************************/
1042
1043             if (gmx_mm_any_lt(rsq21,rcutoff2))
1044             {
1045
1046             r21              = _mm_mul_ps(rsq21,rinv21);
1047             r21              = _mm_andnot_ps(dummy_mask,r21);
1048
1049             /* EWALD ELECTROSTATICS */
1050
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);
1060
1061             cutoff_mask      = _mm_cmplt_ps(rsq21,rcutoff2);
1062
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);
1067
1068             fscal            = felec;
1069
1070             fscal            = _mm_and_ps(fscal,cutoff_mask);
1071
1072             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1073
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);
1078
1079             fjx1             = _mm_macc_ps(dx21,fscal,fjx1);
1080             fjy1             = _mm_macc_ps(dy21,fscal,fjy1);
1081             fjz1             = _mm_macc_ps(dz21,fscal,fjz1);
1082
1083             }
1084
1085             /**************************
1086              * CALCULATE INTERACTIONS *
1087              **************************/
1088
1089             if (gmx_mm_any_lt(rsq22,rcutoff2))
1090             {
1091
1092             r22              = _mm_mul_ps(rsq22,rinv22);
1093             r22              = _mm_andnot_ps(dummy_mask,r22);
1094
1095             /* EWALD ELECTROSTATICS */
1096
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);
1106
1107             cutoff_mask      = _mm_cmplt_ps(rsq22,rcutoff2);
1108
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);
1113
1114             fscal            = felec;
1115
1116             fscal            = _mm_and_ps(fscal,cutoff_mask);
1117
1118             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1119
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);
1124
1125             fjx2             = _mm_macc_ps(dx22,fscal,fjx2);
1126             fjy2             = _mm_macc_ps(dy22,fscal,fjy2);
1127             fjz2             = _mm_macc_ps(dz22,fscal,fjz2);
1128
1129             }
1130
1131             /**************************
1132              * CALCULATE INTERACTIONS *
1133              **************************/
1134
1135             if (gmx_mm_any_lt(rsq23,rcutoff2))
1136             {
1137
1138             r23              = _mm_mul_ps(rsq23,rinv23);
1139             r23              = _mm_andnot_ps(dummy_mask,r23);
1140
1141             /* EWALD ELECTROSTATICS */
1142
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);
1152
1153             cutoff_mask      = _mm_cmplt_ps(rsq23,rcutoff2);
1154
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);
1159
1160             fscal            = felec;
1161
1162             fscal            = _mm_and_ps(fscal,cutoff_mask);
1163
1164             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1165
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);
1170
1171             fjx3             = _mm_macc_ps(dx23,fscal,fjx3);
1172             fjy3             = _mm_macc_ps(dy23,fscal,fjy3);
1173             fjz3             = _mm_macc_ps(dz23,fscal,fjz3);
1174
1175             }
1176
1177             /**************************
1178              * CALCULATE INTERACTIONS *
1179              **************************/
1180
1181             if (gmx_mm_any_lt(rsq31,rcutoff2))
1182             {
1183
1184             r31              = _mm_mul_ps(rsq31,rinv31);
1185             r31              = _mm_andnot_ps(dummy_mask,r31);
1186
1187             /* EWALD ELECTROSTATICS */
1188
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);
1198
1199             cutoff_mask      = _mm_cmplt_ps(rsq31,rcutoff2);
1200
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);
1205
1206             fscal            = felec;
1207
1208             fscal            = _mm_and_ps(fscal,cutoff_mask);
1209
1210             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1211
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);
1216
1217             fjx1             = _mm_macc_ps(dx31,fscal,fjx1);
1218             fjy1             = _mm_macc_ps(dy31,fscal,fjy1);
1219             fjz1             = _mm_macc_ps(dz31,fscal,fjz1);
1220
1221             }
1222
1223             /**************************
1224              * CALCULATE INTERACTIONS *
1225              **************************/
1226
1227             if (gmx_mm_any_lt(rsq32,rcutoff2))
1228             {
1229
1230             r32              = _mm_mul_ps(rsq32,rinv32);
1231             r32              = _mm_andnot_ps(dummy_mask,r32);
1232
1233             /* EWALD ELECTROSTATICS */
1234
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);
1244
1245             cutoff_mask      = _mm_cmplt_ps(rsq32,rcutoff2);
1246
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);
1251
1252             fscal            = felec;
1253
1254             fscal            = _mm_and_ps(fscal,cutoff_mask);
1255
1256             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1257
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);
1262
1263             fjx2             = _mm_macc_ps(dx32,fscal,fjx2);
1264             fjy2             = _mm_macc_ps(dy32,fscal,fjy2);
1265             fjz2             = _mm_macc_ps(dz32,fscal,fjz2);
1266
1267             }
1268
1269             /**************************
1270              * CALCULATE INTERACTIONS *
1271              **************************/
1272
1273             if (gmx_mm_any_lt(rsq33,rcutoff2))
1274             {
1275
1276             r33              = _mm_mul_ps(rsq33,rinv33);
1277             r33              = _mm_andnot_ps(dummy_mask,r33);
1278
1279             /* EWALD ELECTROSTATICS */
1280
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);
1290
1291             cutoff_mask      = _mm_cmplt_ps(rsq33,rcutoff2);
1292
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);
1297
1298             fscal            = felec;
1299
1300             fscal            = _mm_and_ps(fscal,cutoff_mask);
1301
1302             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1303
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);
1308
1309             fjx3             = _mm_macc_ps(dx33,fscal,fjx3);
1310             fjy3             = _mm_macc_ps(dy33,fscal,fjy3);
1311             fjz3             = _mm_macc_ps(dz33,fscal,fjz3);
1312
1313             }
1314
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;
1319
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);
1323
1324             /* Inner loop uses 353 flops */
1325         }
1326
1327         /* End of innermost loop */
1328
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);
1331
1332         ggid                        = gid[iidx];
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);
1336
1337         /* Increment number of inner iterations */
1338         inneriter                  += j_index_end - j_index_start;
1339
1340         /* Outer loop uses 26 flops */
1341     }
1342
1343     /* Increment number of outer iterations */
1344     outeriter        += nri;
1345
1346     /* Update outer/inner flops */
1347
1348     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*26 + inneriter*353);
1349 }
1350 /*
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
1356  */
1357 void
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)
1366 {
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.
1371      */
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;
1383     int              vdwioffset0;
1384     __m128           ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
1385     int              vdwioffset1;
1386     __m128           ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
1387     int              vdwioffset2;
1388     __m128           ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
1389     int              vdwioffset3;
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;
1410     real             *charge;
1411     int              nvdwtype;
1412     __m128           rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
1413     int              *vdwtype;
1414     real             *vdwparam;
1415     __m128           one_sixth   = _mm_set1_ps(1.0/6.0);
1416     __m128           one_twelfth = _mm_set1_ps(1.0/12.0);
1417     __m128i          ewitab;
1418     __m128           ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
1419     __m128           beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
1420     real             *ewtab;
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);
1425     x                = xx[0];
1426     f                = ff[0];
1427
1428     nri              = nlist->nri;
1429     iinr             = nlist->iinr;
1430     jindex           = nlist->jindex;
1431     jjnr             = nlist->jjnr;
1432     shiftidx         = nlist->shift;
1433     gid              = nlist->gid;
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;
1441
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);
1449
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];
1456
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);
1472
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);
1477
1478     sh_vdw_invrcut6  = _mm_set1_ps(fr->ic->sh_invrc6);
1479     rvdw             = _mm_set1_ps(fr->ic->rvdw);
1480
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;
1487
1488     outeriter        = 0;
1489     inneriter        = 0;
1490
1491     for(iidx=0;iidx<4*DIM;iidx++)
1492     {
1493         scratch[iidx] = 0.0;
1494     }
1495
1496     /* Start outer loop over neighborlists */
1497     for(iidx=0; iidx<nri; iidx++)
1498     {
1499         /* Load shift vector for this list */
1500         i_shift_offset   = DIM*shiftidx[iidx];
1501
1502         /* Load limits for loop over neighbors */
1503         j_index_start    = jindex[iidx];
1504         j_index_end      = jindex[iidx+1];
1505
1506         /* Get outer coordinate index */
1507         inr              = iinr[iidx];
1508         i_coord_offset   = DIM*inr;
1509
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);
1513
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();
1526
1527         /* Start inner kernel loop */
1528         for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
1529         {
1530
1531             /* Get j neighbor index, and coordinate index */
1532             jnrA             = jjnr[jidx];
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;
1540
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);
1546
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);
1578
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);
1590
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);
1600
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);
1611
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();
1624
1625             /**************************
1626              * CALCULATE INTERACTIONS *
1627              **************************/
1628
1629             if (gmx_mm_any_lt(rsq00,rcutoff2))
1630             {
1631
1632             /* LENNARD-JONES DISPERSION/REPULSION */
1633
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));
1636
1637             cutoff_mask      = _mm_cmplt_ps(rsq00,rcutoff2);
1638
1639             fscal            = fvdw;
1640
1641             fscal            = _mm_and_ps(fscal,cutoff_mask);
1642
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);
1647
1648             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
1649             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
1650             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
1651
1652             }
1653
1654             /**************************
1655              * CALCULATE INTERACTIONS *
1656              **************************/
1657
1658             if (gmx_mm_any_lt(rsq11,rcutoff2))
1659             {
1660
1661             r11              = _mm_mul_ps(rsq11,rinv11);
1662
1663             /* EWALD ELECTROSTATICS */
1664
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);
1671
1672             cutoff_mask      = _mm_cmplt_ps(rsq11,rcutoff2);
1673
1674             fscal            = felec;
1675
1676             fscal            = _mm_and_ps(fscal,cutoff_mask);
1677
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);
1682
1683             fjx1             = _mm_macc_ps(dx11,fscal,fjx1);
1684             fjy1             = _mm_macc_ps(dy11,fscal,fjy1);
1685             fjz1             = _mm_macc_ps(dz11,fscal,fjz1);
1686
1687             }
1688
1689             /**************************
1690              * CALCULATE INTERACTIONS *
1691              **************************/
1692
1693             if (gmx_mm_any_lt(rsq12,rcutoff2))
1694             {
1695
1696             r12              = _mm_mul_ps(rsq12,rinv12);
1697
1698             /* EWALD ELECTROSTATICS */
1699
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);
1706
1707             cutoff_mask      = _mm_cmplt_ps(rsq12,rcutoff2);
1708
1709             fscal            = felec;
1710
1711             fscal            = _mm_and_ps(fscal,cutoff_mask);
1712
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);
1717
1718             fjx2             = _mm_macc_ps(dx12,fscal,fjx2);
1719             fjy2             = _mm_macc_ps(dy12,fscal,fjy2);
1720             fjz2             = _mm_macc_ps(dz12,fscal,fjz2);
1721
1722             }
1723
1724             /**************************
1725              * CALCULATE INTERACTIONS *
1726              **************************/
1727
1728             if (gmx_mm_any_lt(rsq13,rcutoff2))
1729             {
1730
1731             r13              = _mm_mul_ps(rsq13,rinv13);
1732
1733             /* EWALD ELECTROSTATICS */
1734
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);
1741
1742             cutoff_mask      = _mm_cmplt_ps(rsq13,rcutoff2);
1743
1744             fscal            = felec;
1745
1746             fscal            = _mm_and_ps(fscal,cutoff_mask);
1747
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);
1752
1753             fjx3             = _mm_macc_ps(dx13,fscal,fjx3);
1754             fjy3             = _mm_macc_ps(dy13,fscal,fjy3);
1755             fjz3             = _mm_macc_ps(dz13,fscal,fjz3);
1756
1757             }
1758
1759             /**************************
1760              * CALCULATE INTERACTIONS *
1761              **************************/
1762
1763             if (gmx_mm_any_lt(rsq21,rcutoff2))
1764             {
1765
1766             r21              = _mm_mul_ps(rsq21,rinv21);
1767
1768             /* EWALD ELECTROSTATICS */
1769
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);
1776
1777             cutoff_mask      = _mm_cmplt_ps(rsq21,rcutoff2);
1778
1779             fscal            = felec;
1780
1781             fscal            = _mm_and_ps(fscal,cutoff_mask);
1782
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);
1787
1788             fjx1             = _mm_macc_ps(dx21,fscal,fjx1);
1789             fjy1             = _mm_macc_ps(dy21,fscal,fjy1);
1790             fjz1             = _mm_macc_ps(dz21,fscal,fjz1);
1791
1792             }
1793
1794             /**************************
1795              * CALCULATE INTERACTIONS *
1796              **************************/
1797
1798             if (gmx_mm_any_lt(rsq22,rcutoff2))
1799             {
1800
1801             r22              = _mm_mul_ps(rsq22,rinv22);
1802
1803             /* EWALD ELECTROSTATICS */
1804
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);
1811
1812             cutoff_mask      = _mm_cmplt_ps(rsq22,rcutoff2);
1813
1814             fscal            = felec;
1815
1816             fscal            = _mm_and_ps(fscal,cutoff_mask);
1817
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);
1822
1823             fjx2             = _mm_macc_ps(dx22,fscal,fjx2);
1824             fjy2             = _mm_macc_ps(dy22,fscal,fjy2);
1825             fjz2             = _mm_macc_ps(dz22,fscal,fjz2);
1826
1827             }
1828
1829             /**************************
1830              * CALCULATE INTERACTIONS *
1831              **************************/
1832
1833             if (gmx_mm_any_lt(rsq23,rcutoff2))
1834             {
1835
1836             r23              = _mm_mul_ps(rsq23,rinv23);
1837
1838             /* EWALD ELECTROSTATICS */
1839
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);
1846
1847             cutoff_mask      = _mm_cmplt_ps(rsq23,rcutoff2);
1848
1849             fscal            = felec;
1850
1851             fscal            = _mm_and_ps(fscal,cutoff_mask);
1852
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);
1857
1858             fjx3             = _mm_macc_ps(dx23,fscal,fjx3);
1859             fjy3             = _mm_macc_ps(dy23,fscal,fjy3);
1860             fjz3             = _mm_macc_ps(dz23,fscal,fjz3);
1861
1862             }
1863
1864             /**************************
1865              * CALCULATE INTERACTIONS *
1866              **************************/
1867
1868             if (gmx_mm_any_lt(rsq31,rcutoff2))
1869             {
1870
1871             r31              = _mm_mul_ps(rsq31,rinv31);
1872
1873             /* EWALD ELECTROSTATICS */
1874
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);
1881
1882             cutoff_mask      = _mm_cmplt_ps(rsq31,rcutoff2);
1883
1884             fscal            = felec;
1885
1886             fscal            = _mm_and_ps(fscal,cutoff_mask);
1887
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);
1892
1893             fjx1             = _mm_macc_ps(dx31,fscal,fjx1);
1894             fjy1             = _mm_macc_ps(dy31,fscal,fjy1);
1895             fjz1             = _mm_macc_ps(dz31,fscal,fjz1);
1896
1897             }
1898
1899             /**************************
1900              * CALCULATE INTERACTIONS *
1901              **************************/
1902
1903             if (gmx_mm_any_lt(rsq32,rcutoff2))
1904             {
1905
1906             r32              = _mm_mul_ps(rsq32,rinv32);
1907
1908             /* EWALD ELECTROSTATICS */
1909
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);
1916
1917             cutoff_mask      = _mm_cmplt_ps(rsq32,rcutoff2);
1918
1919             fscal            = felec;
1920
1921             fscal            = _mm_and_ps(fscal,cutoff_mask);
1922
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);
1927
1928             fjx2             = _mm_macc_ps(dx32,fscal,fjx2);
1929             fjy2             = _mm_macc_ps(dy32,fscal,fjy2);
1930             fjz2             = _mm_macc_ps(dz32,fscal,fjz2);
1931
1932             }
1933
1934             /**************************
1935              * CALCULATE INTERACTIONS *
1936              **************************/
1937
1938             if (gmx_mm_any_lt(rsq33,rcutoff2))
1939             {
1940
1941             r33              = _mm_mul_ps(rsq33,rinv33);
1942
1943             /* EWALD ELECTROSTATICS */
1944
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);
1951
1952             cutoff_mask      = _mm_cmplt_ps(rsq33,rcutoff2);
1953
1954             fscal            = felec;
1955
1956             fscal            = _mm_and_ps(fscal,cutoff_mask);
1957
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);
1962
1963             fjx3             = _mm_macc_ps(dx33,fscal,fjx3);
1964             fjy3             = _mm_macc_ps(dy33,fscal,fjy3);
1965             fjz3             = _mm_macc_ps(dz33,fscal,fjz3);
1966
1967             }
1968
1969             fjptrA             = f+j_coord_offsetA;
1970             fjptrB             = f+j_coord_offsetB;
1971             fjptrC             = f+j_coord_offsetC;
1972             fjptrD             = f+j_coord_offsetD;
1973
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);
1977
1978             /* Inner loop uses 315 flops */
1979         }
1980
1981         if(jidx<j_index_end)
1982         {
1983
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.
1992              */
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;
2002
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);
2008
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);
2040
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);
2052
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);
2062
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);
2073
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();
2086
2087             /**************************
2088              * CALCULATE INTERACTIONS *
2089              **************************/
2090
2091             if (gmx_mm_any_lt(rsq00,rcutoff2))
2092             {
2093
2094             /* LENNARD-JONES DISPERSION/REPULSION */
2095
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));
2098
2099             cutoff_mask      = _mm_cmplt_ps(rsq00,rcutoff2);
2100
2101             fscal            = fvdw;
2102
2103             fscal            = _mm_and_ps(fscal,cutoff_mask);
2104
2105             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2106
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);
2111
2112             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
2113             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
2114             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
2115
2116             }
2117
2118             /**************************
2119              * CALCULATE INTERACTIONS *
2120              **************************/
2121
2122             if (gmx_mm_any_lt(rsq11,rcutoff2))
2123             {
2124
2125             r11              = _mm_mul_ps(rsq11,rinv11);
2126             r11              = _mm_andnot_ps(dummy_mask,r11);
2127
2128             /* EWALD ELECTROSTATICS */
2129
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);
2136
2137             cutoff_mask      = _mm_cmplt_ps(rsq11,rcutoff2);
2138
2139             fscal            = felec;
2140
2141             fscal            = _mm_and_ps(fscal,cutoff_mask);
2142
2143             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2144
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);
2149
2150             fjx1             = _mm_macc_ps(dx11,fscal,fjx1);
2151             fjy1             = _mm_macc_ps(dy11,fscal,fjy1);
2152             fjz1             = _mm_macc_ps(dz11,fscal,fjz1);
2153
2154             }
2155
2156             /**************************
2157              * CALCULATE INTERACTIONS *
2158              **************************/
2159
2160             if (gmx_mm_any_lt(rsq12,rcutoff2))
2161             {
2162
2163             r12              = _mm_mul_ps(rsq12,rinv12);
2164             r12              = _mm_andnot_ps(dummy_mask,r12);
2165
2166             /* EWALD ELECTROSTATICS */
2167
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);
2174
2175             cutoff_mask      = _mm_cmplt_ps(rsq12,rcutoff2);
2176
2177             fscal            = felec;
2178
2179             fscal            = _mm_and_ps(fscal,cutoff_mask);
2180
2181             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2182
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);
2187
2188             fjx2             = _mm_macc_ps(dx12,fscal,fjx2);
2189             fjy2             = _mm_macc_ps(dy12,fscal,fjy2);
2190             fjz2             = _mm_macc_ps(dz12,fscal,fjz2);
2191
2192             }
2193
2194             /**************************
2195              * CALCULATE INTERACTIONS *
2196              **************************/
2197
2198             if (gmx_mm_any_lt(rsq13,rcutoff2))
2199             {
2200
2201             r13              = _mm_mul_ps(rsq13,rinv13);
2202             r13              = _mm_andnot_ps(dummy_mask,r13);
2203
2204             /* EWALD ELECTROSTATICS */
2205
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);
2212
2213             cutoff_mask      = _mm_cmplt_ps(rsq13,rcutoff2);
2214
2215             fscal            = felec;
2216
2217             fscal            = _mm_and_ps(fscal,cutoff_mask);
2218
2219             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2220
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);
2225
2226             fjx3             = _mm_macc_ps(dx13,fscal,fjx3);
2227             fjy3             = _mm_macc_ps(dy13,fscal,fjy3);
2228             fjz3             = _mm_macc_ps(dz13,fscal,fjz3);
2229
2230             }
2231
2232             /**************************
2233              * CALCULATE INTERACTIONS *
2234              **************************/
2235
2236             if (gmx_mm_any_lt(rsq21,rcutoff2))
2237             {
2238
2239             r21              = _mm_mul_ps(rsq21,rinv21);
2240             r21              = _mm_andnot_ps(dummy_mask,r21);
2241
2242             /* EWALD ELECTROSTATICS */
2243
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);
2250
2251             cutoff_mask      = _mm_cmplt_ps(rsq21,rcutoff2);
2252
2253             fscal            = felec;
2254
2255             fscal            = _mm_and_ps(fscal,cutoff_mask);
2256
2257             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2258
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);
2263
2264             fjx1             = _mm_macc_ps(dx21,fscal,fjx1);
2265             fjy1             = _mm_macc_ps(dy21,fscal,fjy1);
2266             fjz1             = _mm_macc_ps(dz21,fscal,fjz1);
2267
2268             }
2269
2270             /**************************
2271              * CALCULATE INTERACTIONS *
2272              **************************/
2273
2274             if (gmx_mm_any_lt(rsq22,rcutoff2))
2275             {
2276
2277             r22              = _mm_mul_ps(rsq22,rinv22);
2278             r22              = _mm_andnot_ps(dummy_mask,r22);
2279
2280             /* EWALD ELECTROSTATICS */
2281
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);
2288
2289             cutoff_mask      = _mm_cmplt_ps(rsq22,rcutoff2);
2290
2291             fscal            = felec;
2292
2293             fscal            = _mm_and_ps(fscal,cutoff_mask);
2294
2295             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2296
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);
2301
2302             fjx2             = _mm_macc_ps(dx22,fscal,fjx2);
2303             fjy2             = _mm_macc_ps(dy22,fscal,fjy2);
2304             fjz2             = _mm_macc_ps(dz22,fscal,fjz2);
2305
2306             }
2307
2308             /**************************
2309              * CALCULATE INTERACTIONS *
2310              **************************/
2311
2312             if (gmx_mm_any_lt(rsq23,rcutoff2))
2313             {
2314
2315             r23              = _mm_mul_ps(rsq23,rinv23);
2316             r23              = _mm_andnot_ps(dummy_mask,r23);
2317
2318             /* EWALD ELECTROSTATICS */
2319
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);
2326
2327             cutoff_mask      = _mm_cmplt_ps(rsq23,rcutoff2);
2328
2329             fscal            = felec;
2330
2331             fscal            = _mm_and_ps(fscal,cutoff_mask);
2332
2333             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2334
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);
2339
2340             fjx3             = _mm_macc_ps(dx23,fscal,fjx3);
2341             fjy3             = _mm_macc_ps(dy23,fscal,fjy3);
2342             fjz3             = _mm_macc_ps(dz23,fscal,fjz3);
2343
2344             }
2345
2346             /**************************
2347              * CALCULATE INTERACTIONS *
2348              **************************/
2349
2350             if (gmx_mm_any_lt(rsq31,rcutoff2))
2351             {
2352
2353             r31              = _mm_mul_ps(rsq31,rinv31);
2354             r31              = _mm_andnot_ps(dummy_mask,r31);
2355
2356             /* EWALD ELECTROSTATICS */
2357
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);
2364
2365             cutoff_mask      = _mm_cmplt_ps(rsq31,rcutoff2);
2366
2367             fscal            = felec;
2368
2369             fscal            = _mm_and_ps(fscal,cutoff_mask);
2370
2371             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2372
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);
2377
2378             fjx1             = _mm_macc_ps(dx31,fscal,fjx1);
2379             fjy1             = _mm_macc_ps(dy31,fscal,fjy1);
2380             fjz1             = _mm_macc_ps(dz31,fscal,fjz1);
2381
2382             }
2383
2384             /**************************
2385              * CALCULATE INTERACTIONS *
2386              **************************/
2387
2388             if (gmx_mm_any_lt(rsq32,rcutoff2))
2389             {
2390
2391             r32              = _mm_mul_ps(rsq32,rinv32);
2392             r32              = _mm_andnot_ps(dummy_mask,r32);
2393
2394             /* EWALD ELECTROSTATICS */
2395
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);
2402
2403             cutoff_mask      = _mm_cmplt_ps(rsq32,rcutoff2);
2404
2405             fscal            = felec;
2406
2407             fscal            = _mm_and_ps(fscal,cutoff_mask);
2408
2409             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2410
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);
2415
2416             fjx2             = _mm_macc_ps(dx32,fscal,fjx2);
2417             fjy2             = _mm_macc_ps(dy32,fscal,fjy2);
2418             fjz2             = _mm_macc_ps(dz32,fscal,fjz2);
2419
2420             }
2421
2422             /**************************
2423              * CALCULATE INTERACTIONS *
2424              **************************/
2425
2426             if (gmx_mm_any_lt(rsq33,rcutoff2))
2427             {
2428
2429             r33              = _mm_mul_ps(rsq33,rinv33);
2430             r33              = _mm_andnot_ps(dummy_mask,r33);
2431
2432             /* EWALD ELECTROSTATICS */
2433
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);
2440
2441             cutoff_mask      = _mm_cmplt_ps(rsq33,rcutoff2);
2442
2443             fscal            = felec;
2444
2445             fscal            = _mm_and_ps(fscal,cutoff_mask);
2446
2447             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2448
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);
2453
2454             fjx3             = _mm_macc_ps(dx33,fscal,fjx3);
2455             fjy3             = _mm_macc_ps(dy33,fscal,fjy3);
2456             fjz3             = _mm_macc_ps(dz33,fscal,fjz3);
2457
2458             }
2459
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;
2464
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);
2468
2469             /* Inner loop uses 324 flops */
2470         }
2471
2472         /* End of innermost loop */
2473
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);
2476
2477         /* Increment number of inner iterations */
2478         inneriter                  += j_index_end - j_index_start;
2479
2480         /* Outer loop uses 24 flops */
2481     }
2482
2483     /* Increment number of outer iterations */
2484     outeriter        += nri;
2485
2486     /* Update outer/inner flops */
2487
2488     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*24 + inneriter*324);
2489 }