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