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