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