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