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