dcf435ccdee5bbb784d77852eb6f7bd0e3db6a33
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_avx_128_fma_single / nb_kernel_ElecCoul_VdwLJ_GeomW4P1_avx_128_fma_single.c
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6  * and including many others, as listed in the AUTHORS file in the
7  * top-level source directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35 /*
36  * Note: this file was generated by the GROMACS avx_128_fma_single kernel generator.
37  */
38 #include "config.h"
39
40 #include <math.h>
41
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "nrnb.h"
46
47 #include "gromacs/simd/math_x86_avx_128_fma_single.h"
48 #include "kernelutil_x86_avx_128_fma_single.h"
49
50 /*
51  * Gromacs nonbonded kernel:   nb_kernel_ElecCoul_VdwLJ_GeomW4P1_VF_avx_128_fma_single
52  * Electrostatics interaction: Coulomb
53  * VdW interaction:            LennardJones
54  * Geometry:                   Water4-Particle
55  * Calculate force/pot:        PotentialAndForce
56  */
57 void
58 nb_kernel_ElecCoul_VdwLJ_GeomW4P1_VF_avx_128_fma_single
59                     (t_nblist                    * gmx_restrict       nlist,
60                      rvec                        * gmx_restrict          xx,
61                      rvec                        * gmx_restrict          ff,
62                      t_forcerec                  * gmx_restrict          fr,
63                      t_mdatoms                   * gmx_restrict     mdatoms,
64                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
65                      t_nrnb                      * gmx_restrict        nrnb)
66 {
67     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
68      * just 0 for non-waters.
69      * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
70      * jnr indices corresponding to data put in the four positions in the SIMD register.
71      */
72     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
73     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
74     int              jnrA,jnrB,jnrC,jnrD;
75     int              jnrlistA,jnrlistB,jnrlistC,jnrlistD;
76     int              j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
77     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
78     real             rcutoff_scalar;
79     real             *shiftvec,*fshift,*x,*f;
80     real             *fjptrA,*fjptrB,*fjptrC,*fjptrD;
81     real             scratch[4*DIM];
82     __m128           fscal,rcutoff,rcutoff2,jidxall;
83     int              vdwioffset0;
84     __m128           ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
85     int              vdwioffset1;
86     __m128           ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
87     int              vdwioffset2;
88     __m128           ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
89     int              vdwioffset3;
90     __m128           ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
91     int              vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
92     __m128           jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
93     __m128           dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
94     __m128           dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
95     __m128           dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
96     __m128           dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
97     __m128           velec,felec,velecsum,facel,crf,krf,krf2;
98     real             *charge;
99     int              nvdwtype;
100     __m128           rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
101     int              *vdwtype;
102     real             *vdwparam;
103     __m128           one_sixth   = _mm_set1_ps(1.0/6.0);
104     __m128           one_twelfth = _mm_set1_ps(1.0/12.0);
105     __m128           dummy_mask,cutoff_mask;
106     __m128           signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
107     __m128           one     = _mm_set1_ps(1.0);
108     __m128           two     = _mm_set1_ps(2.0);
109     x                = xx[0];
110     f                = ff[0];
111
112     nri              = nlist->nri;
113     iinr             = nlist->iinr;
114     jindex           = nlist->jindex;
115     jjnr             = nlist->jjnr;
116     shiftidx         = nlist->shift;
117     gid              = nlist->gid;
118     shiftvec         = fr->shift_vec[0];
119     fshift           = fr->fshift[0];
120     facel            = _mm_set1_ps(fr->epsfac);
121     charge           = mdatoms->chargeA;
122     nvdwtype         = fr->ntype;
123     vdwparam         = fr->nbfp;
124     vdwtype          = mdatoms->typeA;
125
126     /* Setup water-specific parameters */
127     inr              = nlist->iinr[0];
128     iq1              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
129     iq2              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
130     iq3              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
131     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
132
133     /* Avoid stupid compiler warnings */
134     jnrA = jnrB = jnrC = jnrD = 0;
135     j_coord_offsetA = 0;
136     j_coord_offsetB = 0;
137     j_coord_offsetC = 0;
138     j_coord_offsetD = 0;
139
140     outeriter        = 0;
141     inneriter        = 0;
142
143     for(iidx=0;iidx<4*DIM;iidx++)
144     {
145         scratch[iidx] = 0.0;
146     }
147
148     /* Start outer loop over neighborlists */
149     for(iidx=0; iidx<nri; iidx++)
150     {
151         /* Load shift vector for this list */
152         i_shift_offset   = DIM*shiftidx[iidx];
153
154         /* Load limits for loop over neighbors */
155         j_index_start    = jindex[iidx];
156         j_index_end      = jindex[iidx+1];
157
158         /* Get outer coordinate index */
159         inr              = iinr[iidx];
160         i_coord_offset   = DIM*inr;
161
162         /* Load i particle coords and add shift vector */
163         gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
164                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
165
166         fix0             = _mm_setzero_ps();
167         fiy0             = _mm_setzero_ps();
168         fiz0             = _mm_setzero_ps();
169         fix1             = _mm_setzero_ps();
170         fiy1             = _mm_setzero_ps();
171         fiz1             = _mm_setzero_ps();
172         fix2             = _mm_setzero_ps();
173         fiy2             = _mm_setzero_ps();
174         fiz2             = _mm_setzero_ps();
175         fix3             = _mm_setzero_ps();
176         fiy3             = _mm_setzero_ps();
177         fiz3             = _mm_setzero_ps();
178
179         /* Reset potential sums */
180         velecsum         = _mm_setzero_ps();
181         vvdwsum          = _mm_setzero_ps();
182
183         /* Start inner kernel loop */
184         for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
185         {
186
187             /* Get j neighbor index, and coordinate index */
188             jnrA             = jjnr[jidx];
189             jnrB             = jjnr[jidx+1];
190             jnrC             = jjnr[jidx+2];
191             jnrD             = jjnr[jidx+3];
192             j_coord_offsetA  = DIM*jnrA;
193             j_coord_offsetB  = DIM*jnrB;
194             j_coord_offsetC  = DIM*jnrC;
195             j_coord_offsetD  = DIM*jnrD;
196
197             /* load j atom coordinates */
198             gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
199                                               x+j_coord_offsetC,x+j_coord_offsetD,
200                                               &jx0,&jy0,&jz0);
201
202             /* Calculate displacement vector */
203             dx00             = _mm_sub_ps(ix0,jx0);
204             dy00             = _mm_sub_ps(iy0,jy0);
205             dz00             = _mm_sub_ps(iz0,jz0);
206             dx10             = _mm_sub_ps(ix1,jx0);
207             dy10             = _mm_sub_ps(iy1,jy0);
208             dz10             = _mm_sub_ps(iz1,jz0);
209             dx20             = _mm_sub_ps(ix2,jx0);
210             dy20             = _mm_sub_ps(iy2,jy0);
211             dz20             = _mm_sub_ps(iz2,jz0);
212             dx30             = _mm_sub_ps(ix3,jx0);
213             dy30             = _mm_sub_ps(iy3,jy0);
214             dz30             = _mm_sub_ps(iz3,jz0);
215
216             /* Calculate squared distance and things based on it */
217             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
218             rsq10            = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
219             rsq20            = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
220             rsq30            = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
221
222             rinv10           = gmx_mm_invsqrt_ps(rsq10);
223             rinv20           = gmx_mm_invsqrt_ps(rsq20);
224             rinv30           = gmx_mm_invsqrt_ps(rsq30);
225
226             rinvsq00         = gmx_mm_inv_ps(rsq00);
227             rinvsq10         = _mm_mul_ps(rinv10,rinv10);
228             rinvsq20         = _mm_mul_ps(rinv20,rinv20);
229             rinvsq30         = _mm_mul_ps(rinv30,rinv30);
230
231             /* Load parameters for j particles */
232             jq0              = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
233                                                               charge+jnrC+0,charge+jnrD+0);
234             vdwjidx0A        = 2*vdwtype[jnrA+0];
235             vdwjidx0B        = 2*vdwtype[jnrB+0];
236             vdwjidx0C        = 2*vdwtype[jnrC+0];
237             vdwjidx0D        = 2*vdwtype[jnrD+0];
238
239             fjx0             = _mm_setzero_ps();
240             fjy0             = _mm_setzero_ps();
241             fjz0             = _mm_setzero_ps();
242
243             /**************************
244              * CALCULATE INTERACTIONS *
245              **************************/
246
247             /* Compute parameters for interactions between i and j atoms */
248             gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
249                                          vdwparam+vdwioffset0+vdwjidx0B,
250                                          vdwparam+vdwioffset0+vdwjidx0C,
251                                          vdwparam+vdwioffset0+vdwjidx0D,
252                                          &c6_00,&c12_00);
253
254             /* LENNARD-JONES DISPERSION/REPULSION */
255
256             rinvsix          = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
257             vvdw6            = _mm_mul_ps(c6_00,rinvsix);
258             vvdw12           = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
259             vvdw             = _mm_msub_ps(vvdw12,one_twelfth,_mm_mul_ps(vvdw6,one_sixth));
260             fvdw             = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
261
262             /* Update potential sum for this i atom from the interaction with this j atom. */
263             vvdwsum          = _mm_add_ps(vvdwsum,vvdw);
264
265             fscal            = fvdw;
266
267              /* Update vectorial force */
268             fix0             = _mm_macc_ps(dx00,fscal,fix0);
269             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
270             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
271
272             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
273             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
274             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
275
276             /**************************
277              * CALCULATE INTERACTIONS *
278              **************************/
279
280             /* Compute parameters for interactions between i and j atoms */
281             qq10             = _mm_mul_ps(iq1,jq0);
282
283             /* COULOMB ELECTROSTATICS */
284             velec            = _mm_mul_ps(qq10,rinv10);
285             felec            = _mm_mul_ps(velec,rinvsq10);
286
287             /* Update potential sum for this i atom from the interaction with this j atom. */
288             velecsum         = _mm_add_ps(velecsum,velec);
289
290             fscal            = felec;
291
292              /* Update vectorial force */
293             fix1             = _mm_macc_ps(dx10,fscal,fix1);
294             fiy1             = _mm_macc_ps(dy10,fscal,fiy1);
295             fiz1             = _mm_macc_ps(dz10,fscal,fiz1);
296
297             fjx0             = _mm_macc_ps(dx10,fscal,fjx0);
298             fjy0             = _mm_macc_ps(dy10,fscal,fjy0);
299             fjz0             = _mm_macc_ps(dz10,fscal,fjz0);
300
301             /**************************
302              * CALCULATE INTERACTIONS *
303              **************************/
304
305             /* Compute parameters for interactions between i and j atoms */
306             qq20             = _mm_mul_ps(iq2,jq0);
307
308             /* COULOMB ELECTROSTATICS */
309             velec            = _mm_mul_ps(qq20,rinv20);
310             felec            = _mm_mul_ps(velec,rinvsq20);
311
312             /* Update potential sum for this i atom from the interaction with this j atom. */
313             velecsum         = _mm_add_ps(velecsum,velec);
314
315             fscal            = felec;
316
317              /* Update vectorial force */
318             fix2             = _mm_macc_ps(dx20,fscal,fix2);
319             fiy2             = _mm_macc_ps(dy20,fscal,fiy2);
320             fiz2             = _mm_macc_ps(dz20,fscal,fiz2);
321
322             fjx0             = _mm_macc_ps(dx20,fscal,fjx0);
323             fjy0             = _mm_macc_ps(dy20,fscal,fjy0);
324             fjz0             = _mm_macc_ps(dz20,fscal,fjz0);
325
326             /**************************
327              * CALCULATE INTERACTIONS *
328              **************************/
329
330             /* Compute parameters for interactions between i and j atoms */
331             qq30             = _mm_mul_ps(iq3,jq0);
332
333             /* COULOMB ELECTROSTATICS */
334             velec            = _mm_mul_ps(qq30,rinv30);
335             felec            = _mm_mul_ps(velec,rinvsq30);
336
337             /* Update potential sum for this i atom from the interaction with this j atom. */
338             velecsum         = _mm_add_ps(velecsum,velec);
339
340             fscal            = felec;
341
342              /* Update vectorial force */
343             fix3             = _mm_macc_ps(dx30,fscal,fix3);
344             fiy3             = _mm_macc_ps(dy30,fscal,fiy3);
345             fiz3             = _mm_macc_ps(dz30,fscal,fiz3);
346
347             fjx0             = _mm_macc_ps(dx30,fscal,fjx0);
348             fjy0             = _mm_macc_ps(dy30,fscal,fjy0);
349             fjz0             = _mm_macc_ps(dz30,fscal,fjz0);
350
351             fjptrA             = f+j_coord_offsetA;
352             fjptrB             = f+j_coord_offsetB;
353             fjptrC             = f+j_coord_offsetC;
354             fjptrD             = f+j_coord_offsetD;
355
356             gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
357
358             /* Inner loop uses 128 flops */
359         }
360
361         if(jidx<j_index_end)
362         {
363
364             /* Get j neighbor index, and coordinate index */
365             jnrlistA         = jjnr[jidx];
366             jnrlistB         = jjnr[jidx+1];
367             jnrlistC         = jjnr[jidx+2];
368             jnrlistD         = jjnr[jidx+3];
369             /* Sign of each element will be negative for non-real atoms.
370              * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
371              * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
372              */
373             dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
374             jnrA       = (jnrlistA>=0) ? jnrlistA : 0;
375             jnrB       = (jnrlistB>=0) ? jnrlistB : 0;
376             jnrC       = (jnrlistC>=0) ? jnrlistC : 0;
377             jnrD       = (jnrlistD>=0) ? jnrlistD : 0;
378             j_coord_offsetA  = DIM*jnrA;
379             j_coord_offsetB  = DIM*jnrB;
380             j_coord_offsetC  = DIM*jnrC;
381             j_coord_offsetD  = DIM*jnrD;
382
383             /* load j atom coordinates */
384             gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
385                                               x+j_coord_offsetC,x+j_coord_offsetD,
386                                               &jx0,&jy0,&jz0);
387
388             /* Calculate displacement vector */
389             dx00             = _mm_sub_ps(ix0,jx0);
390             dy00             = _mm_sub_ps(iy0,jy0);
391             dz00             = _mm_sub_ps(iz0,jz0);
392             dx10             = _mm_sub_ps(ix1,jx0);
393             dy10             = _mm_sub_ps(iy1,jy0);
394             dz10             = _mm_sub_ps(iz1,jz0);
395             dx20             = _mm_sub_ps(ix2,jx0);
396             dy20             = _mm_sub_ps(iy2,jy0);
397             dz20             = _mm_sub_ps(iz2,jz0);
398             dx30             = _mm_sub_ps(ix3,jx0);
399             dy30             = _mm_sub_ps(iy3,jy0);
400             dz30             = _mm_sub_ps(iz3,jz0);
401
402             /* Calculate squared distance and things based on it */
403             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
404             rsq10            = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
405             rsq20            = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
406             rsq30            = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
407
408             rinv10           = gmx_mm_invsqrt_ps(rsq10);
409             rinv20           = gmx_mm_invsqrt_ps(rsq20);
410             rinv30           = gmx_mm_invsqrt_ps(rsq30);
411
412             rinvsq00         = gmx_mm_inv_ps(rsq00);
413             rinvsq10         = _mm_mul_ps(rinv10,rinv10);
414             rinvsq20         = _mm_mul_ps(rinv20,rinv20);
415             rinvsq30         = _mm_mul_ps(rinv30,rinv30);
416
417             /* Load parameters for j particles */
418             jq0              = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
419                                                               charge+jnrC+0,charge+jnrD+0);
420             vdwjidx0A        = 2*vdwtype[jnrA+0];
421             vdwjidx0B        = 2*vdwtype[jnrB+0];
422             vdwjidx0C        = 2*vdwtype[jnrC+0];
423             vdwjidx0D        = 2*vdwtype[jnrD+0];
424
425             fjx0             = _mm_setzero_ps();
426             fjy0             = _mm_setzero_ps();
427             fjz0             = _mm_setzero_ps();
428
429             /**************************
430              * CALCULATE INTERACTIONS *
431              **************************/
432
433             /* Compute parameters for interactions between i and j atoms */
434             gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
435                                          vdwparam+vdwioffset0+vdwjidx0B,
436                                          vdwparam+vdwioffset0+vdwjidx0C,
437                                          vdwparam+vdwioffset0+vdwjidx0D,
438                                          &c6_00,&c12_00);
439
440             /* LENNARD-JONES DISPERSION/REPULSION */
441
442             rinvsix          = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
443             vvdw6            = _mm_mul_ps(c6_00,rinvsix);
444             vvdw12           = _mm_mul_ps(c12_00,_mm_mul_ps(rinvsix,rinvsix));
445             vvdw             = _mm_msub_ps(vvdw12,one_twelfth,_mm_mul_ps(vvdw6,one_sixth));
446             fvdw             = _mm_mul_ps(_mm_sub_ps(vvdw12,vvdw6),rinvsq00);
447
448             /* Update potential sum for this i atom from the interaction with this j atom. */
449             vvdw             = _mm_andnot_ps(dummy_mask,vvdw);
450             vvdwsum          = _mm_add_ps(vvdwsum,vvdw);
451
452             fscal            = fvdw;
453
454             fscal            = _mm_andnot_ps(dummy_mask,fscal);
455
456              /* Update vectorial force */
457             fix0             = _mm_macc_ps(dx00,fscal,fix0);
458             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
459             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
460
461             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
462             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
463             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
464
465             /**************************
466              * CALCULATE INTERACTIONS *
467              **************************/
468
469             /* Compute parameters for interactions between i and j atoms */
470             qq10             = _mm_mul_ps(iq1,jq0);
471
472             /* COULOMB ELECTROSTATICS */
473             velec            = _mm_mul_ps(qq10,rinv10);
474             felec            = _mm_mul_ps(velec,rinvsq10);
475
476             /* Update potential sum for this i atom from the interaction with this j atom. */
477             velec            = _mm_andnot_ps(dummy_mask,velec);
478             velecsum         = _mm_add_ps(velecsum,velec);
479
480             fscal            = felec;
481
482             fscal            = _mm_andnot_ps(dummy_mask,fscal);
483
484              /* Update vectorial force */
485             fix1             = _mm_macc_ps(dx10,fscal,fix1);
486             fiy1             = _mm_macc_ps(dy10,fscal,fiy1);
487             fiz1             = _mm_macc_ps(dz10,fscal,fiz1);
488
489             fjx0             = _mm_macc_ps(dx10,fscal,fjx0);
490             fjy0             = _mm_macc_ps(dy10,fscal,fjy0);
491             fjz0             = _mm_macc_ps(dz10,fscal,fjz0);
492
493             /**************************
494              * CALCULATE INTERACTIONS *
495              **************************/
496
497             /* Compute parameters for interactions between i and j atoms */
498             qq20             = _mm_mul_ps(iq2,jq0);
499
500             /* COULOMB ELECTROSTATICS */
501             velec            = _mm_mul_ps(qq20,rinv20);
502             felec            = _mm_mul_ps(velec,rinvsq20);
503
504             /* Update potential sum for this i atom from the interaction with this j atom. */
505             velec            = _mm_andnot_ps(dummy_mask,velec);
506             velecsum         = _mm_add_ps(velecsum,velec);
507
508             fscal            = felec;
509
510             fscal            = _mm_andnot_ps(dummy_mask,fscal);
511
512              /* Update vectorial force */
513             fix2             = _mm_macc_ps(dx20,fscal,fix2);
514             fiy2             = _mm_macc_ps(dy20,fscal,fiy2);
515             fiz2             = _mm_macc_ps(dz20,fscal,fiz2);
516
517             fjx0             = _mm_macc_ps(dx20,fscal,fjx0);
518             fjy0             = _mm_macc_ps(dy20,fscal,fjy0);
519             fjz0             = _mm_macc_ps(dz20,fscal,fjz0);
520
521             /**************************
522              * CALCULATE INTERACTIONS *
523              **************************/
524
525             /* Compute parameters for interactions between i and j atoms */
526             qq30             = _mm_mul_ps(iq3,jq0);
527
528             /* COULOMB ELECTROSTATICS */
529             velec            = _mm_mul_ps(qq30,rinv30);
530             felec            = _mm_mul_ps(velec,rinvsq30);
531
532             /* Update potential sum for this i atom from the interaction with this j atom. */
533             velec            = _mm_andnot_ps(dummy_mask,velec);
534             velecsum         = _mm_add_ps(velecsum,velec);
535
536             fscal            = felec;
537
538             fscal            = _mm_andnot_ps(dummy_mask,fscal);
539
540              /* Update vectorial force */
541             fix3             = _mm_macc_ps(dx30,fscal,fix3);
542             fiy3             = _mm_macc_ps(dy30,fscal,fiy3);
543             fiz3             = _mm_macc_ps(dz30,fscal,fiz3);
544
545             fjx0             = _mm_macc_ps(dx30,fscal,fjx0);
546             fjy0             = _mm_macc_ps(dy30,fscal,fjy0);
547             fjz0             = _mm_macc_ps(dz30,fscal,fjz0);
548
549             fjptrA             = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
550             fjptrB             = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
551             fjptrC             = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
552             fjptrD             = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
553
554             gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
555
556             /* Inner loop uses 128 flops */
557         }
558
559         /* End of innermost loop */
560
561         gmx_mm_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
562                                               f+i_coord_offset,fshift+i_shift_offset);
563
564         ggid                        = gid[iidx];
565         /* Update potential energies */
566         gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
567         gmx_mm_update_1pot_ps(vvdwsum,kernel_data->energygrp_vdw+ggid);
568
569         /* Increment number of inner iterations */
570         inneriter                  += j_index_end - j_index_start;
571
572         /* Outer loop uses 26 flops */
573     }
574
575     /* Increment number of outer iterations */
576     outeriter        += nri;
577
578     /* Update outer/inner flops */
579
580     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*26 + inneriter*128);
581 }
582 /*
583  * Gromacs nonbonded kernel:   nb_kernel_ElecCoul_VdwLJ_GeomW4P1_F_avx_128_fma_single
584  * Electrostatics interaction: Coulomb
585  * VdW interaction:            LennardJones
586  * Geometry:                   Water4-Particle
587  * Calculate force/pot:        Force
588  */
589 void
590 nb_kernel_ElecCoul_VdwLJ_GeomW4P1_F_avx_128_fma_single
591                     (t_nblist                    * gmx_restrict       nlist,
592                      rvec                        * gmx_restrict          xx,
593                      rvec                        * gmx_restrict          ff,
594                      t_forcerec                  * gmx_restrict          fr,
595                      t_mdatoms                   * gmx_restrict     mdatoms,
596                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
597                      t_nrnb                      * gmx_restrict        nrnb)
598 {
599     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
600      * just 0 for non-waters.
601      * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
602      * jnr indices corresponding to data put in the four positions in the SIMD register.
603      */
604     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
605     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
606     int              jnrA,jnrB,jnrC,jnrD;
607     int              jnrlistA,jnrlistB,jnrlistC,jnrlistD;
608     int              j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
609     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
610     real             rcutoff_scalar;
611     real             *shiftvec,*fshift,*x,*f;
612     real             *fjptrA,*fjptrB,*fjptrC,*fjptrD;
613     real             scratch[4*DIM];
614     __m128           fscal,rcutoff,rcutoff2,jidxall;
615     int              vdwioffset0;
616     __m128           ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
617     int              vdwioffset1;
618     __m128           ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
619     int              vdwioffset2;
620     __m128           ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
621     int              vdwioffset3;
622     __m128           ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
623     int              vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
624     __m128           jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
625     __m128           dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
626     __m128           dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
627     __m128           dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
628     __m128           dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30;
629     __m128           velec,felec,velecsum,facel,crf,krf,krf2;
630     real             *charge;
631     int              nvdwtype;
632     __m128           rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,sh_vdw_invrcut6;
633     int              *vdwtype;
634     real             *vdwparam;
635     __m128           one_sixth   = _mm_set1_ps(1.0/6.0);
636     __m128           one_twelfth = _mm_set1_ps(1.0/12.0);
637     __m128           dummy_mask,cutoff_mask;
638     __m128           signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
639     __m128           one     = _mm_set1_ps(1.0);
640     __m128           two     = _mm_set1_ps(2.0);
641     x                = xx[0];
642     f                = ff[0];
643
644     nri              = nlist->nri;
645     iinr             = nlist->iinr;
646     jindex           = nlist->jindex;
647     jjnr             = nlist->jjnr;
648     shiftidx         = nlist->shift;
649     gid              = nlist->gid;
650     shiftvec         = fr->shift_vec[0];
651     fshift           = fr->fshift[0];
652     facel            = _mm_set1_ps(fr->epsfac);
653     charge           = mdatoms->chargeA;
654     nvdwtype         = fr->ntype;
655     vdwparam         = fr->nbfp;
656     vdwtype          = mdatoms->typeA;
657
658     /* Setup water-specific parameters */
659     inr              = nlist->iinr[0];
660     iq1              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
661     iq2              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
662     iq3              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+3]));
663     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
664
665     /* Avoid stupid compiler warnings */
666     jnrA = jnrB = jnrC = jnrD = 0;
667     j_coord_offsetA = 0;
668     j_coord_offsetB = 0;
669     j_coord_offsetC = 0;
670     j_coord_offsetD = 0;
671
672     outeriter        = 0;
673     inneriter        = 0;
674
675     for(iidx=0;iidx<4*DIM;iidx++)
676     {
677         scratch[iidx] = 0.0;
678     }
679
680     /* Start outer loop over neighborlists */
681     for(iidx=0; iidx<nri; iidx++)
682     {
683         /* Load shift vector for this list */
684         i_shift_offset   = DIM*shiftidx[iidx];
685
686         /* Load limits for loop over neighbors */
687         j_index_start    = jindex[iidx];
688         j_index_end      = jindex[iidx+1];
689
690         /* Get outer coordinate index */
691         inr              = iinr[iidx];
692         i_coord_offset   = DIM*inr;
693
694         /* Load i particle coords and add shift vector */
695         gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
696                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
697
698         fix0             = _mm_setzero_ps();
699         fiy0             = _mm_setzero_ps();
700         fiz0             = _mm_setzero_ps();
701         fix1             = _mm_setzero_ps();
702         fiy1             = _mm_setzero_ps();
703         fiz1             = _mm_setzero_ps();
704         fix2             = _mm_setzero_ps();
705         fiy2             = _mm_setzero_ps();
706         fiz2             = _mm_setzero_ps();
707         fix3             = _mm_setzero_ps();
708         fiy3             = _mm_setzero_ps();
709         fiz3             = _mm_setzero_ps();
710
711         /* Start inner kernel loop */
712         for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
713         {
714
715             /* Get j neighbor index, and coordinate index */
716             jnrA             = jjnr[jidx];
717             jnrB             = jjnr[jidx+1];
718             jnrC             = jjnr[jidx+2];
719             jnrD             = jjnr[jidx+3];
720             j_coord_offsetA  = DIM*jnrA;
721             j_coord_offsetB  = DIM*jnrB;
722             j_coord_offsetC  = DIM*jnrC;
723             j_coord_offsetD  = DIM*jnrD;
724
725             /* load j atom coordinates */
726             gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
727                                               x+j_coord_offsetC,x+j_coord_offsetD,
728                                               &jx0,&jy0,&jz0);
729
730             /* Calculate displacement vector */
731             dx00             = _mm_sub_ps(ix0,jx0);
732             dy00             = _mm_sub_ps(iy0,jy0);
733             dz00             = _mm_sub_ps(iz0,jz0);
734             dx10             = _mm_sub_ps(ix1,jx0);
735             dy10             = _mm_sub_ps(iy1,jy0);
736             dz10             = _mm_sub_ps(iz1,jz0);
737             dx20             = _mm_sub_ps(ix2,jx0);
738             dy20             = _mm_sub_ps(iy2,jy0);
739             dz20             = _mm_sub_ps(iz2,jz0);
740             dx30             = _mm_sub_ps(ix3,jx0);
741             dy30             = _mm_sub_ps(iy3,jy0);
742             dz30             = _mm_sub_ps(iz3,jz0);
743
744             /* Calculate squared distance and things based on it */
745             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
746             rsq10            = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
747             rsq20            = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
748             rsq30            = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
749
750             rinv10           = gmx_mm_invsqrt_ps(rsq10);
751             rinv20           = gmx_mm_invsqrt_ps(rsq20);
752             rinv30           = gmx_mm_invsqrt_ps(rsq30);
753
754             rinvsq00         = gmx_mm_inv_ps(rsq00);
755             rinvsq10         = _mm_mul_ps(rinv10,rinv10);
756             rinvsq20         = _mm_mul_ps(rinv20,rinv20);
757             rinvsq30         = _mm_mul_ps(rinv30,rinv30);
758
759             /* Load parameters for j particles */
760             jq0              = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
761                                                               charge+jnrC+0,charge+jnrD+0);
762             vdwjidx0A        = 2*vdwtype[jnrA+0];
763             vdwjidx0B        = 2*vdwtype[jnrB+0];
764             vdwjidx0C        = 2*vdwtype[jnrC+0];
765             vdwjidx0D        = 2*vdwtype[jnrD+0];
766
767             fjx0             = _mm_setzero_ps();
768             fjy0             = _mm_setzero_ps();
769             fjz0             = _mm_setzero_ps();
770
771             /**************************
772              * CALCULATE INTERACTIONS *
773              **************************/
774
775             /* Compute parameters for interactions between i and j atoms */
776             gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
777                                          vdwparam+vdwioffset0+vdwjidx0B,
778                                          vdwparam+vdwioffset0+vdwjidx0C,
779                                          vdwparam+vdwioffset0+vdwjidx0D,
780                                          &c6_00,&c12_00);
781
782             /* LENNARD-JONES DISPERSION/REPULSION */
783
784             rinvsix          = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
785             fvdw             = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
786
787             fscal            = fvdw;
788
789              /* Update vectorial force */
790             fix0             = _mm_macc_ps(dx00,fscal,fix0);
791             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
792             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
793
794             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
795             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
796             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
797
798             /**************************
799              * CALCULATE INTERACTIONS *
800              **************************/
801
802             /* Compute parameters for interactions between i and j atoms */
803             qq10             = _mm_mul_ps(iq1,jq0);
804
805             /* COULOMB ELECTROSTATICS */
806             velec            = _mm_mul_ps(qq10,rinv10);
807             felec            = _mm_mul_ps(velec,rinvsq10);
808
809             fscal            = felec;
810
811              /* Update vectorial force */
812             fix1             = _mm_macc_ps(dx10,fscal,fix1);
813             fiy1             = _mm_macc_ps(dy10,fscal,fiy1);
814             fiz1             = _mm_macc_ps(dz10,fscal,fiz1);
815
816             fjx0             = _mm_macc_ps(dx10,fscal,fjx0);
817             fjy0             = _mm_macc_ps(dy10,fscal,fjy0);
818             fjz0             = _mm_macc_ps(dz10,fscal,fjz0);
819
820             /**************************
821              * CALCULATE INTERACTIONS *
822              **************************/
823
824             /* Compute parameters for interactions between i and j atoms */
825             qq20             = _mm_mul_ps(iq2,jq0);
826
827             /* COULOMB ELECTROSTATICS */
828             velec            = _mm_mul_ps(qq20,rinv20);
829             felec            = _mm_mul_ps(velec,rinvsq20);
830
831             fscal            = felec;
832
833              /* Update vectorial force */
834             fix2             = _mm_macc_ps(dx20,fscal,fix2);
835             fiy2             = _mm_macc_ps(dy20,fscal,fiy2);
836             fiz2             = _mm_macc_ps(dz20,fscal,fiz2);
837
838             fjx0             = _mm_macc_ps(dx20,fscal,fjx0);
839             fjy0             = _mm_macc_ps(dy20,fscal,fjy0);
840             fjz0             = _mm_macc_ps(dz20,fscal,fjz0);
841
842             /**************************
843              * CALCULATE INTERACTIONS *
844              **************************/
845
846             /* Compute parameters for interactions between i and j atoms */
847             qq30             = _mm_mul_ps(iq3,jq0);
848
849             /* COULOMB ELECTROSTATICS */
850             velec            = _mm_mul_ps(qq30,rinv30);
851             felec            = _mm_mul_ps(velec,rinvsq30);
852
853             fscal            = felec;
854
855              /* Update vectorial force */
856             fix3             = _mm_macc_ps(dx30,fscal,fix3);
857             fiy3             = _mm_macc_ps(dy30,fscal,fiy3);
858             fiz3             = _mm_macc_ps(dz30,fscal,fiz3);
859
860             fjx0             = _mm_macc_ps(dx30,fscal,fjx0);
861             fjy0             = _mm_macc_ps(dy30,fscal,fjy0);
862             fjz0             = _mm_macc_ps(dz30,fscal,fjz0);
863
864             fjptrA             = f+j_coord_offsetA;
865             fjptrB             = f+j_coord_offsetB;
866             fjptrC             = f+j_coord_offsetC;
867             fjptrD             = f+j_coord_offsetD;
868
869             gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
870
871             /* Inner loop uses 120 flops */
872         }
873
874         if(jidx<j_index_end)
875         {
876
877             /* Get j neighbor index, and coordinate index */
878             jnrlistA         = jjnr[jidx];
879             jnrlistB         = jjnr[jidx+1];
880             jnrlistC         = jjnr[jidx+2];
881             jnrlistD         = jjnr[jidx+3];
882             /* Sign of each element will be negative for non-real atoms.
883              * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
884              * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
885              */
886             dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
887             jnrA       = (jnrlistA>=0) ? jnrlistA : 0;
888             jnrB       = (jnrlistB>=0) ? jnrlistB : 0;
889             jnrC       = (jnrlistC>=0) ? jnrlistC : 0;
890             jnrD       = (jnrlistD>=0) ? jnrlistD : 0;
891             j_coord_offsetA  = DIM*jnrA;
892             j_coord_offsetB  = DIM*jnrB;
893             j_coord_offsetC  = DIM*jnrC;
894             j_coord_offsetD  = DIM*jnrD;
895
896             /* load j atom coordinates */
897             gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
898                                               x+j_coord_offsetC,x+j_coord_offsetD,
899                                               &jx0,&jy0,&jz0);
900
901             /* Calculate displacement vector */
902             dx00             = _mm_sub_ps(ix0,jx0);
903             dy00             = _mm_sub_ps(iy0,jy0);
904             dz00             = _mm_sub_ps(iz0,jz0);
905             dx10             = _mm_sub_ps(ix1,jx0);
906             dy10             = _mm_sub_ps(iy1,jy0);
907             dz10             = _mm_sub_ps(iz1,jz0);
908             dx20             = _mm_sub_ps(ix2,jx0);
909             dy20             = _mm_sub_ps(iy2,jy0);
910             dz20             = _mm_sub_ps(iz2,jz0);
911             dx30             = _mm_sub_ps(ix3,jx0);
912             dy30             = _mm_sub_ps(iy3,jy0);
913             dz30             = _mm_sub_ps(iz3,jz0);
914
915             /* Calculate squared distance and things based on it */
916             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
917             rsq10            = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
918             rsq20            = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
919             rsq30            = gmx_mm_calc_rsq_ps(dx30,dy30,dz30);
920
921             rinv10           = gmx_mm_invsqrt_ps(rsq10);
922             rinv20           = gmx_mm_invsqrt_ps(rsq20);
923             rinv30           = gmx_mm_invsqrt_ps(rsq30);
924
925             rinvsq00         = gmx_mm_inv_ps(rsq00);
926             rinvsq10         = _mm_mul_ps(rinv10,rinv10);
927             rinvsq20         = _mm_mul_ps(rinv20,rinv20);
928             rinvsq30         = _mm_mul_ps(rinv30,rinv30);
929
930             /* Load parameters for j particles */
931             jq0              = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
932                                                               charge+jnrC+0,charge+jnrD+0);
933             vdwjidx0A        = 2*vdwtype[jnrA+0];
934             vdwjidx0B        = 2*vdwtype[jnrB+0];
935             vdwjidx0C        = 2*vdwtype[jnrC+0];
936             vdwjidx0D        = 2*vdwtype[jnrD+0];
937
938             fjx0             = _mm_setzero_ps();
939             fjy0             = _mm_setzero_ps();
940             fjz0             = _mm_setzero_ps();
941
942             /**************************
943              * CALCULATE INTERACTIONS *
944              **************************/
945
946             /* Compute parameters for interactions between i and j atoms */
947             gmx_mm_load_4pair_swizzle_ps(vdwparam+vdwioffset0+vdwjidx0A,
948                                          vdwparam+vdwioffset0+vdwjidx0B,
949                                          vdwparam+vdwioffset0+vdwjidx0C,
950                                          vdwparam+vdwioffset0+vdwjidx0D,
951                                          &c6_00,&c12_00);
952
953             /* LENNARD-JONES DISPERSION/REPULSION */
954
955             rinvsix          = _mm_mul_ps(_mm_mul_ps(rinvsq00,rinvsq00),rinvsq00);
956             fvdw             = _mm_mul_ps(_mm_msub_ps(c12_00,rinvsix,c6_00),_mm_mul_ps(rinvsix,rinvsq00));
957
958             fscal            = fvdw;
959
960             fscal            = _mm_andnot_ps(dummy_mask,fscal);
961
962              /* Update vectorial force */
963             fix0             = _mm_macc_ps(dx00,fscal,fix0);
964             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
965             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
966
967             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
968             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
969             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
970
971             /**************************
972              * CALCULATE INTERACTIONS *
973              **************************/
974
975             /* Compute parameters for interactions between i and j atoms */
976             qq10             = _mm_mul_ps(iq1,jq0);
977
978             /* COULOMB ELECTROSTATICS */
979             velec            = _mm_mul_ps(qq10,rinv10);
980             felec            = _mm_mul_ps(velec,rinvsq10);
981
982             fscal            = felec;
983
984             fscal            = _mm_andnot_ps(dummy_mask,fscal);
985
986              /* Update vectorial force */
987             fix1             = _mm_macc_ps(dx10,fscal,fix1);
988             fiy1             = _mm_macc_ps(dy10,fscal,fiy1);
989             fiz1             = _mm_macc_ps(dz10,fscal,fiz1);
990
991             fjx0             = _mm_macc_ps(dx10,fscal,fjx0);
992             fjy0             = _mm_macc_ps(dy10,fscal,fjy0);
993             fjz0             = _mm_macc_ps(dz10,fscal,fjz0);
994
995             /**************************
996              * CALCULATE INTERACTIONS *
997              **************************/
998
999             /* Compute parameters for interactions between i and j atoms */
1000             qq20             = _mm_mul_ps(iq2,jq0);
1001
1002             /* COULOMB ELECTROSTATICS */
1003             velec            = _mm_mul_ps(qq20,rinv20);
1004             felec            = _mm_mul_ps(velec,rinvsq20);
1005
1006             fscal            = felec;
1007
1008             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1009
1010              /* Update vectorial force */
1011             fix2             = _mm_macc_ps(dx20,fscal,fix2);
1012             fiy2             = _mm_macc_ps(dy20,fscal,fiy2);
1013             fiz2             = _mm_macc_ps(dz20,fscal,fiz2);
1014
1015             fjx0             = _mm_macc_ps(dx20,fscal,fjx0);
1016             fjy0             = _mm_macc_ps(dy20,fscal,fjy0);
1017             fjz0             = _mm_macc_ps(dz20,fscal,fjz0);
1018
1019             /**************************
1020              * CALCULATE INTERACTIONS *
1021              **************************/
1022
1023             /* Compute parameters for interactions between i and j atoms */
1024             qq30             = _mm_mul_ps(iq3,jq0);
1025
1026             /* COULOMB ELECTROSTATICS */
1027             velec            = _mm_mul_ps(qq30,rinv30);
1028             felec            = _mm_mul_ps(velec,rinvsq30);
1029
1030             fscal            = felec;
1031
1032             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1033
1034              /* Update vectorial force */
1035             fix3             = _mm_macc_ps(dx30,fscal,fix3);
1036             fiy3             = _mm_macc_ps(dy30,fscal,fiy3);
1037             fiz3             = _mm_macc_ps(dz30,fscal,fiz3);
1038
1039             fjx0             = _mm_macc_ps(dx30,fscal,fjx0);
1040             fjy0             = _mm_macc_ps(dy30,fscal,fjy0);
1041             fjz0             = _mm_macc_ps(dz30,fscal,fjz0);
1042
1043             fjptrA             = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1044             fjptrB             = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1045             fjptrC             = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1046             fjptrD             = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1047
1048             gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
1049
1050             /* Inner loop uses 120 flops */
1051         }
1052
1053         /* End of innermost loop */
1054
1055         gmx_mm_update_iforce_4atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1056                                               f+i_coord_offset,fshift+i_shift_offset);
1057
1058         /* Increment number of inner iterations */
1059         inneriter                  += j_index_end - j_index_start;
1060
1061         /* Outer loop uses 24 flops */
1062     }
1063
1064     /* Increment number of outer iterations */
1065     outeriter        += nri;
1066
1067     /* Update outer/inner flops */
1068
1069     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*24 + inneriter*120);
1070 }