Valgrind suppression for OS X 10.9
[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, 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 #ifdef HAVE_CONFIG_H
39 #include <config.h>
40 #endif
41
42 #include <math.h>
43
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
46 #include "vec.h"
47 #include "nrnb.h"
48
49 #include "gromacs/simd/math_x86_avx_128_fma_single.h"
50 #include "kernelutil_x86_avx_128_fma_single.h"
51
52 /*
53  * Gromacs nonbonded kernel:   nb_kernel_ElecEwSh_VdwLJSh_GeomW4W4_VF_avx_128_fma_single
54  * Electrostatics interaction: Ewald
55  * VdW interaction:            LennardJones
56  * Geometry:                   Water4-Water4
57  * Calculate force/pot:        PotentialAndForce
58  */
59 void
60 nb_kernel_ElecEwSh_VdwLJSh_GeomW4W4_VF_avx_128_fma_single
61                     (t_nblist                    * gmx_restrict       nlist,
62                      rvec                        * gmx_restrict          xx,
63                      rvec                        * gmx_restrict          ff,
64                      t_forcerec                  * gmx_restrict          fr,
65                      t_mdatoms                   * gmx_restrict     mdatoms,
66                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
67                      t_nrnb                      * gmx_restrict        nrnb)
68 {
69     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
70      * just 0 for non-waters.
71      * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
72      * jnr indices corresponding to data put in the four positions in the SIMD register.
73      */
74     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
75     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
76     int              jnrA,jnrB,jnrC,jnrD;
77     int              jnrlistA,jnrlistB,jnrlistC,jnrlistD;
78     int              j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
79     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
80     real             rcutoff_scalar;
81     real             *shiftvec,*fshift,*x,*f;
82     real             *fjptrA,*fjptrB,*fjptrC,*fjptrD;
83     real             scratch[4*DIM];
84     __m128           fscal,rcutoff,rcutoff2,jidxall;
85     int              vdwioffset0;
86     __m128           ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
87     int              vdwioffset1;
88     __m128           ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
89     int              vdwioffset2;
90     __m128           ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
91     int              vdwioffset3;
92     __m128           ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
93     int              vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
94     __m128           jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
95     int              vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D;
96     __m128           jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
97     int              vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D;
98     __m128           jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
99     int              vdwjidx3A,vdwjidx3B,vdwjidx3C,vdwjidx3D;
100     __m128           jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
101     __m128           dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
102     __m128           dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
103     __m128           dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
104     __m128           dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
105     __m128           dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
106     __m128           dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
107     __m128           dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
108     __m128           dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
109     __m128           dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
110     __m128           dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
111     __m128           velec,felec,velecsum,facel,crf,krf,krf2;
112     real             *charge;
113     int              nvdwtype;
114     __m128           rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
115     int              *vdwtype;
116     real             *vdwparam;
117     __m128           one_sixth   = _mm_set1_ps(1.0/6.0);
118     __m128           one_twelfth = _mm_set1_ps(1.0/12.0);
119     __m128i          ewitab;
120     __m128           ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
121     __m128           beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
122     real             *ewtab;
123     __m128           dummy_mask,cutoff_mask;
124     __m128           signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
125     __m128           one     = _mm_set1_ps(1.0);
126     __m128           two     = _mm_set1_ps(2.0);
127     x                = xx[0];
128     f                = ff[0];
129
130     nri              = nlist->nri;
131     iinr             = nlist->iinr;
132     jindex           = nlist->jindex;
133     jjnr             = nlist->jjnr;
134     shiftidx         = nlist->shift;
135     gid              = nlist->gid;
136     shiftvec         = fr->shift_vec[0];
137     fshift           = fr->fshift[0];
138     facel            = _mm_set1_ps(fr->epsfac);
139     charge           = mdatoms->chargeA;
140     nvdwtype         = fr->ntype;
141     vdwparam         = fr->nbfp;
142     vdwtype          = mdatoms->typeA;
143
144     sh_ewald         = _mm_set1_ps(fr->ic->sh_ewald);
145     beta             = _mm_set1_ps(fr->ic->ewaldcoeff_q);
146     beta2            = _mm_mul_ps(beta,beta);
147     beta3            = _mm_mul_ps(beta,beta2);
148     ewtab            = fr->ic->tabq_coul_FDV0;
149     ewtabscale       = _mm_set1_ps(fr->ic->tabq_scale);
150     ewtabhalfspace   = _mm_set1_ps(0.5/fr->ic->tabq_scale);
151
152     /* Setup water-specific parameters */
153     inr              = nlist->iinr[0];
154     iq1              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
155     iq2              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
156     iq3              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
157     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
158
159     jq1              = _mm_set1_ps(charge[inr+1]);
160     jq2              = _mm_set1_ps(charge[inr+2]);
161     jq3              = _mm_set1_ps(charge[inr+3]);
162     vdwjidx0A        = 2*vdwtype[inr+0];
163     c6_00            = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A]);
164     c12_00           = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A+1]);
165     qq11             = _mm_mul_ps(iq1,jq1);
166     qq12             = _mm_mul_ps(iq1,jq2);
167     qq13             = _mm_mul_ps(iq1,jq3);
168     qq21             = _mm_mul_ps(iq2,jq1);
169     qq22             = _mm_mul_ps(iq2,jq2);
170     qq23             = _mm_mul_ps(iq2,jq3);
171     qq31             = _mm_mul_ps(iq3,jq1);
172     qq32             = _mm_mul_ps(iq3,jq2);
173     qq33             = _mm_mul_ps(iq3,jq3);
174
175     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
176     rcutoff_scalar   = fr->rcoulomb;
177     rcutoff          = _mm_set1_ps(rcutoff_scalar);
178     rcutoff2         = _mm_mul_ps(rcutoff,rcutoff);
179
180     sh_vdw_invrcut6  = _mm_set1_ps(fr->ic->sh_invrc6);
181     rvdw             = _mm_set1_ps(fr->rvdw);
182
183     /* Avoid stupid compiler warnings */
184     jnrA = jnrB = jnrC = jnrD = 0;
185     j_coord_offsetA = 0;
186     j_coord_offsetB = 0;
187     j_coord_offsetC = 0;
188     j_coord_offsetD = 0;
189
190     outeriter        = 0;
191     inneriter        = 0;
192
193     for(iidx=0;iidx<4*DIM;iidx++)
194     {
195         scratch[iidx] = 0.0;
196     }
197
198     /* Start outer loop over neighborlists */
199     for(iidx=0; iidx<nri; iidx++)
200     {
201         /* Load shift vector for this list */
202         i_shift_offset   = DIM*shiftidx[iidx];
203
204         /* Load limits for loop over neighbors */
205         j_index_start    = jindex[iidx];
206         j_index_end      = jindex[iidx+1];
207
208         /* Get outer coordinate index */
209         inr              = iinr[iidx];
210         i_coord_offset   = DIM*inr;
211
212         /* Load i particle coords and add shift vector */
213         gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
214                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
215
216         fix0             = _mm_setzero_ps();
217         fiy0             = _mm_setzero_ps();
218         fiz0             = _mm_setzero_ps();
219         fix1             = _mm_setzero_ps();
220         fiy1             = _mm_setzero_ps();
221         fiz1             = _mm_setzero_ps();
222         fix2             = _mm_setzero_ps();
223         fiy2             = _mm_setzero_ps();
224         fiz2             = _mm_setzero_ps();
225         fix3             = _mm_setzero_ps();
226         fiy3             = _mm_setzero_ps();
227         fiz3             = _mm_setzero_ps();
228
229         /* Reset potential sums */
230         velecsum         = _mm_setzero_ps();
231         vvdwsum          = _mm_setzero_ps();
232
233         /* Start inner kernel loop */
234         for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
235         {
236
237             /* Get j neighbor index, and coordinate index */
238             jnrA             = jjnr[jidx];
239             jnrB             = jjnr[jidx+1];
240             jnrC             = jjnr[jidx+2];
241             jnrD             = jjnr[jidx+3];
242             j_coord_offsetA  = DIM*jnrA;
243             j_coord_offsetB  = DIM*jnrB;
244             j_coord_offsetC  = DIM*jnrC;
245             j_coord_offsetD  = DIM*jnrD;
246
247             /* load j atom coordinates */
248             gmx_mm_load_4rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
249                                               x+j_coord_offsetC,x+j_coord_offsetD,
250                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
251                                               &jy2,&jz2,&jx3,&jy3,&jz3);
252
253             /* Calculate displacement vector */
254             dx00             = _mm_sub_ps(ix0,jx0);
255             dy00             = _mm_sub_ps(iy0,jy0);
256             dz00             = _mm_sub_ps(iz0,jz0);
257             dx11             = _mm_sub_ps(ix1,jx1);
258             dy11             = _mm_sub_ps(iy1,jy1);
259             dz11             = _mm_sub_ps(iz1,jz1);
260             dx12             = _mm_sub_ps(ix1,jx2);
261             dy12             = _mm_sub_ps(iy1,jy2);
262             dz12             = _mm_sub_ps(iz1,jz2);
263             dx13             = _mm_sub_ps(ix1,jx3);
264             dy13             = _mm_sub_ps(iy1,jy3);
265             dz13             = _mm_sub_ps(iz1,jz3);
266             dx21             = _mm_sub_ps(ix2,jx1);
267             dy21             = _mm_sub_ps(iy2,jy1);
268             dz21             = _mm_sub_ps(iz2,jz1);
269             dx22             = _mm_sub_ps(ix2,jx2);
270             dy22             = _mm_sub_ps(iy2,jy2);
271             dz22             = _mm_sub_ps(iz2,jz2);
272             dx23             = _mm_sub_ps(ix2,jx3);
273             dy23             = _mm_sub_ps(iy2,jy3);
274             dz23             = _mm_sub_ps(iz2,jz3);
275             dx31             = _mm_sub_ps(ix3,jx1);
276             dy31             = _mm_sub_ps(iy3,jy1);
277             dz31             = _mm_sub_ps(iz3,jz1);
278             dx32             = _mm_sub_ps(ix3,jx2);
279             dy32             = _mm_sub_ps(iy3,jy2);
280             dz32             = _mm_sub_ps(iz3,jz2);
281             dx33             = _mm_sub_ps(ix3,jx3);
282             dy33             = _mm_sub_ps(iy3,jy3);
283             dz33             = _mm_sub_ps(iz3,jz3);
284
285             /* Calculate squared distance and things based on it */
286             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
287             rsq11            = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
288             rsq12            = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
289             rsq13            = gmx_mm_calc_rsq_ps(dx13,dy13,dz13);
290             rsq21            = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
291             rsq22            = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
292             rsq23            = gmx_mm_calc_rsq_ps(dx23,dy23,dz23);
293             rsq31            = gmx_mm_calc_rsq_ps(dx31,dy31,dz31);
294             rsq32            = gmx_mm_calc_rsq_ps(dx32,dy32,dz32);
295             rsq33            = gmx_mm_calc_rsq_ps(dx33,dy33,dz33);
296
297             rinv11           = gmx_mm_invsqrt_ps(rsq11);
298             rinv12           = gmx_mm_invsqrt_ps(rsq12);
299             rinv13           = gmx_mm_invsqrt_ps(rsq13);
300             rinv21           = gmx_mm_invsqrt_ps(rsq21);
301             rinv22           = gmx_mm_invsqrt_ps(rsq22);
302             rinv23           = gmx_mm_invsqrt_ps(rsq23);
303             rinv31           = gmx_mm_invsqrt_ps(rsq31);
304             rinv32           = gmx_mm_invsqrt_ps(rsq32);
305             rinv33           = gmx_mm_invsqrt_ps(rsq33);
306
307             rinvsq00         = gmx_mm_inv_ps(rsq00);
308             rinvsq11         = _mm_mul_ps(rinv11,rinv11);
309             rinvsq12         = _mm_mul_ps(rinv12,rinv12);
310             rinvsq13         = _mm_mul_ps(rinv13,rinv13);
311             rinvsq21         = _mm_mul_ps(rinv21,rinv21);
312             rinvsq22         = _mm_mul_ps(rinv22,rinv22);
313             rinvsq23         = _mm_mul_ps(rinv23,rinv23);
314             rinvsq31         = _mm_mul_ps(rinv31,rinv31);
315             rinvsq32         = _mm_mul_ps(rinv32,rinv32);
316             rinvsq33         = _mm_mul_ps(rinv33,rinv33);
317
318             fjx0             = _mm_setzero_ps();
319             fjy0             = _mm_setzero_ps();
320             fjz0             = _mm_setzero_ps();
321             fjx1             = _mm_setzero_ps();
322             fjy1             = _mm_setzero_ps();
323             fjz1             = _mm_setzero_ps();
324             fjx2             = _mm_setzero_ps();
325             fjy2             = _mm_setzero_ps();
326             fjz2             = _mm_setzero_ps();
327             fjx3             = _mm_setzero_ps();
328             fjy3             = _mm_setzero_ps();
329             fjz3             = _mm_setzero_ps();
330
331             /**************************
332              * CALCULATE INTERACTIONS *
333              **************************/
334
335             if (gmx_mm_any_lt(rsq00,rcutoff2))
336             {
337
338             /* LENNARD-JONES DISPERSION/REPULSION */
339
340             rinvsix          = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
341             vvdw6            = _mm_mul_ps(c6_00,rinvsix);
342             vvdw12           = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
343             vvdw             = _mm_msub_ps(_mm_nmacc_ps(c12_00,_mm_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
344                                           _mm_mul_ps( _mm_nmacc_ps(c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
345             fvdw             = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
346
347             cutoff_mask      = _mm_cmplt_ps(rsq00,rcutoff2);
348
349             /* Update potential sum for this i atom from the interaction with this j atom. */
350             vvdw             = _mm_and_ps(vvdw,cutoff_mask);
351             vvdwsum          = _mm_add_ps(vvdwsum,vvdw);
352
353             fscal            = fvdw;
354
355             fscal            = _mm_and_ps(fscal,cutoff_mask);
356
357              /* Update vectorial force */
358             fix0             = _mm_macc_ps(dx00,fscal,fix0);
359             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
360             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
361
362             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
363             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
364             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
365
366             }
367
368             /**************************
369              * CALCULATE INTERACTIONS *
370              **************************/
371
372             if (gmx_mm_any_lt(rsq11,rcutoff2))
373             {
374
375             r11              = _mm_mul_ps(rsq11,rinv11);
376
377             /* EWALD ELECTROSTATICS */
378
379             /* Analytical PME correction */
380             zeta2            = _mm_mul_ps(beta2,rsq11);
381             rinv3            = _mm_mul_ps(rinvsq11,rinv11);
382             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
383             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
384             felec            = _mm_mul_ps(qq11,felec);
385             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
386             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv11,sh_ewald));
387             velec            = _mm_mul_ps(qq11,velec);
388
389             cutoff_mask      = _mm_cmplt_ps(rsq11,rcutoff2);
390
391             /* Update potential sum for this i atom from the interaction with this j atom. */
392             velec            = _mm_and_ps(velec,cutoff_mask);
393             velecsum         = _mm_add_ps(velecsum,velec);
394
395             fscal            = felec;
396
397             fscal            = _mm_and_ps(fscal,cutoff_mask);
398
399              /* Update vectorial force */
400             fix1             = _mm_macc_ps(dx11,fscal,fix1);
401             fiy1             = _mm_macc_ps(dy11,fscal,fiy1);
402             fiz1             = _mm_macc_ps(dz11,fscal,fiz1);
403
404             fjx1             = _mm_macc_ps(dx11,fscal,fjx1);
405             fjy1             = _mm_macc_ps(dy11,fscal,fjy1);
406             fjz1             = _mm_macc_ps(dz11,fscal,fjz1);
407
408             }
409
410             /**************************
411              * CALCULATE INTERACTIONS *
412              **************************/
413
414             if (gmx_mm_any_lt(rsq12,rcutoff2))
415             {
416
417             r12              = _mm_mul_ps(rsq12,rinv12);
418
419             /* EWALD ELECTROSTATICS */
420
421             /* Analytical PME correction */
422             zeta2            = _mm_mul_ps(beta2,rsq12);
423             rinv3            = _mm_mul_ps(rinvsq12,rinv12);
424             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
425             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
426             felec            = _mm_mul_ps(qq12,felec);
427             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
428             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv12,sh_ewald));
429             velec            = _mm_mul_ps(qq12,velec);
430
431             cutoff_mask      = _mm_cmplt_ps(rsq12,rcutoff2);
432
433             /* Update potential sum for this i atom from the interaction with this j atom. */
434             velec            = _mm_and_ps(velec,cutoff_mask);
435             velecsum         = _mm_add_ps(velecsum,velec);
436
437             fscal            = felec;
438
439             fscal            = _mm_and_ps(fscal,cutoff_mask);
440
441              /* Update vectorial force */
442             fix1             = _mm_macc_ps(dx12,fscal,fix1);
443             fiy1             = _mm_macc_ps(dy12,fscal,fiy1);
444             fiz1             = _mm_macc_ps(dz12,fscal,fiz1);
445
446             fjx2             = _mm_macc_ps(dx12,fscal,fjx2);
447             fjy2             = _mm_macc_ps(dy12,fscal,fjy2);
448             fjz2             = _mm_macc_ps(dz12,fscal,fjz2);
449
450             }
451
452             /**************************
453              * CALCULATE INTERACTIONS *
454              **************************/
455
456             if (gmx_mm_any_lt(rsq13,rcutoff2))
457             {
458
459             r13              = _mm_mul_ps(rsq13,rinv13);
460
461             /* EWALD ELECTROSTATICS */
462
463             /* Analytical PME correction */
464             zeta2            = _mm_mul_ps(beta2,rsq13);
465             rinv3            = _mm_mul_ps(rinvsq13,rinv13);
466             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
467             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
468             felec            = _mm_mul_ps(qq13,felec);
469             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
470             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv13,sh_ewald));
471             velec            = _mm_mul_ps(qq13,velec);
472
473             cutoff_mask      = _mm_cmplt_ps(rsq13,rcutoff2);
474
475             /* Update potential sum for this i atom from the interaction with this j atom. */
476             velec            = _mm_and_ps(velec,cutoff_mask);
477             velecsum         = _mm_add_ps(velecsum,velec);
478
479             fscal            = felec;
480
481             fscal            = _mm_and_ps(fscal,cutoff_mask);
482
483              /* Update vectorial force */
484             fix1             = _mm_macc_ps(dx13,fscal,fix1);
485             fiy1             = _mm_macc_ps(dy13,fscal,fiy1);
486             fiz1             = _mm_macc_ps(dz13,fscal,fiz1);
487
488             fjx3             = _mm_macc_ps(dx13,fscal,fjx3);
489             fjy3             = _mm_macc_ps(dy13,fscal,fjy3);
490             fjz3             = _mm_macc_ps(dz13,fscal,fjz3);
491
492             }
493
494             /**************************
495              * CALCULATE INTERACTIONS *
496              **************************/
497
498             if (gmx_mm_any_lt(rsq21,rcutoff2))
499             {
500
501             r21              = _mm_mul_ps(rsq21,rinv21);
502
503             /* EWALD ELECTROSTATICS */
504
505             /* Analytical PME correction */
506             zeta2            = _mm_mul_ps(beta2,rsq21);
507             rinv3            = _mm_mul_ps(rinvsq21,rinv21);
508             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
509             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
510             felec            = _mm_mul_ps(qq21,felec);
511             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
512             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv21,sh_ewald));
513             velec            = _mm_mul_ps(qq21,velec);
514
515             cutoff_mask      = _mm_cmplt_ps(rsq21,rcutoff2);
516
517             /* Update potential sum for this i atom from the interaction with this j atom. */
518             velec            = _mm_and_ps(velec,cutoff_mask);
519             velecsum         = _mm_add_ps(velecsum,velec);
520
521             fscal            = felec;
522
523             fscal            = _mm_and_ps(fscal,cutoff_mask);
524
525              /* Update vectorial force */
526             fix2             = _mm_macc_ps(dx21,fscal,fix2);
527             fiy2             = _mm_macc_ps(dy21,fscal,fiy2);
528             fiz2             = _mm_macc_ps(dz21,fscal,fiz2);
529
530             fjx1             = _mm_macc_ps(dx21,fscal,fjx1);
531             fjy1             = _mm_macc_ps(dy21,fscal,fjy1);
532             fjz1             = _mm_macc_ps(dz21,fscal,fjz1);
533
534             }
535
536             /**************************
537              * CALCULATE INTERACTIONS *
538              **************************/
539
540             if (gmx_mm_any_lt(rsq22,rcutoff2))
541             {
542
543             r22              = _mm_mul_ps(rsq22,rinv22);
544
545             /* EWALD ELECTROSTATICS */
546
547             /* Analytical PME correction */
548             zeta2            = _mm_mul_ps(beta2,rsq22);
549             rinv3            = _mm_mul_ps(rinvsq22,rinv22);
550             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
551             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
552             felec            = _mm_mul_ps(qq22,felec);
553             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
554             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv22,sh_ewald));
555             velec            = _mm_mul_ps(qq22,velec);
556
557             cutoff_mask      = _mm_cmplt_ps(rsq22,rcutoff2);
558
559             /* Update potential sum for this i atom from the interaction with this j atom. */
560             velec            = _mm_and_ps(velec,cutoff_mask);
561             velecsum         = _mm_add_ps(velecsum,velec);
562
563             fscal            = felec;
564
565             fscal            = _mm_and_ps(fscal,cutoff_mask);
566
567              /* Update vectorial force */
568             fix2             = _mm_macc_ps(dx22,fscal,fix2);
569             fiy2             = _mm_macc_ps(dy22,fscal,fiy2);
570             fiz2             = _mm_macc_ps(dz22,fscal,fiz2);
571
572             fjx2             = _mm_macc_ps(dx22,fscal,fjx2);
573             fjy2             = _mm_macc_ps(dy22,fscal,fjy2);
574             fjz2             = _mm_macc_ps(dz22,fscal,fjz2);
575
576             }
577
578             /**************************
579              * CALCULATE INTERACTIONS *
580              **************************/
581
582             if (gmx_mm_any_lt(rsq23,rcutoff2))
583             {
584
585             r23              = _mm_mul_ps(rsq23,rinv23);
586
587             /* EWALD ELECTROSTATICS */
588
589             /* Analytical PME correction */
590             zeta2            = _mm_mul_ps(beta2,rsq23);
591             rinv3            = _mm_mul_ps(rinvsq23,rinv23);
592             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
593             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
594             felec            = _mm_mul_ps(qq23,felec);
595             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
596             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv23,sh_ewald));
597             velec            = _mm_mul_ps(qq23,velec);
598
599             cutoff_mask      = _mm_cmplt_ps(rsq23,rcutoff2);
600
601             /* Update potential sum for this i atom from the interaction with this j atom. */
602             velec            = _mm_and_ps(velec,cutoff_mask);
603             velecsum         = _mm_add_ps(velecsum,velec);
604
605             fscal            = felec;
606
607             fscal            = _mm_and_ps(fscal,cutoff_mask);
608
609              /* Update vectorial force */
610             fix2             = _mm_macc_ps(dx23,fscal,fix2);
611             fiy2             = _mm_macc_ps(dy23,fscal,fiy2);
612             fiz2             = _mm_macc_ps(dz23,fscal,fiz2);
613
614             fjx3             = _mm_macc_ps(dx23,fscal,fjx3);
615             fjy3             = _mm_macc_ps(dy23,fscal,fjy3);
616             fjz3             = _mm_macc_ps(dz23,fscal,fjz3);
617
618             }
619
620             /**************************
621              * CALCULATE INTERACTIONS *
622              **************************/
623
624             if (gmx_mm_any_lt(rsq31,rcutoff2))
625             {
626
627             r31              = _mm_mul_ps(rsq31,rinv31);
628
629             /* EWALD ELECTROSTATICS */
630
631             /* Analytical PME correction */
632             zeta2            = _mm_mul_ps(beta2,rsq31);
633             rinv3            = _mm_mul_ps(rinvsq31,rinv31);
634             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
635             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
636             felec            = _mm_mul_ps(qq31,felec);
637             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
638             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv31,sh_ewald));
639             velec            = _mm_mul_ps(qq31,velec);
640
641             cutoff_mask      = _mm_cmplt_ps(rsq31,rcutoff2);
642
643             /* Update potential sum for this i atom from the interaction with this j atom. */
644             velec            = _mm_and_ps(velec,cutoff_mask);
645             velecsum         = _mm_add_ps(velecsum,velec);
646
647             fscal            = felec;
648
649             fscal            = _mm_and_ps(fscal,cutoff_mask);
650
651              /* Update vectorial force */
652             fix3             = _mm_macc_ps(dx31,fscal,fix3);
653             fiy3             = _mm_macc_ps(dy31,fscal,fiy3);
654             fiz3             = _mm_macc_ps(dz31,fscal,fiz3);
655
656             fjx1             = _mm_macc_ps(dx31,fscal,fjx1);
657             fjy1             = _mm_macc_ps(dy31,fscal,fjy1);
658             fjz1             = _mm_macc_ps(dz31,fscal,fjz1);
659
660             }
661
662             /**************************
663              * CALCULATE INTERACTIONS *
664              **************************/
665
666             if (gmx_mm_any_lt(rsq32,rcutoff2))
667             {
668
669             r32              = _mm_mul_ps(rsq32,rinv32);
670
671             /* EWALD ELECTROSTATICS */
672
673             /* Analytical PME correction */
674             zeta2            = _mm_mul_ps(beta2,rsq32);
675             rinv3            = _mm_mul_ps(rinvsq32,rinv32);
676             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
677             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
678             felec            = _mm_mul_ps(qq32,felec);
679             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
680             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv32,sh_ewald));
681             velec            = _mm_mul_ps(qq32,velec);
682
683             cutoff_mask      = _mm_cmplt_ps(rsq32,rcutoff2);
684
685             /* Update potential sum for this i atom from the interaction with this j atom. */
686             velec            = _mm_and_ps(velec,cutoff_mask);
687             velecsum         = _mm_add_ps(velecsum,velec);
688
689             fscal            = felec;
690
691             fscal            = _mm_and_ps(fscal,cutoff_mask);
692
693              /* Update vectorial force */
694             fix3             = _mm_macc_ps(dx32,fscal,fix3);
695             fiy3             = _mm_macc_ps(dy32,fscal,fiy3);
696             fiz3             = _mm_macc_ps(dz32,fscal,fiz3);
697
698             fjx2             = _mm_macc_ps(dx32,fscal,fjx2);
699             fjy2             = _mm_macc_ps(dy32,fscal,fjy2);
700             fjz2             = _mm_macc_ps(dz32,fscal,fjz2);
701
702             }
703
704             /**************************
705              * CALCULATE INTERACTIONS *
706              **************************/
707
708             if (gmx_mm_any_lt(rsq33,rcutoff2))
709             {
710
711             r33              = _mm_mul_ps(rsq33,rinv33);
712
713             /* EWALD ELECTROSTATICS */
714
715             /* Analytical PME correction */
716             zeta2            = _mm_mul_ps(beta2,rsq33);
717             rinv3            = _mm_mul_ps(rinvsq33,rinv33);
718             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
719             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
720             felec            = _mm_mul_ps(qq33,felec);
721             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
722             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv33,sh_ewald));
723             velec            = _mm_mul_ps(qq33,velec);
724
725             cutoff_mask      = _mm_cmplt_ps(rsq33,rcutoff2);
726
727             /* Update potential sum for this i atom from the interaction with this j atom. */
728             velec            = _mm_and_ps(velec,cutoff_mask);
729             velecsum         = _mm_add_ps(velecsum,velec);
730
731             fscal            = felec;
732
733             fscal            = _mm_and_ps(fscal,cutoff_mask);
734
735              /* Update vectorial force */
736             fix3             = _mm_macc_ps(dx33,fscal,fix3);
737             fiy3             = _mm_macc_ps(dy33,fscal,fiy3);
738             fiz3             = _mm_macc_ps(dz33,fscal,fiz3);
739
740             fjx3             = _mm_macc_ps(dx33,fscal,fjx3);
741             fjy3             = _mm_macc_ps(dy33,fscal,fjy3);
742             fjz3             = _mm_macc_ps(dz33,fscal,fjz3);
743
744             }
745
746             fjptrA             = f+j_coord_offsetA;
747             fjptrB             = f+j_coord_offsetB;
748             fjptrC             = f+j_coord_offsetC;
749             fjptrD             = f+j_coord_offsetD;
750
751             gmx_mm_decrement_4rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
752                                                    fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
753                                                    fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
754
755             /* Inner loop uses 344 flops */
756         }
757
758         if(jidx<j_index_end)
759         {
760
761             /* Get j neighbor index, and coordinate index */
762             jnrlistA         = jjnr[jidx];
763             jnrlistB         = jjnr[jidx+1];
764             jnrlistC         = jjnr[jidx+2];
765             jnrlistD         = jjnr[jidx+3];
766             /* Sign of each element will be negative for non-real atoms.
767              * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
768              * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
769              */
770             dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
771             jnrA       = (jnrlistA>=0) ? jnrlistA : 0;
772             jnrB       = (jnrlistB>=0) ? jnrlistB : 0;
773             jnrC       = (jnrlistC>=0) ? jnrlistC : 0;
774             jnrD       = (jnrlistD>=0) ? jnrlistD : 0;
775             j_coord_offsetA  = DIM*jnrA;
776             j_coord_offsetB  = DIM*jnrB;
777             j_coord_offsetC  = DIM*jnrC;
778             j_coord_offsetD  = DIM*jnrD;
779
780             /* load j atom coordinates */
781             gmx_mm_load_4rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
782                                               x+j_coord_offsetC,x+j_coord_offsetD,
783                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
784                                               &jy2,&jz2,&jx3,&jy3,&jz3);
785
786             /* Calculate displacement vector */
787             dx00             = _mm_sub_ps(ix0,jx0);
788             dy00             = _mm_sub_ps(iy0,jy0);
789             dz00             = _mm_sub_ps(iz0,jz0);
790             dx11             = _mm_sub_ps(ix1,jx1);
791             dy11             = _mm_sub_ps(iy1,jy1);
792             dz11             = _mm_sub_ps(iz1,jz1);
793             dx12             = _mm_sub_ps(ix1,jx2);
794             dy12             = _mm_sub_ps(iy1,jy2);
795             dz12             = _mm_sub_ps(iz1,jz2);
796             dx13             = _mm_sub_ps(ix1,jx3);
797             dy13             = _mm_sub_ps(iy1,jy3);
798             dz13             = _mm_sub_ps(iz1,jz3);
799             dx21             = _mm_sub_ps(ix2,jx1);
800             dy21             = _mm_sub_ps(iy2,jy1);
801             dz21             = _mm_sub_ps(iz2,jz1);
802             dx22             = _mm_sub_ps(ix2,jx2);
803             dy22             = _mm_sub_ps(iy2,jy2);
804             dz22             = _mm_sub_ps(iz2,jz2);
805             dx23             = _mm_sub_ps(ix2,jx3);
806             dy23             = _mm_sub_ps(iy2,jy3);
807             dz23             = _mm_sub_ps(iz2,jz3);
808             dx31             = _mm_sub_ps(ix3,jx1);
809             dy31             = _mm_sub_ps(iy3,jy1);
810             dz31             = _mm_sub_ps(iz3,jz1);
811             dx32             = _mm_sub_ps(ix3,jx2);
812             dy32             = _mm_sub_ps(iy3,jy2);
813             dz32             = _mm_sub_ps(iz3,jz2);
814             dx33             = _mm_sub_ps(ix3,jx3);
815             dy33             = _mm_sub_ps(iy3,jy3);
816             dz33             = _mm_sub_ps(iz3,jz3);
817
818             /* Calculate squared distance and things based on it */
819             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
820             rsq11            = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
821             rsq12            = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
822             rsq13            = gmx_mm_calc_rsq_ps(dx13,dy13,dz13);
823             rsq21            = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
824             rsq22            = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
825             rsq23            = gmx_mm_calc_rsq_ps(dx23,dy23,dz23);
826             rsq31            = gmx_mm_calc_rsq_ps(dx31,dy31,dz31);
827             rsq32            = gmx_mm_calc_rsq_ps(dx32,dy32,dz32);
828             rsq33            = gmx_mm_calc_rsq_ps(dx33,dy33,dz33);
829
830             rinv11           = gmx_mm_invsqrt_ps(rsq11);
831             rinv12           = gmx_mm_invsqrt_ps(rsq12);
832             rinv13           = gmx_mm_invsqrt_ps(rsq13);
833             rinv21           = gmx_mm_invsqrt_ps(rsq21);
834             rinv22           = gmx_mm_invsqrt_ps(rsq22);
835             rinv23           = gmx_mm_invsqrt_ps(rsq23);
836             rinv31           = gmx_mm_invsqrt_ps(rsq31);
837             rinv32           = gmx_mm_invsqrt_ps(rsq32);
838             rinv33           = gmx_mm_invsqrt_ps(rsq33);
839
840             rinvsq00         = gmx_mm_inv_ps(rsq00);
841             rinvsq11         = _mm_mul_ps(rinv11,rinv11);
842             rinvsq12         = _mm_mul_ps(rinv12,rinv12);
843             rinvsq13         = _mm_mul_ps(rinv13,rinv13);
844             rinvsq21         = _mm_mul_ps(rinv21,rinv21);
845             rinvsq22         = _mm_mul_ps(rinv22,rinv22);
846             rinvsq23         = _mm_mul_ps(rinv23,rinv23);
847             rinvsq31         = _mm_mul_ps(rinv31,rinv31);
848             rinvsq32         = _mm_mul_ps(rinv32,rinv32);
849             rinvsq33         = _mm_mul_ps(rinv33,rinv33);
850
851             fjx0             = _mm_setzero_ps();
852             fjy0             = _mm_setzero_ps();
853             fjz0             = _mm_setzero_ps();
854             fjx1             = _mm_setzero_ps();
855             fjy1             = _mm_setzero_ps();
856             fjz1             = _mm_setzero_ps();
857             fjx2             = _mm_setzero_ps();
858             fjy2             = _mm_setzero_ps();
859             fjz2             = _mm_setzero_ps();
860             fjx3             = _mm_setzero_ps();
861             fjy3             = _mm_setzero_ps();
862             fjz3             = _mm_setzero_ps();
863
864             /**************************
865              * CALCULATE INTERACTIONS *
866              **************************/
867
868             if (gmx_mm_any_lt(rsq00,rcutoff2))
869             {
870
871             /* LENNARD-JONES DISPERSION/REPULSION */
872
873             rinvsix          = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
874             vvdw6            = _mm_mul_ps(c6_00,rinvsix);
875             vvdw12           = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
876             vvdw             = _mm_msub_ps(_mm_nmacc_ps(c12_00,_mm_mul_ps(sh_vdw_invrcut6,sh_vdw_invrcut6),vvdw12),one_twelfth,
877                                           _mm_mul_ps( _mm_nmacc_ps(c6_00,sh_vdw_invrcut6,vvdw6),one_sixth));
878             fvdw             = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
879
880             cutoff_mask      = _mm_cmplt_ps(rsq00,rcutoff2);
881
882             /* Update potential sum for this i atom from the interaction with this j atom. */
883             vvdw             = _mm_and_ps(vvdw,cutoff_mask);
884             vvdw             = _mm_andnot_ps(dummy_mask,vvdw);
885             vvdwsum          = _mm_add_ps(vvdwsum,vvdw);
886
887             fscal            = fvdw;
888
889             fscal            = _mm_and_ps(fscal,cutoff_mask);
890
891             fscal            = _mm_andnot_ps(dummy_mask,fscal);
892
893              /* Update vectorial force */
894             fix0             = _mm_macc_ps(dx00,fscal,fix0);
895             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
896             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
897
898             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
899             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
900             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
901
902             }
903
904             /**************************
905              * CALCULATE INTERACTIONS *
906              **************************/
907
908             if (gmx_mm_any_lt(rsq11,rcutoff2))
909             {
910
911             r11              = _mm_mul_ps(rsq11,rinv11);
912             r11              = _mm_andnot_ps(dummy_mask,r11);
913
914             /* EWALD ELECTROSTATICS */
915
916             /* Analytical PME correction */
917             zeta2            = _mm_mul_ps(beta2,rsq11);
918             rinv3            = _mm_mul_ps(rinvsq11,rinv11);
919             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
920             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
921             felec            = _mm_mul_ps(qq11,felec);
922             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
923             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv11,sh_ewald));
924             velec            = _mm_mul_ps(qq11,velec);
925
926             cutoff_mask      = _mm_cmplt_ps(rsq11,rcutoff2);
927
928             /* Update potential sum for this i atom from the interaction with this j atom. */
929             velec            = _mm_and_ps(velec,cutoff_mask);
930             velec            = _mm_andnot_ps(dummy_mask,velec);
931             velecsum         = _mm_add_ps(velecsum,velec);
932
933             fscal            = felec;
934
935             fscal            = _mm_and_ps(fscal,cutoff_mask);
936
937             fscal            = _mm_andnot_ps(dummy_mask,fscal);
938
939              /* Update vectorial force */
940             fix1             = _mm_macc_ps(dx11,fscal,fix1);
941             fiy1             = _mm_macc_ps(dy11,fscal,fiy1);
942             fiz1             = _mm_macc_ps(dz11,fscal,fiz1);
943
944             fjx1             = _mm_macc_ps(dx11,fscal,fjx1);
945             fjy1             = _mm_macc_ps(dy11,fscal,fjy1);
946             fjz1             = _mm_macc_ps(dz11,fscal,fjz1);
947
948             }
949
950             /**************************
951              * CALCULATE INTERACTIONS *
952              **************************/
953
954             if (gmx_mm_any_lt(rsq12,rcutoff2))
955             {
956
957             r12              = _mm_mul_ps(rsq12,rinv12);
958             r12              = _mm_andnot_ps(dummy_mask,r12);
959
960             /* EWALD ELECTROSTATICS */
961
962             /* Analytical PME correction */
963             zeta2            = _mm_mul_ps(beta2,rsq12);
964             rinv3            = _mm_mul_ps(rinvsq12,rinv12);
965             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
966             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
967             felec            = _mm_mul_ps(qq12,felec);
968             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
969             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv12,sh_ewald));
970             velec            = _mm_mul_ps(qq12,velec);
971
972             cutoff_mask      = _mm_cmplt_ps(rsq12,rcutoff2);
973
974             /* Update potential sum for this i atom from the interaction with this j atom. */
975             velec            = _mm_and_ps(velec,cutoff_mask);
976             velec            = _mm_andnot_ps(dummy_mask,velec);
977             velecsum         = _mm_add_ps(velecsum,velec);
978
979             fscal            = felec;
980
981             fscal            = _mm_and_ps(fscal,cutoff_mask);
982
983             fscal            = _mm_andnot_ps(dummy_mask,fscal);
984
985              /* Update vectorial force */
986             fix1             = _mm_macc_ps(dx12,fscal,fix1);
987             fiy1             = _mm_macc_ps(dy12,fscal,fiy1);
988             fiz1             = _mm_macc_ps(dz12,fscal,fiz1);
989
990             fjx2             = _mm_macc_ps(dx12,fscal,fjx2);
991             fjy2             = _mm_macc_ps(dy12,fscal,fjy2);
992             fjz2             = _mm_macc_ps(dz12,fscal,fjz2);
993
994             }
995
996             /**************************
997              * CALCULATE INTERACTIONS *
998              **************************/
999
1000             if (gmx_mm_any_lt(rsq13,rcutoff2))
1001             {
1002
1003             r13              = _mm_mul_ps(rsq13,rinv13);
1004             r13              = _mm_andnot_ps(dummy_mask,r13);
1005
1006             /* EWALD ELECTROSTATICS */
1007
1008             /* Analytical PME correction */
1009             zeta2            = _mm_mul_ps(beta2,rsq13);
1010             rinv3            = _mm_mul_ps(rinvsq13,rinv13);
1011             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1012             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1013             felec            = _mm_mul_ps(qq13,felec);
1014             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
1015             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv13,sh_ewald));
1016             velec            = _mm_mul_ps(qq13,velec);
1017
1018             cutoff_mask      = _mm_cmplt_ps(rsq13,rcutoff2);
1019
1020             /* Update potential sum for this i atom from the interaction with this j atom. */
1021             velec            = _mm_and_ps(velec,cutoff_mask);
1022             velec            = _mm_andnot_ps(dummy_mask,velec);
1023             velecsum         = _mm_add_ps(velecsum,velec);
1024
1025             fscal            = felec;
1026
1027             fscal            = _mm_and_ps(fscal,cutoff_mask);
1028
1029             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1030
1031              /* Update vectorial force */
1032             fix1             = _mm_macc_ps(dx13,fscal,fix1);
1033             fiy1             = _mm_macc_ps(dy13,fscal,fiy1);
1034             fiz1             = _mm_macc_ps(dz13,fscal,fiz1);
1035
1036             fjx3             = _mm_macc_ps(dx13,fscal,fjx3);
1037             fjy3             = _mm_macc_ps(dy13,fscal,fjy3);
1038             fjz3             = _mm_macc_ps(dz13,fscal,fjz3);
1039
1040             }
1041
1042             /**************************
1043              * CALCULATE INTERACTIONS *
1044              **************************/
1045
1046             if (gmx_mm_any_lt(rsq21,rcutoff2))
1047             {
1048
1049             r21              = _mm_mul_ps(rsq21,rinv21);
1050             r21              = _mm_andnot_ps(dummy_mask,r21);
1051
1052             /* EWALD ELECTROSTATICS */
1053
1054             /* Analytical PME correction */
1055             zeta2            = _mm_mul_ps(beta2,rsq21);
1056             rinv3            = _mm_mul_ps(rinvsq21,rinv21);
1057             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1058             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1059             felec            = _mm_mul_ps(qq21,felec);
1060             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
1061             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv21,sh_ewald));
1062             velec            = _mm_mul_ps(qq21,velec);
1063
1064             cutoff_mask      = _mm_cmplt_ps(rsq21,rcutoff2);
1065
1066             /* Update potential sum for this i atom from the interaction with this j atom. */
1067             velec            = _mm_and_ps(velec,cutoff_mask);
1068             velec            = _mm_andnot_ps(dummy_mask,velec);
1069             velecsum         = _mm_add_ps(velecsum,velec);
1070
1071             fscal            = felec;
1072
1073             fscal            = _mm_and_ps(fscal,cutoff_mask);
1074
1075             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1076
1077              /* Update vectorial force */
1078             fix2             = _mm_macc_ps(dx21,fscal,fix2);
1079             fiy2             = _mm_macc_ps(dy21,fscal,fiy2);
1080             fiz2             = _mm_macc_ps(dz21,fscal,fiz2);
1081
1082             fjx1             = _mm_macc_ps(dx21,fscal,fjx1);
1083             fjy1             = _mm_macc_ps(dy21,fscal,fjy1);
1084             fjz1             = _mm_macc_ps(dz21,fscal,fjz1);
1085
1086             }
1087
1088             /**************************
1089              * CALCULATE INTERACTIONS *
1090              **************************/
1091
1092             if (gmx_mm_any_lt(rsq22,rcutoff2))
1093             {
1094
1095             r22              = _mm_mul_ps(rsq22,rinv22);
1096             r22              = _mm_andnot_ps(dummy_mask,r22);
1097
1098             /* EWALD ELECTROSTATICS */
1099
1100             /* Analytical PME correction */
1101             zeta2            = _mm_mul_ps(beta2,rsq22);
1102             rinv3            = _mm_mul_ps(rinvsq22,rinv22);
1103             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1104             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1105             felec            = _mm_mul_ps(qq22,felec);
1106             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
1107             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv22,sh_ewald));
1108             velec            = _mm_mul_ps(qq22,velec);
1109
1110             cutoff_mask      = _mm_cmplt_ps(rsq22,rcutoff2);
1111
1112             /* Update potential sum for this i atom from the interaction with this j atom. */
1113             velec            = _mm_and_ps(velec,cutoff_mask);
1114             velec            = _mm_andnot_ps(dummy_mask,velec);
1115             velecsum         = _mm_add_ps(velecsum,velec);
1116
1117             fscal            = felec;
1118
1119             fscal            = _mm_and_ps(fscal,cutoff_mask);
1120
1121             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1122
1123              /* Update vectorial force */
1124             fix2             = _mm_macc_ps(dx22,fscal,fix2);
1125             fiy2             = _mm_macc_ps(dy22,fscal,fiy2);
1126             fiz2             = _mm_macc_ps(dz22,fscal,fiz2);
1127
1128             fjx2             = _mm_macc_ps(dx22,fscal,fjx2);
1129             fjy2             = _mm_macc_ps(dy22,fscal,fjy2);
1130             fjz2             = _mm_macc_ps(dz22,fscal,fjz2);
1131
1132             }
1133
1134             /**************************
1135              * CALCULATE INTERACTIONS *
1136              **************************/
1137
1138             if (gmx_mm_any_lt(rsq23,rcutoff2))
1139             {
1140
1141             r23              = _mm_mul_ps(rsq23,rinv23);
1142             r23              = _mm_andnot_ps(dummy_mask,r23);
1143
1144             /* EWALD ELECTROSTATICS */
1145
1146             /* Analytical PME correction */
1147             zeta2            = _mm_mul_ps(beta2,rsq23);
1148             rinv3            = _mm_mul_ps(rinvsq23,rinv23);
1149             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1150             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1151             felec            = _mm_mul_ps(qq23,felec);
1152             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
1153             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv23,sh_ewald));
1154             velec            = _mm_mul_ps(qq23,velec);
1155
1156             cutoff_mask      = _mm_cmplt_ps(rsq23,rcutoff2);
1157
1158             /* Update potential sum for this i atom from the interaction with this j atom. */
1159             velec            = _mm_and_ps(velec,cutoff_mask);
1160             velec            = _mm_andnot_ps(dummy_mask,velec);
1161             velecsum         = _mm_add_ps(velecsum,velec);
1162
1163             fscal            = felec;
1164
1165             fscal            = _mm_and_ps(fscal,cutoff_mask);
1166
1167             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1168
1169              /* Update vectorial force */
1170             fix2             = _mm_macc_ps(dx23,fscal,fix2);
1171             fiy2             = _mm_macc_ps(dy23,fscal,fiy2);
1172             fiz2             = _mm_macc_ps(dz23,fscal,fiz2);
1173
1174             fjx3             = _mm_macc_ps(dx23,fscal,fjx3);
1175             fjy3             = _mm_macc_ps(dy23,fscal,fjy3);
1176             fjz3             = _mm_macc_ps(dz23,fscal,fjz3);
1177
1178             }
1179
1180             /**************************
1181              * CALCULATE INTERACTIONS *
1182              **************************/
1183
1184             if (gmx_mm_any_lt(rsq31,rcutoff2))
1185             {
1186
1187             r31              = _mm_mul_ps(rsq31,rinv31);
1188             r31              = _mm_andnot_ps(dummy_mask,r31);
1189
1190             /* EWALD ELECTROSTATICS */
1191
1192             /* Analytical PME correction */
1193             zeta2            = _mm_mul_ps(beta2,rsq31);
1194             rinv3            = _mm_mul_ps(rinvsq31,rinv31);
1195             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1196             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1197             felec            = _mm_mul_ps(qq31,felec);
1198             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
1199             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv31,sh_ewald));
1200             velec            = _mm_mul_ps(qq31,velec);
1201
1202             cutoff_mask      = _mm_cmplt_ps(rsq31,rcutoff2);
1203
1204             /* Update potential sum for this i atom from the interaction with this j atom. */
1205             velec            = _mm_and_ps(velec,cutoff_mask);
1206             velec            = _mm_andnot_ps(dummy_mask,velec);
1207             velecsum         = _mm_add_ps(velecsum,velec);
1208
1209             fscal            = felec;
1210
1211             fscal            = _mm_and_ps(fscal,cutoff_mask);
1212
1213             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1214
1215              /* Update vectorial force */
1216             fix3             = _mm_macc_ps(dx31,fscal,fix3);
1217             fiy3             = _mm_macc_ps(dy31,fscal,fiy3);
1218             fiz3             = _mm_macc_ps(dz31,fscal,fiz3);
1219
1220             fjx1             = _mm_macc_ps(dx31,fscal,fjx1);
1221             fjy1             = _mm_macc_ps(dy31,fscal,fjy1);
1222             fjz1             = _mm_macc_ps(dz31,fscal,fjz1);
1223
1224             }
1225
1226             /**************************
1227              * CALCULATE INTERACTIONS *
1228              **************************/
1229
1230             if (gmx_mm_any_lt(rsq32,rcutoff2))
1231             {
1232
1233             r32              = _mm_mul_ps(rsq32,rinv32);
1234             r32              = _mm_andnot_ps(dummy_mask,r32);
1235
1236             /* EWALD ELECTROSTATICS */
1237
1238             /* Analytical PME correction */
1239             zeta2            = _mm_mul_ps(beta2,rsq32);
1240             rinv3            = _mm_mul_ps(rinvsq32,rinv32);
1241             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1242             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1243             felec            = _mm_mul_ps(qq32,felec);
1244             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
1245             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv32,sh_ewald));
1246             velec            = _mm_mul_ps(qq32,velec);
1247
1248             cutoff_mask      = _mm_cmplt_ps(rsq32,rcutoff2);
1249
1250             /* Update potential sum for this i atom from the interaction with this j atom. */
1251             velec            = _mm_and_ps(velec,cutoff_mask);
1252             velec            = _mm_andnot_ps(dummy_mask,velec);
1253             velecsum         = _mm_add_ps(velecsum,velec);
1254
1255             fscal            = felec;
1256
1257             fscal            = _mm_and_ps(fscal,cutoff_mask);
1258
1259             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1260
1261              /* Update vectorial force */
1262             fix3             = _mm_macc_ps(dx32,fscal,fix3);
1263             fiy3             = _mm_macc_ps(dy32,fscal,fiy3);
1264             fiz3             = _mm_macc_ps(dz32,fscal,fiz3);
1265
1266             fjx2             = _mm_macc_ps(dx32,fscal,fjx2);
1267             fjy2             = _mm_macc_ps(dy32,fscal,fjy2);
1268             fjz2             = _mm_macc_ps(dz32,fscal,fjz2);
1269
1270             }
1271
1272             /**************************
1273              * CALCULATE INTERACTIONS *
1274              **************************/
1275
1276             if (gmx_mm_any_lt(rsq33,rcutoff2))
1277             {
1278
1279             r33              = _mm_mul_ps(rsq33,rinv33);
1280             r33              = _mm_andnot_ps(dummy_mask,r33);
1281
1282             /* EWALD ELECTROSTATICS */
1283
1284             /* Analytical PME correction */
1285             zeta2            = _mm_mul_ps(beta2,rsq33);
1286             rinv3            = _mm_mul_ps(rinvsq33,rinv33);
1287             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1288             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1289             felec            = _mm_mul_ps(qq33,felec);
1290             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
1291             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv33,sh_ewald));
1292             velec            = _mm_mul_ps(qq33,velec);
1293
1294             cutoff_mask      = _mm_cmplt_ps(rsq33,rcutoff2);
1295
1296             /* Update potential sum for this i atom from the interaction with this j atom. */
1297             velec            = _mm_and_ps(velec,cutoff_mask);
1298             velec            = _mm_andnot_ps(dummy_mask,velec);
1299             velecsum         = _mm_add_ps(velecsum,velec);
1300
1301             fscal            = felec;
1302
1303             fscal            = _mm_and_ps(fscal,cutoff_mask);
1304
1305             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1306
1307              /* Update vectorial force */
1308             fix3             = _mm_macc_ps(dx33,fscal,fix3);
1309             fiy3             = _mm_macc_ps(dy33,fscal,fiy3);
1310             fiz3             = _mm_macc_ps(dz33,fscal,fiz3);
1311
1312             fjx3             = _mm_macc_ps(dx33,fscal,fjx3);
1313             fjy3             = _mm_macc_ps(dy33,fscal,fjy3);
1314             fjz3             = _mm_macc_ps(dz33,fscal,fjz3);
1315
1316             }
1317
1318             fjptrA             = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1319             fjptrB             = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1320             fjptrC             = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1321             fjptrD             = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1322
1323             gmx_mm_decrement_4rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
1324                                                    fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
1325                                                    fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1326
1327             /* Inner loop uses 353 flops */
1328         }
1329
1330         /* End of innermost loop */
1331
1332         gmx_mm_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1333                                               f+i_coord_offset,fshift+i_shift_offset);
1334
1335         ggid                        = gid[iidx];
1336         /* Update potential energies */
1337         gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
1338         gmx_mm_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
1339
1340         /* Increment number of inner iterations */
1341         inneriter                  += j_index_end - j_index_start;
1342
1343         /* Outer loop uses 26 flops */
1344     }
1345
1346     /* Increment number of outer iterations */
1347     outeriter        += nri;
1348
1349     /* Update outer/inner flops */
1350
1351     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*26 + inneriter*353);
1352 }
1353 /*
1354  * Gromacs nonbonded kernel:   nb_kernel_ElecEwSh_VdwLJSh_GeomW4W4_F_avx_128_fma_single
1355  * Electrostatics interaction: Ewald
1356  * VdW interaction:            LennardJones
1357  * Geometry:                   Water4-Water4
1358  * Calculate force/pot:        Force
1359  */
1360 void
1361 nb_kernel_ElecEwSh_VdwLJSh_GeomW4W4_F_avx_128_fma_single
1362                     (t_nblist                    * gmx_restrict       nlist,
1363                      rvec                        * gmx_restrict          xx,
1364                      rvec                        * gmx_restrict          ff,
1365                      t_forcerec                  * gmx_restrict          fr,
1366                      t_mdatoms                   * gmx_restrict     mdatoms,
1367                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
1368                      t_nrnb                      * gmx_restrict        nrnb)
1369 {
1370     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
1371      * just 0 for non-waters.
1372      * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
1373      * jnr indices corresponding to data put in the four positions in the SIMD register.
1374      */
1375     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
1376     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
1377     int              jnrA,jnrB,jnrC,jnrD;
1378     int              jnrlistA,jnrlistB,jnrlistC,jnrlistD;
1379     int              j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
1380     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
1381     real             rcutoff_scalar;
1382     real             *shiftvec,*fshift,*x,*f;
1383     real             *fjptrA,*fjptrB,*fjptrC,*fjptrD;
1384     real             scratch[4*DIM];
1385     __m128           fscal,rcutoff,rcutoff2,jidxall;
1386     int              vdwioffset0;
1387     __m128           ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
1388     int              vdwioffset1;
1389     __m128           ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
1390     int              vdwioffset2;
1391     __m128           ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
1392     int              vdwioffset3;
1393     __m128           ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
1394     int              vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
1395     __m128           jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
1396     int              vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D;
1397     __m128           jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
1398     int              vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D;
1399     __m128           jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
1400     int              vdwjidx3A,vdwjidx3B,vdwjidx3C,vdwjidx3D;
1401     __m128           jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
1402     __m128           dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
1403     __m128           dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
1404     __m128           dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
1405     __m128           dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
1406     __m128           dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
1407     __m128           dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
1408     __m128           dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
1409     __m128           dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
1410     __m128           dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
1411     __m128           dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
1412     __m128           velec,felec,velecsum,facel,crf,krf,krf2;
1413     real             *charge;
1414     int              nvdwtype;
1415     __m128           rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
1416     int              *vdwtype;
1417     real             *vdwparam;
1418     __m128           one_sixth   = _mm_set1_ps(1.0/6.0);
1419     __m128           one_twelfth = _mm_set1_ps(1.0/12.0);
1420     __m128i          ewitab;
1421     __m128           ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
1422     __m128           beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
1423     real             *ewtab;
1424     __m128           dummy_mask,cutoff_mask;
1425     __m128           signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
1426     __m128           one     = _mm_set1_ps(1.0);
1427     __m128           two     = _mm_set1_ps(2.0);
1428     x                = xx[0];
1429     f                = ff[0];
1430
1431     nri              = nlist->nri;
1432     iinr             = nlist->iinr;
1433     jindex           = nlist->jindex;
1434     jjnr             = nlist->jjnr;
1435     shiftidx         = nlist->shift;
1436     gid              = nlist->gid;
1437     shiftvec         = fr->shift_vec[0];
1438     fshift           = fr->fshift[0];
1439     facel            = _mm_set1_ps(fr->epsfac);
1440     charge           = mdatoms->chargeA;
1441     nvdwtype         = fr->ntype;
1442     vdwparam         = fr->nbfp;
1443     vdwtype          = mdatoms->typeA;
1444
1445     sh_ewald         = _mm_set1_ps(fr->ic->sh_ewald);
1446     beta             = _mm_set1_ps(fr->ic->ewaldcoeff_q);
1447     beta2            = _mm_mul_ps(beta,beta);
1448     beta3            = _mm_mul_ps(beta,beta2);
1449     ewtab            = fr->ic->tabq_coul_F;
1450     ewtabscale       = _mm_set1_ps(fr->ic->tabq_scale);
1451     ewtabhalfspace   = _mm_set1_ps(0.5/fr->ic->tabq_scale);
1452
1453     /* Setup water-specific parameters */
1454     inr              = nlist->iinr[0];
1455     iq1              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
1456     iq2              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
1457     iq3              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
1458     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
1459
1460     jq1              = _mm_set1_ps(charge[inr+1]);
1461     jq2              = _mm_set1_ps(charge[inr+2]);
1462     jq3              = _mm_set1_ps(charge[inr+3]);
1463     vdwjidx0A        = 2*vdwtype[inr+0];
1464     c6_00            = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A]);
1465     c12_00           = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A+1]);
1466     qq11             = _mm_mul_ps(iq1,jq1);
1467     qq12             = _mm_mul_ps(iq1,jq2);
1468     qq13             = _mm_mul_ps(iq1,jq3);
1469     qq21             = _mm_mul_ps(iq2,jq1);
1470     qq22             = _mm_mul_ps(iq2,jq2);
1471     qq23             = _mm_mul_ps(iq2,jq3);
1472     qq31             = _mm_mul_ps(iq3,jq1);
1473     qq32             = _mm_mul_ps(iq3,jq2);
1474     qq33             = _mm_mul_ps(iq3,jq3);
1475
1476     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
1477     rcutoff_scalar   = fr->rcoulomb;
1478     rcutoff          = _mm_set1_ps(rcutoff_scalar);
1479     rcutoff2         = _mm_mul_ps(rcutoff,rcutoff);
1480
1481     sh_vdw_invrcut6  = _mm_set1_ps(fr->ic->sh_invrc6);
1482     rvdw             = _mm_set1_ps(fr->rvdw);
1483
1484     /* Avoid stupid compiler warnings */
1485     jnrA = jnrB = jnrC = jnrD = 0;
1486     j_coord_offsetA = 0;
1487     j_coord_offsetB = 0;
1488     j_coord_offsetC = 0;
1489     j_coord_offsetD = 0;
1490
1491     outeriter        = 0;
1492     inneriter        = 0;
1493
1494     for(iidx=0;iidx<4*DIM;iidx++)
1495     {
1496         scratch[iidx] = 0.0;
1497     }
1498
1499     /* Start outer loop over neighborlists */
1500     for(iidx=0; iidx<nri; iidx++)
1501     {
1502         /* Load shift vector for this list */
1503         i_shift_offset   = DIM*shiftidx[iidx];
1504
1505         /* Load limits for loop over neighbors */
1506         j_index_start    = jindex[iidx];
1507         j_index_end      = jindex[iidx+1];
1508
1509         /* Get outer coordinate index */
1510         inr              = iinr[iidx];
1511         i_coord_offset   = DIM*inr;
1512
1513         /* Load i particle coords and add shift vector */
1514         gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
1515                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
1516
1517         fix0             = _mm_setzero_ps();
1518         fiy0             = _mm_setzero_ps();
1519         fiz0             = _mm_setzero_ps();
1520         fix1             = _mm_setzero_ps();
1521         fiy1             = _mm_setzero_ps();
1522         fiz1             = _mm_setzero_ps();
1523         fix2             = _mm_setzero_ps();
1524         fiy2             = _mm_setzero_ps();
1525         fiz2             = _mm_setzero_ps();
1526         fix3             = _mm_setzero_ps();
1527         fiy3             = _mm_setzero_ps();
1528         fiz3             = _mm_setzero_ps();
1529
1530         /* Start inner kernel loop */
1531         for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
1532         {
1533
1534             /* Get j neighbor index, and coordinate index */
1535             jnrA             = jjnr[jidx];
1536             jnrB             = jjnr[jidx+1];
1537             jnrC             = jjnr[jidx+2];
1538             jnrD             = jjnr[jidx+3];
1539             j_coord_offsetA  = DIM*jnrA;
1540             j_coord_offsetB  = DIM*jnrB;
1541             j_coord_offsetC  = DIM*jnrC;
1542             j_coord_offsetD  = DIM*jnrD;
1543
1544             /* load j atom coordinates */
1545             gmx_mm_load_4rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1546                                               x+j_coord_offsetC,x+j_coord_offsetD,
1547                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
1548                                               &jy2,&jz2,&jx3,&jy3,&jz3);
1549
1550             /* Calculate displacement vector */
1551             dx00             = _mm_sub_ps(ix0,jx0);
1552             dy00             = _mm_sub_ps(iy0,jy0);
1553             dz00             = _mm_sub_ps(iz0,jz0);
1554             dx11             = _mm_sub_ps(ix1,jx1);
1555             dy11             = _mm_sub_ps(iy1,jy1);
1556             dz11             = _mm_sub_ps(iz1,jz1);
1557             dx12             = _mm_sub_ps(ix1,jx2);
1558             dy12             = _mm_sub_ps(iy1,jy2);
1559             dz12             = _mm_sub_ps(iz1,jz2);
1560             dx13             = _mm_sub_ps(ix1,jx3);
1561             dy13             = _mm_sub_ps(iy1,jy3);
1562             dz13             = _mm_sub_ps(iz1,jz3);
1563             dx21             = _mm_sub_ps(ix2,jx1);
1564             dy21             = _mm_sub_ps(iy2,jy1);
1565             dz21             = _mm_sub_ps(iz2,jz1);
1566             dx22             = _mm_sub_ps(ix2,jx2);
1567             dy22             = _mm_sub_ps(iy2,jy2);
1568             dz22             = _mm_sub_ps(iz2,jz2);
1569             dx23             = _mm_sub_ps(ix2,jx3);
1570             dy23             = _mm_sub_ps(iy2,jy3);
1571             dz23             = _mm_sub_ps(iz2,jz3);
1572             dx31             = _mm_sub_ps(ix3,jx1);
1573             dy31             = _mm_sub_ps(iy3,jy1);
1574             dz31             = _mm_sub_ps(iz3,jz1);
1575             dx32             = _mm_sub_ps(ix3,jx2);
1576             dy32             = _mm_sub_ps(iy3,jy2);
1577             dz32             = _mm_sub_ps(iz3,jz2);
1578             dx33             = _mm_sub_ps(ix3,jx3);
1579             dy33             = _mm_sub_ps(iy3,jy3);
1580             dz33             = _mm_sub_ps(iz3,jz3);
1581
1582             /* Calculate squared distance and things based on it */
1583             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1584             rsq11            = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
1585             rsq12            = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
1586             rsq13            = gmx_mm_calc_rsq_ps(dx13,dy13,dz13);
1587             rsq21            = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
1588             rsq22            = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
1589             rsq23            = gmx_mm_calc_rsq_ps(dx23,dy23,dz23);
1590             rsq31            = gmx_mm_calc_rsq_ps(dx31,dy31,dz31);
1591             rsq32            = gmx_mm_calc_rsq_ps(dx32,dy32,dz32);
1592             rsq33            = gmx_mm_calc_rsq_ps(dx33,dy33,dz33);
1593
1594             rinv11           = gmx_mm_invsqrt_ps(rsq11);
1595             rinv12           = gmx_mm_invsqrt_ps(rsq12);
1596             rinv13           = gmx_mm_invsqrt_ps(rsq13);
1597             rinv21           = gmx_mm_invsqrt_ps(rsq21);
1598             rinv22           = gmx_mm_invsqrt_ps(rsq22);
1599             rinv23           = gmx_mm_invsqrt_ps(rsq23);
1600             rinv31           = gmx_mm_invsqrt_ps(rsq31);
1601             rinv32           = gmx_mm_invsqrt_ps(rsq32);
1602             rinv33           = gmx_mm_invsqrt_ps(rsq33);
1603
1604             rinvsq00         = gmx_mm_inv_ps(rsq00);
1605             rinvsq11         = _mm_mul_ps(rinv11,rinv11);
1606             rinvsq12         = _mm_mul_ps(rinv12,rinv12);
1607             rinvsq13         = _mm_mul_ps(rinv13,rinv13);
1608             rinvsq21         = _mm_mul_ps(rinv21,rinv21);
1609             rinvsq22         = _mm_mul_ps(rinv22,rinv22);
1610             rinvsq23         = _mm_mul_ps(rinv23,rinv23);
1611             rinvsq31         = _mm_mul_ps(rinv31,rinv31);
1612             rinvsq32         = _mm_mul_ps(rinv32,rinv32);
1613             rinvsq33         = _mm_mul_ps(rinv33,rinv33);
1614
1615             fjx0             = _mm_setzero_ps();
1616             fjy0             = _mm_setzero_ps();
1617             fjz0             = _mm_setzero_ps();
1618             fjx1             = _mm_setzero_ps();
1619             fjy1             = _mm_setzero_ps();
1620             fjz1             = _mm_setzero_ps();
1621             fjx2             = _mm_setzero_ps();
1622             fjy2             = _mm_setzero_ps();
1623             fjz2             = _mm_setzero_ps();
1624             fjx3             = _mm_setzero_ps();
1625             fjy3             = _mm_setzero_ps();
1626             fjz3             = _mm_setzero_ps();
1627
1628             /**************************
1629              * CALCULATE INTERACTIONS *
1630              **************************/
1631
1632             if (gmx_mm_any_lt(rsq00,rcutoff2))
1633             {
1634
1635             /* LENNARD-JONES DISPERSION/REPULSION */
1636
1637             rinvsix          = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
1638             fvdw             = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
1639
1640             cutoff_mask      = _mm_cmplt_ps(rsq00,rcutoff2);
1641
1642             fscal            = fvdw;
1643
1644             fscal            = _mm_and_ps(fscal,cutoff_mask);
1645
1646              /* Update vectorial force */
1647             fix0             = _mm_macc_ps(dx00,fscal,fix0);
1648             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
1649             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
1650
1651             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
1652             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
1653             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
1654
1655             }
1656
1657             /**************************
1658              * CALCULATE INTERACTIONS *
1659              **************************/
1660
1661             if (gmx_mm_any_lt(rsq11,rcutoff2))
1662             {
1663
1664             r11              = _mm_mul_ps(rsq11,rinv11);
1665
1666             /* EWALD ELECTROSTATICS */
1667
1668             /* Analytical PME correction */
1669             zeta2            = _mm_mul_ps(beta2,rsq11);
1670             rinv3            = _mm_mul_ps(rinvsq11,rinv11);
1671             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1672             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1673             felec            = _mm_mul_ps(qq11,felec);
1674
1675             cutoff_mask      = _mm_cmplt_ps(rsq11,rcutoff2);
1676
1677             fscal            = felec;
1678
1679             fscal            = _mm_and_ps(fscal,cutoff_mask);
1680
1681              /* Update vectorial force */
1682             fix1             = _mm_macc_ps(dx11,fscal,fix1);
1683             fiy1             = _mm_macc_ps(dy11,fscal,fiy1);
1684             fiz1             = _mm_macc_ps(dz11,fscal,fiz1);
1685
1686             fjx1             = _mm_macc_ps(dx11,fscal,fjx1);
1687             fjy1             = _mm_macc_ps(dy11,fscal,fjy1);
1688             fjz1             = _mm_macc_ps(dz11,fscal,fjz1);
1689
1690             }
1691
1692             /**************************
1693              * CALCULATE INTERACTIONS *
1694              **************************/
1695
1696             if (gmx_mm_any_lt(rsq12,rcutoff2))
1697             {
1698
1699             r12              = _mm_mul_ps(rsq12,rinv12);
1700
1701             /* EWALD ELECTROSTATICS */
1702
1703             /* Analytical PME correction */
1704             zeta2            = _mm_mul_ps(beta2,rsq12);
1705             rinv3            = _mm_mul_ps(rinvsq12,rinv12);
1706             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1707             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1708             felec            = _mm_mul_ps(qq12,felec);
1709
1710             cutoff_mask      = _mm_cmplt_ps(rsq12,rcutoff2);
1711
1712             fscal            = felec;
1713
1714             fscal            = _mm_and_ps(fscal,cutoff_mask);
1715
1716              /* Update vectorial force */
1717             fix1             = _mm_macc_ps(dx12,fscal,fix1);
1718             fiy1             = _mm_macc_ps(dy12,fscal,fiy1);
1719             fiz1             = _mm_macc_ps(dz12,fscal,fiz1);
1720
1721             fjx2             = _mm_macc_ps(dx12,fscal,fjx2);
1722             fjy2             = _mm_macc_ps(dy12,fscal,fjy2);
1723             fjz2             = _mm_macc_ps(dz12,fscal,fjz2);
1724
1725             }
1726
1727             /**************************
1728              * CALCULATE INTERACTIONS *
1729              **************************/
1730
1731             if (gmx_mm_any_lt(rsq13,rcutoff2))
1732             {
1733
1734             r13              = _mm_mul_ps(rsq13,rinv13);
1735
1736             /* EWALD ELECTROSTATICS */
1737
1738             /* Analytical PME correction */
1739             zeta2            = _mm_mul_ps(beta2,rsq13);
1740             rinv3            = _mm_mul_ps(rinvsq13,rinv13);
1741             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1742             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1743             felec            = _mm_mul_ps(qq13,felec);
1744
1745             cutoff_mask      = _mm_cmplt_ps(rsq13,rcutoff2);
1746
1747             fscal            = felec;
1748
1749             fscal            = _mm_and_ps(fscal,cutoff_mask);
1750
1751              /* Update vectorial force */
1752             fix1             = _mm_macc_ps(dx13,fscal,fix1);
1753             fiy1             = _mm_macc_ps(dy13,fscal,fiy1);
1754             fiz1             = _mm_macc_ps(dz13,fscal,fiz1);
1755
1756             fjx3             = _mm_macc_ps(dx13,fscal,fjx3);
1757             fjy3             = _mm_macc_ps(dy13,fscal,fjy3);
1758             fjz3             = _mm_macc_ps(dz13,fscal,fjz3);
1759
1760             }
1761
1762             /**************************
1763              * CALCULATE INTERACTIONS *
1764              **************************/
1765
1766             if (gmx_mm_any_lt(rsq21,rcutoff2))
1767             {
1768
1769             r21              = _mm_mul_ps(rsq21,rinv21);
1770
1771             /* EWALD ELECTROSTATICS */
1772
1773             /* Analytical PME correction */
1774             zeta2            = _mm_mul_ps(beta2,rsq21);
1775             rinv3            = _mm_mul_ps(rinvsq21,rinv21);
1776             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1777             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1778             felec            = _mm_mul_ps(qq21,felec);
1779
1780             cutoff_mask      = _mm_cmplt_ps(rsq21,rcutoff2);
1781
1782             fscal            = felec;
1783
1784             fscal            = _mm_and_ps(fscal,cutoff_mask);
1785
1786              /* Update vectorial force */
1787             fix2             = _mm_macc_ps(dx21,fscal,fix2);
1788             fiy2             = _mm_macc_ps(dy21,fscal,fiy2);
1789             fiz2             = _mm_macc_ps(dz21,fscal,fiz2);
1790
1791             fjx1             = _mm_macc_ps(dx21,fscal,fjx1);
1792             fjy1             = _mm_macc_ps(dy21,fscal,fjy1);
1793             fjz1             = _mm_macc_ps(dz21,fscal,fjz1);
1794
1795             }
1796
1797             /**************************
1798              * CALCULATE INTERACTIONS *
1799              **************************/
1800
1801             if (gmx_mm_any_lt(rsq22,rcutoff2))
1802             {
1803
1804             r22              = _mm_mul_ps(rsq22,rinv22);
1805
1806             /* EWALD ELECTROSTATICS */
1807
1808             /* Analytical PME correction */
1809             zeta2            = _mm_mul_ps(beta2,rsq22);
1810             rinv3            = _mm_mul_ps(rinvsq22,rinv22);
1811             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1812             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1813             felec            = _mm_mul_ps(qq22,felec);
1814
1815             cutoff_mask      = _mm_cmplt_ps(rsq22,rcutoff2);
1816
1817             fscal            = felec;
1818
1819             fscal            = _mm_and_ps(fscal,cutoff_mask);
1820
1821              /* Update vectorial force */
1822             fix2             = _mm_macc_ps(dx22,fscal,fix2);
1823             fiy2             = _mm_macc_ps(dy22,fscal,fiy2);
1824             fiz2             = _mm_macc_ps(dz22,fscal,fiz2);
1825
1826             fjx2             = _mm_macc_ps(dx22,fscal,fjx2);
1827             fjy2             = _mm_macc_ps(dy22,fscal,fjy2);
1828             fjz2             = _mm_macc_ps(dz22,fscal,fjz2);
1829
1830             }
1831
1832             /**************************
1833              * CALCULATE INTERACTIONS *
1834              **************************/
1835
1836             if (gmx_mm_any_lt(rsq23,rcutoff2))
1837             {
1838
1839             r23              = _mm_mul_ps(rsq23,rinv23);
1840
1841             /* EWALD ELECTROSTATICS */
1842
1843             /* Analytical PME correction */
1844             zeta2            = _mm_mul_ps(beta2,rsq23);
1845             rinv3            = _mm_mul_ps(rinvsq23,rinv23);
1846             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1847             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1848             felec            = _mm_mul_ps(qq23,felec);
1849
1850             cutoff_mask      = _mm_cmplt_ps(rsq23,rcutoff2);
1851
1852             fscal            = felec;
1853
1854             fscal            = _mm_and_ps(fscal,cutoff_mask);
1855
1856              /* Update vectorial force */
1857             fix2             = _mm_macc_ps(dx23,fscal,fix2);
1858             fiy2             = _mm_macc_ps(dy23,fscal,fiy2);
1859             fiz2             = _mm_macc_ps(dz23,fscal,fiz2);
1860
1861             fjx3             = _mm_macc_ps(dx23,fscal,fjx3);
1862             fjy3             = _mm_macc_ps(dy23,fscal,fjy3);
1863             fjz3             = _mm_macc_ps(dz23,fscal,fjz3);
1864
1865             }
1866
1867             /**************************
1868              * CALCULATE INTERACTIONS *
1869              **************************/
1870
1871             if (gmx_mm_any_lt(rsq31,rcutoff2))
1872             {
1873
1874             r31              = _mm_mul_ps(rsq31,rinv31);
1875
1876             /* EWALD ELECTROSTATICS */
1877
1878             /* Analytical PME correction */
1879             zeta2            = _mm_mul_ps(beta2,rsq31);
1880             rinv3            = _mm_mul_ps(rinvsq31,rinv31);
1881             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1882             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1883             felec            = _mm_mul_ps(qq31,felec);
1884
1885             cutoff_mask      = _mm_cmplt_ps(rsq31,rcutoff2);
1886
1887             fscal            = felec;
1888
1889             fscal            = _mm_and_ps(fscal,cutoff_mask);
1890
1891              /* Update vectorial force */
1892             fix3             = _mm_macc_ps(dx31,fscal,fix3);
1893             fiy3             = _mm_macc_ps(dy31,fscal,fiy3);
1894             fiz3             = _mm_macc_ps(dz31,fscal,fiz3);
1895
1896             fjx1             = _mm_macc_ps(dx31,fscal,fjx1);
1897             fjy1             = _mm_macc_ps(dy31,fscal,fjy1);
1898             fjz1             = _mm_macc_ps(dz31,fscal,fjz1);
1899
1900             }
1901
1902             /**************************
1903              * CALCULATE INTERACTIONS *
1904              **************************/
1905
1906             if (gmx_mm_any_lt(rsq32,rcutoff2))
1907             {
1908
1909             r32              = _mm_mul_ps(rsq32,rinv32);
1910
1911             /* EWALD ELECTROSTATICS */
1912
1913             /* Analytical PME correction */
1914             zeta2            = _mm_mul_ps(beta2,rsq32);
1915             rinv3            = _mm_mul_ps(rinvsq32,rinv32);
1916             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1917             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1918             felec            = _mm_mul_ps(qq32,felec);
1919
1920             cutoff_mask      = _mm_cmplt_ps(rsq32,rcutoff2);
1921
1922             fscal            = felec;
1923
1924             fscal            = _mm_and_ps(fscal,cutoff_mask);
1925
1926              /* Update vectorial force */
1927             fix3             = _mm_macc_ps(dx32,fscal,fix3);
1928             fiy3             = _mm_macc_ps(dy32,fscal,fiy3);
1929             fiz3             = _mm_macc_ps(dz32,fscal,fiz3);
1930
1931             fjx2             = _mm_macc_ps(dx32,fscal,fjx2);
1932             fjy2             = _mm_macc_ps(dy32,fscal,fjy2);
1933             fjz2             = _mm_macc_ps(dz32,fscal,fjz2);
1934
1935             }
1936
1937             /**************************
1938              * CALCULATE INTERACTIONS *
1939              **************************/
1940
1941             if (gmx_mm_any_lt(rsq33,rcutoff2))
1942             {
1943
1944             r33              = _mm_mul_ps(rsq33,rinv33);
1945
1946             /* EWALD ELECTROSTATICS */
1947
1948             /* Analytical PME correction */
1949             zeta2            = _mm_mul_ps(beta2,rsq33);
1950             rinv3            = _mm_mul_ps(rinvsq33,rinv33);
1951             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1952             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1953             felec            = _mm_mul_ps(qq33,felec);
1954
1955             cutoff_mask      = _mm_cmplt_ps(rsq33,rcutoff2);
1956
1957             fscal            = felec;
1958
1959             fscal            = _mm_and_ps(fscal,cutoff_mask);
1960
1961              /* Update vectorial force */
1962             fix3             = _mm_macc_ps(dx33,fscal,fix3);
1963             fiy3             = _mm_macc_ps(dy33,fscal,fiy3);
1964             fiz3             = _mm_macc_ps(dz33,fscal,fiz3);
1965
1966             fjx3             = _mm_macc_ps(dx33,fscal,fjx3);
1967             fjy3             = _mm_macc_ps(dy33,fscal,fjy3);
1968             fjz3             = _mm_macc_ps(dz33,fscal,fjz3);
1969
1970             }
1971
1972             fjptrA             = f+j_coord_offsetA;
1973             fjptrB             = f+j_coord_offsetB;
1974             fjptrC             = f+j_coord_offsetC;
1975             fjptrD             = f+j_coord_offsetD;
1976
1977             gmx_mm_decrement_4rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
1978                                                    fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
1979                                                    fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1980
1981             /* Inner loop uses 315 flops */
1982         }
1983
1984         if(jidx<j_index_end)
1985         {
1986
1987             /* Get j neighbor index, and coordinate index */
1988             jnrlistA         = jjnr[jidx];
1989             jnrlistB         = jjnr[jidx+1];
1990             jnrlistC         = jjnr[jidx+2];
1991             jnrlistD         = jjnr[jidx+3];
1992             /* Sign of each element will be negative for non-real atoms.
1993              * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1994              * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1995              */
1996             dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
1997             jnrA       = (jnrlistA>=0) ? jnrlistA : 0;
1998             jnrB       = (jnrlistB>=0) ? jnrlistB : 0;
1999             jnrC       = (jnrlistC>=0) ? jnrlistC : 0;
2000             jnrD       = (jnrlistD>=0) ? jnrlistD : 0;
2001             j_coord_offsetA  = DIM*jnrA;
2002             j_coord_offsetB  = DIM*jnrB;
2003             j_coord_offsetC  = DIM*jnrC;
2004             j_coord_offsetD  = DIM*jnrD;
2005
2006             /* load j atom coordinates */
2007             gmx_mm_load_4rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
2008                                               x+j_coord_offsetC,x+j_coord_offsetD,
2009                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
2010                                               &jy2,&jz2,&jx3,&jy3,&jz3);
2011
2012             /* Calculate displacement vector */
2013             dx00             = _mm_sub_ps(ix0,jx0);
2014             dy00             = _mm_sub_ps(iy0,jy0);
2015             dz00             = _mm_sub_ps(iz0,jz0);
2016             dx11             = _mm_sub_ps(ix1,jx1);
2017             dy11             = _mm_sub_ps(iy1,jy1);
2018             dz11             = _mm_sub_ps(iz1,jz1);
2019             dx12             = _mm_sub_ps(ix1,jx2);
2020             dy12             = _mm_sub_ps(iy1,jy2);
2021             dz12             = _mm_sub_ps(iz1,jz2);
2022             dx13             = _mm_sub_ps(ix1,jx3);
2023             dy13             = _mm_sub_ps(iy1,jy3);
2024             dz13             = _mm_sub_ps(iz1,jz3);
2025             dx21             = _mm_sub_ps(ix2,jx1);
2026             dy21             = _mm_sub_ps(iy2,jy1);
2027             dz21             = _mm_sub_ps(iz2,jz1);
2028             dx22             = _mm_sub_ps(ix2,jx2);
2029             dy22             = _mm_sub_ps(iy2,jy2);
2030             dz22             = _mm_sub_ps(iz2,jz2);
2031             dx23             = _mm_sub_ps(ix2,jx3);
2032             dy23             = _mm_sub_ps(iy2,jy3);
2033             dz23             = _mm_sub_ps(iz2,jz3);
2034             dx31             = _mm_sub_ps(ix3,jx1);
2035             dy31             = _mm_sub_ps(iy3,jy1);
2036             dz31             = _mm_sub_ps(iz3,jz1);
2037             dx32             = _mm_sub_ps(ix3,jx2);
2038             dy32             = _mm_sub_ps(iy3,jy2);
2039             dz32             = _mm_sub_ps(iz3,jz2);
2040             dx33             = _mm_sub_ps(ix3,jx3);
2041             dy33             = _mm_sub_ps(iy3,jy3);
2042             dz33             = _mm_sub_ps(iz3,jz3);
2043
2044             /* Calculate squared distance and things based on it */
2045             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
2046             rsq11            = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
2047             rsq12            = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
2048             rsq13            = gmx_mm_calc_rsq_ps(dx13,dy13,dz13);
2049             rsq21            = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
2050             rsq22            = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
2051             rsq23            = gmx_mm_calc_rsq_ps(dx23,dy23,dz23);
2052             rsq31            = gmx_mm_calc_rsq_ps(dx31,dy31,dz31);
2053             rsq32            = gmx_mm_calc_rsq_ps(dx32,dy32,dz32);
2054             rsq33            = gmx_mm_calc_rsq_ps(dx33,dy33,dz33);
2055
2056             rinv11           = gmx_mm_invsqrt_ps(rsq11);
2057             rinv12           = gmx_mm_invsqrt_ps(rsq12);
2058             rinv13           = gmx_mm_invsqrt_ps(rsq13);
2059             rinv21           = gmx_mm_invsqrt_ps(rsq21);
2060             rinv22           = gmx_mm_invsqrt_ps(rsq22);
2061             rinv23           = gmx_mm_invsqrt_ps(rsq23);
2062             rinv31           = gmx_mm_invsqrt_ps(rsq31);
2063             rinv32           = gmx_mm_invsqrt_ps(rsq32);
2064             rinv33           = gmx_mm_invsqrt_ps(rsq33);
2065
2066             rinvsq00         = gmx_mm_inv_ps(rsq00);
2067             rinvsq11         = _mm_mul_ps(rinv11,rinv11);
2068             rinvsq12         = _mm_mul_ps(rinv12,rinv12);
2069             rinvsq13         = _mm_mul_ps(rinv13,rinv13);
2070             rinvsq21         = _mm_mul_ps(rinv21,rinv21);
2071             rinvsq22         = _mm_mul_ps(rinv22,rinv22);
2072             rinvsq23         = _mm_mul_ps(rinv23,rinv23);
2073             rinvsq31         = _mm_mul_ps(rinv31,rinv31);
2074             rinvsq32         = _mm_mul_ps(rinv32,rinv32);
2075             rinvsq33         = _mm_mul_ps(rinv33,rinv33);
2076
2077             fjx0             = _mm_setzero_ps();
2078             fjy0             = _mm_setzero_ps();
2079             fjz0             = _mm_setzero_ps();
2080             fjx1             = _mm_setzero_ps();
2081             fjy1             = _mm_setzero_ps();
2082             fjz1             = _mm_setzero_ps();
2083             fjx2             = _mm_setzero_ps();
2084             fjy2             = _mm_setzero_ps();
2085             fjz2             = _mm_setzero_ps();
2086             fjx3             = _mm_setzero_ps();
2087             fjy3             = _mm_setzero_ps();
2088             fjz3             = _mm_setzero_ps();
2089
2090             /**************************
2091              * CALCULATE INTERACTIONS *
2092              **************************/
2093
2094             if (gmx_mm_any_lt(rsq00,rcutoff2))
2095             {
2096
2097             /* LENNARD-JONES DISPERSION/REPULSION */
2098
2099             rinvsix          = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
2100             fvdw             = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
2101
2102             cutoff_mask      = _mm_cmplt_ps(rsq00,rcutoff2);
2103
2104             fscal            = fvdw;
2105
2106             fscal            = _mm_and_ps(fscal,cutoff_mask);
2107
2108             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2109
2110              /* Update vectorial force */
2111             fix0             = _mm_macc_ps(dx00,fscal,fix0);
2112             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
2113             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
2114
2115             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
2116             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
2117             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
2118
2119             }
2120
2121             /**************************
2122              * CALCULATE INTERACTIONS *
2123              **************************/
2124
2125             if (gmx_mm_any_lt(rsq11,rcutoff2))
2126             {
2127
2128             r11              = _mm_mul_ps(rsq11,rinv11);
2129             r11              = _mm_andnot_ps(dummy_mask,r11);
2130
2131             /* EWALD ELECTROSTATICS */
2132
2133             /* Analytical PME correction */
2134             zeta2            = _mm_mul_ps(beta2,rsq11);
2135             rinv3            = _mm_mul_ps(rinvsq11,rinv11);
2136             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
2137             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
2138             felec            = _mm_mul_ps(qq11,felec);
2139
2140             cutoff_mask      = _mm_cmplt_ps(rsq11,rcutoff2);
2141
2142             fscal            = felec;
2143
2144             fscal            = _mm_and_ps(fscal,cutoff_mask);
2145
2146             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2147
2148              /* Update vectorial force */
2149             fix1             = _mm_macc_ps(dx11,fscal,fix1);
2150             fiy1             = _mm_macc_ps(dy11,fscal,fiy1);
2151             fiz1             = _mm_macc_ps(dz11,fscal,fiz1);
2152
2153             fjx1             = _mm_macc_ps(dx11,fscal,fjx1);
2154             fjy1             = _mm_macc_ps(dy11,fscal,fjy1);
2155             fjz1             = _mm_macc_ps(dz11,fscal,fjz1);
2156
2157             }
2158
2159             /**************************
2160              * CALCULATE INTERACTIONS *
2161              **************************/
2162
2163             if (gmx_mm_any_lt(rsq12,rcutoff2))
2164             {
2165
2166             r12              = _mm_mul_ps(rsq12,rinv12);
2167             r12              = _mm_andnot_ps(dummy_mask,r12);
2168
2169             /* EWALD ELECTROSTATICS */
2170
2171             /* Analytical PME correction */
2172             zeta2            = _mm_mul_ps(beta2,rsq12);
2173             rinv3            = _mm_mul_ps(rinvsq12,rinv12);
2174             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
2175             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
2176             felec            = _mm_mul_ps(qq12,felec);
2177
2178             cutoff_mask      = _mm_cmplt_ps(rsq12,rcutoff2);
2179
2180             fscal            = felec;
2181
2182             fscal            = _mm_and_ps(fscal,cutoff_mask);
2183
2184             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2185
2186              /* Update vectorial force */
2187             fix1             = _mm_macc_ps(dx12,fscal,fix1);
2188             fiy1             = _mm_macc_ps(dy12,fscal,fiy1);
2189             fiz1             = _mm_macc_ps(dz12,fscal,fiz1);
2190
2191             fjx2             = _mm_macc_ps(dx12,fscal,fjx2);
2192             fjy2             = _mm_macc_ps(dy12,fscal,fjy2);
2193             fjz2             = _mm_macc_ps(dz12,fscal,fjz2);
2194
2195             }
2196
2197             /**************************
2198              * CALCULATE INTERACTIONS *
2199              **************************/
2200
2201             if (gmx_mm_any_lt(rsq13,rcutoff2))
2202             {
2203
2204             r13              = _mm_mul_ps(rsq13,rinv13);
2205             r13              = _mm_andnot_ps(dummy_mask,r13);
2206
2207             /* EWALD ELECTROSTATICS */
2208
2209             /* Analytical PME correction */
2210             zeta2            = _mm_mul_ps(beta2,rsq13);
2211             rinv3            = _mm_mul_ps(rinvsq13,rinv13);
2212             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
2213             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
2214             felec            = _mm_mul_ps(qq13,felec);
2215
2216             cutoff_mask      = _mm_cmplt_ps(rsq13,rcutoff2);
2217
2218             fscal            = felec;
2219
2220             fscal            = _mm_and_ps(fscal,cutoff_mask);
2221
2222             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2223
2224              /* Update vectorial force */
2225             fix1             = _mm_macc_ps(dx13,fscal,fix1);
2226             fiy1             = _mm_macc_ps(dy13,fscal,fiy1);
2227             fiz1             = _mm_macc_ps(dz13,fscal,fiz1);
2228
2229             fjx3             = _mm_macc_ps(dx13,fscal,fjx3);
2230             fjy3             = _mm_macc_ps(dy13,fscal,fjy3);
2231             fjz3             = _mm_macc_ps(dz13,fscal,fjz3);
2232
2233             }
2234
2235             /**************************
2236              * CALCULATE INTERACTIONS *
2237              **************************/
2238
2239             if (gmx_mm_any_lt(rsq21,rcutoff2))
2240             {
2241
2242             r21              = _mm_mul_ps(rsq21,rinv21);
2243             r21              = _mm_andnot_ps(dummy_mask,r21);
2244
2245             /* EWALD ELECTROSTATICS */
2246
2247             /* Analytical PME correction */
2248             zeta2            = _mm_mul_ps(beta2,rsq21);
2249             rinv3            = _mm_mul_ps(rinvsq21,rinv21);
2250             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
2251             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
2252             felec            = _mm_mul_ps(qq21,felec);
2253
2254             cutoff_mask      = _mm_cmplt_ps(rsq21,rcutoff2);
2255
2256             fscal            = felec;
2257
2258             fscal            = _mm_and_ps(fscal,cutoff_mask);
2259
2260             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2261
2262              /* Update vectorial force */
2263             fix2             = _mm_macc_ps(dx21,fscal,fix2);
2264             fiy2             = _mm_macc_ps(dy21,fscal,fiy2);
2265             fiz2             = _mm_macc_ps(dz21,fscal,fiz2);
2266
2267             fjx1             = _mm_macc_ps(dx21,fscal,fjx1);
2268             fjy1             = _mm_macc_ps(dy21,fscal,fjy1);
2269             fjz1             = _mm_macc_ps(dz21,fscal,fjz1);
2270
2271             }
2272
2273             /**************************
2274              * CALCULATE INTERACTIONS *
2275              **************************/
2276
2277             if (gmx_mm_any_lt(rsq22,rcutoff2))
2278             {
2279
2280             r22              = _mm_mul_ps(rsq22,rinv22);
2281             r22              = _mm_andnot_ps(dummy_mask,r22);
2282
2283             /* EWALD ELECTROSTATICS */
2284
2285             /* Analytical PME correction */
2286             zeta2            = _mm_mul_ps(beta2,rsq22);
2287             rinv3            = _mm_mul_ps(rinvsq22,rinv22);
2288             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
2289             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
2290             felec            = _mm_mul_ps(qq22,felec);
2291
2292             cutoff_mask      = _mm_cmplt_ps(rsq22,rcutoff2);
2293
2294             fscal            = felec;
2295
2296             fscal            = _mm_and_ps(fscal,cutoff_mask);
2297
2298             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2299
2300              /* Update vectorial force */
2301             fix2             = _mm_macc_ps(dx22,fscal,fix2);
2302             fiy2             = _mm_macc_ps(dy22,fscal,fiy2);
2303             fiz2             = _mm_macc_ps(dz22,fscal,fiz2);
2304
2305             fjx2             = _mm_macc_ps(dx22,fscal,fjx2);
2306             fjy2             = _mm_macc_ps(dy22,fscal,fjy2);
2307             fjz2             = _mm_macc_ps(dz22,fscal,fjz2);
2308
2309             }
2310
2311             /**************************
2312              * CALCULATE INTERACTIONS *
2313              **************************/
2314
2315             if (gmx_mm_any_lt(rsq23,rcutoff2))
2316             {
2317
2318             r23              = _mm_mul_ps(rsq23,rinv23);
2319             r23              = _mm_andnot_ps(dummy_mask,r23);
2320
2321             /* EWALD ELECTROSTATICS */
2322
2323             /* Analytical PME correction */
2324             zeta2            = _mm_mul_ps(beta2,rsq23);
2325             rinv3            = _mm_mul_ps(rinvsq23,rinv23);
2326             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
2327             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
2328             felec            = _mm_mul_ps(qq23,felec);
2329
2330             cutoff_mask      = _mm_cmplt_ps(rsq23,rcutoff2);
2331
2332             fscal            = felec;
2333
2334             fscal            = _mm_and_ps(fscal,cutoff_mask);
2335
2336             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2337
2338              /* Update vectorial force */
2339             fix2             = _mm_macc_ps(dx23,fscal,fix2);
2340             fiy2             = _mm_macc_ps(dy23,fscal,fiy2);
2341             fiz2             = _mm_macc_ps(dz23,fscal,fiz2);
2342
2343             fjx3             = _mm_macc_ps(dx23,fscal,fjx3);
2344             fjy3             = _mm_macc_ps(dy23,fscal,fjy3);
2345             fjz3             = _mm_macc_ps(dz23,fscal,fjz3);
2346
2347             }
2348
2349             /**************************
2350              * CALCULATE INTERACTIONS *
2351              **************************/
2352
2353             if (gmx_mm_any_lt(rsq31,rcutoff2))
2354             {
2355
2356             r31              = _mm_mul_ps(rsq31,rinv31);
2357             r31              = _mm_andnot_ps(dummy_mask,r31);
2358
2359             /* EWALD ELECTROSTATICS */
2360
2361             /* Analytical PME correction */
2362             zeta2            = _mm_mul_ps(beta2,rsq31);
2363             rinv3            = _mm_mul_ps(rinvsq31,rinv31);
2364             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
2365             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
2366             felec            = _mm_mul_ps(qq31,felec);
2367
2368             cutoff_mask      = _mm_cmplt_ps(rsq31,rcutoff2);
2369
2370             fscal            = felec;
2371
2372             fscal            = _mm_and_ps(fscal,cutoff_mask);
2373
2374             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2375
2376              /* Update vectorial force */
2377             fix3             = _mm_macc_ps(dx31,fscal,fix3);
2378             fiy3             = _mm_macc_ps(dy31,fscal,fiy3);
2379             fiz3             = _mm_macc_ps(dz31,fscal,fiz3);
2380
2381             fjx1             = _mm_macc_ps(dx31,fscal,fjx1);
2382             fjy1             = _mm_macc_ps(dy31,fscal,fjy1);
2383             fjz1             = _mm_macc_ps(dz31,fscal,fjz1);
2384
2385             }
2386
2387             /**************************
2388              * CALCULATE INTERACTIONS *
2389              **************************/
2390
2391             if (gmx_mm_any_lt(rsq32,rcutoff2))
2392             {
2393
2394             r32              = _mm_mul_ps(rsq32,rinv32);
2395             r32              = _mm_andnot_ps(dummy_mask,r32);
2396
2397             /* EWALD ELECTROSTATICS */
2398
2399             /* Analytical PME correction */
2400             zeta2            = _mm_mul_ps(beta2,rsq32);
2401             rinv3            = _mm_mul_ps(rinvsq32,rinv32);
2402             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
2403             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
2404             felec            = _mm_mul_ps(qq32,felec);
2405
2406             cutoff_mask      = _mm_cmplt_ps(rsq32,rcutoff2);
2407
2408             fscal            = felec;
2409
2410             fscal            = _mm_and_ps(fscal,cutoff_mask);
2411
2412             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2413
2414              /* Update vectorial force */
2415             fix3             = _mm_macc_ps(dx32,fscal,fix3);
2416             fiy3             = _mm_macc_ps(dy32,fscal,fiy3);
2417             fiz3             = _mm_macc_ps(dz32,fscal,fiz3);
2418
2419             fjx2             = _mm_macc_ps(dx32,fscal,fjx2);
2420             fjy2             = _mm_macc_ps(dy32,fscal,fjy2);
2421             fjz2             = _mm_macc_ps(dz32,fscal,fjz2);
2422
2423             }
2424
2425             /**************************
2426              * CALCULATE INTERACTIONS *
2427              **************************/
2428
2429             if (gmx_mm_any_lt(rsq33,rcutoff2))
2430             {
2431
2432             r33              = _mm_mul_ps(rsq33,rinv33);
2433             r33              = _mm_andnot_ps(dummy_mask,r33);
2434
2435             /* EWALD ELECTROSTATICS */
2436
2437             /* Analytical PME correction */
2438             zeta2            = _mm_mul_ps(beta2,rsq33);
2439             rinv3            = _mm_mul_ps(rinvsq33,rinv33);
2440             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
2441             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
2442             felec            = _mm_mul_ps(qq33,felec);
2443
2444             cutoff_mask      = _mm_cmplt_ps(rsq33,rcutoff2);
2445
2446             fscal            = felec;
2447
2448             fscal            = _mm_and_ps(fscal,cutoff_mask);
2449
2450             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2451
2452              /* Update vectorial force */
2453             fix3             = _mm_macc_ps(dx33,fscal,fix3);
2454             fiy3             = _mm_macc_ps(dy33,fscal,fiy3);
2455             fiz3             = _mm_macc_ps(dz33,fscal,fiz3);
2456
2457             fjx3             = _mm_macc_ps(dx33,fscal,fjx3);
2458             fjy3             = _mm_macc_ps(dy33,fscal,fjy3);
2459             fjz3             = _mm_macc_ps(dz33,fscal,fjz3);
2460
2461             }
2462
2463             fjptrA             = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
2464             fjptrB             = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
2465             fjptrC             = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
2466             fjptrD             = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
2467
2468             gmx_mm_decrement_4rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
2469                                                    fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
2470                                                    fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
2471
2472             /* Inner loop uses 324 flops */
2473         }
2474
2475         /* End of innermost loop */
2476
2477         gmx_mm_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
2478                                               f+i_coord_offset,fshift+i_shift_offset);
2479
2480         /* Increment number of inner iterations */
2481         inneriter                  += j_index_end - j_index_start;
2482
2483         /* Outer loop uses 24 flops */
2484     }
2485
2486     /* Increment number of outer iterations */
2487     outeriter        += nri;
2488
2489     /* Update outer/inner flops */
2490
2491     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*24 + inneriter*324);
2492 }