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