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