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