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