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