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