Merge release-5-0 into master
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_avx_128_fma_double / nb_kernel_ElecRF_VdwNone_GeomW4W4_avx_128_fma_double.c
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6  * and including many others, as listed in the AUTHORS file in the
7  * top-level source directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35 /*
36  * Note: this file was generated by the GROMACS avx_128_fma_double kernel generator.
37  */
38 #include "gmxpre.h"
39
40 #include "config.h"
41
42 #include <math.h>
43
44 #include "../nb_kernel.h"
45 #include "gromacs/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
48
49 #include "gromacs/simd/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_GeomW4W4_VF_avx_128_fma_double
54  * Electrostatics interaction: ReactionField
55  * VdW interaction:            None
56  * Geometry:                   Water4-Water4
57  * Calculate force/pot:        PotentialAndForce
58  */
59 void
60 nb_kernel_ElecRF_VdwNone_GeomW4W4_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              vdwioffset1;
83     __m128d          ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
84     int              vdwioffset2;
85     __m128d          ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
86     int              vdwioffset3;
87     __m128d          ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
88     int              vdwjidx1A,vdwjidx1B;
89     __m128d          jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
90     int              vdwjidx2A,vdwjidx2B;
91     __m128d          jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
92     int              vdwjidx3A,vdwjidx3B;
93     __m128d          jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
94     __m128d          dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
95     __m128d          dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
96     __m128d          dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
97     __m128d          dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
98     __m128d          dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
99     __m128d          dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
100     __m128d          dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
101     __m128d          dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
102     __m128d          dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
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     iq1              = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
129     iq2              = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
130     iq3              = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
131
132     jq1              = _mm_set1_pd(charge[inr+1]);
133     jq2              = _mm_set1_pd(charge[inr+2]);
134     jq3              = _mm_set1_pd(charge[inr+3]);
135     qq11             = _mm_mul_pd(iq1,jq1);
136     qq12             = _mm_mul_pd(iq1,jq2);
137     qq13             = _mm_mul_pd(iq1,jq3);
138     qq21             = _mm_mul_pd(iq2,jq1);
139     qq22             = _mm_mul_pd(iq2,jq2);
140     qq23             = _mm_mul_pd(iq2,jq3);
141     qq31             = _mm_mul_pd(iq3,jq1);
142     qq32             = _mm_mul_pd(iq3,jq2);
143     qq33             = _mm_mul_pd(iq3,jq3);
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+DIM,
169                                                  &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
170
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         fix3             = _mm_setzero_pd();
178         fiy3             = _mm_setzero_pd();
179         fiz3             = _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+DIM,x+j_coord_offsetB+DIM,
196                                               &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
197
198             /* Calculate displacement vector */
199             dx11             = _mm_sub_pd(ix1,jx1);
200             dy11             = _mm_sub_pd(iy1,jy1);
201             dz11             = _mm_sub_pd(iz1,jz1);
202             dx12             = _mm_sub_pd(ix1,jx2);
203             dy12             = _mm_sub_pd(iy1,jy2);
204             dz12             = _mm_sub_pd(iz1,jz2);
205             dx13             = _mm_sub_pd(ix1,jx3);
206             dy13             = _mm_sub_pd(iy1,jy3);
207             dz13             = _mm_sub_pd(iz1,jz3);
208             dx21             = _mm_sub_pd(ix2,jx1);
209             dy21             = _mm_sub_pd(iy2,jy1);
210             dz21             = _mm_sub_pd(iz2,jz1);
211             dx22             = _mm_sub_pd(ix2,jx2);
212             dy22             = _mm_sub_pd(iy2,jy2);
213             dz22             = _mm_sub_pd(iz2,jz2);
214             dx23             = _mm_sub_pd(ix2,jx3);
215             dy23             = _mm_sub_pd(iy2,jy3);
216             dz23             = _mm_sub_pd(iz2,jz3);
217             dx31             = _mm_sub_pd(ix3,jx1);
218             dy31             = _mm_sub_pd(iy3,jy1);
219             dz31             = _mm_sub_pd(iz3,jz1);
220             dx32             = _mm_sub_pd(ix3,jx2);
221             dy32             = _mm_sub_pd(iy3,jy2);
222             dz32             = _mm_sub_pd(iz3,jz2);
223             dx33             = _mm_sub_pd(ix3,jx3);
224             dy33             = _mm_sub_pd(iy3,jy3);
225             dz33             = _mm_sub_pd(iz3,jz3);
226
227             /* Calculate squared distance and things based on it */
228             rsq11            = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
229             rsq12            = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
230             rsq13            = gmx_mm_calc_rsq_pd(dx13,dy13,dz13);
231             rsq21            = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
232             rsq22            = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
233             rsq23            = gmx_mm_calc_rsq_pd(dx23,dy23,dz23);
234             rsq31            = gmx_mm_calc_rsq_pd(dx31,dy31,dz31);
235             rsq32            = gmx_mm_calc_rsq_pd(dx32,dy32,dz32);
236             rsq33            = gmx_mm_calc_rsq_pd(dx33,dy33,dz33);
237
238             rinv11           = gmx_mm_invsqrt_pd(rsq11);
239             rinv12           = gmx_mm_invsqrt_pd(rsq12);
240             rinv13           = gmx_mm_invsqrt_pd(rsq13);
241             rinv21           = gmx_mm_invsqrt_pd(rsq21);
242             rinv22           = gmx_mm_invsqrt_pd(rsq22);
243             rinv23           = gmx_mm_invsqrt_pd(rsq23);
244             rinv31           = gmx_mm_invsqrt_pd(rsq31);
245             rinv32           = gmx_mm_invsqrt_pd(rsq32);
246             rinv33           = gmx_mm_invsqrt_pd(rsq33);
247
248             rinvsq11         = _mm_mul_pd(rinv11,rinv11);
249             rinvsq12         = _mm_mul_pd(rinv12,rinv12);
250             rinvsq13         = _mm_mul_pd(rinv13,rinv13);
251             rinvsq21         = _mm_mul_pd(rinv21,rinv21);
252             rinvsq22         = _mm_mul_pd(rinv22,rinv22);
253             rinvsq23         = _mm_mul_pd(rinv23,rinv23);
254             rinvsq31         = _mm_mul_pd(rinv31,rinv31);
255             rinvsq32         = _mm_mul_pd(rinv32,rinv32);
256             rinvsq33         = _mm_mul_pd(rinv33,rinv33);
257
258             fjx1             = _mm_setzero_pd();
259             fjy1             = _mm_setzero_pd();
260             fjz1             = _mm_setzero_pd();
261             fjx2             = _mm_setzero_pd();
262             fjy2             = _mm_setzero_pd();
263             fjz2             = _mm_setzero_pd();
264             fjx3             = _mm_setzero_pd();
265             fjy3             = _mm_setzero_pd();
266             fjz3             = _mm_setzero_pd();
267
268             /**************************
269              * CALCULATE INTERACTIONS *
270              **************************/
271
272             /* REACTION-FIELD ELECTROSTATICS */
273             velec            = _mm_mul_pd(qq11,_mm_sub_pd(_mm_macc_pd(krf,rsq11,rinv11),crf));
274             felec            = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,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             fix1             = _mm_macc_pd(dx11,fscal,fix1);
283             fiy1             = _mm_macc_pd(dy11,fscal,fiy1);
284             fiz1             = _mm_macc_pd(dz11,fscal,fiz1);
285             
286             fjx1             = _mm_macc_pd(dx11,fscal,fjx1);
287             fjy1             = _mm_macc_pd(dy11,fscal,fjy1);
288             fjz1             = _mm_macc_pd(dz11,fscal,fjz1);
289
290             /**************************
291              * CALCULATE INTERACTIONS *
292              **************************/
293
294             /* REACTION-FIELD ELECTROSTATICS */
295             velec            = _mm_mul_pd(qq12,_mm_sub_pd(_mm_macc_pd(krf,rsq12,rinv12),crf));
296             felec            = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,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             fix1             = _mm_macc_pd(dx12,fscal,fix1);
305             fiy1             = _mm_macc_pd(dy12,fscal,fiy1);
306             fiz1             = _mm_macc_pd(dz12,fscal,fiz1);
307             
308             fjx2             = _mm_macc_pd(dx12,fscal,fjx2);
309             fjy2             = _mm_macc_pd(dy12,fscal,fjy2);
310             fjz2             = _mm_macc_pd(dz12,fscal,fjz2);
311
312             /**************************
313              * CALCULATE INTERACTIONS *
314              **************************/
315
316             /* REACTION-FIELD ELECTROSTATICS */
317             velec            = _mm_mul_pd(qq13,_mm_sub_pd(_mm_macc_pd(krf,rsq13,rinv13),crf));
318             felec            = _mm_mul_pd(qq13,_mm_msub_pd(rinv13,rinvsq13,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             fix1             = _mm_macc_pd(dx13,fscal,fix1);
327             fiy1             = _mm_macc_pd(dy13,fscal,fiy1);
328             fiz1             = _mm_macc_pd(dz13,fscal,fiz1);
329             
330             fjx3             = _mm_macc_pd(dx13,fscal,fjx3);
331             fjy3             = _mm_macc_pd(dy13,fscal,fjy3);
332             fjz3             = _mm_macc_pd(dz13,fscal,fjz3);
333
334             /**************************
335              * CALCULATE INTERACTIONS *
336              **************************/
337
338             /* REACTION-FIELD ELECTROSTATICS */
339             velec            = _mm_mul_pd(qq21,_mm_sub_pd(_mm_macc_pd(krf,rsq21,rinv21),crf));
340             felec            = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,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             fix2             = _mm_macc_pd(dx21,fscal,fix2);
349             fiy2             = _mm_macc_pd(dy21,fscal,fiy2);
350             fiz2             = _mm_macc_pd(dz21,fscal,fiz2);
351             
352             fjx1             = _mm_macc_pd(dx21,fscal,fjx1);
353             fjy1             = _mm_macc_pd(dy21,fscal,fjy1);
354             fjz1             = _mm_macc_pd(dz21,fscal,fjz1);
355
356             /**************************
357              * CALCULATE INTERACTIONS *
358              **************************/
359
360             /* REACTION-FIELD ELECTROSTATICS */
361             velec            = _mm_mul_pd(qq22,_mm_sub_pd(_mm_macc_pd(krf,rsq22,rinv22),crf));
362             felec            = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,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             fix2             = _mm_macc_pd(dx22,fscal,fix2);
371             fiy2             = _mm_macc_pd(dy22,fscal,fiy2);
372             fiz2             = _mm_macc_pd(dz22,fscal,fiz2);
373             
374             fjx2             = _mm_macc_pd(dx22,fscal,fjx2);
375             fjy2             = _mm_macc_pd(dy22,fscal,fjy2);
376             fjz2             = _mm_macc_pd(dz22,fscal,fjz2);
377
378             /**************************
379              * CALCULATE INTERACTIONS *
380              **************************/
381
382             /* REACTION-FIELD ELECTROSTATICS */
383             velec            = _mm_mul_pd(qq23,_mm_sub_pd(_mm_macc_pd(krf,rsq23,rinv23),crf));
384             felec            = _mm_mul_pd(qq23,_mm_msub_pd(rinv23,rinvsq23,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             fix2             = _mm_macc_pd(dx23,fscal,fix2);
393             fiy2             = _mm_macc_pd(dy23,fscal,fiy2);
394             fiz2             = _mm_macc_pd(dz23,fscal,fiz2);
395             
396             fjx3             = _mm_macc_pd(dx23,fscal,fjx3);
397             fjy3             = _mm_macc_pd(dy23,fscal,fjy3);
398             fjz3             = _mm_macc_pd(dz23,fscal,fjz3);
399
400             /**************************
401              * CALCULATE INTERACTIONS *
402              **************************/
403
404             /* REACTION-FIELD ELECTROSTATICS */
405             velec            = _mm_mul_pd(qq31,_mm_sub_pd(_mm_macc_pd(krf,rsq31,rinv31),crf));
406             felec            = _mm_mul_pd(qq31,_mm_msub_pd(rinv31,rinvsq31,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             fix3             = _mm_macc_pd(dx31,fscal,fix3);
415             fiy3             = _mm_macc_pd(dy31,fscal,fiy3);
416             fiz3             = _mm_macc_pd(dz31,fscal,fiz3);
417             
418             fjx1             = _mm_macc_pd(dx31,fscal,fjx1);
419             fjy1             = _mm_macc_pd(dy31,fscal,fjy1);
420             fjz1             = _mm_macc_pd(dz31,fscal,fjz1);
421
422             /**************************
423              * CALCULATE INTERACTIONS *
424              **************************/
425
426             /* REACTION-FIELD ELECTROSTATICS */
427             velec            = _mm_mul_pd(qq32,_mm_sub_pd(_mm_macc_pd(krf,rsq32,rinv32),crf));
428             felec            = _mm_mul_pd(qq32,_mm_msub_pd(rinv32,rinvsq32,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             fix3             = _mm_macc_pd(dx32,fscal,fix3);
437             fiy3             = _mm_macc_pd(dy32,fscal,fiy3);
438             fiz3             = _mm_macc_pd(dz32,fscal,fiz3);
439             
440             fjx2             = _mm_macc_pd(dx32,fscal,fjx2);
441             fjy2             = _mm_macc_pd(dy32,fscal,fjy2);
442             fjz2             = _mm_macc_pd(dz32,fscal,fjz2);
443
444             /**************************
445              * CALCULATE INTERACTIONS *
446              **************************/
447
448             /* REACTION-FIELD ELECTROSTATICS */
449             velec            = _mm_mul_pd(qq33,_mm_sub_pd(_mm_macc_pd(krf,rsq33,rinv33),crf));
450             felec            = _mm_mul_pd(qq33,_mm_msub_pd(rinv33,rinvsq33,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             fix3             = _mm_macc_pd(dx33,fscal,fix3);
459             fiy3             = _mm_macc_pd(dy33,fscal,fiy3);
460             fiz3             = _mm_macc_pd(dz33,fscal,fiz3);
461             
462             fjx3             = _mm_macc_pd(dx33,fscal,fjx3);
463             fjy3             = _mm_macc_pd(dy33,fscal,fjy3);
464             fjz3             = _mm_macc_pd(dz33,fscal,fjz3);
465
466             gmx_mm_decrement_3rvec_2ptr_swizzle_pd(f+j_coord_offsetA+DIM,f+j_coord_offsetB+DIM,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
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+DIM,
479                                               &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
480
481             /* Calculate displacement vector */
482             dx11             = _mm_sub_pd(ix1,jx1);
483             dy11             = _mm_sub_pd(iy1,jy1);
484             dz11             = _mm_sub_pd(iz1,jz1);
485             dx12             = _mm_sub_pd(ix1,jx2);
486             dy12             = _mm_sub_pd(iy1,jy2);
487             dz12             = _mm_sub_pd(iz1,jz2);
488             dx13             = _mm_sub_pd(ix1,jx3);
489             dy13             = _mm_sub_pd(iy1,jy3);
490             dz13             = _mm_sub_pd(iz1,jz3);
491             dx21             = _mm_sub_pd(ix2,jx1);
492             dy21             = _mm_sub_pd(iy2,jy1);
493             dz21             = _mm_sub_pd(iz2,jz1);
494             dx22             = _mm_sub_pd(ix2,jx2);
495             dy22             = _mm_sub_pd(iy2,jy2);
496             dz22             = _mm_sub_pd(iz2,jz2);
497             dx23             = _mm_sub_pd(ix2,jx3);
498             dy23             = _mm_sub_pd(iy2,jy3);
499             dz23             = _mm_sub_pd(iz2,jz3);
500             dx31             = _mm_sub_pd(ix3,jx1);
501             dy31             = _mm_sub_pd(iy3,jy1);
502             dz31             = _mm_sub_pd(iz3,jz1);
503             dx32             = _mm_sub_pd(ix3,jx2);
504             dy32             = _mm_sub_pd(iy3,jy2);
505             dz32             = _mm_sub_pd(iz3,jz2);
506             dx33             = _mm_sub_pd(ix3,jx3);
507             dy33             = _mm_sub_pd(iy3,jy3);
508             dz33             = _mm_sub_pd(iz3,jz3);
509
510             /* Calculate squared distance and things based on it */
511             rsq11            = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
512             rsq12            = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
513             rsq13            = gmx_mm_calc_rsq_pd(dx13,dy13,dz13);
514             rsq21            = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
515             rsq22            = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
516             rsq23            = gmx_mm_calc_rsq_pd(dx23,dy23,dz23);
517             rsq31            = gmx_mm_calc_rsq_pd(dx31,dy31,dz31);
518             rsq32            = gmx_mm_calc_rsq_pd(dx32,dy32,dz32);
519             rsq33            = gmx_mm_calc_rsq_pd(dx33,dy33,dz33);
520
521             rinv11           = gmx_mm_invsqrt_pd(rsq11);
522             rinv12           = gmx_mm_invsqrt_pd(rsq12);
523             rinv13           = gmx_mm_invsqrt_pd(rsq13);
524             rinv21           = gmx_mm_invsqrt_pd(rsq21);
525             rinv22           = gmx_mm_invsqrt_pd(rsq22);
526             rinv23           = gmx_mm_invsqrt_pd(rsq23);
527             rinv31           = gmx_mm_invsqrt_pd(rsq31);
528             rinv32           = gmx_mm_invsqrt_pd(rsq32);
529             rinv33           = gmx_mm_invsqrt_pd(rsq33);
530
531             rinvsq11         = _mm_mul_pd(rinv11,rinv11);
532             rinvsq12         = _mm_mul_pd(rinv12,rinv12);
533             rinvsq13         = _mm_mul_pd(rinv13,rinv13);
534             rinvsq21         = _mm_mul_pd(rinv21,rinv21);
535             rinvsq22         = _mm_mul_pd(rinv22,rinv22);
536             rinvsq23         = _mm_mul_pd(rinv23,rinv23);
537             rinvsq31         = _mm_mul_pd(rinv31,rinv31);
538             rinvsq32         = _mm_mul_pd(rinv32,rinv32);
539             rinvsq33         = _mm_mul_pd(rinv33,rinv33);
540
541             fjx1             = _mm_setzero_pd();
542             fjy1             = _mm_setzero_pd();
543             fjz1             = _mm_setzero_pd();
544             fjx2             = _mm_setzero_pd();
545             fjy2             = _mm_setzero_pd();
546             fjz2             = _mm_setzero_pd();
547             fjx3             = _mm_setzero_pd();
548             fjy3             = _mm_setzero_pd();
549             fjz3             = _mm_setzero_pd();
550
551             /**************************
552              * CALCULATE INTERACTIONS *
553              **************************/
554
555             /* REACTION-FIELD ELECTROSTATICS */
556             velec            = _mm_mul_pd(qq11,_mm_sub_pd(_mm_macc_pd(krf,rsq11,rinv11),crf));
557             felec            = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,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             fix1             = _mm_macc_pd(dx11,fscal,fix1);
569             fiy1             = _mm_macc_pd(dy11,fscal,fiy1);
570             fiz1             = _mm_macc_pd(dz11,fscal,fiz1);
571             
572             fjx1             = _mm_macc_pd(dx11,fscal,fjx1);
573             fjy1             = _mm_macc_pd(dy11,fscal,fjy1);
574             fjz1             = _mm_macc_pd(dz11,fscal,fjz1);
575
576             /**************************
577              * CALCULATE INTERACTIONS *
578              **************************/
579
580             /* REACTION-FIELD ELECTROSTATICS */
581             velec            = _mm_mul_pd(qq12,_mm_sub_pd(_mm_macc_pd(krf,rsq12,rinv12),crf));
582             felec            = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,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             fix1             = _mm_macc_pd(dx12,fscal,fix1);
594             fiy1             = _mm_macc_pd(dy12,fscal,fiy1);
595             fiz1             = _mm_macc_pd(dz12,fscal,fiz1);
596             
597             fjx2             = _mm_macc_pd(dx12,fscal,fjx2);
598             fjy2             = _mm_macc_pd(dy12,fscal,fjy2);
599             fjz2             = _mm_macc_pd(dz12,fscal,fjz2);
600
601             /**************************
602              * CALCULATE INTERACTIONS *
603              **************************/
604
605             /* REACTION-FIELD ELECTROSTATICS */
606             velec            = _mm_mul_pd(qq13,_mm_sub_pd(_mm_macc_pd(krf,rsq13,rinv13),crf));
607             felec            = _mm_mul_pd(qq13,_mm_msub_pd(rinv13,rinvsq13,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             fix1             = _mm_macc_pd(dx13,fscal,fix1);
619             fiy1             = _mm_macc_pd(dy13,fscal,fiy1);
620             fiz1             = _mm_macc_pd(dz13,fscal,fiz1);
621             
622             fjx3             = _mm_macc_pd(dx13,fscal,fjx3);
623             fjy3             = _mm_macc_pd(dy13,fscal,fjy3);
624             fjz3             = _mm_macc_pd(dz13,fscal,fjz3);
625
626             /**************************
627              * CALCULATE INTERACTIONS *
628              **************************/
629
630             /* REACTION-FIELD ELECTROSTATICS */
631             velec            = _mm_mul_pd(qq21,_mm_sub_pd(_mm_macc_pd(krf,rsq21,rinv21),crf));
632             felec            = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,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             fix2             = _mm_macc_pd(dx21,fscal,fix2);
644             fiy2             = _mm_macc_pd(dy21,fscal,fiy2);
645             fiz2             = _mm_macc_pd(dz21,fscal,fiz2);
646             
647             fjx1             = _mm_macc_pd(dx21,fscal,fjx1);
648             fjy1             = _mm_macc_pd(dy21,fscal,fjy1);
649             fjz1             = _mm_macc_pd(dz21,fscal,fjz1);
650
651             /**************************
652              * CALCULATE INTERACTIONS *
653              **************************/
654
655             /* REACTION-FIELD ELECTROSTATICS */
656             velec            = _mm_mul_pd(qq22,_mm_sub_pd(_mm_macc_pd(krf,rsq22,rinv22),crf));
657             felec            = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,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             fix2             = _mm_macc_pd(dx22,fscal,fix2);
669             fiy2             = _mm_macc_pd(dy22,fscal,fiy2);
670             fiz2             = _mm_macc_pd(dz22,fscal,fiz2);
671             
672             fjx2             = _mm_macc_pd(dx22,fscal,fjx2);
673             fjy2             = _mm_macc_pd(dy22,fscal,fjy2);
674             fjz2             = _mm_macc_pd(dz22,fscal,fjz2);
675
676             /**************************
677              * CALCULATE INTERACTIONS *
678              **************************/
679
680             /* REACTION-FIELD ELECTROSTATICS */
681             velec            = _mm_mul_pd(qq23,_mm_sub_pd(_mm_macc_pd(krf,rsq23,rinv23),crf));
682             felec            = _mm_mul_pd(qq23,_mm_msub_pd(rinv23,rinvsq23,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             fix2             = _mm_macc_pd(dx23,fscal,fix2);
694             fiy2             = _mm_macc_pd(dy23,fscal,fiy2);
695             fiz2             = _mm_macc_pd(dz23,fscal,fiz2);
696             
697             fjx3             = _mm_macc_pd(dx23,fscal,fjx3);
698             fjy3             = _mm_macc_pd(dy23,fscal,fjy3);
699             fjz3             = _mm_macc_pd(dz23,fscal,fjz3);
700
701             /**************************
702              * CALCULATE INTERACTIONS *
703              **************************/
704
705             /* REACTION-FIELD ELECTROSTATICS */
706             velec            = _mm_mul_pd(qq31,_mm_sub_pd(_mm_macc_pd(krf,rsq31,rinv31),crf));
707             felec            = _mm_mul_pd(qq31,_mm_msub_pd(rinv31,rinvsq31,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             fix3             = _mm_macc_pd(dx31,fscal,fix3);
719             fiy3             = _mm_macc_pd(dy31,fscal,fiy3);
720             fiz3             = _mm_macc_pd(dz31,fscal,fiz3);
721             
722             fjx1             = _mm_macc_pd(dx31,fscal,fjx1);
723             fjy1             = _mm_macc_pd(dy31,fscal,fjy1);
724             fjz1             = _mm_macc_pd(dz31,fscal,fjz1);
725
726             /**************************
727              * CALCULATE INTERACTIONS *
728              **************************/
729
730             /* REACTION-FIELD ELECTROSTATICS */
731             velec            = _mm_mul_pd(qq32,_mm_sub_pd(_mm_macc_pd(krf,rsq32,rinv32),crf));
732             felec            = _mm_mul_pd(qq32,_mm_msub_pd(rinv32,rinvsq32,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             fix3             = _mm_macc_pd(dx32,fscal,fix3);
744             fiy3             = _mm_macc_pd(dy32,fscal,fiy3);
745             fiz3             = _mm_macc_pd(dz32,fscal,fiz3);
746             
747             fjx2             = _mm_macc_pd(dx32,fscal,fjx2);
748             fjy2             = _mm_macc_pd(dy32,fscal,fjy2);
749             fjz2             = _mm_macc_pd(dz32,fscal,fjz2);
750
751             /**************************
752              * CALCULATE INTERACTIONS *
753              **************************/
754
755             /* REACTION-FIELD ELECTROSTATICS */
756             velec            = _mm_mul_pd(qq33,_mm_sub_pd(_mm_macc_pd(krf,rsq33,rinv33),crf));
757             felec            = _mm_mul_pd(qq33,_mm_msub_pd(rinv33,rinvsq33,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             fix3             = _mm_macc_pd(dx33,fscal,fix3);
769             fiy3             = _mm_macc_pd(dy33,fscal,fiy3);
770             fiz3             = _mm_macc_pd(dz33,fscal,fiz3);
771             
772             fjx3             = _mm_macc_pd(dx33,fscal,fjx3);
773             fjy3             = _mm_macc_pd(dy33,fscal,fjy3);
774             fjz3             = _mm_macc_pd(dz33,fscal,fjz3);
775
776             gmx_mm_decrement_3rvec_1ptr_swizzle_pd(f+j_coord_offsetA+DIM,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
777
778             /* Inner loop uses 315 flops */
779         }
780
781         /* End of innermost loop */
782
783         gmx_mm_update_iforce_3atom_swizzle_pd(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
784                                               f+i_coord_offset+DIM,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_W4W4_VF,outeriter*19 + inneriter*315);
802 }
803 /*
804  * Gromacs nonbonded kernel:   nb_kernel_ElecRF_VdwNone_GeomW4W4_F_avx_128_fma_double
805  * Electrostatics interaction: ReactionField
806  * VdW interaction:            None
807  * Geometry:                   Water4-Water4
808  * Calculate force/pot:        Force
809  */
810 void
811 nb_kernel_ElecRF_VdwNone_GeomW4W4_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              vdwioffset1;
834     __m128d          ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
835     int              vdwioffset2;
836     __m128d          ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
837     int              vdwioffset3;
838     __m128d          ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
839     int              vdwjidx1A,vdwjidx1B;
840     __m128d          jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
841     int              vdwjidx2A,vdwjidx2B;
842     __m128d          jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
843     int              vdwjidx3A,vdwjidx3B;
844     __m128d          jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
845     __m128d          dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
846     __m128d          dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
847     __m128d          dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13;
848     __m128d          dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
849     __m128d          dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
850     __m128d          dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23;
851     __m128d          dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31;
852     __m128d          dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32;
853     __m128d          dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33;
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     iq1              = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+1]));
880     iq2              = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+2]));
881     iq3              = _mm_mul_pd(facel,_mm_set1_pd(charge[inr+3]));
882
883     jq1              = _mm_set1_pd(charge[inr+1]);
884     jq2              = _mm_set1_pd(charge[inr+2]);
885     jq3              = _mm_set1_pd(charge[inr+3]);
886     qq11             = _mm_mul_pd(iq1,jq1);
887     qq12             = _mm_mul_pd(iq1,jq2);
888     qq13             = _mm_mul_pd(iq1,jq3);
889     qq21             = _mm_mul_pd(iq2,jq1);
890     qq22             = _mm_mul_pd(iq2,jq2);
891     qq23             = _mm_mul_pd(iq2,jq3);
892     qq31             = _mm_mul_pd(iq3,jq1);
893     qq32             = _mm_mul_pd(iq3,jq2);
894     qq33             = _mm_mul_pd(iq3,jq3);
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+DIM,
920                                                  &ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
921
922         fix1             = _mm_setzero_pd();
923         fiy1             = _mm_setzero_pd();
924         fiz1             = _mm_setzero_pd();
925         fix2             = _mm_setzero_pd();
926         fiy2             = _mm_setzero_pd();
927         fiz2             = _mm_setzero_pd();
928         fix3             = _mm_setzero_pd();
929         fiy3             = _mm_setzero_pd();
930         fiz3             = _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+DIM,x+j_coord_offsetB+DIM,
944                                               &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
945
946             /* Calculate displacement vector */
947             dx11             = _mm_sub_pd(ix1,jx1);
948             dy11             = _mm_sub_pd(iy1,jy1);
949             dz11             = _mm_sub_pd(iz1,jz1);
950             dx12             = _mm_sub_pd(ix1,jx2);
951             dy12             = _mm_sub_pd(iy1,jy2);
952             dz12             = _mm_sub_pd(iz1,jz2);
953             dx13             = _mm_sub_pd(ix1,jx3);
954             dy13             = _mm_sub_pd(iy1,jy3);
955             dz13             = _mm_sub_pd(iz1,jz3);
956             dx21             = _mm_sub_pd(ix2,jx1);
957             dy21             = _mm_sub_pd(iy2,jy1);
958             dz21             = _mm_sub_pd(iz2,jz1);
959             dx22             = _mm_sub_pd(ix2,jx2);
960             dy22             = _mm_sub_pd(iy2,jy2);
961             dz22             = _mm_sub_pd(iz2,jz2);
962             dx23             = _mm_sub_pd(ix2,jx3);
963             dy23             = _mm_sub_pd(iy2,jy3);
964             dz23             = _mm_sub_pd(iz2,jz3);
965             dx31             = _mm_sub_pd(ix3,jx1);
966             dy31             = _mm_sub_pd(iy3,jy1);
967             dz31             = _mm_sub_pd(iz3,jz1);
968             dx32             = _mm_sub_pd(ix3,jx2);
969             dy32             = _mm_sub_pd(iy3,jy2);
970             dz32             = _mm_sub_pd(iz3,jz2);
971             dx33             = _mm_sub_pd(ix3,jx3);
972             dy33             = _mm_sub_pd(iy3,jy3);
973             dz33             = _mm_sub_pd(iz3,jz3);
974
975             /* Calculate squared distance and things based on it */
976             rsq11            = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
977             rsq12            = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
978             rsq13            = gmx_mm_calc_rsq_pd(dx13,dy13,dz13);
979             rsq21            = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
980             rsq22            = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
981             rsq23            = gmx_mm_calc_rsq_pd(dx23,dy23,dz23);
982             rsq31            = gmx_mm_calc_rsq_pd(dx31,dy31,dz31);
983             rsq32            = gmx_mm_calc_rsq_pd(dx32,dy32,dz32);
984             rsq33            = gmx_mm_calc_rsq_pd(dx33,dy33,dz33);
985
986             rinv11           = gmx_mm_invsqrt_pd(rsq11);
987             rinv12           = gmx_mm_invsqrt_pd(rsq12);
988             rinv13           = gmx_mm_invsqrt_pd(rsq13);
989             rinv21           = gmx_mm_invsqrt_pd(rsq21);
990             rinv22           = gmx_mm_invsqrt_pd(rsq22);
991             rinv23           = gmx_mm_invsqrt_pd(rsq23);
992             rinv31           = gmx_mm_invsqrt_pd(rsq31);
993             rinv32           = gmx_mm_invsqrt_pd(rsq32);
994             rinv33           = gmx_mm_invsqrt_pd(rsq33);
995
996             rinvsq11         = _mm_mul_pd(rinv11,rinv11);
997             rinvsq12         = _mm_mul_pd(rinv12,rinv12);
998             rinvsq13         = _mm_mul_pd(rinv13,rinv13);
999             rinvsq21         = _mm_mul_pd(rinv21,rinv21);
1000             rinvsq22         = _mm_mul_pd(rinv22,rinv22);
1001             rinvsq23         = _mm_mul_pd(rinv23,rinv23);
1002             rinvsq31         = _mm_mul_pd(rinv31,rinv31);
1003             rinvsq32         = _mm_mul_pd(rinv32,rinv32);
1004             rinvsq33         = _mm_mul_pd(rinv33,rinv33);
1005
1006             fjx1             = _mm_setzero_pd();
1007             fjy1             = _mm_setzero_pd();
1008             fjz1             = _mm_setzero_pd();
1009             fjx2             = _mm_setzero_pd();
1010             fjy2             = _mm_setzero_pd();
1011             fjz2             = _mm_setzero_pd();
1012             fjx3             = _mm_setzero_pd();
1013             fjy3             = _mm_setzero_pd();
1014             fjz3             = _mm_setzero_pd();
1015
1016             /**************************
1017              * CALCULATE INTERACTIONS *
1018              **************************/
1019
1020             /* REACTION-FIELD ELECTROSTATICS */
1021             felec            = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
1022
1023             fscal            = felec;
1024
1025             /* Update vectorial force */
1026             fix1             = _mm_macc_pd(dx11,fscal,fix1);
1027             fiy1             = _mm_macc_pd(dy11,fscal,fiy1);
1028             fiz1             = _mm_macc_pd(dz11,fscal,fiz1);
1029             
1030             fjx1             = _mm_macc_pd(dx11,fscal,fjx1);
1031             fjy1             = _mm_macc_pd(dy11,fscal,fjy1);
1032             fjz1             = _mm_macc_pd(dz11,fscal,fjz1);
1033
1034             /**************************
1035              * CALCULATE INTERACTIONS *
1036              **************************/
1037
1038             /* REACTION-FIELD ELECTROSTATICS */
1039             felec            = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
1040
1041             fscal            = felec;
1042
1043             /* Update vectorial force */
1044             fix1             = _mm_macc_pd(dx12,fscal,fix1);
1045             fiy1             = _mm_macc_pd(dy12,fscal,fiy1);
1046             fiz1             = _mm_macc_pd(dz12,fscal,fiz1);
1047             
1048             fjx2             = _mm_macc_pd(dx12,fscal,fjx2);
1049             fjy2             = _mm_macc_pd(dy12,fscal,fjy2);
1050             fjz2             = _mm_macc_pd(dz12,fscal,fjz2);
1051
1052             /**************************
1053              * CALCULATE INTERACTIONS *
1054              **************************/
1055
1056             /* REACTION-FIELD ELECTROSTATICS */
1057             felec            = _mm_mul_pd(qq13,_mm_msub_pd(rinv13,rinvsq13,krf2));
1058
1059             fscal            = felec;
1060
1061             /* Update vectorial force */
1062             fix1             = _mm_macc_pd(dx13,fscal,fix1);
1063             fiy1             = _mm_macc_pd(dy13,fscal,fiy1);
1064             fiz1             = _mm_macc_pd(dz13,fscal,fiz1);
1065             
1066             fjx3             = _mm_macc_pd(dx13,fscal,fjx3);
1067             fjy3             = _mm_macc_pd(dy13,fscal,fjy3);
1068             fjz3             = _mm_macc_pd(dz13,fscal,fjz3);
1069
1070             /**************************
1071              * CALCULATE INTERACTIONS *
1072              **************************/
1073
1074             /* REACTION-FIELD ELECTROSTATICS */
1075             felec            = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
1076
1077             fscal            = felec;
1078
1079             /* Update vectorial force */
1080             fix2             = _mm_macc_pd(dx21,fscal,fix2);
1081             fiy2             = _mm_macc_pd(dy21,fscal,fiy2);
1082             fiz2             = _mm_macc_pd(dz21,fscal,fiz2);
1083             
1084             fjx1             = _mm_macc_pd(dx21,fscal,fjx1);
1085             fjy1             = _mm_macc_pd(dy21,fscal,fjy1);
1086             fjz1             = _mm_macc_pd(dz21,fscal,fjz1);
1087
1088             /**************************
1089              * CALCULATE INTERACTIONS *
1090              **************************/
1091
1092             /* REACTION-FIELD ELECTROSTATICS */
1093             felec            = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
1094
1095             fscal            = felec;
1096
1097             /* Update vectorial force */
1098             fix2             = _mm_macc_pd(dx22,fscal,fix2);
1099             fiy2             = _mm_macc_pd(dy22,fscal,fiy2);
1100             fiz2             = _mm_macc_pd(dz22,fscal,fiz2);
1101             
1102             fjx2             = _mm_macc_pd(dx22,fscal,fjx2);
1103             fjy2             = _mm_macc_pd(dy22,fscal,fjy2);
1104             fjz2             = _mm_macc_pd(dz22,fscal,fjz2);
1105
1106             /**************************
1107              * CALCULATE INTERACTIONS *
1108              **************************/
1109
1110             /* REACTION-FIELD ELECTROSTATICS */
1111             felec            = _mm_mul_pd(qq23,_mm_msub_pd(rinv23,rinvsq23,krf2));
1112
1113             fscal            = felec;
1114
1115             /* Update vectorial force */
1116             fix2             = _mm_macc_pd(dx23,fscal,fix2);
1117             fiy2             = _mm_macc_pd(dy23,fscal,fiy2);
1118             fiz2             = _mm_macc_pd(dz23,fscal,fiz2);
1119             
1120             fjx3             = _mm_macc_pd(dx23,fscal,fjx3);
1121             fjy3             = _mm_macc_pd(dy23,fscal,fjy3);
1122             fjz3             = _mm_macc_pd(dz23,fscal,fjz3);
1123
1124             /**************************
1125              * CALCULATE INTERACTIONS *
1126              **************************/
1127
1128             /* REACTION-FIELD ELECTROSTATICS */
1129             felec            = _mm_mul_pd(qq31,_mm_msub_pd(rinv31,rinvsq31,krf2));
1130
1131             fscal            = felec;
1132
1133             /* Update vectorial force */
1134             fix3             = _mm_macc_pd(dx31,fscal,fix3);
1135             fiy3             = _mm_macc_pd(dy31,fscal,fiy3);
1136             fiz3             = _mm_macc_pd(dz31,fscal,fiz3);
1137             
1138             fjx1             = _mm_macc_pd(dx31,fscal,fjx1);
1139             fjy1             = _mm_macc_pd(dy31,fscal,fjy1);
1140             fjz1             = _mm_macc_pd(dz31,fscal,fjz1);
1141
1142             /**************************
1143              * CALCULATE INTERACTIONS *
1144              **************************/
1145
1146             /* REACTION-FIELD ELECTROSTATICS */
1147             felec            = _mm_mul_pd(qq32,_mm_msub_pd(rinv32,rinvsq32,krf2));
1148
1149             fscal            = felec;
1150
1151             /* Update vectorial force */
1152             fix3             = _mm_macc_pd(dx32,fscal,fix3);
1153             fiy3             = _mm_macc_pd(dy32,fscal,fiy3);
1154             fiz3             = _mm_macc_pd(dz32,fscal,fiz3);
1155             
1156             fjx2             = _mm_macc_pd(dx32,fscal,fjx2);
1157             fjy2             = _mm_macc_pd(dy32,fscal,fjy2);
1158             fjz2             = _mm_macc_pd(dz32,fscal,fjz2);
1159
1160             /**************************
1161              * CALCULATE INTERACTIONS *
1162              **************************/
1163
1164             /* REACTION-FIELD ELECTROSTATICS */
1165             felec            = _mm_mul_pd(qq33,_mm_msub_pd(rinv33,rinvsq33,krf2));
1166
1167             fscal            = felec;
1168
1169             /* Update vectorial force */
1170             fix3             = _mm_macc_pd(dx33,fscal,fix3);
1171             fiy3             = _mm_macc_pd(dy33,fscal,fiy3);
1172             fiz3             = _mm_macc_pd(dz33,fscal,fiz3);
1173             
1174             fjx3             = _mm_macc_pd(dx33,fscal,fjx3);
1175             fjy3             = _mm_macc_pd(dy33,fscal,fjy3);
1176             fjz3             = _mm_macc_pd(dz33,fscal,fjz3);
1177
1178             gmx_mm_decrement_3rvec_2ptr_swizzle_pd(f+j_coord_offsetA+DIM,f+j_coord_offsetB+DIM,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
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+DIM,
1191                                               &jx1,&jy1,&jz1,&jx2,&jy2,&jz2,&jx3,&jy3,&jz3);
1192
1193             /* Calculate displacement vector */
1194             dx11             = _mm_sub_pd(ix1,jx1);
1195             dy11             = _mm_sub_pd(iy1,jy1);
1196             dz11             = _mm_sub_pd(iz1,jz1);
1197             dx12             = _mm_sub_pd(ix1,jx2);
1198             dy12             = _mm_sub_pd(iy1,jy2);
1199             dz12             = _mm_sub_pd(iz1,jz2);
1200             dx13             = _mm_sub_pd(ix1,jx3);
1201             dy13             = _mm_sub_pd(iy1,jy3);
1202             dz13             = _mm_sub_pd(iz1,jz3);
1203             dx21             = _mm_sub_pd(ix2,jx1);
1204             dy21             = _mm_sub_pd(iy2,jy1);
1205             dz21             = _mm_sub_pd(iz2,jz1);
1206             dx22             = _mm_sub_pd(ix2,jx2);
1207             dy22             = _mm_sub_pd(iy2,jy2);
1208             dz22             = _mm_sub_pd(iz2,jz2);
1209             dx23             = _mm_sub_pd(ix2,jx3);
1210             dy23             = _mm_sub_pd(iy2,jy3);
1211             dz23             = _mm_sub_pd(iz2,jz3);
1212             dx31             = _mm_sub_pd(ix3,jx1);
1213             dy31             = _mm_sub_pd(iy3,jy1);
1214             dz31             = _mm_sub_pd(iz3,jz1);
1215             dx32             = _mm_sub_pd(ix3,jx2);
1216             dy32             = _mm_sub_pd(iy3,jy2);
1217             dz32             = _mm_sub_pd(iz3,jz2);
1218             dx33             = _mm_sub_pd(ix3,jx3);
1219             dy33             = _mm_sub_pd(iy3,jy3);
1220             dz33             = _mm_sub_pd(iz3,jz3);
1221
1222             /* Calculate squared distance and things based on it */
1223             rsq11            = gmx_mm_calc_rsq_pd(dx11,dy11,dz11);
1224             rsq12            = gmx_mm_calc_rsq_pd(dx12,dy12,dz12);
1225             rsq13            = gmx_mm_calc_rsq_pd(dx13,dy13,dz13);
1226             rsq21            = gmx_mm_calc_rsq_pd(dx21,dy21,dz21);
1227             rsq22            = gmx_mm_calc_rsq_pd(dx22,dy22,dz22);
1228             rsq23            = gmx_mm_calc_rsq_pd(dx23,dy23,dz23);
1229             rsq31            = gmx_mm_calc_rsq_pd(dx31,dy31,dz31);
1230             rsq32            = gmx_mm_calc_rsq_pd(dx32,dy32,dz32);
1231             rsq33            = gmx_mm_calc_rsq_pd(dx33,dy33,dz33);
1232
1233             rinv11           = gmx_mm_invsqrt_pd(rsq11);
1234             rinv12           = gmx_mm_invsqrt_pd(rsq12);
1235             rinv13           = gmx_mm_invsqrt_pd(rsq13);
1236             rinv21           = gmx_mm_invsqrt_pd(rsq21);
1237             rinv22           = gmx_mm_invsqrt_pd(rsq22);
1238             rinv23           = gmx_mm_invsqrt_pd(rsq23);
1239             rinv31           = gmx_mm_invsqrt_pd(rsq31);
1240             rinv32           = gmx_mm_invsqrt_pd(rsq32);
1241             rinv33           = gmx_mm_invsqrt_pd(rsq33);
1242
1243             rinvsq11         = _mm_mul_pd(rinv11,rinv11);
1244             rinvsq12         = _mm_mul_pd(rinv12,rinv12);
1245             rinvsq13         = _mm_mul_pd(rinv13,rinv13);
1246             rinvsq21         = _mm_mul_pd(rinv21,rinv21);
1247             rinvsq22         = _mm_mul_pd(rinv22,rinv22);
1248             rinvsq23         = _mm_mul_pd(rinv23,rinv23);
1249             rinvsq31         = _mm_mul_pd(rinv31,rinv31);
1250             rinvsq32         = _mm_mul_pd(rinv32,rinv32);
1251             rinvsq33         = _mm_mul_pd(rinv33,rinv33);
1252
1253             fjx1             = _mm_setzero_pd();
1254             fjy1             = _mm_setzero_pd();
1255             fjz1             = _mm_setzero_pd();
1256             fjx2             = _mm_setzero_pd();
1257             fjy2             = _mm_setzero_pd();
1258             fjz2             = _mm_setzero_pd();
1259             fjx3             = _mm_setzero_pd();
1260             fjy3             = _mm_setzero_pd();
1261             fjz3             = _mm_setzero_pd();
1262
1263             /**************************
1264              * CALCULATE INTERACTIONS *
1265              **************************/
1266
1267             /* REACTION-FIELD ELECTROSTATICS */
1268             felec            = _mm_mul_pd(qq11,_mm_msub_pd(rinv11,rinvsq11,krf2));
1269
1270             fscal            = felec;
1271
1272             fscal            = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1273
1274             /* Update vectorial force */
1275             fix1             = _mm_macc_pd(dx11,fscal,fix1);
1276             fiy1             = _mm_macc_pd(dy11,fscal,fiy1);
1277             fiz1             = _mm_macc_pd(dz11,fscal,fiz1);
1278             
1279             fjx1             = _mm_macc_pd(dx11,fscal,fjx1);
1280             fjy1             = _mm_macc_pd(dy11,fscal,fjy1);
1281             fjz1             = _mm_macc_pd(dz11,fscal,fjz1);
1282
1283             /**************************
1284              * CALCULATE INTERACTIONS *
1285              **************************/
1286
1287             /* REACTION-FIELD ELECTROSTATICS */
1288             felec            = _mm_mul_pd(qq12,_mm_msub_pd(rinv12,rinvsq12,krf2));
1289
1290             fscal            = felec;
1291
1292             fscal            = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1293
1294             /* Update vectorial force */
1295             fix1             = _mm_macc_pd(dx12,fscal,fix1);
1296             fiy1             = _mm_macc_pd(dy12,fscal,fiy1);
1297             fiz1             = _mm_macc_pd(dz12,fscal,fiz1);
1298             
1299             fjx2             = _mm_macc_pd(dx12,fscal,fjx2);
1300             fjy2             = _mm_macc_pd(dy12,fscal,fjy2);
1301             fjz2             = _mm_macc_pd(dz12,fscal,fjz2);
1302
1303             /**************************
1304              * CALCULATE INTERACTIONS *
1305              **************************/
1306
1307             /* REACTION-FIELD ELECTROSTATICS */
1308             felec            = _mm_mul_pd(qq13,_mm_msub_pd(rinv13,rinvsq13,krf2));
1309
1310             fscal            = felec;
1311
1312             fscal            = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1313
1314             /* Update vectorial force */
1315             fix1             = _mm_macc_pd(dx13,fscal,fix1);
1316             fiy1             = _mm_macc_pd(dy13,fscal,fiy1);
1317             fiz1             = _mm_macc_pd(dz13,fscal,fiz1);
1318             
1319             fjx3             = _mm_macc_pd(dx13,fscal,fjx3);
1320             fjy3             = _mm_macc_pd(dy13,fscal,fjy3);
1321             fjz3             = _mm_macc_pd(dz13,fscal,fjz3);
1322
1323             /**************************
1324              * CALCULATE INTERACTIONS *
1325              **************************/
1326
1327             /* REACTION-FIELD ELECTROSTATICS */
1328             felec            = _mm_mul_pd(qq21,_mm_msub_pd(rinv21,rinvsq21,krf2));
1329
1330             fscal            = felec;
1331
1332             fscal            = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1333
1334             /* Update vectorial force */
1335             fix2             = _mm_macc_pd(dx21,fscal,fix2);
1336             fiy2             = _mm_macc_pd(dy21,fscal,fiy2);
1337             fiz2             = _mm_macc_pd(dz21,fscal,fiz2);
1338             
1339             fjx1             = _mm_macc_pd(dx21,fscal,fjx1);
1340             fjy1             = _mm_macc_pd(dy21,fscal,fjy1);
1341             fjz1             = _mm_macc_pd(dz21,fscal,fjz1);
1342
1343             /**************************
1344              * CALCULATE INTERACTIONS *
1345              **************************/
1346
1347             /* REACTION-FIELD ELECTROSTATICS */
1348             felec            = _mm_mul_pd(qq22,_mm_msub_pd(rinv22,rinvsq22,krf2));
1349
1350             fscal            = felec;
1351
1352             fscal            = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1353
1354             /* Update vectorial force */
1355             fix2             = _mm_macc_pd(dx22,fscal,fix2);
1356             fiy2             = _mm_macc_pd(dy22,fscal,fiy2);
1357             fiz2             = _mm_macc_pd(dz22,fscal,fiz2);
1358             
1359             fjx2             = _mm_macc_pd(dx22,fscal,fjx2);
1360             fjy2             = _mm_macc_pd(dy22,fscal,fjy2);
1361             fjz2             = _mm_macc_pd(dz22,fscal,fjz2);
1362
1363             /**************************
1364              * CALCULATE INTERACTIONS *
1365              **************************/
1366
1367             /* REACTION-FIELD ELECTROSTATICS */
1368             felec            = _mm_mul_pd(qq23,_mm_msub_pd(rinv23,rinvsq23,krf2));
1369
1370             fscal            = felec;
1371
1372             fscal            = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1373
1374             /* Update vectorial force */
1375             fix2             = _mm_macc_pd(dx23,fscal,fix2);
1376             fiy2             = _mm_macc_pd(dy23,fscal,fiy2);
1377             fiz2             = _mm_macc_pd(dz23,fscal,fiz2);
1378             
1379             fjx3             = _mm_macc_pd(dx23,fscal,fjx3);
1380             fjy3             = _mm_macc_pd(dy23,fscal,fjy3);
1381             fjz3             = _mm_macc_pd(dz23,fscal,fjz3);
1382
1383             /**************************
1384              * CALCULATE INTERACTIONS *
1385              **************************/
1386
1387             /* REACTION-FIELD ELECTROSTATICS */
1388             felec            = _mm_mul_pd(qq31,_mm_msub_pd(rinv31,rinvsq31,krf2));
1389
1390             fscal            = felec;
1391
1392             fscal            = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1393
1394             /* Update vectorial force */
1395             fix3             = _mm_macc_pd(dx31,fscal,fix3);
1396             fiy3             = _mm_macc_pd(dy31,fscal,fiy3);
1397             fiz3             = _mm_macc_pd(dz31,fscal,fiz3);
1398             
1399             fjx1             = _mm_macc_pd(dx31,fscal,fjx1);
1400             fjy1             = _mm_macc_pd(dy31,fscal,fjy1);
1401             fjz1             = _mm_macc_pd(dz31,fscal,fjz1);
1402
1403             /**************************
1404              * CALCULATE INTERACTIONS *
1405              **************************/
1406
1407             /* REACTION-FIELD ELECTROSTATICS */
1408             felec            = _mm_mul_pd(qq32,_mm_msub_pd(rinv32,rinvsq32,krf2));
1409
1410             fscal            = felec;
1411
1412             fscal            = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1413
1414             /* Update vectorial force */
1415             fix3             = _mm_macc_pd(dx32,fscal,fix3);
1416             fiy3             = _mm_macc_pd(dy32,fscal,fiy3);
1417             fiz3             = _mm_macc_pd(dz32,fscal,fiz3);
1418             
1419             fjx2             = _mm_macc_pd(dx32,fscal,fjx2);
1420             fjy2             = _mm_macc_pd(dy32,fscal,fjy2);
1421             fjz2             = _mm_macc_pd(dz32,fscal,fjz2);
1422
1423             /**************************
1424              * CALCULATE INTERACTIONS *
1425              **************************/
1426
1427             /* REACTION-FIELD ELECTROSTATICS */
1428             felec            = _mm_mul_pd(qq33,_mm_msub_pd(rinv33,rinvsq33,krf2));
1429
1430             fscal            = felec;
1431
1432             fscal            = _mm_unpacklo_pd(fscal,_mm_setzero_pd());
1433
1434             /* Update vectorial force */
1435             fix3             = _mm_macc_pd(dx33,fscal,fix3);
1436             fiy3             = _mm_macc_pd(dy33,fscal,fiy3);
1437             fiz3             = _mm_macc_pd(dz33,fscal,fiz3);
1438             
1439             fjx3             = _mm_macc_pd(dx33,fscal,fjx3);
1440             fjy3             = _mm_macc_pd(dy33,fscal,fjy3);
1441             fjz3             = _mm_macc_pd(dz33,fscal,fjz3);
1442
1443             gmx_mm_decrement_3rvec_1ptr_swizzle_pd(f+j_coord_offsetA+DIM,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
1444
1445             /* Inner loop uses 270 flops */
1446         }
1447
1448         /* End of innermost loop */
1449
1450         gmx_mm_update_iforce_3atom_swizzle_pd(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,
1451                                               f+i_coord_offset+DIM,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_W4W4_F,outeriter*18 + inneriter*270);
1465 }