Compile nonbonded kernels as C++
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_avx_128_fma_single / nb_kernel_ElecCoul_VdwNone_GeomW3W3_avx_128_fma_single.cpp
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013,2014,2015,2017,2018, 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 "gmxpre.h"
39
40 #include "config.h"
41
42 #include <math.h>
43
44 #include "../nb_kernel.h"
45 #include "gromacs/gmxlib/nrnb.h"
46
47 #include "kernelutil_x86_avx_128_fma_single.h"
48
49 /*
50  * Gromacs nonbonded kernel:   nb_kernel_ElecCoul_VdwNone_GeomW3W3_VF_avx_128_fma_single
51  * Electrostatics interaction: Coulomb
52  * VdW interaction:            None
53  * Geometry:                   Water3-Water3
54  * Calculate force/pot:        PotentialAndForce
55  */
56 void
57 nb_kernel_ElecCoul_VdwNone_GeomW3W3_VF_avx_128_fma_single
58                     (t_nblist                    * gmx_restrict       nlist,
59                      rvec                        * gmx_restrict          xx,
60                      rvec                        * gmx_restrict          ff,
61                      struct t_forcerec           * gmx_restrict          fr,
62                      t_mdatoms                   * gmx_restrict     mdatoms,
63                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64                      t_nrnb                      * gmx_restrict        nrnb)
65 {
66     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
67      * just 0 for non-waters.
68      * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
69      * jnr indices corresponding to data put in the four positions in the SIMD register.
70      */
71     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
72     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
73     int              jnrA,jnrB,jnrC,jnrD;
74     int              jnrlistA,jnrlistB,jnrlistC,jnrlistD;
75     int              j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
76     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
77     real             rcutoff_scalar;
78     real             *shiftvec,*fshift,*x,*f;
79     real             *fjptrA,*fjptrB,*fjptrC,*fjptrD;
80     real             scratch[4*DIM];
81     __m128           fscal,rcutoff,rcutoff2,jidxall;
82     int              vdwioffset0;
83     __m128           ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
84     int              vdwioffset1;
85     __m128           ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
86     int              vdwioffset2;
87     __m128           ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
88     int              vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
89     __m128           jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
90     int              vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D;
91     __m128           jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
92     int              vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D;
93     __m128           jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
94     __m128           dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
95     __m128           dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
96     __m128           dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
97     __m128           dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
98     __m128           dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
99     __m128           dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
100     __m128           dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
101     __m128           dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
102     __m128           dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
103     __m128           velec,felec,velecsum,facel,crf,krf,krf2;
104     real             *charge;
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->ic->epsfac);
121     charge           = mdatoms->chargeA;
122
123     /* Setup water-specific parameters */
124     inr              = nlist->iinr[0];
125     iq0              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
126     iq1              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
127     iq2              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
128
129     jq0              = _mm_set1_ps(charge[inr+0]);
130     jq1              = _mm_set1_ps(charge[inr+1]);
131     jq2              = _mm_set1_ps(charge[inr+2]);
132     qq00             = _mm_mul_ps(iq0,jq0);
133     qq01             = _mm_mul_ps(iq0,jq1);
134     qq02             = _mm_mul_ps(iq0,jq2);
135     qq10             = _mm_mul_ps(iq1,jq0);
136     qq11             = _mm_mul_ps(iq1,jq1);
137     qq12             = _mm_mul_ps(iq1,jq2);
138     qq20             = _mm_mul_ps(iq2,jq0);
139     qq21             = _mm_mul_ps(iq2,jq1);
140     qq22             = _mm_mul_ps(iq2,jq2);
141
142     /* Avoid stupid compiler warnings */
143     jnrA = jnrB = jnrC = jnrD = 0;
144     j_coord_offsetA = 0;
145     j_coord_offsetB = 0;
146     j_coord_offsetC = 0;
147     j_coord_offsetD = 0;
148
149     outeriter        = 0;
150     inneriter        = 0;
151
152     for(iidx=0;iidx<4*DIM;iidx++)
153     {
154         scratch[iidx] = 0.0;
155     }
156
157     /* Start outer loop over neighborlists */
158     for(iidx=0; iidx<nri; iidx++)
159     {
160         /* Load shift vector for this list */
161         i_shift_offset   = DIM*shiftidx[iidx];
162
163         /* Load limits for loop over neighbors */
164         j_index_start    = jindex[iidx];
165         j_index_end      = jindex[iidx+1];
166
167         /* Get outer coordinate index */
168         inr              = iinr[iidx];
169         i_coord_offset   = DIM*inr;
170
171         /* Load i particle coords and add shift vector */
172         gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
173                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
174
175         fix0             = _mm_setzero_ps();
176         fiy0             = _mm_setzero_ps();
177         fiz0             = _mm_setzero_ps();
178         fix1             = _mm_setzero_ps();
179         fiy1             = _mm_setzero_ps();
180         fiz1             = _mm_setzero_ps();
181         fix2             = _mm_setzero_ps();
182         fiy2             = _mm_setzero_ps();
183         fiz2             = _mm_setzero_ps();
184
185         /* Reset potential sums */
186         velecsum         = _mm_setzero_ps();
187
188         /* Start inner kernel loop */
189         for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
190         {
191
192             /* Get j neighbor index, and coordinate index */
193             jnrA             = jjnr[jidx];
194             jnrB             = jjnr[jidx+1];
195             jnrC             = jjnr[jidx+2];
196             jnrD             = jjnr[jidx+3];
197             j_coord_offsetA  = DIM*jnrA;
198             j_coord_offsetB  = DIM*jnrB;
199             j_coord_offsetC  = DIM*jnrC;
200             j_coord_offsetD  = DIM*jnrD;
201
202             /* load j atom coordinates */
203             gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
204                                               x+j_coord_offsetC,x+j_coord_offsetD,
205                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
206
207             /* Calculate displacement vector */
208             dx00             = _mm_sub_ps(ix0,jx0);
209             dy00             = _mm_sub_ps(iy0,jy0);
210             dz00             = _mm_sub_ps(iz0,jz0);
211             dx01             = _mm_sub_ps(ix0,jx1);
212             dy01             = _mm_sub_ps(iy0,jy1);
213             dz01             = _mm_sub_ps(iz0,jz1);
214             dx02             = _mm_sub_ps(ix0,jx2);
215             dy02             = _mm_sub_ps(iy0,jy2);
216             dz02             = _mm_sub_ps(iz0,jz2);
217             dx10             = _mm_sub_ps(ix1,jx0);
218             dy10             = _mm_sub_ps(iy1,jy0);
219             dz10             = _mm_sub_ps(iz1,jz0);
220             dx11             = _mm_sub_ps(ix1,jx1);
221             dy11             = _mm_sub_ps(iy1,jy1);
222             dz11             = _mm_sub_ps(iz1,jz1);
223             dx12             = _mm_sub_ps(ix1,jx2);
224             dy12             = _mm_sub_ps(iy1,jy2);
225             dz12             = _mm_sub_ps(iz1,jz2);
226             dx20             = _mm_sub_ps(ix2,jx0);
227             dy20             = _mm_sub_ps(iy2,jy0);
228             dz20             = _mm_sub_ps(iz2,jz0);
229             dx21             = _mm_sub_ps(ix2,jx1);
230             dy21             = _mm_sub_ps(iy2,jy1);
231             dz21             = _mm_sub_ps(iz2,jz1);
232             dx22             = _mm_sub_ps(ix2,jx2);
233             dy22             = _mm_sub_ps(iy2,jy2);
234             dz22             = _mm_sub_ps(iz2,jz2);
235
236             /* Calculate squared distance and things based on it */
237             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
238             rsq01            = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
239             rsq02            = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
240             rsq10            = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
241             rsq11            = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
242             rsq12            = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
243             rsq20            = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
244             rsq21            = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
245             rsq22            = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
246
247             rinv00           = avx128fma_invsqrt_f(rsq00);
248             rinv01           = avx128fma_invsqrt_f(rsq01);
249             rinv02           = avx128fma_invsqrt_f(rsq02);
250             rinv10           = avx128fma_invsqrt_f(rsq10);
251             rinv11           = avx128fma_invsqrt_f(rsq11);
252             rinv12           = avx128fma_invsqrt_f(rsq12);
253             rinv20           = avx128fma_invsqrt_f(rsq20);
254             rinv21           = avx128fma_invsqrt_f(rsq21);
255             rinv22           = avx128fma_invsqrt_f(rsq22);
256
257             rinvsq00         = _mm_mul_ps(rinv00,rinv00);
258             rinvsq01         = _mm_mul_ps(rinv01,rinv01);
259             rinvsq02         = _mm_mul_ps(rinv02,rinv02);
260             rinvsq10         = _mm_mul_ps(rinv10,rinv10);
261             rinvsq11         = _mm_mul_ps(rinv11,rinv11);
262             rinvsq12         = _mm_mul_ps(rinv12,rinv12);
263             rinvsq20         = _mm_mul_ps(rinv20,rinv20);
264             rinvsq21         = _mm_mul_ps(rinv21,rinv21);
265             rinvsq22         = _mm_mul_ps(rinv22,rinv22);
266
267             fjx0             = _mm_setzero_ps();
268             fjy0             = _mm_setzero_ps();
269             fjz0             = _mm_setzero_ps();
270             fjx1             = _mm_setzero_ps();
271             fjy1             = _mm_setzero_ps();
272             fjz1             = _mm_setzero_ps();
273             fjx2             = _mm_setzero_ps();
274             fjy2             = _mm_setzero_ps();
275             fjz2             = _mm_setzero_ps();
276
277             /**************************
278              * CALCULATE INTERACTIONS *
279              **************************/
280
281             /* COULOMB ELECTROSTATICS */
282             velec            = _mm_mul_ps(qq00,rinv00);
283             felec            = _mm_mul_ps(velec,rinvsq00);
284
285             /* Update potential sum for this i atom from the interaction with this j atom. */
286             velecsum         = _mm_add_ps(velecsum,velec);
287
288             fscal            = felec;
289
290              /* Update vectorial force */
291             fix0             = _mm_macc_ps(dx00,fscal,fix0);
292             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
293             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
294
295             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
296             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
297             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
298
299             /**************************
300              * CALCULATE INTERACTIONS *
301              **************************/
302
303             /* COULOMB ELECTROSTATICS */
304             velec            = _mm_mul_ps(qq01,rinv01);
305             felec            = _mm_mul_ps(velec,rinvsq01);
306
307             /* Update potential sum for this i atom from the interaction with this j atom. */
308             velecsum         = _mm_add_ps(velecsum,velec);
309
310             fscal            = felec;
311
312              /* Update vectorial force */
313             fix0             = _mm_macc_ps(dx01,fscal,fix0);
314             fiy0             = _mm_macc_ps(dy01,fscal,fiy0);
315             fiz0             = _mm_macc_ps(dz01,fscal,fiz0);
316
317             fjx1             = _mm_macc_ps(dx01,fscal,fjx1);
318             fjy1             = _mm_macc_ps(dy01,fscal,fjy1);
319             fjz1             = _mm_macc_ps(dz01,fscal,fjz1);
320
321             /**************************
322              * CALCULATE INTERACTIONS *
323              **************************/
324
325             /* COULOMB ELECTROSTATICS */
326             velec            = _mm_mul_ps(qq02,rinv02);
327             felec            = _mm_mul_ps(velec,rinvsq02);
328
329             /* Update potential sum for this i atom from the interaction with this j atom. */
330             velecsum         = _mm_add_ps(velecsum,velec);
331
332             fscal            = felec;
333
334              /* Update vectorial force */
335             fix0             = _mm_macc_ps(dx02,fscal,fix0);
336             fiy0             = _mm_macc_ps(dy02,fscal,fiy0);
337             fiz0             = _mm_macc_ps(dz02,fscal,fiz0);
338
339             fjx2             = _mm_macc_ps(dx02,fscal,fjx2);
340             fjy2             = _mm_macc_ps(dy02,fscal,fjy2);
341             fjz2             = _mm_macc_ps(dz02,fscal,fjz2);
342
343             /**************************
344              * CALCULATE INTERACTIONS *
345              **************************/
346
347             /* COULOMB ELECTROSTATICS */
348             velec            = _mm_mul_ps(qq10,rinv10);
349             felec            = _mm_mul_ps(velec,rinvsq10);
350
351             /* Update potential sum for this i atom from the interaction with this j atom. */
352             velecsum         = _mm_add_ps(velecsum,velec);
353
354             fscal            = felec;
355
356              /* Update vectorial force */
357             fix1             = _mm_macc_ps(dx10,fscal,fix1);
358             fiy1             = _mm_macc_ps(dy10,fscal,fiy1);
359             fiz1             = _mm_macc_ps(dz10,fscal,fiz1);
360
361             fjx0             = _mm_macc_ps(dx10,fscal,fjx0);
362             fjy0             = _mm_macc_ps(dy10,fscal,fjy0);
363             fjz0             = _mm_macc_ps(dz10,fscal,fjz0);
364
365             /**************************
366              * CALCULATE INTERACTIONS *
367              **************************/
368
369             /* COULOMB ELECTROSTATICS */
370             velec            = _mm_mul_ps(qq11,rinv11);
371             felec            = _mm_mul_ps(velec,rinvsq11);
372
373             /* Update potential sum for this i atom from the interaction with this j atom. */
374             velecsum         = _mm_add_ps(velecsum,velec);
375
376             fscal            = felec;
377
378              /* Update vectorial force */
379             fix1             = _mm_macc_ps(dx11,fscal,fix1);
380             fiy1             = _mm_macc_ps(dy11,fscal,fiy1);
381             fiz1             = _mm_macc_ps(dz11,fscal,fiz1);
382
383             fjx1             = _mm_macc_ps(dx11,fscal,fjx1);
384             fjy1             = _mm_macc_ps(dy11,fscal,fjy1);
385             fjz1             = _mm_macc_ps(dz11,fscal,fjz1);
386
387             /**************************
388              * CALCULATE INTERACTIONS *
389              **************************/
390
391             /* COULOMB ELECTROSTATICS */
392             velec            = _mm_mul_ps(qq12,rinv12);
393             felec            = _mm_mul_ps(velec,rinvsq12);
394
395             /* Update potential sum for this i atom from the interaction with this j atom. */
396             velecsum         = _mm_add_ps(velecsum,velec);
397
398             fscal            = felec;
399
400              /* Update vectorial force */
401             fix1             = _mm_macc_ps(dx12,fscal,fix1);
402             fiy1             = _mm_macc_ps(dy12,fscal,fiy1);
403             fiz1             = _mm_macc_ps(dz12,fscal,fiz1);
404
405             fjx2             = _mm_macc_ps(dx12,fscal,fjx2);
406             fjy2             = _mm_macc_ps(dy12,fscal,fjy2);
407             fjz2             = _mm_macc_ps(dz12,fscal,fjz2);
408
409             /**************************
410              * CALCULATE INTERACTIONS *
411              **************************/
412
413             /* COULOMB ELECTROSTATICS */
414             velec            = _mm_mul_ps(qq20,rinv20);
415             felec            = _mm_mul_ps(velec,rinvsq20);
416
417             /* Update potential sum for this i atom from the interaction with this j atom. */
418             velecsum         = _mm_add_ps(velecsum,velec);
419
420             fscal            = felec;
421
422              /* Update vectorial force */
423             fix2             = _mm_macc_ps(dx20,fscal,fix2);
424             fiy2             = _mm_macc_ps(dy20,fscal,fiy2);
425             fiz2             = _mm_macc_ps(dz20,fscal,fiz2);
426
427             fjx0             = _mm_macc_ps(dx20,fscal,fjx0);
428             fjy0             = _mm_macc_ps(dy20,fscal,fjy0);
429             fjz0             = _mm_macc_ps(dz20,fscal,fjz0);
430
431             /**************************
432              * CALCULATE INTERACTIONS *
433              **************************/
434
435             /* COULOMB ELECTROSTATICS */
436             velec            = _mm_mul_ps(qq21,rinv21);
437             felec            = _mm_mul_ps(velec,rinvsq21);
438
439             /* Update potential sum for this i atom from the interaction with this j atom. */
440             velecsum         = _mm_add_ps(velecsum,velec);
441
442             fscal            = felec;
443
444              /* Update vectorial force */
445             fix2             = _mm_macc_ps(dx21,fscal,fix2);
446             fiy2             = _mm_macc_ps(dy21,fscal,fiy2);
447             fiz2             = _mm_macc_ps(dz21,fscal,fiz2);
448
449             fjx1             = _mm_macc_ps(dx21,fscal,fjx1);
450             fjy1             = _mm_macc_ps(dy21,fscal,fjy1);
451             fjz1             = _mm_macc_ps(dz21,fscal,fjz1);
452
453             /**************************
454              * CALCULATE INTERACTIONS *
455              **************************/
456
457             /* COULOMB ELECTROSTATICS */
458             velec            = _mm_mul_ps(qq22,rinv22);
459             felec            = _mm_mul_ps(velec,rinvsq22);
460
461             /* Update potential sum for this i atom from the interaction with this j atom. */
462             velecsum         = _mm_add_ps(velecsum,velec);
463
464             fscal            = felec;
465
466              /* Update vectorial force */
467             fix2             = _mm_macc_ps(dx22,fscal,fix2);
468             fiy2             = _mm_macc_ps(dy22,fscal,fiy2);
469             fiz2             = _mm_macc_ps(dz22,fscal,fiz2);
470
471             fjx2             = _mm_macc_ps(dx22,fscal,fjx2);
472             fjy2             = _mm_macc_ps(dy22,fscal,fjy2);
473             fjz2             = _mm_macc_ps(dz22,fscal,fjz2);
474
475             fjptrA             = f+j_coord_offsetA;
476             fjptrB             = f+j_coord_offsetB;
477             fjptrC             = f+j_coord_offsetC;
478             fjptrD             = f+j_coord_offsetD;
479
480             gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
481                                                    fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
482
483             /* Inner loop uses 279 flops */
484         }
485
486         if(jidx<j_index_end)
487         {
488
489             /* Get j neighbor index, and coordinate index */
490             jnrlistA         = jjnr[jidx];
491             jnrlistB         = jjnr[jidx+1];
492             jnrlistC         = jjnr[jidx+2];
493             jnrlistD         = jjnr[jidx+3];
494             /* Sign of each element will be negative for non-real atoms.
495              * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
496              * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
497              */
498             dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
499             jnrA       = (jnrlistA>=0) ? jnrlistA : 0;
500             jnrB       = (jnrlistB>=0) ? jnrlistB : 0;
501             jnrC       = (jnrlistC>=0) ? jnrlistC : 0;
502             jnrD       = (jnrlistD>=0) ? jnrlistD : 0;
503             j_coord_offsetA  = DIM*jnrA;
504             j_coord_offsetB  = DIM*jnrB;
505             j_coord_offsetC  = DIM*jnrC;
506             j_coord_offsetD  = DIM*jnrD;
507
508             /* load j atom coordinates */
509             gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
510                                               x+j_coord_offsetC,x+j_coord_offsetD,
511                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
512
513             /* Calculate displacement vector */
514             dx00             = _mm_sub_ps(ix0,jx0);
515             dy00             = _mm_sub_ps(iy0,jy0);
516             dz00             = _mm_sub_ps(iz0,jz0);
517             dx01             = _mm_sub_ps(ix0,jx1);
518             dy01             = _mm_sub_ps(iy0,jy1);
519             dz01             = _mm_sub_ps(iz0,jz1);
520             dx02             = _mm_sub_ps(ix0,jx2);
521             dy02             = _mm_sub_ps(iy0,jy2);
522             dz02             = _mm_sub_ps(iz0,jz2);
523             dx10             = _mm_sub_ps(ix1,jx0);
524             dy10             = _mm_sub_ps(iy1,jy0);
525             dz10             = _mm_sub_ps(iz1,jz0);
526             dx11             = _mm_sub_ps(ix1,jx1);
527             dy11             = _mm_sub_ps(iy1,jy1);
528             dz11             = _mm_sub_ps(iz1,jz1);
529             dx12             = _mm_sub_ps(ix1,jx2);
530             dy12             = _mm_sub_ps(iy1,jy2);
531             dz12             = _mm_sub_ps(iz1,jz2);
532             dx20             = _mm_sub_ps(ix2,jx0);
533             dy20             = _mm_sub_ps(iy2,jy0);
534             dz20             = _mm_sub_ps(iz2,jz0);
535             dx21             = _mm_sub_ps(ix2,jx1);
536             dy21             = _mm_sub_ps(iy2,jy1);
537             dz21             = _mm_sub_ps(iz2,jz1);
538             dx22             = _mm_sub_ps(ix2,jx2);
539             dy22             = _mm_sub_ps(iy2,jy2);
540             dz22             = _mm_sub_ps(iz2,jz2);
541
542             /* Calculate squared distance and things based on it */
543             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
544             rsq01            = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
545             rsq02            = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
546             rsq10            = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
547             rsq11            = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
548             rsq12            = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
549             rsq20            = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
550             rsq21            = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
551             rsq22            = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
552
553             rinv00           = avx128fma_invsqrt_f(rsq00);
554             rinv01           = avx128fma_invsqrt_f(rsq01);
555             rinv02           = avx128fma_invsqrt_f(rsq02);
556             rinv10           = avx128fma_invsqrt_f(rsq10);
557             rinv11           = avx128fma_invsqrt_f(rsq11);
558             rinv12           = avx128fma_invsqrt_f(rsq12);
559             rinv20           = avx128fma_invsqrt_f(rsq20);
560             rinv21           = avx128fma_invsqrt_f(rsq21);
561             rinv22           = avx128fma_invsqrt_f(rsq22);
562
563             rinvsq00         = _mm_mul_ps(rinv00,rinv00);
564             rinvsq01         = _mm_mul_ps(rinv01,rinv01);
565             rinvsq02         = _mm_mul_ps(rinv02,rinv02);
566             rinvsq10         = _mm_mul_ps(rinv10,rinv10);
567             rinvsq11         = _mm_mul_ps(rinv11,rinv11);
568             rinvsq12         = _mm_mul_ps(rinv12,rinv12);
569             rinvsq20         = _mm_mul_ps(rinv20,rinv20);
570             rinvsq21         = _mm_mul_ps(rinv21,rinv21);
571             rinvsq22         = _mm_mul_ps(rinv22,rinv22);
572
573             fjx0             = _mm_setzero_ps();
574             fjy0             = _mm_setzero_ps();
575             fjz0             = _mm_setzero_ps();
576             fjx1             = _mm_setzero_ps();
577             fjy1             = _mm_setzero_ps();
578             fjz1             = _mm_setzero_ps();
579             fjx2             = _mm_setzero_ps();
580             fjy2             = _mm_setzero_ps();
581             fjz2             = _mm_setzero_ps();
582
583             /**************************
584              * CALCULATE INTERACTIONS *
585              **************************/
586
587             /* COULOMB ELECTROSTATICS */
588             velec            = _mm_mul_ps(qq00,rinv00);
589             felec            = _mm_mul_ps(velec,rinvsq00);
590
591             /* Update potential sum for this i atom from the interaction with this j atom. */
592             velec            = _mm_andnot_ps(dummy_mask,velec);
593             velecsum         = _mm_add_ps(velecsum,velec);
594
595             fscal            = felec;
596
597             fscal            = _mm_andnot_ps(dummy_mask,fscal);
598
599              /* Update vectorial force */
600             fix0             = _mm_macc_ps(dx00,fscal,fix0);
601             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
602             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
603
604             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
605             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
606             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
607
608             /**************************
609              * CALCULATE INTERACTIONS *
610              **************************/
611
612             /* COULOMB ELECTROSTATICS */
613             velec            = _mm_mul_ps(qq01,rinv01);
614             felec            = _mm_mul_ps(velec,rinvsq01);
615
616             /* Update potential sum for this i atom from the interaction with this j atom. */
617             velec            = _mm_andnot_ps(dummy_mask,velec);
618             velecsum         = _mm_add_ps(velecsum,velec);
619
620             fscal            = felec;
621
622             fscal            = _mm_andnot_ps(dummy_mask,fscal);
623
624              /* Update vectorial force */
625             fix0             = _mm_macc_ps(dx01,fscal,fix0);
626             fiy0             = _mm_macc_ps(dy01,fscal,fiy0);
627             fiz0             = _mm_macc_ps(dz01,fscal,fiz0);
628
629             fjx1             = _mm_macc_ps(dx01,fscal,fjx1);
630             fjy1             = _mm_macc_ps(dy01,fscal,fjy1);
631             fjz1             = _mm_macc_ps(dz01,fscal,fjz1);
632
633             /**************************
634              * CALCULATE INTERACTIONS *
635              **************************/
636
637             /* COULOMB ELECTROSTATICS */
638             velec            = _mm_mul_ps(qq02,rinv02);
639             felec            = _mm_mul_ps(velec,rinvsq02);
640
641             /* Update potential sum for this i atom from the interaction with this j atom. */
642             velec            = _mm_andnot_ps(dummy_mask,velec);
643             velecsum         = _mm_add_ps(velecsum,velec);
644
645             fscal            = felec;
646
647             fscal            = _mm_andnot_ps(dummy_mask,fscal);
648
649              /* Update vectorial force */
650             fix0             = _mm_macc_ps(dx02,fscal,fix0);
651             fiy0             = _mm_macc_ps(dy02,fscal,fiy0);
652             fiz0             = _mm_macc_ps(dz02,fscal,fiz0);
653
654             fjx2             = _mm_macc_ps(dx02,fscal,fjx2);
655             fjy2             = _mm_macc_ps(dy02,fscal,fjy2);
656             fjz2             = _mm_macc_ps(dz02,fscal,fjz2);
657
658             /**************************
659              * CALCULATE INTERACTIONS *
660              **************************/
661
662             /* COULOMB ELECTROSTATICS */
663             velec            = _mm_mul_ps(qq10,rinv10);
664             felec            = _mm_mul_ps(velec,rinvsq10);
665
666             /* Update potential sum for this i atom from the interaction with this j atom. */
667             velec            = _mm_andnot_ps(dummy_mask,velec);
668             velecsum         = _mm_add_ps(velecsum,velec);
669
670             fscal            = felec;
671
672             fscal            = _mm_andnot_ps(dummy_mask,fscal);
673
674              /* Update vectorial force */
675             fix1             = _mm_macc_ps(dx10,fscal,fix1);
676             fiy1             = _mm_macc_ps(dy10,fscal,fiy1);
677             fiz1             = _mm_macc_ps(dz10,fscal,fiz1);
678
679             fjx0             = _mm_macc_ps(dx10,fscal,fjx0);
680             fjy0             = _mm_macc_ps(dy10,fscal,fjy0);
681             fjz0             = _mm_macc_ps(dz10,fscal,fjz0);
682
683             /**************************
684              * CALCULATE INTERACTIONS *
685              **************************/
686
687             /* COULOMB ELECTROSTATICS */
688             velec            = _mm_mul_ps(qq11,rinv11);
689             felec            = _mm_mul_ps(velec,rinvsq11);
690
691             /* Update potential sum for this i atom from the interaction with this j atom. */
692             velec            = _mm_andnot_ps(dummy_mask,velec);
693             velecsum         = _mm_add_ps(velecsum,velec);
694
695             fscal            = felec;
696
697             fscal            = _mm_andnot_ps(dummy_mask,fscal);
698
699              /* Update vectorial force */
700             fix1             = _mm_macc_ps(dx11,fscal,fix1);
701             fiy1             = _mm_macc_ps(dy11,fscal,fiy1);
702             fiz1             = _mm_macc_ps(dz11,fscal,fiz1);
703
704             fjx1             = _mm_macc_ps(dx11,fscal,fjx1);
705             fjy1             = _mm_macc_ps(dy11,fscal,fjy1);
706             fjz1             = _mm_macc_ps(dz11,fscal,fjz1);
707
708             /**************************
709              * CALCULATE INTERACTIONS *
710              **************************/
711
712             /* COULOMB ELECTROSTATICS */
713             velec            = _mm_mul_ps(qq12,rinv12);
714             felec            = _mm_mul_ps(velec,rinvsq12);
715
716             /* Update potential sum for this i atom from the interaction with this j atom. */
717             velec            = _mm_andnot_ps(dummy_mask,velec);
718             velecsum         = _mm_add_ps(velecsum,velec);
719
720             fscal            = felec;
721
722             fscal            = _mm_andnot_ps(dummy_mask,fscal);
723
724              /* Update vectorial force */
725             fix1             = _mm_macc_ps(dx12,fscal,fix1);
726             fiy1             = _mm_macc_ps(dy12,fscal,fiy1);
727             fiz1             = _mm_macc_ps(dz12,fscal,fiz1);
728
729             fjx2             = _mm_macc_ps(dx12,fscal,fjx2);
730             fjy2             = _mm_macc_ps(dy12,fscal,fjy2);
731             fjz2             = _mm_macc_ps(dz12,fscal,fjz2);
732
733             /**************************
734              * CALCULATE INTERACTIONS *
735              **************************/
736
737             /* COULOMB ELECTROSTATICS */
738             velec            = _mm_mul_ps(qq20,rinv20);
739             felec            = _mm_mul_ps(velec,rinvsq20);
740
741             /* Update potential sum for this i atom from the interaction with this j atom. */
742             velec            = _mm_andnot_ps(dummy_mask,velec);
743             velecsum         = _mm_add_ps(velecsum,velec);
744
745             fscal            = felec;
746
747             fscal            = _mm_andnot_ps(dummy_mask,fscal);
748
749              /* Update vectorial force */
750             fix2             = _mm_macc_ps(dx20,fscal,fix2);
751             fiy2             = _mm_macc_ps(dy20,fscal,fiy2);
752             fiz2             = _mm_macc_ps(dz20,fscal,fiz2);
753
754             fjx0             = _mm_macc_ps(dx20,fscal,fjx0);
755             fjy0             = _mm_macc_ps(dy20,fscal,fjy0);
756             fjz0             = _mm_macc_ps(dz20,fscal,fjz0);
757
758             /**************************
759              * CALCULATE INTERACTIONS *
760              **************************/
761
762             /* COULOMB ELECTROSTATICS */
763             velec            = _mm_mul_ps(qq21,rinv21);
764             felec            = _mm_mul_ps(velec,rinvsq21);
765
766             /* Update potential sum for this i atom from the interaction with this j atom. */
767             velec            = _mm_andnot_ps(dummy_mask,velec);
768             velecsum         = _mm_add_ps(velecsum,velec);
769
770             fscal            = felec;
771
772             fscal            = _mm_andnot_ps(dummy_mask,fscal);
773
774              /* Update vectorial force */
775             fix2             = _mm_macc_ps(dx21,fscal,fix2);
776             fiy2             = _mm_macc_ps(dy21,fscal,fiy2);
777             fiz2             = _mm_macc_ps(dz21,fscal,fiz2);
778
779             fjx1             = _mm_macc_ps(dx21,fscal,fjx1);
780             fjy1             = _mm_macc_ps(dy21,fscal,fjy1);
781             fjz1             = _mm_macc_ps(dz21,fscal,fjz1);
782
783             /**************************
784              * CALCULATE INTERACTIONS *
785              **************************/
786
787             /* COULOMB ELECTROSTATICS */
788             velec            = _mm_mul_ps(qq22,rinv22);
789             felec            = _mm_mul_ps(velec,rinvsq22);
790
791             /* Update potential sum for this i atom from the interaction with this j atom. */
792             velec            = _mm_andnot_ps(dummy_mask,velec);
793             velecsum         = _mm_add_ps(velecsum,velec);
794
795             fscal            = felec;
796
797             fscal            = _mm_andnot_ps(dummy_mask,fscal);
798
799              /* Update vectorial force */
800             fix2             = _mm_macc_ps(dx22,fscal,fix2);
801             fiy2             = _mm_macc_ps(dy22,fscal,fiy2);
802             fiz2             = _mm_macc_ps(dz22,fscal,fiz2);
803
804             fjx2             = _mm_macc_ps(dx22,fscal,fjx2);
805             fjy2             = _mm_macc_ps(dy22,fscal,fjy2);
806             fjz2             = _mm_macc_ps(dz22,fscal,fjz2);
807
808             fjptrA             = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
809             fjptrB             = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
810             fjptrC             = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
811             fjptrD             = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
812
813             gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
814                                                    fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
815
816             /* Inner loop uses 279 flops */
817         }
818
819         /* End of innermost loop */
820
821         gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
822                                               f+i_coord_offset,fshift+i_shift_offset);
823
824         ggid                        = gid[iidx];
825         /* Update potential energies */
826         gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
827
828         /* Increment number of inner iterations */
829         inneriter                  += j_index_end - j_index_start;
830
831         /* Outer loop uses 19 flops */
832     }
833
834     /* Increment number of outer iterations */
835     outeriter        += nri;
836
837     /* Update outer/inner flops */
838
839     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3W3_VF,outeriter*19 + inneriter*279);
840 }
841 /*
842  * Gromacs nonbonded kernel:   nb_kernel_ElecCoul_VdwNone_GeomW3W3_F_avx_128_fma_single
843  * Electrostatics interaction: Coulomb
844  * VdW interaction:            None
845  * Geometry:                   Water3-Water3
846  * Calculate force/pot:        Force
847  */
848 void
849 nb_kernel_ElecCoul_VdwNone_GeomW3W3_F_avx_128_fma_single
850                     (t_nblist                    * gmx_restrict       nlist,
851                      rvec                        * gmx_restrict          xx,
852                      rvec                        * gmx_restrict          ff,
853                      struct t_forcerec           * gmx_restrict          fr,
854                      t_mdatoms                   * gmx_restrict     mdatoms,
855                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
856                      t_nrnb                      * gmx_restrict        nrnb)
857 {
858     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
859      * just 0 for non-waters.
860      * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
861      * jnr indices corresponding to data put in the four positions in the SIMD register.
862      */
863     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
864     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
865     int              jnrA,jnrB,jnrC,jnrD;
866     int              jnrlistA,jnrlistB,jnrlistC,jnrlistD;
867     int              j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
868     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
869     real             rcutoff_scalar;
870     real             *shiftvec,*fshift,*x,*f;
871     real             *fjptrA,*fjptrB,*fjptrC,*fjptrD;
872     real             scratch[4*DIM];
873     __m128           fscal,rcutoff,rcutoff2,jidxall;
874     int              vdwioffset0;
875     __m128           ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
876     int              vdwioffset1;
877     __m128           ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
878     int              vdwioffset2;
879     __m128           ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
880     int              vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
881     __m128           jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
882     int              vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D;
883     __m128           jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
884     int              vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D;
885     __m128           jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
886     __m128           dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
887     __m128           dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
888     __m128           dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
889     __m128           dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
890     __m128           dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
891     __m128           dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
892     __m128           dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
893     __m128           dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
894     __m128           dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
895     __m128           velec,felec,velecsum,facel,crf,krf,krf2;
896     real             *charge;
897     __m128           dummy_mask,cutoff_mask;
898     __m128           signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
899     __m128           one     = _mm_set1_ps(1.0);
900     __m128           two     = _mm_set1_ps(2.0);
901     x                = xx[0];
902     f                = ff[0];
903
904     nri              = nlist->nri;
905     iinr             = nlist->iinr;
906     jindex           = nlist->jindex;
907     jjnr             = nlist->jjnr;
908     shiftidx         = nlist->shift;
909     gid              = nlist->gid;
910     shiftvec         = fr->shift_vec[0];
911     fshift           = fr->fshift[0];
912     facel            = _mm_set1_ps(fr->ic->epsfac);
913     charge           = mdatoms->chargeA;
914
915     /* Setup water-specific parameters */
916     inr              = nlist->iinr[0];
917     iq0              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
918     iq1              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
919     iq2              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
920
921     jq0              = _mm_set1_ps(charge[inr+0]);
922     jq1              = _mm_set1_ps(charge[inr+1]);
923     jq2              = _mm_set1_ps(charge[inr+2]);
924     qq00             = _mm_mul_ps(iq0,jq0);
925     qq01             = _mm_mul_ps(iq0,jq1);
926     qq02             = _mm_mul_ps(iq0,jq2);
927     qq10             = _mm_mul_ps(iq1,jq0);
928     qq11             = _mm_mul_ps(iq1,jq1);
929     qq12             = _mm_mul_ps(iq1,jq2);
930     qq20             = _mm_mul_ps(iq2,jq0);
931     qq21             = _mm_mul_ps(iq2,jq1);
932     qq22             = _mm_mul_ps(iq2,jq2);
933
934     /* Avoid stupid compiler warnings */
935     jnrA = jnrB = jnrC = jnrD = 0;
936     j_coord_offsetA = 0;
937     j_coord_offsetB = 0;
938     j_coord_offsetC = 0;
939     j_coord_offsetD = 0;
940
941     outeriter        = 0;
942     inneriter        = 0;
943
944     for(iidx=0;iidx<4*DIM;iidx++)
945     {
946         scratch[iidx] = 0.0;
947     }
948
949     /* Start outer loop over neighborlists */
950     for(iidx=0; iidx<nri; iidx++)
951     {
952         /* Load shift vector for this list */
953         i_shift_offset   = DIM*shiftidx[iidx];
954
955         /* Load limits for loop over neighbors */
956         j_index_start    = jindex[iidx];
957         j_index_end      = jindex[iidx+1];
958
959         /* Get outer coordinate index */
960         inr              = iinr[iidx];
961         i_coord_offset   = DIM*inr;
962
963         /* Load i particle coords and add shift vector */
964         gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
965                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
966
967         fix0             = _mm_setzero_ps();
968         fiy0             = _mm_setzero_ps();
969         fiz0             = _mm_setzero_ps();
970         fix1             = _mm_setzero_ps();
971         fiy1             = _mm_setzero_ps();
972         fiz1             = _mm_setzero_ps();
973         fix2             = _mm_setzero_ps();
974         fiy2             = _mm_setzero_ps();
975         fiz2             = _mm_setzero_ps();
976
977         /* Start inner kernel loop */
978         for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
979         {
980
981             /* Get j neighbor index, and coordinate index */
982             jnrA             = jjnr[jidx];
983             jnrB             = jjnr[jidx+1];
984             jnrC             = jjnr[jidx+2];
985             jnrD             = jjnr[jidx+3];
986             j_coord_offsetA  = DIM*jnrA;
987             j_coord_offsetB  = DIM*jnrB;
988             j_coord_offsetC  = DIM*jnrC;
989             j_coord_offsetD  = DIM*jnrD;
990
991             /* load j atom coordinates */
992             gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
993                                               x+j_coord_offsetC,x+j_coord_offsetD,
994                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
995
996             /* Calculate displacement vector */
997             dx00             = _mm_sub_ps(ix0,jx0);
998             dy00             = _mm_sub_ps(iy0,jy0);
999             dz00             = _mm_sub_ps(iz0,jz0);
1000             dx01             = _mm_sub_ps(ix0,jx1);
1001             dy01             = _mm_sub_ps(iy0,jy1);
1002             dz01             = _mm_sub_ps(iz0,jz1);
1003             dx02             = _mm_sub_ps(ix0,jx2);
1004             dy02             = _mm_sub_ps(iy0,jy2);
1005             dz02             = _mm_sub_ps(iz0,jz2);
1006             dx10             = _mm_sub_ps(ix1,jx0);
1007             dy10             = _mm_sub_ps(iy1,jy0);
1008             dz10             = _mm_sub_ps(iz1,jz0);
1009             dx11             = _mm_sub_ps(ix1,jx1);
1010             dy11             = _mm_sub_ps(iy1,jy1);
1011             dz11             = _mm_sub_ps(iz1,jz1);
1012             dx12             = _mm_sub_ps(ix1,jx2);
1013             dy12             = _mm_sub_ps(iy1,jy2);
1014             dz12             = _mm_sub_ps(iz1,jz2);
1015             dx20             = _mm_sub_ps(ix2,jx0);
1016             dy20             = _mm_sub_ps(iy2,jy0);
1017             dz20             = _mm_sub_ps(iz2,jz0);
1018             dx21             = _mm_sub_ps(ix2,jx1);
1019             dy21             = _mm_sub_ps(iy2,jy1);
1020             dz21             = _mm_sub_ps(iz2,jz1);
1021             dx22             = _mm_sub_ps(ix2,jx2);
1022             dy22             = _mm_sub_ps(iy2,jy2);
1023             dz22             = _mm_sub_ps(iz2,jz2);
1024
1025             /* Calculate squared distance and things based on it */
1026             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1027             rsq01            = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
1028             rsq02            = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
1029             rsq10            = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
1030             rsq11            = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
1031             rsq12            = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
1032             rsq20            = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
1033             rsq21            = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
1034             rsq22            = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
1035
1036             rinv00           = avx128fma_invsqrt_f(rsq00);
1037             rinv01           = avx128fma_invsqrt_f(rsq01);
1038             rinv02           = avx128fma_invsqrt_f(rsq02);
1039             rinv10           = avx128fma_invsqrt_f(rsq10);
1040             rinv11           = avx128fma_invsqrt_f(rsq11);
1041             rinv12           = avx128fma_invsqrt_f(rsq12);
1042             rinv20           = avx128fma_invsqrt_f(rsq20);
1043             rinv21           = avx128fma_invsqrt_f(rsq21);
1044             rinv22           = avx128fma_invsqrt_f(rsq22);
1045
1046             rinvsq00         = _mm_mul_ps(rinv00,rinv00);
1047             rinvsq01         = _mm_mul_ps(rinv01,rinv01);
1048             rinvsq02         = _mm_mul_ps(rinv02,rinv02);
1049             rinvsq10         = _mm_mul_ps(rinv10,rinv10);
1050             rinvsq11         = _mm_mul_ps(rinv11,rinv11);
1051             rinvsq12         = _mm_mul_ps(rinv12,rinv12);
1052             rinvsq20         = _mm_mul_ps(rinv20,rinv20);
1053             rinvsq21         = _mm_mul_ps(rinv21,rinv21);
1054             rinvsq22         = _mm_mul_ps(rinv22,rinv22);
1055
1056             fjx0             = _mm_setzero_ps();
1057             fjy0             = _mm_setzero_ps();
1058             fjz0             = _mm_setzero_ps();
1059             fjx1             = _mm_setzero_ps();
1060             fjy1             = _mm_setzero_ps();
1061             fjz1             = _mm_setzero_ps();
1062             fjx2             = _mm_setzero_ps();
1063             fjy2             = _mm_setzero_ps();
1064             fjz2             = _mm_setzero_ps();
1065
1066             /**************************
1067              * CALCULATE INTERACTIONS *
1068              **************************/
1069
1070             /* COULOMB ELECTROSTATICS */
1071             velec            = _mm_mul_ps(qq00,rinv00);
1072             felec            = _mm_mul_ps(velec,rinvsq00);
1073
1074             fscal            = felec;
1075
1076              /* Update vectorial force */
1077             fix0             = _mm_macc_ps(dx00,fscal,fix0);
1078             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
1079             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
1080
1081             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
1082             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
1083             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
1084
1085             /**************************
1086              * CALCULATE INTERACTIONS *
1087              **************************/
1088
1089             /* COULOMB ELECTROSTATICS */
1090             velec            = _mm_mul_ps(qq01,rinv01);
1091             felec            = _mm_mul_ps(velec,rinvsq01);
1092
1093             fscal            = felec;
1094
1095              /* Update vectorial force */
1096             fix0             = _mm_macc_ps(dx01,fscal,fix0);
1097             fiy0             = _mm_macc_ps(dy01,fscal,fiy0);
1098             fiz0             = _mm_macc_ps(dz01,fscal,fiz0);
1099
1100             fjx1             = _mm_macc_ps(dx01,fscal,fjx1);
1101             fjy1             = _mm_macc_ps(dy01,fscal,fjy1);
1102             fjz1             = _mm_macc_ps(dz01,fscal,fjz1);
1103
1104             /**************************
1105              * CALCULATE INTERACTIONS *
1106              **************************/
1107
1108             /* COULOMB ELECTROSTATICS */
1109             velec            = _mm_mul_ps(qq02,rinv02);
1110             felec            = _mm_mul_ps(velec,rinvsq02);
1111
1112             fscal            = felec;
1113
1114              /* Update vectorial force */
1115             fix0             = _mm_macc_ps(dx02,fscal,fix0);
1116             fiy0             = _mm_macc_ps(dy02,fscal,fiy0);
1117             fiz0             = _mm_macc_ps(dz02,fscal,fiz0);
1118
1119             fjx2             = _mm_macc_ps(dx02,fscal,fjx2);
1120             fjy2             = _mm_macc_ps(dy02,fscal,fjy2);
1121             fjz2             = _mm_macc_ps(dz02,fscal,fjz2);
1122
1123             /**************************
1124              * CALCULATE INTERACTIONS *
1125              **************************/
1126
1127             /* COULOMB ELECTROSTATICS */
1128             velec            = _mm_mul_ps(qq10,rinv10);
1129             felec            = _mm_mul_ps(velec,rinvsq10);
1130
1131             fscal            = felec;
1132
1133              /* Update vectorial force */
1134             fix1             = _mm_macc_ps(dx10,fscal,fix1);
1135             fiy1             = _mm_macc_ps(dy10,fscal,fiy1);
1136             fiz1             = _mm_macc_ps(dz10,fscal,fiz1);
1137
1138             fjx0             = _mm_macc_ps(dx10,fscal,fjx0);
1139             fjy0             = _mm_macc_ps(dy10,fscal,fjy0);
1140             fjz0             = _mm_macc_ps(dz10,fscal,fjz0);
1141
1142             /**************************
1143              * CALCULATE INTERACTIONS *
1144              **************************/
1145
1146             /* COULOMB ELECTROSTATICS */
1147             velec            = _mm_mul_ps(qq11,rinv11);
1148             felec            = _mm_mul_ps(velec,rinvsq11);
1149
1150             fscal            = felec;
1151
1152              /* Update vectorial force */
1153             fix1             = _mm_macc_ps(dx11,fscal,fix1);
1154             fiy1             = _mm_macc_ps(dy11,fscal,fiy1);
1155             fiz1             = _mm_macc_ps(dz11,fscal,fiz1);
1156
1157             fjx1             = _mm_macc_ps(dx11,fscal,fjx1);
1158             fjy1             = _mm_macc_ps(dy11,fscal,fjy1);
1159             fjz1             = _mm_macc_ps(dz11,fscal,fjz1);
1160
1161             /**************************
1162              * CALCULATE INTERACTIONS *
1163              **************************/
1164
1165             /* COULOMB ELECTROSTATICS */
1166             velec            = _mm_mul_ps(qq12,rinv12);
1167             felec            = _mm_mul_ps(velec,rinvsq12);
1168
1169             fscal            = felec;
1170
1171              /* Update vectorial force */
1172             fix1             = _mm_macc_ps(dx12,fscal,fix1);
1173             fiy1             = _mm_macc_ps(dy12,fscal,fiy1);
1174             fiz1             = _mm_macc_ps(dz12,fscal,fiz1);
1175
1176             fjx2             = _mm_macc_ps(dx12,fscal,fjx2);
1177             fjy2             = _mm_macc_ps(dy12,fscal,fjy2);
1178             fjz2             = _mm_macc_ps(dz12,fscal,fjz2);
1179
1180             /**************************
1181              * CALCULATE INTERACTIONS *
1182              **************************/
1183
1184             /* COULOMB ELECTROSTATICS */
1185             velec            = _mm_mul_ps(qq20,rinv20);
1186             felec            = _mm_mul_ps(velec,rinvsq20);
1187
1188             fscal            = felec;
1189
1190              /* Update vectorial force */
1191             fix2             = _mm_macc_ps(dx20,fscal,fix2);
1192             fiy2             = _mm_macc_ps(dy20,fscal,fiy2);
1193             fiz2             = _mm_macc_ps(dz20,fscal,fiz2);
1194
1195             fjx0             = _mm_macc_ps(dx20,fscal,fjx0);
1196             fjy0             = _mm_macc_ps(dy20,fscal,fjy0);
1197             fjz0             = _mm_macc_ps(dz20,fscal,fjz0);
1198
1199             /**************************
1200              * CALCULATE INTERACTIONS *
1201              **************************/
1202
1203             /* COULOMB ELECTROSTATICS */
1204             velec            = _mm_mul_ps(qq21,rinv21);
1205             felec            = _mm_mul_ps(velec,rinvsq21);
1206
1207             fscal            = felec;
1208
1209              /* Update vectorial force */
1210             fix2             = _mm_macc_ps(dx21,fscal,fix2);
1211             fiy2             = _mm_macc_ps(dy21,fscal,fiy2);
1212             fiz2             = _mm_macc_ps(dz21,fscal,fiz2);
1213
1214             fjx1             = _mm_macc_ps(dx21,fscal,fjx1);
1215             fjy1             = _mm_macc_ps(dy21,fscal,fjy1);
1216             fjz1             = _mm_macc_ps(dz21,fscal,fjz1);
1217
1218             /**************************
1219              * CALCULATE INTERACTIONS *
1220              **************************/
1221
1222             /* COULOMB ELECTROSTATICS */
1223             velec            = _mm_mul_ps(qq22,rinv22);
1224             felec            = _mm_mul_ps(velec,rinvsq22);
1225
1226             fscal            = felec;
1227
1228              /* Update vectorial force */
1229             fix2             = _mm_macc_ps(dx22,fscal,fix2);
1230             fiy2             = _mm_macc_ps(dy22,fscal,fiy2);
1231             fiz2             = _mm_macc_ps(dz22,fscal,fiz2);
1232
1233             fjx2             = _mm_macc_ps(dx22,fscal,fjx2);
1234             fjy2             = _mm_macc_ps(dy22,fscal,fjy2);
1235             fjz2             = _mm_macc_ps(dz22,fscal,fjz2);
1236
1237             fjptrA             = f+j_coord_offsetA;
1238             fjptrB             = f+j_coord_offsetB;
1239             fjptrC             = f+j_coord_offsetC;
1240             fjptrD             = f+j_coord_offsetD;
1241
1242             gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
1243                                                    fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1244
1245             /* Inner loop uses 270 flops */
1246         }
1247
1248         if(jidx<j_index_end)
1249         {
1250
1251             /* Get j neighbor index, and coordinate index */
1252             jnrlistA         = jjnr[jidx];
1253             jnrlistB         = jjnr[jidx+1];
1254             jnrlistC         = jjnr[jidx+2];
1255             jnrlistD         = jjnr[jidx+3];
1256             /* Sign of each element will be negative for non-real atoms.
1257              * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1258              * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1259              */
1260             dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
1261             jnrA       = (jnrlistA>=0) ? jnrlistA : 0;
1262             jnrB       = (jnrlistB>=0) ? jnrlistB : 0;
1263             jnrC       = (jnrlistC>=0) ? jnrlistC : 0;
1264             jnrD       = (jnrlistD>=0) ? jnrlistD : 0;
1265             j_coord_offsetA  = DIM*jnrA;
1266             j_coord_offsetB  = DIM*jnrB;
1267             j_coord_offsetC  = DIM*jnrC;
1268             j_coord_offsetD  = DIM*jnrD;
1269
1270             /* load j atom coordinates */
1271             gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1272                                               x+j_coord_offsetC,x+j_coord_offsetD,
1273                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1274
1275             /* Calculate displacement vector */
1276             dx00             = _mm_sub_ps(ix0,jx0);
1277             dy00             = _mm_sub_ps(iy0,jy0);
1278             dz00             = _mm_sub_ps(iz0,jz0);
1279             dx01             = _mm_sub_ps(ix0,jx1);
1280             dy01             = _mm_sub_ps(iy0,jy1);
1281             dz01             = _mm_sub_ps(iz0,jz1);
1282             dx02             = _mm_sub_ps(ix0,jx2);
1283             dy02             = _mm_sub_ps(iy0,jy2);
1284             dz02             = _mm_sub_ps(iz0,jz2);
1285             dx10             = _mm_sub_ps(ix1,jx0);
1286             dy10             = _mm_sub_ps(iy1,jy0);
1287             dz10             = _mm_sub_ps(iz1,jz0);
1288             dx11             = _mm_sub_ps(ix1,jx1);
1289             dy11             = _mm_sub_ps(iy1,jy1);
1290             dz11             = _mm_sub_ps(iz1,jz1);
1291             dx12             = _mm_sub_ps(ix1,jx2);
1292             dy12             = _mm_sub_ps(iy1,jy2);
1293             dz12             = _mm_sub_ps(iz1,jz2);
1294             dx20             = _mm_sub_ps(ix2,jx0);
1295             dy20             = _mm_sub_ps(iy2,jy0);
1296             dz20             = _mm_sub_ps(iz2,jz0);
1297             dx21             = _mm_sub_ps(ix2,jx1);
1298             dy21             = _mm_sub_ps(iy2,jy1);
1299             dz21             = _mm_sub_ps(iz2,jz1);
1300             dx22             = _mm_sub_ps(ix2,jx2);
1301             dy22             = _mm_sub_ps(iy2,jy2);
1302             dz22             = _mm_sub_ps(iz2,jz2);
1303
1304             /* Calculate squared distance and things based on it */
1305             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1306             rsq01            = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
1307             rsq02            = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
1308             rsq10            = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
1309             rsq11            = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
1310             rsq12            = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
1311             rsq20            = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
1312             rsq21            = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
1313             rsq22            = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
1314
1315             rinv00           = avx128fma_invsqrt_f(rsq00);
1316             rinv01           = avx128fma_invsqrt_f(rsq01);
1317             rinv02           = avx128fma_invsqrt_f(rsq02);
1318             rinv10           = avx128fma_invsqrt_f(rsq10);
1319             rinv11           = avx128fma_invsqrt_f(rsq11);
1320             rinv12           = avx128fma_invsqrt_f(rsq12);
1321             rinv20           = avx128fma_invsqrt_f(rsq20);
1322             rinv21           = avx128fma_invsqrt_f(rsq21);
1323             rinv22           = avx128fma_invsqrt_f(rsq22);
1324
1325             rinvsq00         = _mm_mul_ps(rinv00,rinv00);
1326             rinvsq01         = _mm_mul_ps(rinv01,rinv01);
1327             rinvsq02         = _mm_mul_ps(rinv02,rinv02);
1328             rinvsq10         = _mm_mul_ps(rinv10,rinv10);
1329             rinvsq11         = _mm_mul_ps(rinv11,rinv11);
1330             rinvsq12         = _mm_mul_ps(rinv12,rinv12);
1331             rinvsq20         = _mm_mul_ps(rinv20,rinv20);
1332             rinvsq21         = _mm_mul_ps(rinv21,rinv21);
1333             rinvsq22         = _mm_mul_ps(rinv22,rinv22);
1334
1335             fjx0             = _mm_setzero_ps();
1336             fjy0             = _mm_setzero_ps();
1337             fjz0             = _mm_setzero_ps();
1338             fjx1             = _mm_setzero_ps();
1339             fjy1             = _mm_setzero_ps();
1340             fjz1             = _mm_setzero_ps();
1341             fjx2             = _mm_setzero_ps();
1342             fjy2             = _mm_setzero_ps();
1343             fjz2             = _mm_setzero_ps();
1344
1345             /**************************
1346              * CALCULATE INTERACTIONS *
1347              **************************/
1348
1349             /* COULOMB ELECTROSTATICS */
1350             velec            = _mm_mul_ps(qq00,rinv00);
1351             felec            = _mm_mul_ps(velec,rinvsq00);
1352
1353             fscal            = felec;
1354
1355             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1356
1357              /* Update vectorial force */
1358             fix0             = _mm_macc_ps(dx00,fscal,fix0);
1359             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
1360             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
1361
1362             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
1363             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
1364             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
1365
1366             /**************************
1367              * CALCULATE INTERACTIONS *
1368              **************************/
1369
1370             /* COULOMB ELECTROSTATICS */
1371             velec            = _mm_mul_ps(qq01,rinv01);
1372             felec            = _mm_mul_ps(velec,rinvsq01);
1373
1374             fscal            = felec;
1375
1376             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1377
1378              /* Update vectorial force */
1379             fix0             = _mm_macc_ps(dx01,fscal,fix0);
1380             fiy0             = _mm_macc_ps(dy01,fscal,fiy0);
1381             fiz0             = _mm_macc_ps(dz01,fscal,fiz0);
1382
1383             fjx1             = _mm_macc_ps(dx01,fscal,fjx1);
1384             fjy1             = _mm_macc_ps(dy01,fscal,fjy1);
1385             fjz1             = _mm_macc_ps(dz01,fscal,fjz1);
1386
1387             /**************************
1388              * CALCULATE INTERACTIONS *
1389              **************************/
1390
1391             /* COULOMB ELECTROSTATICS */
1392             velec            = _mm_mul_ps(qq02,rinv02);
1393             felec            = _mm_mul_ps(velec,rinvsq02);
1394
1395             fscal            = felec;
1396
1397             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1398
1399              /* Update vectorial force */
1400             fix0             = _mm_macc_ps(dx02,fscal,fix0);
1401             fiy0             = _mm_macc_ps(dy02,fscal,fiy0);
1402             fiz0             = _mm_macc_ps(dz02,fscal,fiz0);
1403
1404             fjx2             = _mm_macc_ps(dx02,fscal,fjx2);
1405             fjy2             = _mm_macc_ps(dy02,fscal,fjy2);
1406             fjz2             = _mm_macc_ps(dz02,fscal,fjz2);
1407
1408             /**************************
1409              * CALCULATE INTERACTIONS *
1410              **************************/
1411
1412             /* COULOMB ELECTROSTATICS */
1413             velec            = _mm_mul_ps(qq10,rinv10);
1414             felec            = _mm_mul_ps(velec,rinvsq10);
1415
1416             fscal            = felec;
1417
1418             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1419
1420              /* Update vectorial force */
1421             fix1             = _mm_macc_ps(dx10,fscal,fix1);
1422             fiy1             = _mm_macc_ps(dy10,fscal,fiy1);
1423             fiz1             = _mm_macc_ps(dz10,fscal,fiz1);
1424
1425             fjx0             = _mm_macc_ps(dx10,fscal,fjx0);
1426             fjy0             = _mm_macc_ps(dy10,fscal,fjy0);
1427             fjz0             = _mm_macc_ps(dz10,fscal,fjz0);
1428
1429             /**************************
1430              * CALCULATE INTERACTIONS *
1431              **************************/
1432
1433             /* COULOMB ELECTROSTATICS */
1434             velec            = _mm_mul_ps(qq11,rinv11);
1435             felec            = _mm_mul_ps(velec,rinvsq11);
1436
1437             fscal            = felec;
1438
1439             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1440
1441              /* Update vectorial force */
1442             fix1             = _mm_macc_ps(dx11,fscal,fix1);
1443             fiy1             = _mm_macc_ps(dy11,fscal,fiy1);
1444             fiz1             = _mm_macc_ps(dz11,fscal,fiz1);
1445
1446             fjx1             = _mm_macc_ps(dx11,fscal,fjx1);
1447             fjy1             = _mm_macc_ps(dy11,fscal,fjy1);
1448             fjz1             = _mm_macc_ps(dz11,fscal,fjz1);
1449
1450             /**************************
1451              * CALCULATE INTERACTIONS *
1452              **************************/
1453
1454             /* COULOMB ELECTROSTATICS */
1455             velec            = _mm_mul_ps(qq12,rinv12);
1456             felec            = _mm_mul_ps(velec,rinvsq12);
1457
1458             fscal            = felec;
1459
1460             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1461
1462              /* Update vectorial force */
1463             fix1             = _mm_macc_ps(dx12,fscal,fix1);
1464             fiy1             = _mm_macc_ps(dy12,fscal,fiy1);
1465             fiz1             = _mm_macc_ps(dz12,fscal,fiz1);
1466
1467             fjx2             = _mm_macc_ps(dx12,fscal,fjx2);
1468             fjy2             = _mm_macc_ps(dy12,fscal,fjy2);
1469             fjz2             = _mm_macc_ps(dz12,fscal,fjz2);
1470
1471             /**************************
1472              * CALCULATE INTERACTIONS *
1473              **************************/
1474
1475             /* COULOMB ELECTROSTATICS */
1476             velec            = _mm_mul_ps(qq20,rinv20);
1477             felec            = _mm_mul_ps(velec,rinvsq20);
1478
1479             fscal            = felec;
1480
1481             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1482
1483              /* Update vectorial force */
1484             fix2             = _mm_macc_ps(dx20,fscal,fix2);
1485             fiy2             = _mm_macc_ps(dy20,fscal,fiy2);
1486             fiz2             = _mm_macc_ps(dz20,fscal,fiz2);
1487
1488             fjx0             = _mm_macc_ps(dx20,fscal,fjx0);
1489             fjy0             = _mm_macc_ps(dy20,fscal,fjy0);
1490             fjz0             = _mm_macc_ps(dz20,fscal,fjz0);
1491
1492             /**************************
1493              * CALCULATE INTERACTIONS *
1494              **************************/
1495
1496             /* COULOMB ELECTROSTATICS */
1497             velec            = _mm_mul_ps(qq21,rinv21);
1498             felec            = _mm_mul_ps(velec,rinvsq21);
1499
1500             fscal            = felec;
1501
1502             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1503
1504              /* Update vectorial force */
1505             fix2             = _mm_macc_ps(dx21,fscal,fix2);
1506             fiy2             = _mm_macc_ps(dy21,fscal,fiy2);
1507             fiz2             = _mm_macc_ps(dz21,fscal,fiz2);
1508
1509             fjx1             = _mm_macc_ps(dx21,fscal,fjx1);
1510             fjy1             = _mm_macc_ps(dy21,fscal,fjy1);
1511             fjz1             = _mm_macc_ps(dz21,fscal,fjz1);
1512
1513             /**************************
1514              * CALCULATE INTERACTIONS *
1515              **************************/
1516
1517             /* COULOMB ELECTROSTATICS */
1518             velec            = _mm_mul_ps(qq22,rinv22);
1519             felec            = _mm_mul_ps(velec,rinvsq22);
1520
1521             fscal            = felec;
1522
1523             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1524
1525              /* Update vectorial force */
1526             fix2             = _mm_macc_ps(dx22,fscal,fix2);
1527             fiy2             = _mm_macc_ps(dy22,fscal,fiy2);
1528             fiz2             = _mm_macc_ps(dz22,fscal,fiz2);
1529
1530             fjx2             = _mm_macc_ps(dx22,fscal,fjx2);
1531             fjy2             = _mm_macc_ps(dy22,fscal,fjy2);
1532             fjz2             = _mm_macc_ps(dz22,fscal,fjz2);
1533
1534             fjptrA             = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1535             fjptrB             = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1536             fjptrC             = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1537             fjptrD             = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1538
1539             gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
1540                                                    fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1541
1542             /* Inner loop uses 270 flops */
1543         }
1544
1545         /* End of innermost loop */
1546
1547         gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
1548                                               f+i_coord_offset,fshift+i_shift_offset);
1549
1550         /* Increment number of inner iterations */
1551         inneriter                  += j_index_end - j_index_start;
1552
1553         /* Outer loop uses 18 flops */
1554     }
1555
1556     /* Increment number of outer iterations */
1557     outeriter        += nri;
1558
1559     /* Update outer/inner flops */
1560
1561     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3W3_F,outeriter*18 + inneriter*270);
1562 }