Added option to gmx nmeig to print ZPE.
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_sse2_single / nb_kernel_ElecRF_VdwLJ_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_ElecRF_VdwLJ_GeomW4W4_VF_sse2_single
51  * Electrostatics interaction: ReactionField
52  * VdW interaction:            LennardJones
53  * Geometry:                   Water4-Water4
54  * Calculate force/pot:        PotentialAndForce
55  */
56 void
57 nb_kernel_ElecRF_VdwLJ_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     __m128           dummy_mask,cutoff_mask;
117     __m128           signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
118     __m128           one     = _mm_set1_ps(1.0);
119     __m128           two     = _mm_set1_ps(2.0);
120     x                = xx[0];
121     f                = ff[0];
122
123     nri              = nlist->nri;
124     iinr             = nlist->iinr;
125     jindex           = nlist->jindex;
126     jjnr             = nlist->jjnr;
127     shiftidx         = nlist->shift;
128     gid              = nlist->gid;
129     shiftvec         = fr->shift_vec[0];
130     fshift           = fr->fshift[0];
131     facel            = _mm_set1_ps(fr->ic->epsfac);
132     charge           = mdatoms->chargeA;
133     krf              = _mm_set1_ps(fr->ic->k_rf);
134     krf2             = _mm_set1_ps(fr->ic->k_rf*2.0);
135     crf              = _mm_set1_ps(fr->ic->c_rf);
136     nvdwtype         = fr->ntype;
137     vdwparam         = fr->nbfp;
138     vdwtype          = mdatoms->typeA;
139
140     /* Setup water-specific parameters */
141     inr              = nlist->iinr[0];
142     iq1              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
143     iq2              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
144     iq3              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
145     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
146
147     jq1              = _mm_set1_ps(charge[inr+1]);
148     jq2              = _mm_set1_ps(charge[inr+2]);
149     jq3              = _mm_set1_ps(charge[inr+3]);
150     vdwjidx0A        = 2*vdwtype[inr+0];
151     c6_00            = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A]);
152     c12_00           = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A+1]);
153     qq11             = _mm_mul_ps(iq1,jq1);
154     qq12             = _mm_mul_ps(iq1,jq2);
155     qq13             = _mm_mul_ps(iq1,jq3);
156     qq21             = _mm_mul_ps(iq2,jq1);
157     qq22             = _mm_mul_ps(iq2,jq2);
158     qq23             = _mm_mul_ps(iq2,jq3);
159     qq31             = _mm_mul_ps(iq3,jq1);
160     qq32             = _mm_mul_ps(iq3,jq2);
161     qq33             = _mm_mul_ps(iq3,jq3);
162
163     /* Avoid stupid compiler warnings */
164     jnrA = jnrB = jnrC = jnrD = 0;
165     j_coord_offsetA = 0;
166     j_coord_offsetB = 0;
167     j_coord_offsetC = 0;
168     j_coord_offsetD = 0;
169
170     outeriter        = 0;
171     inneriter        = 0;
172
173     for(iidx=0;iidx<4*DIM;iidx++)
174     {
175         scratch[iidx] = 0.0;
176     }  
177
178     /* Start outer loop over neighborlists */
179     for(iidx=0; iidx<nri; iidx++)
180     {
181         /* Load shift vector for this list */
182         i_shift_offset   = DIM*shiftidx[iidx];
183
184         /* Load limits for loop over neighbors */
185         j_index_start    = jindex[iidx];
186         j_index_end      = jindex[iidx+1];
187
188         /* Get outer coordinate index */
189         inr              = iinr[iidx];
190         i_coord_offset   = DIM*inr;
191
192         /* Load i particle coords and add shift vector */
193         gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
194                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
195         
196         fix0             = _mm_setzero_ps();
197         fiy0             = _mm_setzero_ps();
198         fiz0             = _mm_setzero_ps();
199         fix1             = _mm_setzero_ps();
200         fiy1             = _mm_setzero_ps();
201         fiz1             = _mm_setzero_ps();
202         fix2             = _mm_setzero_ps();
203         fiy2             = _mm_setzero_ps();
204         fiz2             = _mm_setzero_ps();
205         fix3             = _mm_setzero_ps();
206         fiy3             = _mm_setzero_ps();
207         fiz3             = _mm_setzero_ps();
208
209         /* Reset potential sums */
210         velecsum         = _mm_setzero_ps();
211         vvdwsum          = _mm_setzero_ps();
212
213         /* Start inner kernel loop */
214         for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
215         {
216
217             /* Get j neighbor index, and coordinate index */
218             jnrA             = jjnr[jidx];
219             jnrB             = jjnr[jidx+1];
220             jnrC             = jjnr[jidx+2];
221             jnrD             = jjnr[jidx+3];
222             j_coord_offsetA  = DIM*jnrA;
223             j_coord_offsetB  = DIM*jnrB;
224             j_coord_offsetC  = DIM*jnrC;
225             j_coord_offsetD  = DIM*jnrD;
226
227             /* load j atom coordinates */
228             gmx_mm_load_4rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
229                                               x+j_coord_offsetC,x+j_coord_offsetD,
230                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
231                                               &jy2,&jz2,&jx3,&jy3,&jz3);
232
233             /* Calculate displacement vector */
234             dx00             = _mm_sub_ps(ix0,jx0);
235             dy00             = _mm_sub_ps(iy0,jy0);
236             dz00             = _mm_sub_ps(iz0,jz0);
237             dx11             = _mm_sub_ps(ix1,jx1);
238             dy11             = _mm_sub_ps(iy1,jy1);
239             dz11             = _mm_sub_ps(iz1,jz1);
240             dx12             = _mm_sub_ps(ix1,jx2);
241             dy12             = _mm_sub_ps(iy1,jy2);
242             dz12             = _mm_sub_ps(iz1,jz2);
243             dx13             = _mm_sub_ps(ix1,jx3);
244             dy13             = _mm_sub_ps(iy1,jy3);
245             dz13             = _mm_sub_ps(iz1,jz3);
246             dx21             = _mm_sub_ps(ix2,jx1);
247             dy21             = _mm_sub_ps(iy2,jy1);
248             dz21             = _mm_sub_ps(iz2,jz1);
249             dx22             = _mm_sub_ps(ix2,jx2);
250             dy22             = _mm_sub_ps(iy2,jy2);
251             dz22             = _mm_sub_ps(iz2,jz2);
252             dx23             = _mm_sub_ps(ix2,jx3);
253             dy23             = _mm_sub_ps(iy2,jy3);
254             dz23             = _mm_sub_ps(iz2,jz3);
255             dx31             = _mm_sub_ps(ix3,jx1);
256             dy31             = _mm_sub_ps(iy3,jy1);
257             dz31             = _mm_sub_ps(iz3,jz1);
258             dx32             = _mm_sub_ps(ix3,jx2);
259             dy32             = _mm_sub_ps(iy3,jy2);
260             dz32             = _mm_sub_ps(iz3,jz2);
261             dx33             = _mm_sub_ps(ix3,jx3);
262             dy33             = _mm_sub_ps(iy3,jy3);
263             dz33             = _mm_sub_ps(iz3,jz3);
264
265             /* Calculate squared distance and things based on it */
266             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
267             rsq11            = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
268             rsq12            = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
269             rsq13            = gmx_mm_calc_rsq_ps(dx13,dy13,dz13);
270             rsq21            = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
271             rsq22            = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
272             rsq23            = gmx_mm_calc_rsq_ps(dx23,dy23,dz23);
273             rsq31            = gmx_mm_calc_rsq_ps(dx31,dy31,dz31);
274             rsq32            = gmx_mm_calc_rsq_ps(dx32,dy32,dz32);
275             rsq33            = gmx_mm_calc_rsq_ps(dx33,dy33,dz33);
276
277             rinv11           = sse2_invsqrt_f(rsq11);
278             rinv12           = sse2_invsqrt_f(rsq12);
279             rinv13           = sse2_invsqrt_f(rsq13);
280             rinv21           = sse2_invsqrt_f(rsq21);
281             rinv22           = sse2_invsqrt_f(rsq22);
282             rinv23           = sse2_invsqrt_f(rsq23);
283             rinv31           = sse2_invsqrt_f(rsq31);
284             rinv32           = sse2_invsqrt_f(rsq32);
285             rinv33           = sse2_invsqrt_f(rsq33);
286
287             rinvsq00         = sse2_inv_f(rsq00);
288             rinvsq11         = _mm_mul_ps(rinv11,rinv11);
289             rinvsq12         = _mm_mul_ps(rinv12,rinv12);
290             rinvsq13         = _mm_mul_ps(rinv13,rinv13);
291             rinvsq21         = _mm_mul_ps(rinv21,rinv21);
292             rinvsq22         = _mm_mul_ps(rinv22,rinv22);
293             rinvsq23         = _mm_mul_ps(rinv23,rinv23);
294             rinvsq31         = _mm_mul_ps(rinv31,rinv31);
295             rinvsq32         = _mm_mul_ps(rinv32,rinv32);
296             rinvsq33         = _mm_mul_ps(rinv33,rinv33);
297
298             fjx0             = _mm_setzero_ps();
299             fjy0             = _mm_setzero_ps();
300             fjz0             = _mm_setzero_ps();
301             fjx1             = _mm_setzero_ps();
302             fjy1             = _mm_setzero_ps();
303             fjz1             = _mm_setzero_ps();
304             fjx2             = _mm_setzero_ps();
305             fjy2             = _mm_setzero_ps();
306             fjz2             = _mm_setzero_ps();
307             fjx3             = _mm_setzero_ps();
308             fjy3             = _mm_setzero_ps();
309             fjz3             = _mm_setzero_ps();
310
311             /**************************
312              * CALCULATE INTERACTIONS *
313              **************************/
314
315             /* LENNARD-JONES DISPERSION/REPULSION */
316
317             rinvsix          = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
318             vvdw6            = _mm_mul_ps(c6_00,rinvsix);
319             vvdw12           = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
320             vvdw             = _mm_sub_ps( _mm_mul_ps(vvdw12,one_twelfth) , _mm_mul_ps(vvdw6,one_sixth) );
321             fvdw             = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
322
323             /* Update potential sum for this i atom from the interaction with this j atom. */
324             vvdwsum          = _mm_add_ps(vvdwsum,vvdw);
325
326             fscal            = fvdw;
327
328             /* Calculate temporary vectorial force */
329             tx               = _mm_mul_ps(fscal,dx00);
330             ty               = _mm_mul_ps(fscal,dy00);
331             tz               = _mm_mul_ps(fscal,dz00);
332
333             /* Update vectorial force */
334             fix0             = _mm_add_ps(fix0,tx);
335             fiy0             = _mm_add_ps(fiy0,ty);
336             fiz0             = _mm_add_ps(fiz0,tz);
337
338             fjx0             = _mm_add_ps(fjx0,tx);
339             fjy0             = _mm_add_ps(fjy0,ty);
340             fjz0             = _mm_add_ps(fjz0,tz);
341             
342             /**************************
343              * CALCULATE INTERACTIONS *
344              **************************/
345
346             /* REACTION-FIELD ELECTROSTATICS */
347             velec            = _mm_mul_ps(qq11,_mm_sub_ps(_mm_add_ps(rinv11,_mm_mul_ps(krf,rsq11)),crf));
348             felec            = _mm_mul_ps(qq11,_mm_sub_ps(_mm_mul_ps(rinv11,rinvsq11),krf2));
349
350             /* Update potential sum for this i atom from the interaction with this j atom. */
351             velecsum         = _mm_add_ps(velecsum,velec);
352
353             fscal            = felec;
354
355             /* Calculate temporary vectorial force */
356             tx               = _mm_mul_ps(fscal,dx11);
357             ty               = _mm_mul_ps(fscal,dy11);
358             tz               = _mm_mul_ps(fscal,dz11);
359
360             /* Update vectorial force */
361             fix1             = _mm_add_ps(fix1,tx);
362             fiy1             = _mm_add_ps(fiy1,ty);
363             fiz1             = _mm_add_ps(fiz1,tz);
364
365             fjx1             = _mm_add_ps(fjx1,tx);
366             fjy1             = _mm_add_ps(fjy1,ty);
367             fjz1             = _mm_add_ps(fjz1,tz);
368             
369             /**************************
370              * CALCULATE INTERACTIONS *
371              **************************/
372
373             /* REACTION-FIELD ELECTROSTATICS */
374             velec            = _mm_mul_ps(qq12,_mm_sub_ps(_mm_add_ps(rinv12,_mm_mul_ps(krf,rsq12)),crf));
375             felec            = _mm_mul_ps(qq12,_mm_sub_ps(_mm_mul_ps(rinv12,rinvsq12),krf2));
376
377             /* Update potential sum for this i atom from the interaction with this j atom. */
378             velecsum         = _mm_add_ps(velecsum,velec);
379
380             fscal            = felec;
381
382             /* Calculate temporary vectorial force */
383             tx               = _mm_mul_ps(fscal,dx12);
384             ty               = _mm_mul_ps(fscal,dy12);
385             tz               = _mm_mul_ps(fscal,dz12);
386
387             /* Update vectorial force */
388             fix1             = _mm_add_ps(fix1,tx);
389             fiy1             = _mm_add_ps(fiy1,ty);
390             fiz1             = _mm_add_ps(fiz1,tz);
391
392             fjx2             = _mm_add_ps(fjx2,tx);
393             fjy2             = _mm_add_ps(fjy2,ty);
394             fjz2             = _mm_add_ps(fjz2,tz);
395             
396             /**************************
397              * CALCULATE INTERACTIONS *
398              **************************/
399
400             /* REACTION-FIELD ELECTROSTATICS */
401             velec            = _mm_mul_ps(qq13,_mm_sub_ps(_mm_add_ps(rinv13,_mm_mul_ps(krf,rsq13)),crf));
402             felec            = _mm_mul_ps(qq13,_mm_sub_ps(_mm_mul_ps(rinv13,rinvsq13),krf2));
403
404             /* Update potential sum for this i atom from the interaction with this j atom. */
405             velecsum         = _mm_add_ps(velecsum,velec);
406
407             fscal            = felec;
408
409             /* Calculate temporary vectorial force */
410             tx               = _mm_mul_ps(fscal,dx13);
411             ty               = _mm_mul_ps(fscal,dy13);
412             tz               = _mm_mul_ps(fscal,dz13);
413
414             /* Update vectorial force */
415             fix1             = _mm_add_ps(fix1,tx);
416             fiy1             = _mm_add_ps(fiy1,ty);
417             fiz1             = _mm_add_ps(fiz1,tz);
418
419             fjx3             = _mm_add_ps(fjx3,tx);
420             fjy3             = _mm_add_ps(fjy3,ty);
421             fjz3             = _mm_add_ps(fjz3,tz);
422             
423             /**************************
424              * CALCULATE INTERACTIONS *
425              **************************/
426
427             /* REACTION-FIELD ELECTROSTATICS */
428             velec            = _mm_mul_ps(qq21,_mm_sub_ps(_mm_add_ps(rinv21,_mm_mul_ps(krf,rsq21)),crf));
429             felec            = _mm_mul_ps(qq21,_mm_sub_ps(_mm_mul_ps(rinv21,rinvsq21),krf2));
430
431             /* Update potential sum for this i atom from the interaction with this j atom. */
432             velecsum         = _mm_add_ps(velecsum,velec);
433
434             fscal            = felec;
435
436             /* Calculate temporary vectorial force */
437             tx               = _mm_mul_ps(fscal,dx21);
438             ty               = _mm_mul_ps(fscal,dy21);
439             tz               = _mm_mul_ps(fscal,dz21);
440
441             /* Update vectorial force */
442             fix2             = _mm_add_ps(fix2,tx);
443             fiy2             = _mm_add_ps(fiy2,ty);
444             fiz2             = _mm_add_ps(fiz2,tz);
445
446             fjx1             = _mm_add_ps(fjx1,tx);
447             fjy1             = _mm_add_ps(fjy1,ty);
448             fjz1             = _mm_add_ps(fjz1,tz);
449             
450             /**************************
451              * CALCULATE INTERACTIONS *
452              **************************/
453
454             /* REACTION-FIELD ELECTROSTATICS */
455             velec            = _mm_mul_ps(qq22,_mm_sub_ps(_mm_add_ps(rinv22,_mm_mul_ps(krf,rsq22)),crf));
456             felec            = _mm_mul_ps(qq22,_mm_sub_ps(_mm_mul_ps(rinv22,rinvsq22),krf2));
457
458             /* Update potential sum for this i atom from the interaction with this j atom. */
459             velecsum         = _mm_add_ps(velecsum,velec);
460
461             fscal            = felec;
462
463             /* Calculate temporary vectorial force */
464             tx               = _mm_mul_ps(fscal,dx22);
465             ty               = _mm_mul_ps(fscal,dy22);
466             tz               = _mm_mul_ps(fscal,dz22);
467
468             /* Update vectorial force */
469             fix2             = _mm_add_ps(fix2,tx);
470             fiy2             = _mm_add_ps(fiy2,ty);
471             fiz2             = _mm_add_ps(fiz2,tz);
472
473             fjx2             = _mm_add_ps(fjx2,tx);
474             fjy2             = _mm_add_ps(fjy2,ty);
475             fjz2             = _mm_add_ps(fjz2,tz);
476             
477             /**************************
478              * CALCULATE INTERACTIONS *
479              **************************/
480
481             /* REACTION-FIELD ELECTROSTATICS */
482             velec            = _mm_mul_ps(qq23,_mm_sub_ps(_mm_add_ps(rinv23,_mm_mul_ps(krf,rsq23)),crf));
483             felec            = _mm_mul_ps(qq23,_mm_sub_ps(_mm_mul_ps(rinv23,rinvsq23),krf2));
484
485             /* Update potential sum for this i atom from the interaction with this j atom. */
486             velecsum         = _mm_add_ps(velecsum,velec);
487
488             fscal            = felec;
489
490             /* Calculate temporary vectorial force */
491             tx               = _mm_mul_ps(fscal,dx23);
492             ty               = _mm_mul_ps(fscal,dy23);
493             tz               = _mm_mul_ps(fscal,dz23);
494
495             /* Update vectorial force */
496             fix2             = _mm_add_ps(fix2,tx);
497             fiy2             = _mm_add_ps(fiy2,ty);
498             fiz2             = _mm_add_ps(fiz2,tz);
499
500             fjx3             = _mm_add_ps(fjx3,tx);
501             fjy3             = _mm_add_ps(fjy3,ty);
502             fjz3             = _mm_add_ps(fjz3,tz);
503             
504             /**************************
505              * CALCULATE INTERACTIONS *
506              **************************/
507
508             /* REACTION-FIELD ELECTROSTATICS */
509             velec            = _mm_mul_ps(qq31,_mm_sub_ps(_mm_add_ps(rinv31,_mm_mul_ps(krf,rsq31)),crf));
510             felec            = _mm_mul_ps(qq31,_mm_sub_ps(_mm_mul_ps(rinv31,rinvsq31),krf2));
511
512             /* Update potential sum for this i atom from the interaction with this j atom. */
513             velecsum         = _mm_add_ps(velecsum,velec);
514
515             fscal            = felec;
516
517             /* Calculate temporary vectorial force */
518             tx               = _mm_mul_ps(fscal,dx31);
519             ty               = _mm_mul_ps(fscal,dy31);
520             tz               = _mm_mul_ps(fscal,dz31);
521
522             /* Update vectorial force */
523             fix3             = _mm_add_ps(fix3,tx);
524             fiy3             = _mm_add_ps(fiy3,ty);
525             fiz3             = _mm_add_ps(fiz3,tz);
526
527             fjx1             = _mm_add_ps(fjx1,tx);
528             fjy1             = _mm_add_ps(fjy1,ty);
529             fjz1             = _mm_add_ps(fjz1,tz);
530             
531             /**************************
532              * CALCULATE INTERACTIONS *
533              **************************/
534
535             /* REACTION-FIELD ELECTROSTATICS */
536             velec            = _mm_mul_ps(qq32,_mm_sub_ps(_mm_add_ps(rinv32,_mm_mul_ps(krf,rsq32)),crf));
537             felec            = _mm_mul_ps(qq32,_mm_sub_ps(_mm_mul_ps(rinv32,rinvsq32),krf2));
538
539             /* Update potential sum for this i atom from the interaction with this j atom. */
540             velecsum         = _mm_add_ps(velecsum,velec);
541
542             fscal            = felec;
543
544             /* Calculate temporary vectorial force */
545             tx               = _mm_mul_ps(fscal,dx32);
546             ty               = _mm_mul_ps(fscal,dy32);
547             tz               = _mm_mul_ps(fscal,dz32);
548
549             /* Update vectorial force */
550             fix3             = _mm_add_ps(fix3,tx);
551             fiy3             = _mm_add_ps(fiy3,ty);
552             fiz3             = _mm_add_ps(fiz3,tz);
553
554             fjx2             = _mm_add_ps(fjx2,tx);
555             fjy2             = _mm_add_ps(fjy2,ty);
556             fjz2             = _mm_add_ps(fjz2,tz);
557             
558             /**************************
559              * CALCULATE INTERACTIONS *
560              **************************/
561
562             /* REACTION-FIELD ELECTROSTATICS */
563             velec            = _mm_mul_ps(qq33,_mm_sub_ps(_mm_add_ps(rinv33,_mm_mul_ps(krf,rsq33)),crf));
564             felec            = _mm_mul_ps(qq33,_mm_sub_ps(_mm_mul_ps(rinv33,rinvsq33),krf2));
565
566             /* Update potential sum for this i atom from the interaction with this j atom. */
567             velecsum         = _mm_add_ps(velecsum,velec);
568
569             fscal            = felec;
570
571             /* Calculate temporary vectorial force */
572             tx               = _mm_mul_ps(fscal,dx33);
573             ty               = _mm_mul_ps(fscal,dy33);
574             tz               = _mm_mul_ps(fscal,dz33);
575
576             /* Update vectorial force */
577             fix3             = _mm_add_ps(fix3,tx);
578             fiy3             = _mm_add_ps(fiy3,ty);
579             fiz3             = _mm_add_ps(fiz3,tz);
580
581             fjx3             = _mm_add_ps(fjx3,tx);
582             fjy3             = _mm_add_ps(fjy3,ty);
583             fjz3             = _mm_add_ps(fjz3,tz);
584             
585             fjptrA             = f+j_coord_offsetA;
586             fjptrB             = f+j_coord_offsetB;
587             fjptrC             = f+j_coord_offsetC;
588             fjptrD             = f+j_coord_offsetD;
589
590             gmx_mm_decrement_4rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
591                                                    fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
592                                                    fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
593
594             /* Inner loop uses 323 flops */
595         }
596
597         if(jidx<j_index_end)
598         {
599
600             /* Get j neighbor index, and coordinate index */
601             jnrlistA         = jjnr[jidx];
602             jnrlistB         = jjnr[jidx+1];
603             jnrlistC         = jjnr[jidx+2];
604             jnrlistD         = jjnr[jidx+3];
605             /* Sign of each element will be negative for non-real atoms.
606              * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
607              * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
608              */
609             dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
610             jnrA       = (jnrlistA>=0) ? jnrlistA : 0;
611             jnrB       = (jnrlistB>=0) ? jnrlistB : 0;
612             jnrC       = (jnrlistC>=0) ? jnrlistC : 0;
613             jnrD       = (jnrlistD>=0) ? jnrlistD : 0;
614             j_coord_offsetA  = DIM*jnrA;
615             j_coord_offsetB  = DIM*jnrB;
616             j_coord_offsetC  = DIM*jnrC;
617             j_coord_offsetD  = DIM*jnrD;
618
619             /* load j atom coordinates */
620             gmx_mm_load_4rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
621                                               x+j_coord_offsetC,x+j_coord_offsetD,
622                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
623                                               &jy2,&jz2,&jx3,&jy3,&jz3);
624
625             /* Calculate displacement vector */
626             dx00             = _mm_sub_ps(ix0,jx0);
627             dy00             = _mm_sub_ps(iy0,jy0);
628             dz00             = _mm_sub_ps(iz0,jz0);
629             dx11             = _mm_sub_ps(ix1,jx1);
630             dy11             = _mm_sub_ps(iy1,jy1);
631             dz11             = _mm_sub_ps(iz1,jz1);
632             dx12             = _mm_sub_ps(ix1,jx2);
633             dy12             = _mm_sub_ps(iy1,jy2);
634             dz12             = _mm_sub_ps(iz1,jz2);
635             dx13             = _mm_sub_ps(ix1,jx3);
636             dy13             = _mm_sub_ps(iy1,jy3);
637             dz13             = _mm_sub_ps(iz1,jz3);
638             dx21             = _mm_sub_ps(ix2,jx1);
639             dy21             = _mm_sub_ps(iy2,jy1);
640             dz21             = _mm_sub_ps(iz2,jz1);
641             dx22             = _mm_sub_ps(ix2,jx2);
642             dy22             = _mm_sub_ps(iy2,jy2);
643             dz22             = _mm_sub_ps(iz2,jz2);
644             dx23             = _mm_sub_ps(ix2,jx3);
645             dy23             = _mm_sub_ps(iy2,jy3);
646             dz23             = _mm_sub_ps(iz2,jz3);
647             dx31             = _mm_sub_ps(ix3,jx1);
648             dy31             = _mm_sub_ps(iy3,jy1);
649             dz31             = _mm_sub_ps(iz3,jz1);
650             dx32             = _mm_sub_ps(ix3,jx2);
651             dy32             = _mm_sub_ps(iy3,jy2);
652             dz32             = _mm_sub_ps(iz3,jz2);
653             dx33             = _mm_sub_ps(ix3,jx3);
654             dy33             = _mm_sub_ps(iy3,jy3);
655             dz33             = _mm_sub_ps(iz3,jz3);
656
657             /* Calculate squared distance and things based on it */
658             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
659             rsq11            = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
660             rsq12            = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
661             rsq13            = gmx_mm_calc_rsq_ps(dx13,dy13,dz13);
662             rsq21            = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
663             rsq22            = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
664             rsq23            = gmx_mm_calc_rsq_ps(dx23,dy23,dz23);
665             rsq31            = gmx_mm_calc_rsq_ps(dx31,dy31,dz31);
666             rsq32            = gmx_mm_calc_rsq_ps(dx32,dy32,dz32);
667             rsq33            = gmx_mm_calc_rsq_ps(dx33,dy33,dz33);
668
669             rinv11           = sse2_invsqrt_f(rsq11);
670             rinv12           = sse2_invsqrt_f(rsq12);
671             rinv13           = sse2_invsqrt_f(rsq13);
672             rinv21           = sse2_invsqrt_f(rsq21);
673             rinv22           = sse2_invsqrt_f(rsq22);
674             rinv23           = sse2_invsqrt_f(rsq23);
675             rinv31           = sse2_invsqrt_f(rsq31);
676             rinv32           = sse2_invsqrt_f(rsq32);
677             rinv33           = sse2_invsqrt_f(rsq33);
678
679             rinvsq00         = sse2_inv_f(rsq00);
680             rinvsq11         = _mm_mul_ps(rinv11,rinv11);
681             rinvsq12         = _mm_mul_ps(rinv12,rinv12);
682             rinvsq13         = _mm_mul_ps(rinv13,rinv13);
683             rinvsq21         = _mm_mul_ps(rinv21,rinv21);
684             rinvsq22         = _mm_mul_ps(rinv22,rinv22);
685             rinvsq23         = _mm_mul_ps(rinv23,rinv23);
686             rinvsq31         = _mm_mul_ps(rinv31,rinv31);
687             rinvsq32         = _mm_mul_ps(rinv32,rinv32);
688             rinvsq33         = _mm_mul_ps(rinv33,rinv33);
689
690             fjx0             = _mm_setzero_ps();
691             fjy0             = _mm_setzero_ps();
692             fjz0             = _mm_setzero_ps();
693             fjx1             = _mm_setzero_ps();
694             fjy1             = _mm_setzero_ps();
695             fjz1             = _mm_setzero_ps();
696             fjx2             = _mm_setzero_ps();
697             fjy2             = _mm_setzero_ps();
698             fjz2             = _mm_setzero_ps();
699             fjx3             = _mm_setzero_ps();
700             fjy3             = _mm_setzero_ps();
701             fjz3             = _mm_setzero_ps();
702
703             /**************************
704              * CALCULATE INTERACTIONS *
705              **************************/
706
707             /* LENNARD-JONES DISPERSION/REPULSION */
708
709             rinvsix          = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
710             vvdw6            = _mm_mul_ps(c6_00,rinvsix);
711             vvdw12           = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
712             vvdw             = _mm_sub_ps( _mm_mul_ps(vvdw12,one_twelfth) , _mm_mul_ps(vvdw6,one_sixth) );
713             fvdw             = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
714
715             /* Update potential sum for this i atom from the interaction with this j atom. */
716             vvdw             = _mm_andnot_ps(dummy_mask,vvdw);
717             vvdwsum          = _mm_add_ps(vvdwsum,vvdw);
718
719             fscal            = fvdw;
720
721             fscal            = _mm_andnot_ps(dummy_mask,fscal);
722
723             /* Calculate temporary vectorial force */
724             tx               = _mm_mul_ps(fscal,dx00);
725             ty               = _mm_mul_ps(fscal,dy00);
726             tz               = _mm_mul_ps(fscal,dz00);
727
728             /* Update vectorial force */
729             fix0             = _mm_add_ps(fix0,tx);
730             fiy0             = _mm_add_ps(fiy0,ty);
731             fiz0             = _mm_add_ps(fiz0,tz);
732
733             fjx0             = _mm_add_ps(fjx0,tx);
734             fjy0             = _mm_add_ps(fjy0,ty);
735             fjz0             = _mm_add_ps(fjz0,tz);
736             
737             /**************************
738              * CALCULATE INTERACTIONS *
739              **************************/
740
741             /* REACTION-FIELD ELECTROSTATICS */
742             velec            = _mm_mul_ps(qq11,_mm_sub_ps(_mm_add_ps(rinv11,_mm_mul_ps(krf,rsq11)),crf));
743             felec            = _mm_mul_ps(qq11,_mm_sub_ps(_mm_mul_ps(rinv11,rinvsq11),krf2));
744
745             /* Update potential sum for this i atom from the interaction with this j atom. */
746             velec            = _mm_andnot_ps(dummy_mask,velec);
747             velecsum         = _mm_add_ps(velecsum,velec);
748
749             fscal            = felec;
750
751             fscal            = _mm_andnot_ps(dummy_mask,fscal);
752
753             /* Calculate temporary vectorial force */
754             tx               = _mm_mul_ps(fscal,dx11);
755             ty               = _mm_mul_ps(fscal,dy11);
756             tz               = _mm_mul_ps(fscal,dz11);
757
758             /* Update vectorial force */
759             fix1             = _mm_add_ps(fix1,tx);
760             fiy1             = _mm_add_ps(fiy1,ty);
761             fiz1             = _mm_add_ps(fiz1,tz);
762
763             fjx1             = _mm_add_ps(fjx1,tx);
764             fjy1             = _mm_add_ps(fjy1,ty);
765             fjz1             = _mm_add_ps(fjz1,tz);
766             
767             /**************************
768              * CALCULATE INTERACTIONS *
769              **************************/
770
771             /* REACTION-FIELD ELECTROSTATICS */
772             velec            = _mm_mul_ps(qq12,_mm_sub_ps(_mm_add_ps(rinv12,_mm_mul_ps(krf,rsq12)),crf));
773             felec            = _mm_mul_ps(qq12,_mm_sub_ps(_mm_mul_ps(rinv12,rinvsq12),krf2));
774
775             /* Update potential sum for this i atom from the interaction with this j atom. */
776             velec            = _mm_andnot_ps(dummy_mask,velec);
777             velecsum         = _mm_add_ps(velecsum,velec);
778
779             fscal            = felec;
780
781             fscal            = _mm_andnot_ps(dummy_mask,fscal);
782
783             /* Calculate temporary vectorial force */
784             tx               = _mm_mul_ps(fscal,dx12);
785             ty               = _mm_mul_ps(fscal,dy12);
786             tz               = _mm_mul_ps(fscal,dz12);
787
788             /* Update vectorial force */
789             fix1             = _mm_add_ps(fix1,tx);
790             fiy1             = _mm_add_ps(fiy1,ty);
791             fiz1             = _mm_add_ps(fiz1,tz);
792
793             fjx2             = _mm_add_ps(fjx2,tx);
794             fjy2             = _mm_add_ps(fjy2,ty);
795             fjz2             = _mm_add_ps(fjz2,tz);
796             
797             /**************************
798              * CALCULATE INTERACTIONS *
799              **************************/
800
801             /* REACTION-FIELD ELECTROSTATICS */
802             velec            = _mm_mul_ps(qq13,_mm_sub_ps(_mm_add_ps(rinv13,_mm_mul_ps(krf,rsq13)),crf));
803             felec            = _mm_mul_ps(qq13,_mm_sub_ps(_mm_mul_ps(rinv13,rinvsq13),krf2));
804
805             /* Update potential sum for this i atom from the interaction with this j atom. */
806             velec            = _mm_andnot_ps(dummy_mask,velec);
807             velecsum         = _mm_add_ps(velecsum,velec);
808
809             fscal            = felec;
810
811             fscal            = _mm_andnot_ps(dummy_mask,fscal);
812
813             /* Calculate temporary vectorial force */
814             tx               = _mm_mul_ps(fscal,dx13);
815             ty               = _mm_mul_ps(fscal,dy13);
816             tz               = _mm_mul_ps(fscal,dz13);
817
818             /* Update vectorial force */
819             fix1             = _mm_add_ps(fix1,tx);
820             fiy1             = _mm_add_ps(fiy1,ty);
821             fiz1             = _mm_add_ps(fiz1,tz);
822
823             fjx3             = _mm_add_ps(fjx3,tx);
824             fjy3             = _mm_add_ps(fjy3,ty);
825             fjz3             = _mm_add_ps(fjz3,tz);
826             
827             /**************************
828              * CALCULATE INTERACTIONS *
829              **************************/
830
831             /* REACTION-FIELD ELECTROSTATICS */
832             velec            = _mm_mul_ps(qq21,_mm_sub_ps(_mm_add_ps(rinv21,_mm_mul_ps(krf,rsq21)),crf));
833             felec            = _mm_mul_ps(qq21,_mm_sub_ps(_mm_mul_ps(rinv21,rinvsq21),krf2));
834
835             /* Update potential sum for this i atom from the interaction with this j atom. */
836             velec            = _mm_andnot_ps(dummy_mask,velec);
837             velecsum         = _mm_add_ps(velecsum,velec);
838
839             fscal            = felec;
840
841             fscal            = _mm_andnot_ps(dummy_mask,fscal);
842
843             /* Calculate temporary vectorial force */
844             tx               = _mm_mul_ps(fscal,dx21);
845             ty               = _mm_mul_ps(fscal,dy21);
846             tz               = _mm_mul_ps(fscal,dz21);
847
848             /* Update vectorial force */
849             fix2             = _mm_add_ps(fix2,tx);
850             fiy2             = _mm_add_ps(fiy2,ty);
851             fiz2             = _mm_add_ps(fiz2,tz);
852
853             fjx1             = _mm_add_ps(fjx1,tx);
854             fjy1             = _mm_add_ps(fjy1,ty);
855             fjz1             = _mm_add_ps(fjz1,tz);
856             
857             /**************************
858              * CALCULATE INTERACTIONS *
859              **************************/
860
861             /* REACTION-FIELD ELECTROSTATICS */
862             velec            = _mm_mul_ps(qq22,_mm_sub_ps(_mm_add_ps(rinv22,_mm_mul_ps(krf,rsq22)),crf));
863             felec            = _mm_mul_ps(qq22,_mm_sub_ps(_mm_mul_ps(rinv22,rinvsq22),krf2));
864
865             /* Update potential sum for this i atom from the interaction with this j atom. */
866             velec            = _mm_andnot_ps(dummy_mask,velec);
867             velecsum         = _mm_add_ps(velecsum,velec);
868
869             fscal            = felec;
870
871             fscal            = _mm_andnot_ps(dummy_mask,fscal);
872
873             /* Calculate temporary vectorial force */
874             tx               = _mm_mul_ps(fscal,dx22);
875             ty               = _mm_mul_ps(fscal,dy22);
876             tz               = _mm_mul_ps(fscal,dz22);
877
878             /* Update vectorial force */
879             fix2             = _mm_add_ps(fix2,tx);
880             fiy2             = _mm_add_ps(fiy2,ty);
881             fiz2             = _mm_add_ps(fiz2,tz);
882
883             fjx2             = _mm_add_ps(fjx2,tx);
884             fjy2             = _mm_add_ps(fjy2,ty);
885             fjz2             = _mm_add_ps(fjz2,tz);
886             
887             /**************************
888              * CALCULATE INTERACTIONS *
889              **************************/
890
891             /* REACTION-FIELD ELECTROSTATICS */
892             velec            = _mm_mul_ps(qq23,_mm_sub_ps(_mm_add_ps(rinv23,_mm_mul_ps(krf,rsq23)),crf));
893             felec            = _mm_mul_ps(qq23,_mm_sub_ps(_mm_mul_ps(rinv23,rinvsq23),krf2));
894
895             /* Update potential sum for this i atom from the interaction with this j atom. */
896             velec            = _mm_andnot_ps(dummy_mask,velec);
897             velecsum         = _mm_add_ps(velecsum,velec);
898
899             fscal            = felec;
900
901             fscal            = _mm_andnot_ps(dummy_mask,fscal);
902
903             /* Calculate temporary vectorial force */
904             tx               = _mm_mul_ps(fscal,dx23);
905             ty               = _mm_mul_ps(fscal,dy23);
906             tz               = _mm_mul_ps(fscal,dz23);
907
908             /* Update vectorial force */
909             fix2             = _mm_add_ps(fix2,tx);
910             fiy2             = _mm_add_ps(fiy2,ty);
911             fiz2             = _mm_add_ps(fiz2,tz);
912
913             fjx3             = _mm_add_ps(fjx3,tx);
914             fjy3             = _mm_add_ps(fjy3,ty);
915             fjz3             = _mm_add_ps(fjz3,tz);
916             
917             /**************************
918              * CALCULATE INTERACTIONS *
919              **************************/
920
921             /* REACTION-FIELD ELECTROSTATICS */
922             velec            = _mm_mul_ps(qq31,_mm_sub_ps(_mm_add_ps(rinv31,_mm_mul_ps(krf,rsq31)),crf));
923             felec            = _mm_mul_ps(qq31,_mm_sub_ps(_mm_mul_ps(rinv31,rinvsq31),krf2));
924
925             /* Update potential sum for this i atom from the interaction with this j atom. */
926             velec            = _mm_andnot_ps(dummy_mask,velec);
927             velecsum         = _mm_add_ps(velecsum,velec);
928
929             fscal            = felec;
930
931             fscal            = _mm_andnot_ps(dummy_mask,fscal);
932
933             /* Calculate temporary vectorial force */
934             tx               = _mm_mul_ps(fscal,dx31);
935             ty               = _mm_mul_ps(fscal,dy31);
936             tz               = _mm_mul_ps(fscal,dz31);
937
938             /* Update vectorial force */
939             fix3             = _mm_add_ps(fix3,tx);
940             fiy3             = _mm_add_ps(fiy3,ty);
941             fiz3             = _mm_add_ps(fiz3,tz);
942
943             fjx1             = _mm_add_ps(fjx1,tx);
944             fjy1             = _mm_add_ps(fjy1,ty);
945             fjz1             = _mm_add_ps(fjz1,tz);
946             
947             /**************************
948              * CALCULATE INTERACTIONS *
949              **************************/
950
951             /* REACTION-FIELD ELECTROSTATICS */
952             velec            = _mm_mul_ps(qq32,_mm_sub_ps(_mm_add_ps(rinv32,_mm_mul_ps(krf,rsq32)),crf));
953             felec            = _mm_mul_ps(qq32,_mm_sub_ps(_mm_mul_ps(rinv32,rinvsq32),krf2));
954
955             /* Update potential sum for this i atom from the interaction with this j atom. */
956             velec            = _mm_andnot_ps(dummy_mask,velec);
957             velecsum         = _mm_add_ps(velecsum,velec);
958
959             fscal            = felec;
960
961             fscal            = _mm_andnot_ps(dummy_mask,fscal);
962
963             /* Calculate temporary vectorial force */
964             tx               = _mm_mul_ps(fscal,dx32);
965             ty               = _mm_mul_ps(fscal,dy32);
966             tz               = _mm_mul_ps(fscal,dz32);
967
968             /* Update vectorial force */
969             fix3             = _mm_add_ps(fix3,tx);
970             fiy3             = _mm_add_ps(fiy3,ty);
971             fiz3             = _mm_add_ps(fiz3,tz);
972
973             fjx2             = _mm_add_ps(fjx2,tx);
974             fjy2             = _mm_add_ps(fjy2,ty);
975             fjz2             = _mm_add_ps(fjz2,tz);
976             
977             /**************************
978              * CALCULATE INTERACTIONS *
979              **************************/
980
981             /* REACTION-FIELD ELECTROSTATICS */
982             velec            = _mm_mul_ps(qq33,_mm_sub_ps(_mm_add_ps(rinv33,_mm_mul_ps(krf,rsq33)),crf));
983             felec            = _mm_mul_ps(qq33,_mm_sub_ps(_mm_mul_ps(rinv33,rinvsq33),krf2));
984
985             /* Update potential sum for this i atom from the interaction with this j atom. */
986             velec            = _mm_andnot_ps(dummy_mask,velec);
987             velecsum         = _mm_add_ps(velecsum,velec);
988
989             fscal            = felec;
990
991             fscal            = _mm_andnot_ps(dummy_mask,fscal);
992
993             /* Calculate temporary vectorial force */
994             tx               = _mm_mul_ps(fscal,dx33);
995             ty               = _mm_mul_ps(fscal,dy33);
996             tz               = _mm_mul_ps(fscal,dz33);
997
998             /* Update vectorial force */
999             fix3             = _mm_add_ps(fix3,tx);
1000             fiy3             = _mm_add_ps(fiy3,ty);
1001             fiz3             = _mm_add_ps(fiz3,tz);
1002
1003             fjx3             = _mm_add_ps(fjx3,tx);
1004             fjy3             = _mm_add_ps(fjy3,ty);
1005             fjz3             = _mm_add_ps(fjz3,tz);
1006             
1007             fjptrA             = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1008             fjptrB             = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1009             fjptrC             = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1010             fjptrD             = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1011
1012             gmx_mm_decrement_4rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
1013                                                    fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
1014                                                    fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1015
1016             /* Inner loop uses 323 flops */
1017         }
1018
1019         /* End of innermost loop */
1020
1021         gmx_mm_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1022                                               f+i_coord_offset,fshift+i_shift_offset);
1023
1024         ggid                        = gid[iidx];
1025         /* Update potential energies */
1026         gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
1027         gmx_mm_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
1028
1029         /* Increment number of inner iterations */
1030         inneriter                  += j_index_end - j_index_start;
1031
1032         /* Outer loop uses 26 flops */
1033     }
1034
1035     /* Increment number of outer iterations */
1036     outeriter        += nri;
1037
1038     /* Update outer/inner flops */
1039
1040     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*26 + inneriter*323);
1041 }
1042 /*
1043  * Gromacs nonbonded kernel:   nb_kernel_ElecRF_VdwLJ_GeomW4W4_F_sse2_single
1044  * Electrostatics interaction: ReactionField
1045  * VdW interaction:            LennardJones
1046  * Geometry:                   Water4-Water4
1047  * Calculate force/pot:        Force
1048  */
1049 void
1050 nb_kernel_ElecRF_VdwLJ_GeomW4W4_F_sse2_single
1051                     (t_nblist                    * gmx_restrict       nlist,
1052                      rvec                        * gmx_restrict          xx,
1053                      rvec                        * gmx_restrict          ff,
1054                      struct t_forcerec           * gmx_restrict          fr,
1055                      t_mdatoms                   * gmx_restrict     mdatoms,
1056                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
1057                      t_nrnb                      * gmx_restrict        nrnb)
1058 {
1059     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or 
1060      * just 0 for non-waters.
1061      * Suffixes A,B,C,D refer to j loop unrolling done with SSE, e.g. for the four different
1062      * jnr indices corresponding to data put in the four positions in the SIMD register.
1063      */
1064     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
1065     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
1066     int              jnrA,jnrB,jnrC,jnrD;
1067     int              jnrlistA,jnrlistB,jnrlistC,jnrlistD;
1068     int              j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
1069     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
1070     real             rcutoff_scalar;
1071     real             *shiftvec,*fshift,*x,*f;
1072     real             *fjptrA,*fjptrB,*fjptrC,*fjptrD;
1073     real             scratch[4*DIM];
1074     __m128           tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
1075     int              vdwioffset0;
1076     __m128           ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
1077     int              vdwioffset1;
1078     __m128           ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
1079     int              vdwioffset2;
1080     __m128           ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
1081     int              vdwioffset3;
1082     __m128           ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
1083     int              vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
1084     __m128           jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
1085     int              vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D;
1086     __m128           jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
1087     int              vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D;
1088     __m128           jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
1089     int              vdwjidx3A,vdwjidx3B,vdwjidx3C,vdwjidx3D;
1090     __m128           jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
1091     __m128           dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
1092     __m128           dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
1093     __m128           dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
1094     __m128           dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
1095     __m128           dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
1096     __m128           dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
1097     __m128           dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
1098     __m128           dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
1099     __m128           dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
1100     __m128           dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
1101     __m128           velec,felec,velecsum,facel,crf,krf,krf2;
1102     real             *charge;
1103     int              nvdwtype;
1104     __m128           rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
1105     int              *vdwtype;
1106     real             *vdwparam;
1107     __m128           one_sixth   = _mm_set1_ps(1.0/6.0);
1108     __m128           one_twelfth = _mm_set1_ps(1.0/12.0);
1109     __m128           dummy_mask,cutoff_mask;
1110     __m128           signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
1111     __m128           one     = _mm_set1_ps(1.0);
1112     __m128           two     = _mm_set1_ps(2.0);
1113     x                = xx[0];
1114     f                = ff[0];
1115
1116     nri              = nlist->nri;
1117     iinr             = nlist->iinr;
1118     jindex           = nlist->jindex;
1119     jjnr             = nlist->jjnr;
1120     shiftidx         = nlist->shift;
1121     gid              = nlist->gid;
1122     shiftvec         = fr->shift_vec[0];
1123     fshift           = fr->fshift[0];
1124     facel            = _mm_set1_ps(fr->ic->epsfac);
1125     charge           = mdatoms->chargeA;
1126     krf              = _mm_set1_ps(fr->ic->k_rf);
1127     krf2             = _mm_set1_ps(fr->ic->k_rf*2.0);
1128     crf              = _mm_set1_ps(fr->ic->c_rf);
1129     nvdwtype         = fr->ntype;
1130     vdwparam         = fr->nbfp;
1131     vdwtype          = mdatoms->typeA;
1132
1133     /* Setup water-specific parameters */
1134     inr              = nlist->iinr[0];
1135     iq1              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
1136     iq2              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
1137     iq3              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
1138     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
1139
1140     jq1              = _mm_set1_ps(charge[inr+1]);
1141     jq2              = _mm_set1_ps(charge[inr+2]);
1142     jq3              = _mm_set1_ps(charge[inr+3]);
1143     vdwjidx0A        = 2*vdwtype[inr+0];
1144     c6_00            = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A]);
1145     c12_00           = _mm_set1_ps(vdwparam[vdwioffset0+vdwjidx0A+1]);
1146     qq11             = _mm_mul_ps(iq1,jq1);
1147     qq12             = _mm_mul_ps(iq1,jq2);
1148     qq13             = _mm_mul_ps(iq1,jq3);
1149     qq21             = _mm_mul_ps(iq2,jq1);
1150     qq22             = _mm_mul_ps(iq2,jq2);
1151     qq23             = _mm_mul_ps(iq2,jq3);
1152     qq31             = _mm_mul_ps(iq3,jq1);
1153     qq32             = _mm_mul_ps(iq3,jq2);
1154     qq33             = _mm_mul_ps(iq3,jq3);
1155
1156     /* Avoid stupid compiler warnings */
1157     jnrA = jnrB = jnrC = jnrD = 0;
1158     j_coord_offsetA = 0;
1159     j_coord_offsetB = 0;
1160     j_coord_offsetC = 0;
1161     j_coord_offsetD = 0;
1162
1163     outeriter        = 0;
1164     inneriter        = 0;
1165
1166     for(iidx=0;iidx<4*DIM;iidx++)
1167     {
1168         scratch[iidx] = 0.0;
1169     }  
1170
1171     /* Start outer loop over neighborlists */
1172     for(iidx=0; iidx<nri; iidx++)
1173     {
1174         /* Load shift vector for this list */
1175         i_shift_offset   = DIM*shiftidx[iidx];
1176
1177         /* Load limits for loop over neighbors */
1178         j_index_start    = jindex[iidx];
1179         j_index_end      = jindex[iidx+1];
1180
1181         /* Get outer coordinate index */
1182         inr              = iinr[iidx];
1183         i_coord_offset   = DIM*inr;
1184
1185         /* Load i particle coords and add shift vector */
1186         gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
1187                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
1188         
1189         fix0             = _mm_setzero_ps();
1190         fiy0             = _mm_setzero_ps();
1191         fiz0             = _mm_setzero_ps();
1192         fix1             = _mm_setzero_ps();
1193         fiy1             = _mm_setzero_ps();
1194         fiz1             = _mm_setzero_ps();
1195         fix2             = _mm_setzero_ps();
1196         fiy2             = _mm_setzero_ps();
1197         fiz2             = _mm_setzero_ps();
1198         fix3             = _mm_setzero_ps();
1199         fiy3             = _mm_setzero_ps();
1200         fiz3             = _mm_setzero_ps();
1201
1202         /* Start inner kernel loop */
1203         for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
1204         {
1205
1206             /* Get j neighbor index, and coordinate index */
1207             jnrA             = jjnr[jidx];
1208             jnrB             = jjnr[jidx+1];
1209             jnrC             = jjnr[jidx+2];
1210             jnrD             = jjnr[jidx+3];
1211             j_coord_offsetA  = DIM*jnrA;
1212             j_coord_offsetB  = DIM*jnrB;
1213             j_coord_offsetC  = DIM*jnrC;
1214             j_coord_offsetD  = DIM*jnrD;
1215
1216             /* load j atom coordinates */
1217             gmx_mm_load_4rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1218                                               x+j_coord_offsetC,x+j_coord_offsetD,
1219                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
1220                                               &jy2,&jz2,&jx3,&jy3,&jz3);
1221
1222             /* Calculate displacement vector */
1223             dx00             = _mm_sub_ps(ix0,jx0);
1224             dy00             = _mm_sub_ps(iy0,jy0);
1225             dz00             = _mm_sub_ps(iz0,jz0);
1226             dx11             = _mm_sub_ps(ix1,jx1);
1227             dy11             = _mm_sub_ps(iy1,jy1);
1228             dz11             = _mm_sub_ps(iz1,jz1);
1229             dx12             = _mm_sub_ps(ix1,jx2);
1230             dy12             = _mm_sub_ps(iy1,jy2);
1231             dz12             = _mm_sub_ps(iz1,jz2);
1232             dx13             = _mm_sub_ps(ix1,jx3);
1233             dy13             = _mm_sub_ps(iy1,jy3);
1234             dz13             = _mm_sub_ps(iz1,jz3);
1235             dx21             = _mm_sub_ps(ix2,jx1);
1236             dy21             = _mm_sub_ps(iy2,jy1);
1237             dz21             = _mm_sub_ps(iz2,jz1);
1238             dx22             = _mm_sub_ps(ix2,jx2);
1239             dy22             = _mm_sub_ps(iy2,jy2);
1240             dz22             = _mm_sub_ps(iz2,jz2);
1241             dx23             = _mm_sub_ps(ix2,jx3);
1242             dy23             = _mm_sub_ps(iy2,jy3);
1243             dz23             = _mm_sub_ps(iz2,jz3);
1244             dx31             = _mm_sub_ps(ix3,jx1);
1245             dy31             = _mm_sub_ps(iy3,jy1);
1246             dz31             = _mm_sub_ps(iz3,jz1);
1247             dx32             = _mm_sub_ps(ix3,jx2);
1248             dy32             = _mm_sub_ps(iy3,jy2);
1249             dz32             = _mm_sub_ps(iz3,jz2);
1250             dx33             = _mm_sub_ps(ix3,jx3);
1251             dy33             = _mm_sub_ps(iy3,jy3);
1252             dz33             = _mm_sub_ps(iz3,jz3);
1253
1254             /* Calculate squared distance and things based on it */
1255             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1256             rsq11            = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
1257             rsq12            = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
1258             rsq13            = gmx_mm_calc_rsq_ps(dx13,dy13,dz13);
1259             rsq21            = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
1260             rsq22            = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
1261             rsq23            = gmx_mm_calc_rsq_ps(dx23,dy23,dz23);
1262             rsq31            = gmx_mm_calc_rsq_ps(dx31,dy31,dz31);
1263             rsq32            = gmx_mm_calc_rsq_ps(dx32,dy32,dz32);
1264             rsq33            = gmx_mm_calc_rsq_ps(dx33,dy33,dz33);
1265
1266             rinv11           = sse2_invsqrt_f(rsq11);
1267             rinv12           = sse2_invsqrt_f(rsq12);
1268             rinv13           = sse2_invsqrt_f(rsq13);
1269             rinv21           = sse2_invsqrt_f(rsq21);
1270             rinv22           = sse2_invsqrt_f(rsq22);
1271             rinv23           = sse2_invsqrt_f(rsq23);
1272             rinv31           = sse2_invsqrt_f(rsq31);
1273             rinv32           = sse2_invsqrt_f(rsq32);
1274             rinv33           = sse2_invsqrt_f(rsq33);
1275
1276             rinvsq00         = sse2_inv_f(rsq00);
1277             rinvsq11         = _mm_mul_ps(rinv11,rinv11);
1278             rinvsq12         = _mm_mul_ps(rinv12,rinv12);
1279             rinvsq13         = _mm_mul_ps(rinv13,rinv13);
1280             rinvsq21         = _mm_mul_ps(rinv21,rinv21);
1281             rinvsq22         = _mm_mul_ps(rinv22,rinv22);
1282             rinvsq23         = _mm_mul_ps(rinv23,rinv23);
1283             rinvsq31         = _mm_mul_ps(rinv31,rinv31);
1284             rinvsq32         = _mm_mul_ps(rinv32,rinv32);
1285             rinvsq33         = _mm_mul_ps(rinv33,rinv33);
1286
1287             fjx0             = _mm_setzero_ps();
1288             fjy0             = _mm_setzero_ps();
1289             fjz0             = _mm_setzero_ps();
1290             fjx1             = _mm_setzero_ps();
1291             fjy1             = _mm_setzero_ps();
1292             fjz1             = _mm_setzero_ps();
1293             fjx2             = _mm_setzero_ps();
1294             fjy2             = _mm_setzero_ps();
1295             fjz2             = _mm_setzero_ps();
1296             fjx3             = _mm_setzero_ps();
1297             fjy3             = _mm_setzero_ps();
1298             fjz3             = _mm_setzero_ps();
1299
1300             /**************************
1301              * CALCULATE INTERACTIONS *
1302              **************************/
1303
1304             /* LENNARD-JONES DISPERSION/REPULSION */
1305
1306             rinvsix          = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
1307             fvdw             = _mm_mul_ps(_mm_sub_ps(_mm_mul_ps(c12_00,rinvsix),c6_00),_mm_mul_ps(rinvsix,rinvsq00));
1308
1309             fscal            = fvdw;
1310
1311             /* Calculate temporary vectorial force */
1312             tx               = _mm_mul_ps(fscal,dx00);
1313             ty               = _mm_mul_ps(fscal,dy00);
1314             tz               = _mm_mul_ps(fscal,dz00);
1315
1316             /* Update vectorial force */
1317             fix0             = _mm_add_ps(fix0,tx);
1318             fiy0             = _mm_add_ps(fiy0,ty);
1319             fiz0             = _mm_add_ps(fiz0,tz);
1320
1321             fjx0             = _mm_add_ps(fjx0,tx);
1322             fjy0             = _mm_add_ps(fjy0,ty);
1323             fjz0             = _mm_add_ps(fjz0,tz);
1324             
1325             /**************************
1326              * CALCULATE INTERACTIONS *
1327              **************************/
1328
1329             /* REACTION-FIELD ELECTROSTATICS */
1330             felec            = _mm_mul_ps(qq11,_mm_sub_ps(_mm_mul_ps(rinv11,rinvsq11),krf2));
1331
1332             fscal            = felec;
1333
1334             /* Calculate temporary vectorial force */
1335             tx               = _mm_mul_ps(fscal,dx11);
1336             ty               = _mm_mul_ps(fscal,dy11);
1337             tz               = _mm_mul_ps(fscal,dz11);
1338
1339             /* Update vectorial force */
1340             fix1             = _mm_add_ps(fix1,tx);
1341             fiy1             = _mm_add_ps(fiy1,ty);
1342             fiz1             = _mm_add_ps(fiz1,tz);
1343
1344             fjx1             = _mm_add_ps(fjx1,tx);
1345             fjy1             = _mm_add_ps(fjy1,ty);
1346             fjz1             = _mm_add_ps(fjz1,tz);
1347             
1348             /**************************
1349              * CALCULATE INTERACTIONS *
1350              **************************/
1351
1352             /* REACTION-FIELD ELECTROSTATICS */
1353             felec            = _mm_mul_ps(qq12,_mm_sub_ps(_mm_mul_ps(rinv12,rinvsq12),krf2));
1354
1355             fscal            = felec;
1356
1357             /* Calculate temporary vectorial force */
1358             tx               = _mm_mul_ps(fscal,dx12);
1359             ty               = _mm_mul_ps(fscal,dy12);
1360             tz               = _mm_mul_ps(fscal,dz12);
1361
1362             /* Update vectorial force */
1363             fix1             = _mm_add_ps(fix1,tx);
1364             fiy1             = _mm_add_ps(fiy1,ty);
1365             fiz1             = _mm_add_ps(fiz1,tz);
1366
1367             fjx2             = _mm_add_ps(fjx2,tx);
1368             fjy2             = _mm_add_ps(fjy2,ty);
1369             fjz2             = _mm_add_ps(fjz2,tz);
1370             
1371             /**************************
1372              * CALCULATE INTERACTIONS *
1373              **************************/
1374
1375             /* REACTION-FIELD ELECTROSTATICS */
1376             felec            = _mm_mul_ps(qq13,_mm_sub_ps(_mm_mul_ps(rinv13,rinvsq13),krf2));
1377
1378             fscal            = felec;
1379
1380             /* Calculate temporary vectorial force */
1381             tx               = _mm_mul_ps(fscal,dx13);
1382             ty               = _mm_mul_ps(fscal,dy13);
1383             tz               = _mm_mul_ps(fscal,dz13);
1384
1385             /* Update vectorial force */
1386             fix1             = _mm_add_ps(fix1,tx);
1387             fiy1             = _mm_add_ps(fiy1,ty);
1388             fiz1             = _mm_add_ps(fiz1,tz);
1389
1390             fjx3             = _mm_add_ps(fjx3,tx);
1391             fjy3             = _mm_add_ps(fjy3,ty);
1392             fjz3             = _mm_add_ps(fjz3,tz);
1393             
1394             /**************************
1395              * CALCULATE INTERACTIONS *
1396              **************************/
1397
1398             /* REACTION-FIELD ELECTROSTATICS */
1399             felec            = _mm_mul_ps(qq21,_mm_sub_ps(_mm_mul_ps(rinv21,rinvsq21),krf2));
1400
1401             fscal            = felec;
1402
1403             /* Calculate temporary vectorial force */
1404             tx               = _mm_mul_ps(fscal,dx21);
1405             ty               = _mm_mul_ps(fscal,dy21);
1406             tz               = _mm_mul_ps(fscal,dz21);
1407
1408             /* Update vectorial force */
1409             fix2             = _mm_add_ps(fix2,tx);
1410             fiy2             = _mm_add_ps(fiy2,ty);
1411             fiz2             = _mm_add_ps(fiz2,tz);
1412
1413             fjx1             = _mm_add_ps(fjx1,tx);
1414             fjy1             = _mm_add_ps(fjy1,ty);
1415             fjz1             = _mm_add_ps(fjz1,tz);
1416             
1417             /**************************
1418              * CALCULATE INTERACTIONS *
1419              **************************/
1420
1421             /* REACTION-FIELD ELECTROSTATICS */
1422             felec            = _mm_mul_ps(qq22,_mm_sub_ps(_mm_mul_ps(rinv22,rinvsq22),krf2));
1423
1424             fscal            = felec;
1425
1426             /* Calculate temporary vectorial force */
1427             tx               = _mm_mul_ps(fscal,dx22);
1428             ty               = _mm_mul_ps(fscal,dy22);
1429             tz               = _mm_mul_ps(fscal,dz22);
1430
1431             /* Update vectorial force */
1432             fix2             = _mm_add_ps(fix2,tx);
1433             fiy2             = _mm_add_ps(fiy2,ty);
1434             fiz2             = _mm_add_ps(fiz2,tz);
1435
1436             fjx2             = _mm_add_ps(fjx2,tx);
1437             fjy2             = _mm_add_ps(fjy2,ty);
1438             fjz2             = _mm_add_ps(fjz2,tz);
1439             
1440             /**************************
1441              * CALCULATE INTERACTIONS *
1442              **************************/
1443
1444             /* REACTION-FIELD ELECTROSTATICS */
1445             felec            = _mm_mul_ps(qq23,_mm_sub_ps(_mm_mul_ps(rinv23,rinvsq23),krf2));
1446
1447             fscal            = felec;
1448
1449             /* Calculate temporary vectorial force */
1450             tx               = _mm_mul_ps(fscal,dx23);
1451             ty               = _mm_mul_ps(fscal,dy23);
1452             tz               = _mm_mul_ps(fscal,dz23);
1453
1454             /* Update vectorial force */
1455             fix2             = _mm_add_ps(fix2,tx);
1456             fiy2             = _mm_add_ps(fiy2,ty);
1457             fiz2             = _mm_add_ps(fiz2,tz);
1458
1459             fjx3             = _mm_add_ps(fjx3,tx);
1460             fjy3             = _mm_add_ps(fjy3,ty);
1461             fjz3             = _mm_add_ps(fjz3,tz);
1462             
1463             /**************************
1464              * CALCULATE INTERACTIONS *
1465              **************************/
1466
1467             /* REACTION-FIELD ELECTROSTATICS */
1468             felec            = _mm_mul_ps(qq31,_mm_sub_ps(_mm_mul_ps(rinv31,rinvsq31),krf2));
1469
1470             fscal            = felec;
1471
1472             /* Calculate temporary vectorial force */
1473             tx               = _mm_mul_ps(fscal,dx31);
1474             ty               = _mm_mul_ps(fscal,dy31);
1475             tz               = _mm_mul_ps(fscal,dz31);
1476
1477             /* Update vectorial force */
1478             fix3             = _mm_add_ps(fix3,tx);
1479             fiy3             = _mm_add_ps(fiy3,ty);
1480             fiz3             = _mm_add_ps(fiz3,tz);
1481
1482             fjx1             = _mm_add_ps(fjx1,tx);
1483             fjy1             = _mm_add_ps(fjy1,ty);
1484             fjz1             = _mm_add_ps(fjz1,tz);
1485             
1486             /**************************
1487              * CALCULATE INTERACTIONS *
1488              **************************/
1489
1490             /* REACTION-FIELD ELECTROSTATICS */
1491             felec            = _mm_mul_ps(qq32,_mm_sub_ps(_mm_mul_ps(rinv32,rinvsq32),krf2));
1492
1493             fscal            = felec;
1494
1495             /* Calculate temporary vectorial force */
1496             tx               = _mm_mul_ps(fscal,dx32);
1497             ty               = _mm_mul_ps(fscal,dy32);
1498             tz               = _mm_mul_ps(fscal,dz32);
1499
1500             /* Update vectorial force */
1501             fix3             = _mm_add_ps(fix3,tx);
1502             fiy3             = _mm_add_ps(fiy3,ty);
1503             fiz3             = _mm_add_ps(fiz3,tz);
1504
1505             fjx2             = _mm_add_ps(fjx2,tx);
1506             fjy2             = _mm_add_ps(fjy2,ty);
1507             fjz2             = _mm_add_ps(fjz2,tz);
1508             
1509             /**************************
1510              * CALCULATE INTERACTIONS *
1511              **************************/
1512
1513             /* REACTION-FIELD ELECTROSTATICS */
1514             felec            = _mm_mul_ps(qq33,_mm_sub_ps(_mm_mul_ps(rinv33,rinvsq33),krf2));
1515
1516             fscal            = felec;
1517
1518             /* Calculate temporary vectorial force */
1519             tx               = _mm_mul_ps(fscal,dx33);
1520             ty               = _mm_mul_ps(fscal,dy33);
1521             tz               = _mm_mul_ps(fscal,dz33);
1522
1523             /* Update vectorial force */
1524             fix3             = _mm_add_ps(fix3,tx);
1525             fiy3             = _mm_add_ps(fiy3,ty);
1526             fiz3             = _mm_add_ps(fiz3,tz);
1527
1528             fjx3             = _mm_add_ps(fjx3,tx);
1529             fjy3             = _mm_add_ps(fjy3,ty);
1530             fjz3             = _mm_add_ps(fjz3,tz);
1531             
1532             fjptrA             = f+j_coord_offsetA;
1533             fjptrB             = f+j_coord_offsetB;
1534             fjptrC             = f+j_coord_offsetC;
1535             fjptrD             = f+j_coord_offsetD;
1536
1537             gmx_mm_decrement_4rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
1538                                                    fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
1539                                                    fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1540
1541             /* Inner loop uses 273 flops */
1542         }
1543
1544         if(jidx<j_index_end)
1545         {
1546
1547             /* Get j neighbor index, and coordinate index */
1548             jnrlistA         = jjnr[jidx];
1549             jnrlistB         = jjnr[jidx+1];
1550             jnrlistC         = jjnr[jidx+2];
1551             jnrlistD         = jjnr[jidx+3];
1552             /* Sign of each element will be negative for non-real atoms.
1553              * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1554              * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1555              */
1556             dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
1557             jnrA       = (jnrlistA>=0) ? jnrlistA : 0;
1558             jnrB       = (jnrlistB>=0) ? jnrlistB : 0;
1559             jnrC       = (jnrlistC>=0) ? jnrlistC : 0;
1560             jnrD       = (jnrlistD>=0) ? jnrlistD : 0;
1561             j_coord_offsetA  = DIM*jnrA;
1562             j_coord_offsetB  = DIM*jnrB;
1563             j_coord_offsetC  = DIM*jnrC;
1564             j_coord_offsetD  = DIM*jnrD;
1565
1566             /* load j atom coordinates */
1567             gmx_mm_load_4rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1568                                               x+j_coord_offsetC,x+j_coord_offsetD,
1569                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,
1570                                               &jy2,&jz2,&jx3,&jy3,&jz3);
1571
1572             /* Calculate displacement vector */
1573             dx00             = _mm_sub_ps(ix0,jx0);
1574             dy00             = _mm_sub_ps(iy0,jy0);
1575             dz00             = _mm_sub_ps(iz0,jz0);
1576             dx11             = _mm_sub_ps(ix1,jx1);
1577             dy11             = _mm_sub_ps(iy1,jy1);
1578             dz11             = _mm_sub_ps(iz1,jz1);
1579             dx12             = _mm_sub_ps(ix1,jx2);
1580             dy12             = _mm_sub_ps(iy1,jy2);
1581             dz12             = _mm_sub_ps(iz1,jz2);
1582             dx13             = _mm_sub_ps(ix1,jx3);
1583             dy13             = _mm_sub_ps(iy1,jy3);
1584             dz13             = _mm_sub_ps(iz1,jz3);
1585             dx21             = _mm_sub_ps(ix2,jx1);
1586             dy21             = _mm_sub_ps(iy2,jy1);
1587             dz21             = _mm_sub_ps(iz2,jz1);
1588             dx22             = _mm_sub_ps(ix2,jx2);
1589             dy22             = _mm_sub_ps(iy2,jy2);
1590             dz22             = _mm_sub_ps(iz2,jz2);
1591             dx23             = _mm_sub_ps(ix2,jx3);
1592             dy23             = _mm_sub_ps(iy2,jy3);
1593             dz23             = _mm_sub_ps(iz2,jz3);
1594             dx31             = _mm_sub_ps(ix3,jx1);
1595             dy31             = _mm_sub_ps(iy3,jy1);
1596             dz31             = _mm_sub_ps(iz3,jz1);
1597             dx32             = _mm_sub_ps(ix3,jx2);
1598             dy32             = _mm_sub_ps(iy3,jy2);
1599             dz32             = _mm_sub_ps(iz3,jz2);
1600             dx33             = _mm_sub_ps(ix3,jx3);
1601             dy33             = _mm_sub_ps(iy3,jy3);
1602             dz33             = _mm_sub_ps(iz3,jz3);
1603
1604             /* Calculate squared distance and things based on it */
1605             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1606             rsq11            = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
1607             rsq12            = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
1608             rsq13            = gmx_mm_calc_rsq_ps(dx13,dy13,dz13);
1609             rsq21            = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
1610             rsq22            = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
1611             rsq23            = gmx_mm_calc_rsq_ps(dx23,dy23,dz23);
1612             rsq31            = gmx_mm_calc_rsq_ps(dx31,dy31,dz31);
1613             rsq32            = gmx_mm_calc_rsq_ps(dx32,dy32,dz32);
1614             rsq33            = gmx_mm_calc_rsq_ps(dx33,dy33,dz33);
1615
1616             rinv11           = sse2_invsqrt_f(rsq11);
1617             rinv12           = sse2_invsqrt_f(rsq12);
1618             rinv13           = sse2_invsqrt_f(rsq13);
1619             rinv21           = sse2_invsqrt_f(rsq21);
1620             rinv22           = sse2_invsqrt_f(rsq22);
1621             rinv23           = sse2_invsqrt_f(rsq23);
1622             rinv31           = sse2_invsqrt_f(rsq31);
1623             rinv32           = sse2_invsqrt_f(rsq32);
1624             rinv33           = sse2_invsqrt_f(rsq33);
1625
1626             rinvsq00         = sse2_inv_f(rsq00);
1627             rinvsq11         = _mm_mul_ps(rinv11,rinv11);
1628             rinvsq12         = _mm_mul_ps(rinv12,rinv12);
1629             rinvsq13         = _mm_mul_ps(rinv13,rinv13);
1630             rinvsq21         = _mm_mul_ps(rinv21,rinv21);
1631             rinvsq22         = _mm_mul_ps(rinv22,rinv22);
1632             rinvsq23         = _mm_mul_ps(rinv23,rinv23);
1633             rinvsq31         = _mm_mul_ps(rinv31,rinv31);
1634             rinvsq32         = _mm_mul_ps(rinv32,rinv32);
1635             rinvsq33         = _mm_mul_ps(rinv33,rinv33);
1636
1637             fjx0             = _mm_setzero_ps();
1638             fjy0             = _mm_setzero_ps();
1639             fjz0             = _mm_setzero_ps();
1640             fjx1             = _mm_setzero_ps();
1641             fjy1             = _mm_setzero_ps();
1642             fjz1             = _mm_setzero_ps();
1643             fjx2             = _mm_setzero_ps();
1644             fjy2             = _mm_setzero_ps();
1645             fjz2             = _mm_setzero_ps();
1646             fjx3             = _mm_setzero_ps();
1647             fjy3             = _mm_setzero_ps();
1648             fjz3             = _mm_setzero_ps();
1649
1650             /**************************
1651              * CALCULATE INTERACTIONS *
1652              **************************/
1653
1654             /* LENNARD-JONES DISPERSION/REPULSION */
1655
1656             rinvsix          = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
1657             fvdw             = _mm_mul_ps(_mm_sub_ps(_mm_mul_ps(c12_00,rinvsix),c6_00),_mm_mul_ps(rinvsix,rinvsq00));
1658
1659             fscal            = fvdw;
1660
1661             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1662
1663             /* Calculate temporary vectorial force */
1664             tx               = _mm_mul_ps(fscal,dx00);
1665             ty               = _mm_mul_ps(fscal,dy00);
1666             tz               = _mm_mul_ps(fscal,dz00);
1667
1668             /* Update vectorial force */
1669             fix0             = _mm_add_ps(fix0,tx);
1670             fiy0             = _mm_add_ps(fiy0,ty);
1671             fiz0             = _mm_add_ps(fiz0,tz);
1672
1673             fjx0             = _mm_add_ps(fjx0,tx);
1674             fjy0             = _mm_add_ps(fjy0,ty);
1675             fjz0             = _mm_add_ps(fjz0,tz);
1676             
1677             /**************************
1678              * CALCULATE INTERACTIONS *
1679              **************************/
1680
1681             /* REACTION-FIELD ELECTROSTATICS */
1682             felec            = _mm_mul_ps(qq11,_mm_sub_ps(_mm_mul_ps(rinv11,rinvsq11),krf2));
1683
1684             fscal            = felec;
1685
1686             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1687
1688             /* Calculate temporary vectorial force */
1689             tx               = _mm_mul_ps(fscal,dx11);
1690             ty               = _mm_mul_ps(fscal,dy11);
1691             tz               = _mm_mul_ps(fscal,dz11);
1692
1693             /* Update vectorial force */
1694             fix1             = _mm_add_ps(fix1,tx);
1695             fiy1             = _mm_add_ps(fiy1,ty);
1696             fiz1             = _mm_add_ps(fiz1,tz);
1697
1698             fjx1             = _mm_add_ps(fjx1,tx);
1699             fjy1             = _mm_add_ps(fjy1,ty);
1700             fjz1             = _mm_add_ps(fjz1,tz);
1701             
1702             /**************************
1703              * CALCULATE INTERACTIONS *
1704              **************************/
1705
1706             /* REACTION-FIELD ELECTROSTATICS */
1707             felec            = _mm_mul_ps(qq12,_mm_sub_ps(_mm_mul_ps(rinv12,rinvsq12),krf2));
1708
1709             fscal            = felec;
1710
1711             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1712
1713             /* Calculate temporary vectorial force */
1714             tx               = _mm_mul_ps(fscal,dx12);
1715             ty               = _mm_mul_ps(fscal,dy12);
1716             tz               = _mm_mul_ps(fscal,dz12);
1717
1718             /* Update vectorial force */
1719             fix1             = _mm_add_ps(fix1,tx);
1720             fiy1             = _mm_add_ps(fiy1,ty);
1721             fiz1             = _mm_add_ps(fiz1,tz);
1722
1723             fjx2             = _mm_add_ps(fjx2,tx);
1724             fjy2             = _mm_add_ps(fjy2,ty);
1725             fjz2             = _mm_add_ps(fjz2,tz);
1726             
1727             /**************************
1728              * CALCULATE INTERACTIONS *
1729              **************************/
1730
1731             /* REACTION-FIELD ELECTROSTATICS */
1732             felec            = _mm_mul_ps(qq13,_mm_sub_ps(_mm_mul_ps(rinv13,rinvsq13),krf2));
1733
1734             fscal            = felec;
1735
1736             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1737
1738             /* Calculate temporary vectorial force */
1739             tx               = _mm_mul_ps(fscal,dx13);
1740             ty               = _mm_mul_ps(fscal,dy13);
1741             tz               = _mm_mul_ps(fscal,dz13);
1742
1743             /* Update vectorial force */
1744             fix1             = _mm_add_ps(fix1,tx);
1745             fiy1             = _mm_add_ps(fiy1,ty);
1746             fiz1             = _mm_add_ps(fiz1,tz);
1747
1748             fjx3             = _mm_add_ps(fjx3,tx);
1749             fjy3             = _mm_add_ps(fjy3,ty);
1750             fjz3             = _mm_add_ps(fjz3,tz);
1751             
1752             /**************************
1753              * CALCULATE INTERACTIONS *
1754              **************************/
1755
1756             /* REACTION-FIELD ELECTROSTATICS */
1757             felec            = _mm_mul_ps(qq21,_mm_sub_ps(_mm_mul_ps(rinv21,rinvsq21),krf2));
1758
1759             fscal            = felec;
1760
1761             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1762
1763             /* Calculate temporary vectorial force */
1764             tx               = _mm_mul_ps(fscal,dx21);
1765             ty               = _mm_mul_ps(fscal,dy21);
1766             tz               = _mm_mul_ps(fscal,dz21);
1767
1768             /* Update vectorial force */
1769             fix2             = _mm_add_ps(fix2,tx);
1770             fiy2             = _mm_add_ps(fiy2,ty);
1771             fiz2             = _mm_add_ps(fiz2,tz);
1772
1773             fjx1             = _mm_add_ps(fjx1,tx);
1774             fjy1             = _mm_add_ps(fjy1,ty);
1775             fjz1             = _mm_add_ps(fjz1,tz);
1776             
1777             /**************************
1778              * CALCULATE INTERACTIONS *
1779              **************************/
1780
1781             /* REACTION-FIELD ELECTROSTATICS */
1782             felec            = _mm_mul_ps(qq22,_mm_sub_ps(_mm_mul_ps(rinv22,rinvsq22),krf2));
1783
1784             fscal            = felec;
1785
1786             fscal            = _mm_andnot_ps(dummy_mask,fscal);
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              * CALCULATE INTERACTIONS *
1804              **************************/
1805
1806             /* REACTION-FIELD ELECTROSTATICS */
1807             felec            = _mm_mul_ps(qq23,_mm_sub_ps(_mm_mul_ps(rinv23,rinvsq23),krf2));
1808
1809             fscal            = felec;
1810
1811             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1812
1813             /* Calculate temporary vectorial force */
1814             tx               = _mm_mul_ps(fscal,dx23);
1815             ty               = _mm_mul_ps(fscal,dy23);
1816             tz               = _mm_mul_ps(fscal,dz23);
1817
1818             /* Update vectorial force */
1819             fix2             = _mm_add_ps(fix2,tx);
1820             fiy2             = _mm_add_ps(fiy2,ty);
1821             fiz2             = _mm_add_ps(fiz2,tz);
1822
1823             fjx3             = _mm_add_ps(fjx3,tx);
1824             fjy3             = _mm_add_ps(fjy3,ty);
1825             fjz3             = _mm_add_ps(fjz3,tz);
1826             
1827             /**************************
1828              * CALCULATE INTERACTIONS *
1829              **************************/
1830
1831             /* REACTION-FIELD ELECTROSTATICS */
1832             felec            = _mm_mul_ps(qq31,_mm_sub_ps(_mm_mul_ps(rinv31,rinvsq31),krf2));
1833
1834             fscal            = felec;
1835
1836             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1837
1838             /* Calculate temporary vectorial force */
1839             tx               = _mm_mul_ps(fscal,dx31);
1840             ty               = _mm_mul_ps(fscal,dy31);
1841             tz               = _mm_mul_ps(fscal,dz31);
1842
1843             /* Update vectorial force */
1844             fix3             = _mm_add_ps(fix3,tx);
1845             fiy3             = _mm_add_ps(fiy3,ty);
1846             fiz3             = _mm_add_ps(fiz3,tz);
1847
1848             fjx1             = _mm_add_ps(fjx1,tx);
1849             fjy1             = _mm_add_ps(fjy1,ty);
1850             fjz1             = _mm_add_ps(fjz1,tz);
1851             
1852             /**************************
1853              * CALCULATE INTERACTIONS *
1854              **************************/
1855
1856             /* REACTION-FIELD ELECTROSTATICS */
1857             felec            = _mm_mul_ps(qq32,_mm_sub_ps(_mm_mul_ps(rinv32,rinvsq32),krf2));
1858
1859             fscal            = felec;
1860
1861             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1862
1863             /* Calculate temporary vectorial force */
1864             tx               = _mm_mul_ps(fscal,dx32);
1865             ty               = _mm_mul_ps(fscal,dy32);
1866             tz               = _mm_mul_ps(fscal,dz32);
1867
1868             /* Update vectorial force */
1869             fix3             = _mm_add_ps(fix3,tx);
1870             fiy3             = _mm_add_ps(fiy3,ty);
1871             fiz3             = _mm_add_ps(fiz3,tz);
1872
1873             fjx2             = _mm_add_ps(fjx2,tx);
1874             fjy2             = _mm_add_ps(fjy2,ty);
1875             fjz2             = _mm_add_ps(fjz2,tz);
1876             
1877             /**************************
1878              * CALCULATE INTERACTIONS *
1879              **************************/
1880
1881             /* REACTION-FIELD ELECTROSTATICS */
1882             felec            = _mm_mul_ps(qq33,_mm_sub_ps(_mm_mul_ps(rinv33,rinvsq33),krf2));
1883
1884             fscal            = felec;
1885
1886             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1887
1888             /* Calculate temporary vectorial force */
1889             tx               = _mm_mul_ps(fscal,dx33);
1890             ty               = _mm_mul_ps(fscal,dy33);
1891             tz               = _mm_mul_ps(fscal,dz33);
1892
1893             /* Update vectorial force */
1894             fix3             = _mm_add_ps(fix3,tx);
1895             fiy3             = _mm_add_ps(fiy3,ty);
1896             fiz3             = _mm_add_ps(fiz3,tz);
1897
1898             fjx3             = _mm_add_ps(fjx3,tx);
1899             fjy3             = _mm_add_ps(fjy3,ty);
1900             fjz3             = _mm_add_ps(fjz3,tz);
1901             
1902             fjptrA             = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1903             fjptrB             = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1904             fjptrC             = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1905             fjptrD             = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1906
1907             gmx_mm_decrement_4rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
1908                                                    fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
1909                                                    fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1910
1911             /* Inner loop uses 273 flops */
1912         }
1913
1914         /* End of innermost loop */
1915
1916         gmx_mm_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1917                                               f+i_coord_offset,fshift+i_shift_offset);
1918
1919         /* Increment number of inner iterations */
1920         inneriter                  += j_index_end - j_index_start;
1921
1922         /* Outer loop uses 24 flops */
1923     }
1924
1925     /* Increment number of outer iterations */
1926     outeriter        += nri;
1927
1928     /* Update outer/inner flops */
1929
1930     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*24 + inneriter*273);
1931 }