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