Remove all unnecessary HAVE_CONFIG_H
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_avx_128_fma_single / nb_kernel_ElecEwSh_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 "types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "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_ElecEwSh_VdwNone_GeomW3W3_VF_avx_128_fma_single
52  * Electrostatics interaction: Ewald
53  * VdW interaction:            None
54  * Geometry:                   Water3-Water3
55  * Calculate force/pot:        PotentialAndForce
56  */
57 void
58 nb_kernel_ElecEwSh_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     __m128i          ewitab;
107     __m128           ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
108     __m128           beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
109     real             *ewtab;
110     __m128           dummy_mask,cutoff_mask;
111     __m128           signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
112     __m128           one     = _mm_set1_ps(1.0);
113     __m128           two     = _mm_set1_ps(2.0);
114     x                = xx[0];
115     f                = ff[0];
116
117     nri              = nlist->nri;
118     iinr             = nlist->iinr;
119     jindex           = nlist->jindex;
120     jjnr             = nlist->jjnr;
121     shiftidx         = nlist->shift;
122     gid              = nlist->gid;
123     shiftvec         = fr->shift_vec[0];
124     fshift           = fr->fshift[0];
125     facel            = _mm_set1_ps(fr->epsfac);
126     charge           = mdatoms->chargeA;
127
128     sh_ewald         = _mm_set1_ps(fr->ic->sh_ewald);
129     beta             = _mm_set1_ps(fr->ic->ewaldcoeff_q);
130     beta2            = _mm_mul_ps(beta,beta);
131     beta3            = _mm_mul_ps(beta,beta2);
132     ewtab            = fr->ic->tabq_coul_FDV0;
133     ewtabscale       = _mm_set1_ps(fr->ic->tabq_scale);
134     ewtabhalfspace   = _mm_set1_ps(0.5/fr->ic->tabq_scale);
135
136     /* Setup water-specific parameters */
137     inr              = nlist->iinr[0];
138     iq0              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
139     iq1              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
140     iq2              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
141
142     jq0              = _mm_set1_ps(charge[inr+0]);
143     jq1              = _mm_set1_ps(charge[inr+1]);
144     jq2              = _mm_set1_ps(charge[inr+2]);
145     qq00             = _mm_mul_ps(iq0,jq0);
146     qq01             = _mm_mul_ps(iq0,jq1);
147     qq02             = _mm_mul_ps(iq0,jq2);
148     qq10             = _mm_mul_ps(iq1,jq0);
149     qq11             = _mm_mul_ps(iq1,jq1);
150     qq12             = _mm_mul_ps(iq1,jq2);
151     qq20             = _mm_mul_ps(iq2,jq0);
152     qq21             = _mm_mul_ps(iq2,jq1);
153     qq22             = _mm_mul_ps(iq2,jq2);
154
155     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
156     rcutoff_scalar   = fr->rcoulomb;
157     rcutoff          = _mm_set1_ps(rcutoff_scalar);
158     rcutoff2         = _mm_mul_ps(rcutoff,rcutoff);
159
160     /* Avoid stupid compiler warnings */
161     jnrA = jnrB = jnrC = jnrD = 0;
162     j_coord_offsetA = 0;
163     j_coord_offsetB = 0;
164     j_coord_offsetC = 0;
165     j_coord_offsetD = 0;
166
167     outeriter        = 0;
168     inneriter        = 0;
169
170     for(iidx=0;iidx<4*DIM;iidx++)
171     {
172         scratch[iidx] = 0.0;
173     }
174
175     /* Start outer loop over neighborlists */
176     for(iidx=0; iidx<nri; iidx++)
177     {
178         /* Load shift vector for this list */
179         i_shift_offset   = DIM*shiftidx[iidx];
180
181         /* Load limits for loop over neighbors */
182         j_index_start    = jindex[iidx];
183         j_index_end      = jindex[iidx+1];
184
185         /* Get outer coordinate index */
186         inr              = iinr[iidx];
187         i_coord_offset   = DIM*inr;
188
189         /* Load i particle coords and add shift vector */
190         gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
191                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
192
193         fix0             = _mm_setzero_ps();
194         fiy0             = _mm_setzero_ps();
195         fiz0             = _mm_setzero_ps();
196         fix1             = _mm_setzero_ps();
197         fiy1             = _mm_setzero_ps();
198         fiz1             = _mm_setzero_ps();
199         fix2             = _mm_setzero_ps();
200         fiy2             = _mm_setzero_ps();
201         fiz2             = _mm_setzero_ps();
202
203         /* Reset potential sums */
204         velecsum         = _mm_setzero_ps();
205
206         /* Start inner kernel loop */
207         for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
208         {
209
210             /* Get j neighbor index, and coordinate index */
211             jnrA             = jjnr[jidx];
212             jnrB             = jjnr[jidx+1];
213             jnrC             = jjnr[jidx+2];
214             jnrD             = jjnr[jidx+3];
215             j_coord_offsetA  = DIM*jnrA;
216             j_coord_offsetB  = DIM*jnrB;
217             j_coord_offsetC  = DIM*jnrC;
218             j_coord_offsetD  = DIM*jnrD;
219
220             /* load j atom coordinates */
221             gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
222                                               x+j_coord_offsetC,x+j_coord_offsetD,
223                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
224
225             /* Calculate displacement vector */
226             dx00             = _mm_sub_ps(ix0,jx0);
227             dy00             = _mm_sub_ps(iy0,jy0);
228             dz00             = _mm_sub_ps(iz0,jz0);
229             dx01             = _mm_sub_ps(ix0,jx1);
230             dy01             = _mm_sub_ps(iy0,jy1);
231             dz01             = _mm_sub_ps(iz0,jz1);
232             dx02             = _mm_sub_ps(ix0,jx2);
233             dy02             = _mm_sub_ps(iy0,jy2);
234             dz02             = _mm_sub_ps(iz0,jz2);
235             dx10             = _mm_sub_ps(ix1,jx0);
236             dy10             = _mm_sub_ps(iy1,jy0);
237             dz10             = _mm_sub_ps(iz1,jz0);
238             dx11             = _mm_sub_ps(ix1,jx1);
239             dy11             = _mm_sub_ps(iy1,jy1);
240             dz11             = _mm_sub_ps(iz1,jz1);
241             dx12             = _mm_sub_ps(ix1,jx2);
242             dy12             = _mm_sub_ps(iy1,jy2);
243             dz12             = _mm_sub_ps(iz1,jz2);
244             dx20             = _mm_sub_ps(ix2,jx0);
245             dy20             = _mm_sub_ps(iy2,jy0);
246             dz20             = _mm_sub_ps(iz2,jz0);
247             dx21             = _mm_sub_ps(ix2,jx1);
248             dy21             = _mm_sub_ps(iy2,jy1);
249             dz21             = _mm_sub_ps(iz2,jz1);
250             dx22             = _mm_sub_ps(ix2,jx2);
251             dy22             = _mm_sub_ps(iy2,jy2);
252             dz22             = _mm_sub_ps(iz2,jz2);
253
254             /* Calculate squared distance and things based on it */
255             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
256             rsq01            = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
257             rsq02            = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
258             rsq10            = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
259             rsq11            = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
260             rsq12            = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
261             rsq20            = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
262             rsq21            = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
263             rsq22            = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
264
265             rinv00           = gmx_mm_invsqrt_ps(rsq00);
266             rinv01           = gmx_mm_invsqrt_ps(rsq01);
267             rinv02           = gmx_mm_invsqrt_ps(rsq02);
268             rinv10           = gmx_mm_invsqrt_ps(rsq10);
269             rinv11           = gmx_mm_invsqrt_ps(rsq11);
270             rinv12           = gmx_mm_invsqrt_ps(rsq12);
271             rinv20           = gmx_mm_invsqrt_ps(rsq20);
272             rinv21           = gmx_mm_invsqrt_ps(rsq21);
273             rinv22           = gmx_mm_invsqrt_ps(rsq22);
274
275             rinvsq00         = _mm_mul_ps(rinv00,rinv00);
276             rinvsq01         = _mm_mul_ps(rinv01,rinv01);
277             rinvsq02         = _mm_mul_ps(rinv02,rinv02);
278             rinvsq10         = _mm_mul_ps(rinv10,rinv10);
279             rinvsq11         = _mm_mul_ps(rinv11,rinv11);
280             rinvsq12         = _mm_mul_ps(rinv12,rinv12);
281             rinvsq20         = _mm_mul_ps(rinv20,rinv20);
282             rinvsq21         = _mm_mul_ps(rinv21,rinv21);
283             rinvsq22         = _mm_mul_ps(rinv22,rinv22);
284
285             fjx0             = _mm_setzero_ps();
286             fjy0             = _mm_setzero_ps();
287             fjz0             = _mm_setzero_ps();
288             fjx1             = _mm_setzero_ps();
289             fjy1             = _mm_setzero_ps();
290             fjz1             = _mm_setzero_ps();
291             fjx2             = _mm_setzero_ps();
292             fjy2             = _mm_setzero_ps();
293             fjz2             = _mm_setzero_ps();
294
295             /**************************
296              * CALCULATE INTERACTIONS *
297              **************************/
298
299             if (gmx_mm_any_lt(rsq00,rcutoff2))
300             {
301
302             r00              = _mm_mul_ps(rsq00,rinv00);
303
304             /* EWALD ELECTROSTATICS */
305
306             /* Analytical PME correction */
307             zeta2            = _mm_mul_ps(beta2,rsq00);
308             rinv3            = _mm_mul_ps(rinvsq00,rinv00);
309             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
310             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
311             felec            = _mm_mul_ps(qq00,felec);
312             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
313             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv00,sh_ewald));
314             velec            = _mm_mul_ps(qq00,velec);
315
316             cutoff_mask      = _mm_cmplt_ps(rsq00,rcutoff2);
317
318             /* Update potential sum for this i atom from the interaction with this j atom. */
319             velec            = _mm_and_ps(velec,cutoff_mask);
320             velecsum         = _mm_add_ps(velecsum,velec);
321
322             fscal            = felec;
323
324             fscal            = _mm_and_ps(fscal,cutoff_mask);
325
326              /* Update vectorial force */
327             fix0             = _mm_macc_ps(dx00,fscal,fix0);
328             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
329             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
330
331             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
332             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
333             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
334
335             }
336
337             /**************************
338              * CALCULATE INTERACTIONS *
339              **************************/
340
341             if (gmx_mm_any_lt(rsq01,rcutoff2))
342             {
343
344             r01              = _mm_mul_ps(rsq01,rinv01);
345
346             /* EWALD ELECTROSTATICS */
347
348             /* Analytical PME correction */
349             zeta2            = _mm_mul_ps(beta2,rsq01);
350             rinv3            = _mm_mul_ps(rinvsq01,rinv01);
351             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
352             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
353             felec            = _mm_mul_ps(qq01,felec);
354             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
355             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv01,sh_ewald));
356             velec            = _mm_mul_ps(qq01,velec);
357
358             cutoff_mask      = _mm_cmplt_ps(rsq01,rcutoff2);
359
360             /* Update potential sum for this i atom from the interaction with this j atom. */
361             velec            = _mm_and_ps(velec,cutoff_mask);
362             velecsum         = _mm_add_ps(velecsum,velec);
363
364             fscal            = felec;
365
366             fscal            = _mm_and_ps(fscal,cutoff_mask);
367
368              /* Update vectorial force */
369             fix0             = _mm_macc_ps(dx01,fscal,fix0);
370             fiy0             = _mm_macc_ps(dy01,fscal,fiy0);
371             fiz0             = _mm_macc_ps(dz01,fscal,fiz0);
372
373             fjx1             = _mm_macc_ps(dx01,fscal,fjx1);
374             fjy1             = _mm_macc_ps(dy01,fscal,fjy1);
375             fjz1             = _mm_macc_ps(dz01,fscal,fjz1);
376
377             }
378
379             /**************************
380              * CALCULATE INTERACTIONS *
381              **************************/
382
383             if (gmx_mm_any_lt(rsq02,rcutoff2))
384             {
385
386             r02              = _mm_mul_ps(rsq02,rinv02);
387
388             /* EWALD ELECTROSTATICS */
389
390             /* Analytical PME correction */
391             zeta2            = _mm_mul_ps(beta2,rsq02);
392             rinv3            = _mm_mul_ps(rinvsq02,rinv02);
393             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
394             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
395             felec            = _mm_mul_ps(qq02,felec);
396             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
397             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv02,sh_ewald));
398             velec            = _mm_mul_ps(qq02,velec);
399
400             cutoff_mask      = _mm_cmplt_ps(rsq02,rcutoff2);
401
402             /* Update potential sum for this i atom from the interaction with this j atom. */
403             velec            = _mm_and_ps(velec,cutoff_mask);
404             velecsum         = _mm_add_ps(velecsum,velec);
405
406             fscal            = felec;
407
408             fscal            = _mm_and_ps(fscal,cutoff_mask);
409
410              /* Update vectorial force */
411             fix0             = _mm_macc_ps(dx02,fscal,fix0);
412             fiy0             = _mm_macc_ps(dy02,fscal,fiy0);
413             fiz0             = _mm_macc_ps(dz02,fscal,fiz0);
414
415             fjx2             = _mm_macc_ps(dx02,fscal,fjx2);
416             fjy2             = _mm_macc_ps(dy02,fscal,fjy2);
417             fjz2             = _mm_macc_ps(dz02,fscal,fjz2);
418
419             }
420
421             /**************************
422              * CALCULATE INTERACTIONS *
423              **************************/
424
425             if (gmx_mm_any_lt(rsq10,rcutoff2))
426             {
427
428             r10              = _mm_mul_ps(rsq10,rinv10);
429
430             /* EWALD ELECTROSTATICS */
431
432             /* Analytical PME correction */
433             zeta2            = _mm_mul_ps(beta2,rsq10);
434             rinv3            = _mm_mul_ps(rinvsq10,rinv10);
435             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
436             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
437             felec            = _mm_mul_ps(qq10,felec);
438             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
439             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv10,sh_ewald));
440             velec            = _mm_mul_ps(qq10,velec);
441
442             cutoff_mask      = _mm_cmplt_ps(rsq10,rcutoff2);
443
444             /* Update potential sum for this i atom from the interaction with this j atom. */
445             velec            = _mm_and_ps(velec,cutoff_mask);
446             velecsum         = _mm_add_ps(velecsum,velec);
447
448             fscal            = felec;
449
450             fscal            = _mm_and_ps(fscal,cutoff_mask);
451
452              /* Update vectorial force */
453             fix1             = _mm_macc_ps(dx10,fscal,fix1);
454             fiy1             = _mm_macc_ps(dy10,fscal,fiy1);
455             fiz1             = _mm_macc_ps(dz10,fscal,fiz1);
456
457             fjx0             = _mm_macc_ps(dx10,fscal,fjx0);
458             fjy0             = _mm_macc_ps(dy10,fscal,fjy0);
459             fjz0             = _mm_macc_ps(dz10,fscal,fjz0);
460
461             }
462
463             /**************************
464              * CALCULATE INTERACTIONS *
465              **************************/
466
467             if (gmx_mm_any_lt(rsq11,rcutoff2))
468             {
469
470             r11              = _mm_mul_ps(rsq11,rinv11);
471
472             /* EWALD ELECTROSTATICS */
473
474             /* Analytical PME correction */
475             zeta2            = _mm_mul_ps(beta2,rsq11);
476             rinv3            = _mm_mul_ps(rinvsq11,rinv11);
477             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
478             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
479             felec            = _mm_mul_ps(qq11,felec);
480             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
481             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv11,sh_ewald));
482             velec            = _mm_mul_ps(qq11,velec);
483
484             cutoff_mask      = _mm_cmplt_ps(rsq11,rcutoff2);
485
486             /* Update potential sum for this i atom from the interaction with this j atom. */
487             velec            = _mm_and_ps(velec,cutoff_mask);
488             velecsum         = _mm_add_ps(velecsum,velec);
489
490             fscal            = felec;
491
492             fscal            = _mm_and_ps(fscal,cutoff_mask);
493
494              /* Update vectorial force */
495             fix1             = _mm_macc_ps(dx11,fscal,fix1);
496             fiy1             = _mm_macc_ps(dy11,fscal,fiy1);
497             fiz1             = _mm_macc_ps(dz11,fscal,fiz1);
498
499             fjx1             = _mm_macc_ps(dx11,fscal,fjx1);
500             fjy1             = _mm_macc_ps(dy11,fscal,fjy1);
501             fjz1             = _mm_macc_ps(dz11,fscal,fjz1);
502
503             }
504
505             /**************************
506              * CALCULATE INTERACTIONS *
507              **************************/
508
509             if (gmx_mm_any_lt(rsq12,rcutoff2))
510             {
511
512             r12              = _mm_mul_ps(rsq12,rinv12);
513
514             /* EWALD ELECTROSTATICS */
515
516             /* Analytical PME correction */
517             zeta2            = _mm_mul_ps(beta2,rsq12);
518             rinv3            = _mm_mul_ps(rinvsq12,rinv12);
519             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
520             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
521             felec            = _mm_mul_ps(qq12,felec);
522             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
523             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv12,sh_ewald));
524             velec            = _mm_mul_ps(qq12,velec);
525
526             cutoff_mask      = _mm_cmplt_ps(rsq12,rcutoff2);
527
528             /* Update potential sum for this i atom from the interaction with this j atom. */
529             velec            = _mm_and_ps(velec,cutoff_mask);
530             velecsum         = _mm_add_ps(velecsum,velec);
531
532             fscal            = felec;
533
534             fscal            = _mm_and_ps(fscal,cutoff_mask);
535
536              /* Update vectorial force */
537             fix1             = _mm_macc_ps(dx12,fscal,fix1);
538             fiy1             = _mm_macc_ps(dy12,fscal,fiy1);
539             fiz1             = _mm_macc_ps(dz12,fscal,fiz1);
540
541             fjx2             = _mm_macc_ps(dx12,fscal,fjx2);
542             fjy2             = _mm_macc_ps(dy12,fscal,fjy2);
543             fjz2             = _mm_macc_ps(dz12,fscal,fjz2);
544
545             }
546
547             /**************************
548              * CALCULATE INTERACTIONS *
549              **************************/
550
551             if (gmx_mm_any_lt(rsq20,rcutoff2))
552             {
553
554             r20              = _mm_mul_ps(rsq20,rinv20);
555
556             /* EWALD ELECTROSTATICS */
557
558             /* Analytical PME correction */
559             zeta2            = _mm_mul_ps(beta2,rsq20);
560             rinv3            = _mm_mul_ps(rinvsq20,rinv20);
561             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
562             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
563             felec            = _mm_mul_ps(qq20,felec);
564             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
565             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv20,sh_ewald));
566             velec            = _mm_mul_ps(qq20,velec);
567
568             cutoff_mask      = _mm_cmplt_ps(rsq20,rcutoff2);
569
570             /* Update potential sum for this i atom from the interaction with this j atom. */
571             velec            = _mm_and_ps(velec,cutoff_mask);
572             velecsum         = _mm_add_ps(velecsum,velec);
573
574             fscal            = felec;
575
576             fscal            = _mm_and_ps(fscal,cutoff_mask);
577
578              /* Update vectorial force */
579             fix2             = _mm_macc_ps(dx20,fscal,fix2);
580             fiy2             = _mm_macc_ps(dy20,fscal,fiy2);
581             fiz2             = _mm_macc_ps(dz20,fscal,fiz2);
582
583             fjx0             = _mm_macc_ps(dx20,fscal,fjx0);
584             fjy0             = _mm_macc_ps(dy20,fscal,fjy0);
585             fjz0             = _mm_macc_ps(dz20,fscal,fjz0);
586
587             }
588
589             /**************************
590              * CALCULATE INTERACTIONS *
591              **************************/
592
593             if (gmx_mm_any_lt(rsq21,rcutoff2))
594             {
595
596             r21              = _mm_mul_ps(rsq21,rinv21);
597
598             /* EWALD ELECTROSTATICS */
599
600             /* Analytical PME correction */
601             zeta2            = _mm_mul_ps(beta2,rsq21);
602             rinv3            = _mm_mul_ps(rinvsq21,rinv21);
603             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
604             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
605             felec            = _mm_mul_ps(qq21,felec);
606             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
607             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv21,sh_ewald));
608             velec            = _mm_mul_ps(qq21,velec);
609
610             cutoff_mask      = _mm_cmplt_ps(rsq21,rcutoff2);
611
612             /* Update potential sum for this i atom from the interaction with this j atom. */
613             velec            = _mm_and_ps(velec,cutoff_mask);
614             velecsum         = _mm_add_ps(velecsum,velec);
615
616             fscal            = felec;
617
618             fscal            = _mm_and_ps(fscal,cutoff_mask);
619
620              /* Update vectorial force */
621             fix2             = _mm_macc_ps(dx21,fscal,fix2);
622             fiy2             = _mm_macc_ps(dy21,fscal,fiy2);
623             fiz2             = _mm_macc_ps(dz21,fscal,fiz2);
624
625             fjx1             = _mm_macc_ps(dx21,fscal,fjx1);
626             fjy1             = _mm_macc_ps(dy21,fscal,fjy1);
627             fjz1             = _mm_macc_ps(dz21,fscal,fjz1);
628
629             }
630
631             /**************************
632              * CALCULATE INTERACTIONS *
633              **************************/
634
635             if (gmx_mm_any_lt(rsq22,rcutoff2))
636             {
637
638             r22              = _mm_mul_ps(rsq22,rinv22);
639
640             /* EWALD ELECTROSTATICS */
641
642             /* Analytical PME correction */
643             zeta2            = _mm_mul_ps(beta2,rsq22);
644             rinv3            = _mm_mul_ps(rinvsq22,rinv22);
645             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
646             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
647             felec            = _mm_mul_ps(qq22,felec);
648             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
649             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv22,sh_ewald));
650             velec            = _mm_mul_ps(qq22,velec);
651
652             cutoff_mask      = _mm_cmplt_ps(rsq22,rcutoff2);
653
654             /* Update potential sum for this i atom from the interaction with this j atom. */
655             velec            = _mm_and_ps(velec,cutoff_mask);
656             velecsum         = _mm_add_ps(velecsum,velec);
657
658             fscal            = felec;
659
660             fscal            = _mm_and_ps(fscal,cutoff_mask);
661
662              /* Update vectorial force */
663             fix2             = _mm_macc_ps(dx22,fscal,fix2);
664             fiy2             = _mm_macc_ps(dy22,fscal,fiy2);
665             fiz2             = _mm_macc_ps(dz22,fscal,fiz2);
666
667             fjx2             = _mm_macc_ps(dx22,fscal,fjx2);
668             fjy2             = _mm_macc_ps(dy22,fscal,fjy2);
669             fjz2             = _mm_macc_ps(dz22,fscal,fjz2);
670
671             }
672
673             fjptrA             = f+j_coord_offsetA;
674             fjptrB             = f+j_coord_offsetB;
675             fjptrC             = f+j_coord_offsetC;
676             fjptrD             = f+j_coord_offsetD;
677
678             gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
679                                                    fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
680
681             /* Inner loop uses 297 flops */
682         }
683
684         if(jidx<j_index_end)
685         {
686
687             /* Get j neighbor index, and coordinate index */
688             jnrlistA         = jjnr[jidx];
689             jnrlistB         = jjnr[jidx+1];
690             jnrlistC         = jjnr[jidx+2];
691             jnrlistD         = jjnr[jidx+3];
692             /* Sign of each element will be negative for non-real atoms.
693              * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
694              * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
695              */
696             dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
697             jnrA       = (jnrlistA>=0) ? jnrlistA : 0;
698             jnrB       = (jnrlistB>=0) ? jnrlistB : 0;
699             jnrC       = (jnrlistC>=0) ? jnrlistC : 0;
700             jnrD       = (jnrlistD>=0) ? jnrlistD : 0;
701             j_coord_offsetA  = DIM*jnrA;
702             j_coord_offsetB  = DIM*jnrB;
703             j_coord_offsetC  = DIM*jnrC;
704             j_coord_offsetD  = DIM*jnrD;
705
706             /* load j atom coordinates */
707             gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
708                                               x+j_coord_offsetC,x+j_coord_offsetD,
709                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
710
711             /* Calculate displacement vector */
712             dx00             = _mm_sub_ps(ix0,jx0);
713             dy00             = _mm_sub_ps(iy0,jy0);
714             dz00             = _mm_sub_ps(iz0,jz0);
715             dx01             = _mm_sub_ps(ix0,jx1);
716             dy01             = _mm_sub_ps(iy0,jy1);
717             dz01             = _mm_sub_ps(iz0,jz1);
718             dx02             = _mm_sub_ps(ix0,jx2);
719             dy02             = _mm_sub_ps(iy0,jy2);
720             dz02             = _mm_sub_ps(iz0,jz2);
721             dx10             = _mm_sub_ps(ix1,jx0);
722             dy10             = _mm_sub_ps(iy1,jy0);
723             dz10             = _mm_sub_ps(iz1,jz0);
724             dx11             = _mm_sub_ps(ix1,jx1);
725             dy11             = _mm_sub_ps(iy1,jy1);
726             dz11             = _mm_sub_ps(iz1,jz1);
727             dx12             = _mm_sub_ps(ix1,jx2);
728             dy12             = _mm_sub_ps(iy1,jy2);
729             dz12             = _mm_sub_ps(iz1,jz2);
730             dx20             = _mm_sub_ps(ix2,jx0);
731             dy20             = _mm_sub_ps(iy2,jy0);
732             dz20             = _mm_sub_ps(iz2,jz0);
733             dx21             = _mm_sub_ps(ix2,jx1);
734             dy21             = _mm_sub_ps(iy2,jy1);
735             dz21             = _mm_sub_ps(iz2,jz1);
736             dx22             = _mm_sub_ps(ix2,jx2);
737             dy22             = _mm_sub_ps(iy2,jy2);
738             dz22             = _mm_sub_ps(iz2,jz2);
739
740             /* Calculate squared distance and things based on it */
741             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
742             rsq01            = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
743             rsq02            = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
744             rsq10            = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
745             rsq11            = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
746             rsq12            = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
747             rsq20            = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
748             rsq21            = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
749             rsq22            = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
750
751             rinv00           = gmx_mm_invsqrt_ps(rsq00);
752             rinv01           = gmx_mm_invsqrt_ps(rsq01);
753             rinv02           = gmx_mm_invsqrt_ps(rsq02);
754             rinv10           = gmx_mm_invsqrt_ps(rsq10);
755             rinv11           = gmx_mm_invsqrt_ps(rsq11);
756             rinv12           = gmx_mm_invsqrt_ps(rsq12);
757             rinv20           = gmx_mm_invsqrt_ps(rsq20);
758             rinv21           = gmx_mm_invsqrt_ps(rsq21);
759             rinv22           = gmx_mm_invsqrt_ps(rsq22);
760
761             rinvsq00         = _mm_mul_ps(rinv00,rinv00);
762             rinvsq01         = _mm_mul_ps(rinv01,rinv01);
763             rinvsq02         = _mm_mul_ps(rinv02,rinv02);
764             rinvsq10         = _mm_mul_ps(rinv10,rinv10);
765             rinvsq11         = _mm_mul_ps(rinv11,rinv11);
766             rinvsq12         = _mm_mul_ps(rinv12,rinv12);
767             rinvsq20         = _mm_mul_ps(rinv20,rinv20);
768             rinvsq21         = _mm_mul_ps(rinv21,rinv21);
769             rinvsq22         = _mm_mul_ps(rinv22,rinv22);
770
771             fjx0             = _mm_setzero_ps();
772             fjy0             = _mm_setzero_ps();
773             fjz0             = _mm_setzero_ps();
774             fjx1             = _mm_setzero_ps();
775             fjy1             = _mm_setzero_ps();
776             fjz1             = _mm_setzero_ps();
777             fjx2             = _mm_setzero_ps();
778             fjy2             = _mm_setzero_ps();
779             fjz2             = _mm_setzero_ps();
780
781             /**************************
782              * CALCULATE INTERACTIONS *
783              **************************/
784
785             if (gmx_mm_any_lt(rsq00,rcutoff2))
786             {
787
788             r00              = _mm_mul_ps(rsq00,rinv00);
789             r00              = _mm_andnot_ps(dummy_mask,r00);
790
791             /* EWALD ELECTROSTATICS */
792
793             /* Analytical PME correction */
794             zeta2            = _mm_mul_ps(beta2,rsq00);
795             rinv3            = _mm_mul_ps(rinvsq00,rinv00);
796             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
797             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
798             felec            = _mm_mul_ps(qq00,felec);
799             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
800             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv00,sh_ewald));
801             velec            = _mm_mul_ps(qq00,velec);
802
803             cutoff_mask      = _mm_cmplt_ps(rsq00,rcutoff2);
804
805             /* Update potential sum for this i atom from the interaction with this j atom. */
806             velec            = _mm_and_ps(velec,cutoff_mask);
807             velec            = _mm_andnot_ps(dummy_mask,velec);
808             velecsum         = _mm_add_ps(velecsum,velec);
809
810             fscal            = felec;
811
812             fscal            = _mm_and_ps(fscal,cutoff_mask);
813
814             fscal            = _mm_andnot_ps(dummy_mask,fscal);
815
816              /* Update vectorial force */
817             fix0             = _mm_macc_ps(dx00,fscal,fix0);
818             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
819             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
820
821             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
822             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
823             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
824
825             }
826
827             /**************************
828              * CALCULATE INTERACTIONS *
829              **************************/
830
831             if (gmx_mm_any_lt(rsq01,rcutoff2))
832             {
833
834             r01              = _mm_mul_ps(rsq01,rinv01);
835             r01              = _mm_andnot_ps(dummy_mask,r01);
836
837             /* EWALD ELECTROSTATICS */
838
839             /* Analytical PME correction */
840             zeta2            = _mm_mul_ps(beta2,rsq01);
841             rinv3            = _mm_mul_ps(rinvsq01,rinv01);
842             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
843             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
844             felec            = _mm_mul_ps(qq01,felec);
845             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
846             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv01,sh_ewald));
847             velec            = _mm_mul_ps(qq01,velec);
848
849             cutoff_mask      = _mm_cmplt_ps(rsq01,rcutoff2);
850
851             /* Update potential sum for this i atom from the interaction with this j atom. */
852             velec            = _mm_and_ps(velec,cutoff_mask);
853             velec            = _mm_andnot_ps(dummy_mask,velec);
854             velecsum         = _mm_add_ps(velecsum,velec);
855
856             fscal            = felec;
857
858             fscal            = _mm_and_ps(fscal,cutoff_mask);
859
860             fscal            = _mm_andnot_ps(dummy_mask,fscal);
861
862              /* Update vectorial force */
863             fix0             = _mm_macc_ps(dx01,fscal,fix0);
864             fiy0             = _mm_macc_ps(dy01,fscal,fiy0);
865             fiz0             = _mm_macc_ps(dz01,fscal,fiz0);
866
867             fjx1             = _mm_macc_ps(dx01,fscal,fjx1);
868             fjy1             = _mm_macc_ps(dy01,fscal,fjy1);
869             fjz1             = _mm_macc_ps(dz01,fscal,fjz1);
870
871             }
872
873             /**************************
874              * CALCULATE INTERACTIONS *
875              **************************/
876
877             if (gmx_mm_any_lt(rsq02,rcutoff2))
878             {
879
880             r02              = _mm_mul_ps(rsq02,rinv02);
881             r02              = _mm_andnot_ps(dummy_mask,r02);
882
883             /* EWALD ELECTROSTATICS */
884
885             /* Analytical PME correction */
886             zeta2            = _mm_mul_ps(beta2,rsq02);
887             rinv3            = _mm_mul_ps(rinvsq02,rinv02);
888             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
889             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
890             felec            = _mm_mul_ps(qq02,felec);
891             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
892             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv02,sh_ewald));
893             velec            = _mm_mul_ps(qq02,velec);
894
895             cutoff_mask      = _mm_cmplt_ps(rsq02,rcutoff2);
896
897             /* Update potential sum for this i atom from the interaction with this j atom. */
898             velec            = _mm_and_ps(velec,cutoff_mask);
899             velec            = _mm_andnot_ps(dummy_mask,velec);
900             velecsum         = _mm_add_ps(velecsum,velec);
901
902             fscal            = felec;
903
904             fscal            = _mm_and_ps(fscal,cutoff_mask);
905
906             fscal            = _mm_andnot_ps(dummy_mask,fscal);
907
908              /* Update vectorial force */
909             fix0             = _mm_macc_ps(dx02,fscal,fix0);
910             fiy0             = _mm_macc_ps(dy02,fscal,fiy0);
911             fiz0             = _mm_macc_ps(dz02,fscal,fiz0);
912
913             fjx2             = _mm_macc_ps(dx02,fscal,fjx2);
914             fjy2             = _mm_macc_ps(dy02,fscal,fjy2);
915             fjz2             = _mm_macc_ps(dz02,fscal,fjz2);
916
917             }
918
919             /**************************
920              * CALCULATE INTERACTIONS *
921              **************************/
922
923             if (gmx_mm_any_lt(rsq10,rcutoff2))
924             {
925
926             r10              = _mm_mul_ps(rsq10,rinv10);
927             r10              = _mm_andnot_ps(dummy_mask,r10);
928
929             /* EWALD ELECTROSTATICS */
930
931             /* Analytical PME correction */
932             zeta2            = _mm_mul_ps(beta2,rsq10);
933             rinv3            = _mm_mul_ps(rinvsq10,rinv10);
934             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
935             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
936             felec            = _mm_mul_ps(qq10,felec);
937             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
938             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv10,sh_ewald));
939             velec            = _mm_mul_ps(qq10,velec);
940
941             cutoff_mask      = _mm_cmplt_ps(rsq10,rcutoff2);
942
943             /* Update potential sum for this i atom from the interaction with this j atom. */
944             velec            = _mm_and_ps(velec,cutoff_mask);
945             velec            = _mm_andnot_ps(dummy_mask,velec);
946             velecsum         = _mm_add_ps(velecsum,velec);
947
948             fscal            = felec;
949
950             fscal            = _mm_and_ps(fscal,cutoff_mask);
951
952             fscal            = _mm_andnot_ps(dummy_mask,fscal);
953
954              /* Update vectorial force */
955             fix1             = _mm_macc_ps(dx10,fscal,fix1);
956             fiy1             = _mm_macc_ps(dy10,fscal,fiy1);
957             fiz1             = _mm_macc_ps(dz10,fscal,fiz1);
958
959             fjx0             = _mm_macc_ps(dx10,fscal,fjx0);
960             fjy0             = _mm_macc_ps(dy10,fscal,fjy0);
961             fjz0             = _mm_macc_ps(dz10,fscal,fjz0);
962
963             }
964
965             /**************************
966              * CALCULATE INTERACTIONS *
967              **************************/
968
969             if (gmx_mm_any_lt(rsq11,rcutoff2))
970             {
971
972             r11              = _mm_mul_ps(rsq11,rinv11);
973             r11              = _mm_andnot_ps(dummy_mask,r11);
974
975             /* EWALD ELECTROSTATICS */
976
977             /* Analytical PME correction */
978             zeta2            = _mm_mul_ps(beta2,rsq11);
979             rinv3            = _mm_mul_ps(rinvsq11,rinv11);
980             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
981             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
982             felec            = _mm_mul_ps(qq11,felec);
983             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
984             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv11,sh_ewald));
985             velec            = _mm_mul_ps(qq11,velec);
986
987             cutoff_mask      = _mm_cmplt_ps(rsq11,rcutoff2);
988
989             /* Update potential sum for this i atom from the interaction with this j atom. */
990             velec            = _mm_and_ps(velec,cutoff_mask);
991             velec            = _mm_andnot_ps(dummy_mask,velec);
992             velecsum         = _mm_add_ps(velecsum,velec);
993
994             fscal            = felec;
995
996             fscal            = _mm_and_ps(fscal,cutoff_mask);
997
998             fscal            = _mm_andnot_ps(dummy_mask,fscal);
999
1000              /* Update vectorial force */
1001             fix1             = _mm_macc_ps(dx11,fscal,fix1);
1002             fiy1             = _mm_macc_ps(dy11,fscal,fiy1);
1003             fiz1             = _mm_macc_ps(dz11,fscal,fiz1);
1004
1005             fjx1             = _mm_macc_ps(dx11,fscal,fjx1);
1006             fjy1             = _mm_macc_ps(dy11,fscal,fjy1);
1007             fjz1             = _mm_macc_ps(dz11,fscal,fjz1);
1008
1009             }
1010
1011             /**************************
1012              * CALCULATE INTERACTIONS *
1013              **************************/
1014
1015             if (gmx_mm_any_lt(rsq12,rcutoff2))
1016             {
1017
1018             r12              = _mm_mul_ps(rsq12,rinv12);
1019             r12              = _mm_andnot_ps(dummy_mask,r12);
1020
1021             /* EWALD ELECTROSTATICS */
1022
1023             /* Analytical PME correction */
1024             zeta2            = _mm_mul_ps(beta2,rsq12);
1025             rinv3            = _mm_mul_ps(rinvsq12,rinv12);
1026             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1027             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1028             felec            = _mm_mul_ps(qq12,felec);
1029             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
1030             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv12,sh_ewald));
1031             velec            = _mm_mul_ps(qq12,velec);
1032
1033             cutoff_mask      = _mm_cmplt_ps(rsq12,rcutoff2);
1034
1035             /* Update potential sum for this i atom from the interaction with this j atom. */
1036             velec            = _mm_and_ps(velec,cutoff_mask);
1037             velec            = _mm_andnot_ps(dummy_mask,velec);
1038             velecsum         = _mm_add_ps(velecsum,velec);
1039
1040             fscal            = felec;
1041
1042             fscal            = _mm_and_ps(fscal,cutoff_mask);
1043
1044             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1045
1046              /* Update vectorial force */
1047             fix1             = _mm_macc_ps(dx12,fscal,fix1);
1048             fiy1             = _mm_macc_ps(dy12,fscal,fiy1);
1049             fiz1             = _mm_macc_ps(dz12,fscal,fiz1);
1050
1051             fjx2             = _mm_macc_ps(dx12,fscal,fjx2);
1052             fjy2             = _mm_macc_ps(dy12,fscal,fjy2);
1053             fjz2             = _mm_macc_ps(dz12,fscal,fjz2);
1054
1055             }
1056
1057             /**************************
1058              * CALCULATE INTERACTIONS *
1059              **************************/
1060
1061             if (gmx_mm_any_lt(rsq20,rcutoff2))
1062             {
1063
1064             r20              = _mm_mul_ps(rsq20,rinv20);
1065             r20              = _mm_andnot_ps(dummy_mask,r20);
1066
1067             /* EWALD ELECTROSTATICS */
1068
1069             /* Analytical PME correction */
1070             zeta2            = _mm_mul_ps(beta2,rsq20);
1071             rinv3            = _mm_mul_ps(rinvsq20,rinv20);
1072             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1073             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1074             felec            = _mm_mul_ps(qq20,felec);
1075             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
1076             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv20,sh_ewald));
1077             velec            = _mm_mul_ps(qq20,velec);
1078
1079             cutoff_mask      = _mm_cmplt_ps(rsq20,rcutoff2);
1080
1081             /* Update potential sum for this i atom from the interaction with this j atom. */
1082             velec            = _mm_and_ps(velec,cutoff_mask);
1083             velec            = _mm_andnot_ps(dummy_mask,velec);
1084             velecsum         = _mm_add_ps(velecsum,velec);
1085
1086             fscal            = felec;
1087
1088             fscal            = _mm_and_ps(fscal,cutoff_mask);
1089
1090             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1091
1092              /* Update vectorial force */
1093             fix2             = _mm_macc_ps(dx20,fscal,fix2);
1094             fiy2             = _mm_macc_ps(dy20,fscal,fiy2);
1095             fiz2             = _mm_macc_ps(dz20,fscal,fiz2);
1096
1097             fjx0             = _mm_macc_ps(dx20,fscal,fjx0);
1098             fjy0             = _mm_macc_ps(dy20,fscal,fjy0);
1099             fjz0             = _mm_macc_ps(dz20,fscal,fjz0);
1100
1101             }
1102
1103             /**************************
1104              * CALCULATE INTERACTIONS *
1105              **************************/
1106
1107             if (gmx_mm_any_lt(rsq21,rcutoff2))
1108             {
1109
1110             r21              = _mm_mul_ps(rsq21,rinv21);
1111             r21              = _mm_andnot_ps(dummy_mask,r21);
1112
1113             /* EWALD ELECTROSTATICS */
1114
1115             /* Analytical PME correction */
1116             zeta2            = _mm_mul_ps(beta2,rsq21);
1117             rinv3            = _mm_mul_ps(rinvsq21,rinv21);
1118             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1119             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1120             felec            = _mm_mul_ps(qq21,felec);
1121             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
1122             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv21,sh_ewald));
1123             velec            = _mm_mul_ps(qq21,velec);
1124
1125             cutoff_mask      = _mm_cmplt_ps(rsq21,rcutoff2);
1126
1127             /* Update potential sum for this i atom from the interaction with this j atom. */
1128             velec            = _mm_and_ps(velec,cutoff_mask);
1129             velec            = _mm_andnot_ps(dummy_mask,velec);
1130             velecsum         = _mm_add_ps(velecsum,velec);
1131
1132             fscal            = felec;
1133
1134             fscal            = _mm_and_ps(fscal,cutoff_mask);
1135
1136             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1137
1138              /* Update vectorial force */
1139             fix2             = _mm_macc_ps(dx21,fscal,fix2);
1140             fiy2             = _mm_macc_ps(dy21,fscal,fiy2);
1141             fiz2             = _mm_macc_ps(dz21,fscal,fiz2);
1142
1143             fjx1             = _mm_macc_ps(dx21,fscal,fjx1);
1144             fjy1             = _mm_macc_ps(dy21,fscal,fjy1);
1145             fjz1             = _mm_macc_ps(dz21,fscal,fjz1);
1146
1147             }
1148
1149             /**************************
1150              * CALCULATE INTERACTIONS *
1151              **************************/
1152
1153             if (gmx_mm_any_lt(rsq22,rcutoff2))
1154             {
1155
1156             r22              = _mm_mul_ps(rsq22,rinv22);
1157             r22              = _mm_andnot_ps(dummy_mask,r22);
1158
1159             /* EWALD ELECTROSTATICS */
1160
1161             /* Analytical PME correction */
1162             zeta2            = _mm_mul_ps(beta2,rsq22);
1163             rinv3            = _mm_mul_ps(rinvsq22,rinv22);
1164             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1165             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1166             felec            = _mm_mul_ps(qq22,felec);
1167             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
1168             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv22,sh_ewald));
1169             velec            = _mm_mul_ps(qq22,velec);
1170
1171             cutoff_mask      = _mm_cmplt_ps(rsq22,rcutoff2);
1172
1173             /* Update potential sum for this i atom from the interaction with this j atom. */
1174             velec            = _mm_and_ps(velec,cutoff_mask);
1175             velec            = _mm_andnot_ps(dummy_mask,velec);
1176             velecsum         = _mm_add_ps(velecsum,velec);
1177
1178             fscal            = felec;
1179
1180             fscal            = _mm_and_ps(fscal,cutoff_mask);
1181
1182             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1183
1184              /* Update vectorial force */
1185             fix2             = _mm_macc_ps(dx22,fscal,fix2);
1186             fiy2             = _mm_macc_ps(dy22,fscal,fiy2);
1187             fiz2             = _mm_macc_ps(dz22,fscal,fiz2);
1188
1189             fjx2             = _mm_macc_ps(dx22,fscal,fjx2);
1190             fjy2             = _mm_macc_ps(dy22,fscal,fjy2);
1191             fjz2             = _mm_macc_ps(dz22,fscal,fjz2);
1192
1193             }
1194
1195             fjptrA             = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1196             fjptrB             = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1197             fjptrC             = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1198             fjptrD             = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1199
1200             gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
1201                                                    fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1202
1203             /* Inner loop uses 306 flops */
1204         }
1205
1206         /* End of innermost loop */
1207
1208         gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
1209                                               f+i_coord_offset,fshift+i_shift_offset);
1210
1211         ggid                        = gid[iidx];
1212         /* Update potential energies */
1213         gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
1214
1215         /* Increment number of inner iterations */
1216         inneriter                  += j_index_end - j_index_start;
1217
1218         /* Outer loop uses 19 flops */
1219     }
1220
1221     /* Increment number of outer iterations */
1222     outeriter        += nri;
1223
1224     /* Update outer/inner flops */
1225
1226     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3W3_VF,outeriter*19 + inneriter*306);
1227 }
1228 /*
1229  * Gromacs nonbonded kernel:   nb_kernel_ElecEwSh_VdwNone_GeomW3W3_F_avx_128_fma_single
1230  * Electrostatics interaction: Ewald
1231  * VdW interaction:            None
1232  * Geometry:                   Water3-Water3
1233  * Calculate force/pot:        Force
1234  */
1235 void
1236 nb_kernel_ElecEwSh_VdwNone_GeomW3W3_F_avx_128_fma_single
1237                     (t_nblist                    * gmx_restrict       nlist,
1238                      rvec                        * gmx_restrict          xx,
1239                      rvec                        * gmx_restrict          ff,
1240                      t_forcerec                  * gmx_restrict          fr,
1241                      t_mdatoms                   * gmx_restrict     mdatoms,
1242                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
1243                      t_nrnb                      * gmx_restrict        nrnb)
1244 {
1245     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
1246      * just 0 for non-waters.
1247      * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
1248      * jnr indices corresponding to data put in the four positions in the SIMD register.
1249      */
1250     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
1251     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
1252     int              jnrA,jnrB,jnrC,jnrD;
1253     int              jnrlistA,jnrlistB,jnrlistC,jnrlistD;
1254     int              j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
1255     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
1256     real             rcutoff_scalar;
1257     real             *shiftvec,*fshift,*x,*f;
1258     real             *fjptrA,*fjptrB,*fjptrC,*fjptrD;
1259     real             scratch[4*DIM];
1260     __m128           fscal,rcutoff,rcutoff2,jidxall;
1261     int              vdwioffset0;
1262     __m128           ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
1263     int              vdwioffset1;
1264     __m128           ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
1265     int              vdwioffset2;
1266     __m128           ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
1267     int              vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
1268     __m128           jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
1269     int              vdwjidx1A,vdwjidx1B,vdwjidx1C,vdwjidx1D;
1270     __m128           jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
1271     int              vdwjidx2A,vdwjidx2B,vdwjidx2C,vdwjidx2D;
1272     __m128           jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
1273     __m128           dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
1274     __m128           dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01;
1275     __m128           dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02;
1276     __m128           dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
1277     __m128           dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11;
1278     __m128           dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12;
1279     __m128           dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
1280     __m128           dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21;
1281     __m128           dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22;
1282     __m128           velec,felec,velecsum,facel,crf,krf,krf2;
1283     real             *charge;
1284     __m128i          ewitab;
1285     __m128           ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
1286     __m128           beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
1287     real             *ewtab;
1288     __m128           dummy_mask,cutoff_mask;
1289     __m128           signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
1290     __m128           one     = _mm_set1_ps(1.0);
1291     __m128           two     = _mm_set1_ps(2.0);
1292     x                = xx[0];
1293     f                = ff[0];
1294
1295     nri              = nlist->nri;
1296     iinr             = nlist->iinr;
1297     jindex           = nlist->jindex;
1298     jjnr             = nlist->jjnr;
1299     shiftidx         = nlist->shift;
1300     gid              = nlist->gid;
1301     shiftvec         = fr->shift_vec[0];
1302     fshift           = fr->fshift[0];
1303     facel            = _mm_set1_ps(fr->epsfac);
1304     charge           = mdatoms->chargeA;
1305
1306     sh_ewald         = _mm_set1_ps(fr->ic->sh_ewald);
1307     beta             = _mm_set1_ps(fr->ic->ewaldcoeff_q);
1308     beta2            = _mm_mul_ps(beta,beta);
1309     beta3            = _mm_mul_ps(beta,beta2);
1310     ewtab            = fr->ic->tabq_coul_F;
1311     ewtabscale       = _mm_set1_ps(fr->ic->tabq_scale);
1312     ewtabhalfspace   = _mm_set1_ps(0.5/fr->ic->tabq_scale);
1313
1314     /* Setup water-specific parameters */
1315     inr              = nlist->iinr[0];
1316     iq0              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
1317     iq1              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
1318     iq2              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
1319
1320     jq0              = _mm_set1_ps(charge[inr+0]);
1321     jq1              = _mm_set1_ps(charge[inr+1]);
1322     jq2              = _mm_set1_ps(charge[inr+2]);
1323     qq00             = _mm_mul_ps(iq0,jq0);
1324     qq01             = _mm_mul_ps(iq0,jq1);
1325     qq02             = _mm_mul_ps(iq0,jq2);
1326     qq10             = _mm_mul_ps(iq1,jq0);
1327     qq11             = _mm_mul_ps(iq1,jq1);
1328     qq12             = _mm_mul_ps(iq1,jq2);
1329     qq20             = _mm_mul_ps(iq2,jq0);
1330     qq21             = _mm_mul_ps(iq2,jq1);
1331     qq22             = _mm_mul_ps(iq2,jq2);
1332
1333     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
1334     rcutoff_scalar   = fr->rcoulomb;
1335     rcutoff          = _mm_set1_ps(rcutoff_scalar);
1336     rcutoff2         = _mm_mul_ps(rcutoff,rcutoff);
1337
1338     /* Avoid stupid compiler warnings */
1339     jnrA = jnrB = jnrC = jnrD = 0;
1340     j_coord_offsetA = 0;
1341     j_coord_offsetB = 0;
1342     j_coord_offsetC = 0;
1343     j_coord_offsetD = 0;
1344
1345     outeriter        = 0;
1346     inneriter        = 0;
1347
1348     for(iidx=0;iidx<4*DIM;iidx++)
1349     {
1350         scratch[iidx] = 0.0;
1351     }
1352
1353     /* Start outer loop over neighborlists */
1354     for(iidx=0; iidx<nri; iidx++)
1355     {
1356         /* Load shift vector for this list */
1357         i_shift_offset   = DIM*shiftidx[iidx];
1358
1359         /* Load limits for loop over neighbors */
1360         j_index_start    = jindex[iidx];
1361         j_index_end      = jindex[iidx+1];
1362
1363         /* Get outer coordinate index */
1364         inr              = iinr[iidx];
1365         i_coord_offset   = DIM*inr;
1366
1367         /* Load i particle coords and add shift vector */
1368         gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
1369                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
1370
1371         fix0             = _mm_setzero_ps();
1372         fiy0             = _mm_setzero_ps();
1373         fiz0             = _mm_setzero_ps();
1374         fix1             = _mm_setzero_ps();
1375         fiy1             = _mm_setzero_ps();
1376         fiz1             = _mm_setzero_ps();
1377         fix2             = _mm_setzero_ps();
1378         fiy2             = _mm_setzero_ps();
1379         fiz2             = _mm_setzero_ps();
1380
1381         /* Start inner kernel loop */
1382         for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
1383         {
1384
1385             /* Get j neighbor index, and coordinate index */
1386             jnrA             = jjnr[jidx];
1387             jnrB             = jjnr[jidx+1];
1388             jnrC             = jjnr[jidx+2];
1389             jnrD             = jjnr[jidx+3];
1390             j_coord_offsetA  = DIM*jnrA;
1391             j_coord_offsetB  = DIM*jnrB;
1392             j_coord_offsetC  = DIM*jnrC;
1393             j_coord_offsetD  = DIM*jnrD;
1394
1395             /* load j atom coordinates */
1396             gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1397                                               x+j_coord_offsetC,x+j_coord_offsetD,
1398                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1399
1400             /* Calculate displacement vector */
1401             dx00             = _mm_sub_ps(ix0,jx0);
1402             dy00             = _mm_sub_ps(iy0,jy0);
1403             dz00             = _mm_sub_ps(iz0,jz0);
1404             dx01             = _mm_sub_ps(ix0,jx1);
1405             dy01             = _mm_sub_ps(iy0,jy1);
1406             dz01             = _mm_sub_ps(iz0,jz1);
1407             dx02             = _mm_sub_ps(ix0,jx2);
1408             dy02             = _mm_sub_ps(iy0,jy2);
1409             dz02             = _mm_sub_ps(iz0,jz2);
1410             dx10             = _mm_sub_ps(ix1,jx0);
1411             dy10             = _mm_sub_ps(iy1,jy0);
1412             dz10             = _mm_sub_ps(iz1,jz0);
1413             dx11             = _mm_sub_ps(ix1,jx1);
1414             dy11             = _mm_sub_ps(iy1,jy1);
1415             dz11             = _mm_sub_ps(iz1,jz1);
1416             dx12             = _mm_sub_ps(ix1,jx2);
1417             dy12             = _mm_sub_ps(iy1,jy2);
1418             dz12             = _mm_sub_ps(iz1,jz2);
1419             dx20             = _mm_sub_ps(ix2,jx0);
1420             dy20             = _mm_sub_ps(iy2,jy0);
1421             dz20             = _mm_sub_ps(iz2,jz0);
1422             dx21             = _mm_sub_ps(ix2,jx1);
1423             dy21             = _mm_sub_ps(iy2,jy1);
1424             dz21             = _mm_sub_ps(iz2,jz1);
1425             dx22             = _mm_sub_ps(ix2,jx2);
1426             dy22             = _mm_sub_ps(iy2,jy2);
1427             dz22             = _mm_sub_ps(iz2,jz2);
1428
1429             /* Calculate squared distance and things based on it */
1430             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1431             rsq01            = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
1432             rsq02            = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
1433             rsq10            = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
1434             rsq11            = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
1435             rsq12            = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
1436             rsq20            = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
1437             rsq21            = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
1438             rsq22            = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
1439
1440             rinv00           = gmx_mm_invsqrt_ps(rsq00);
1441             rinv01           = gmx_mm_invsqrt_ps(rsq01);
1442             rinv02           = gmx_mm_invsqrt_ps(rsq02);
1443             rinv10           = gmx_mm_invsqrt_ps(rsq10);
1444             rinv11           = gmx_mm_invsqrt_ps(rsq11);
1445             rinv12           = gmx_mm_invsqrt_ps(rsq12);
1446             rinv20           = gmx_mm_invsqrt_ps(rsq20);
1447             rinv21           = gmx_mm_invsqrt_ps(rsq21);
1448             rinv22           = gmx_mm_invsqrt_ps(rsq22);
1449
1450             rinvsq00         = _mm_mul_ps(rinv00,rinv00);
1451             rinvsq01         = _mm_mul_ps(rinv01,rinv01);
1452             rinvsq02         = _mm_mul_ps(rinv02,rinv02);
1453             rinvsq10         = _mm_mul_ps(rinv10,rinv10);
1454             rinvsq11         = _mm_mul_ps(rinv11,rinv11);
1455             rinvsq12         = _mm_mul_ps(rinv12,rinv12);
1456             rinvsq20         = _mm_mul_ps(rinv20,rinv20);
1457             rinvsq21         = _mm_mul_ps(rinv21,rinv21);
1458             rinvsq22         = _mm_mul_ps(rinv22,rinv22);
1459
1460             fjx0             = _mm_setzero_ps();
1461             fjy0             = _mm_setzero_ps();
1462             fjz0             = _mm_setzero_ps();
1463             fjx1             = _mm_setzero_ps();
1464             fjy1             = _mm_setzero_ps();
1465             fjz1             = _mm_setzero_ps();
1466             fjx2             = _mm_setzero_ps();
1467             fjy2             = _mm_setzero_ps();
1468             fjz2             = _mm_setzero_ps();
1469
1470             /**************************
1471              * CALCULATE INTERACTIONS *
1472              **************************/
1473
1474             if (gmx_mm_any_lt(rsq00,rcutoff2))
1475             {
1476
1477             r00              = _mm_mul_ps(rsq00,rinv00);
1478
1479             /* EWALD ELECTROSTATICS */
1480
1481             /* Analytical PME correction */
1482             zeta2            = _mm_mul_ps(beta2,rsq00);
1483             rinv3            = _mm_mul_ps(rinvsq00,rinv00);
1484             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1485             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1486             felec            = _mm_mul_ps(qq00,felec);
1487
1488             cutoff_mask      = _mm_cmplt_ps(rsq00,rcutoff2);
1489
1490             fscal            = felec;
1491
1492             fscal            = _mm_and_ps(fscal,cutoff_mask);
1493
1494              /* Update vectorial force */
1495             fix0             = _mm_macc_ps(dx00,fscal,fix0);
1496             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
1497             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
1498
1499             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
1500             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
1501             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
1502
1503             }
1504
1505             /**************************
1506              * CALCULATE INTERACTIONS *
1507              **************************/
1508
1509             if (gmx_mm_any_lt(rsq01,rcutoff2))
1510             {
1511
1512             r01              = _mm_mul_ps(rsq01,rinv01);
1513
1514             /* EWALD ELECTROSTATICS */
1515
1516             /* Analytical PME correction */
1517             zeta2            = _mm_mul_ps(beta2,rsq01);
1518             rinv3            = _mm_mul_ps(rinvsq01,rinv01);
1519             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1520             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1521             felec            = _mm_mul_ps(qq01,felec);
1522
1523             cutoff_mask      = _mm_cmplt_ps(rsq01,rcutoff2);
1524
1525             fscal            = felec;
1526
1527             fscal            = _mm_and_ps(fscal,cutoff_mask);
1528
1529              /* Update vectorial force */
1530             fix0             = _mm_macc_ps(dx01,fscal,fix0);
1531             fiy0             = _mm_macc_ps(dy01,fscal,fiy0);
1532             fiz0             = _mm_macc_ps(dz01,fscal,fiz0);
1533
1534             fjx1             = _mm_macc_ps(dx01,fscal,fjx1);
1535             fjy1             = _mm_macc_ps(dy01,fscal,fjy1);
1536             fjz1             = _mm_macc_ps(dz01,fscal,fjz1);
1537
1538             }
1539
1540             /**************************
1541              * CALCULATE INTERACTIONS *
1542              **************************/
1543
1544             if (gmx_mm_any_lt(rsq02,rcutoff2))
1545             {
1546
1547             r02              = _mm_mul_ps(rsq02,rinv02);
1548
1549             /* EWALD ELECTROSTATICS */
1550
1551             /* Analytical PME correction */
1552             zeta2            = _mm_mul_ps(beta2,rsq02);
1553             rinv3            = _mm_mul_ps(rinvsq02,rinv02);
1554             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1555             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1556             felec            = _mm_mul_ps(qq02,felec);
1557
1558             cutoff_mask      = _mm_cmplt_ps(rsq02,rcutoff2);
1559
1560             fscal            = felec;
1561
1562             fscal            = _mm_and_ps(fscal,cutoff_mask);
1563
1564              /* Update vectorial force */
1565             fix0             = _mm_macc_ps(dx02,fscal,fix0);
1566             fiy0             = _mm_macc_ps(dy02,fscal,fiy0);
1567             fiz0             = _mm_macc_ps(dz02,fscal,fiz0);
1568
1569             fjx2             = _mm_macc_ps(dx02,fscal,fjx2);
1570             fjy2             = _mm_macc_ps(dy02,fscal,fjy2);
1571             fjz2             = _mm_macc_ps(dz02,fscal,fjz2);
1572
1573             }
1574
1575             /**************************
1576              * CALCULATE INTERACTIONS *
1577              **************************/
1578
1579             if (gmx_mm_any_lt(rsq10,rcutoff2))
1580             {
1581
1582             r10              = _mm_mul_ps(rsq10,rinv10);
1583
1584             /* EWALD ELECTROSTATICS */
1585
1586             /* Analytical PME correction */
1587             zeta2            = _mm_mul_ps(beta2,rsq10);
1588             rinv3            = _mm_mul_ps(rinvsq10,rinv10);
1589             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1590             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1591             felec            = _mm_mul_ps(qq10,felec);
1592
1593             cutoff_mask      = _mm_cmplt_ps(rsq10,rcutoff2);
1594
1595             fscal            = felec;
1596
1597             fscal            = _mm_and_ps(fscal,cutoff_mask);
1598
1599              /* Update vectorial force */
1600             fix1             = _mm_macc_ps(dx10,fscal,fix1);
1601             fiy1             = _mm_macc_ps(dy10,fscal,fiy1);
1602             fiz1             = _mm_macc_ps(dz10,fscal,fiz1);
1603
1604             fjx0             = _mm_macc_ps(dx10,fscal,fjx0);
1605             fjy0             = _mm_macc_ps(dy10,fscal,fjy0);
1606             fjz0             = _mm_macc_ps(dz10,fscal,fjz0);
1607
1608             }
1609
1610             /**************************
1611              * CALCULATE INTERACTIONS *
1612              **************************/
1613
1614             if (gmx_mm_any_lt(rsq11,rcutoff2))
1615             {
1616
1617             r11              = _mm_mul_ps(rsq11,rinv11);
1618
1619             /* EWALD ELECTROSTATICS */
1620
1621             /* Analytical PME correction */
1622             zeta2            = _mm_mul_ps(beta2,rsq11);
1623             rinv3            = _mm_mul_ps(rinvsq11,rinv11);
1624             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1625             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1626             felec            = _mm_mul_ps(qq11,felec);
1627
1628             cutoff_mask      = _mm_cmplt_ps(rsq11,rcutoff2);
1629
1630             fscal            = felec;
1631
1632             fscal            = _mm_and_ps(fscal,cutoff_mask);
1633
1634              /* Update vectorial force */
1635             fix1             = _mm_macc_ps(dx11,fscal,fix1);
1636             fiy1             = _mm_macc_ps(dy11,fscal,fiy1);
1637             fiz1             = _mm_macc_ps(dz11,fscal,fiz1);
1638
1639             fjx1             = _mm_macc_ps(dx11,fscal,fjx1);
1640             fjy1             = _mm_macc_ps(dy11,fscal,fjy1);
1641             fjz1             = _mm_macc_ps(dz11,fscal,fjz1);
1642
1643             }
1644
1645             /**************************
1646              * CALCULATE INTERACTIONS *
1647              **************************/
1648
1649             if (gmx_mm_any_lt(rsq12,rcutoff2))
1650             {
1651
1652             r12              = _mm_mul_ps(rsq12,rinv12);
1653
1654             /* EWALD ELECTROSTATICS */
1655
1656             /* Analytical PME correction */
1657             zeta2            = _mm_mul_ps(beta2,rsq12);
1658             rinv3            = _mm_mul_ps(rinvsq12,rinv12);
1659             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1660             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1661             felec            = _mm_mul_ps(qq12,felec);
1662
1663             cutoff_mask      = _mm_cmplt_ps(rsq12,rcutoff2);
1664
1665             fscal            = felec;
1666
1667             fscal            = _mm_and_ps(fscal,cutoff_mask);
1668
1669              /* Update vectorial force */
1670             fix1             = _mm_macc_ps(dx12,fscal,fix1);
1671             fiy1             = _mm_macc_ps(dy12,fscal,fiy1);
1672             fiz1             = _mm_macc_ps(dz12,fscal,fiz1);
1673
1674             fjx2             = _mm_macc_ps(dx12,fscal,fjx2);
1675             fjy2             = _mm_macc_ps(dy12,fscal,fjy2);
1676             fjz2             = _mm_macc_ps(dz12,fscal,fjz2);
1677
1678             }
1679
1680             /**************************
1681              * CALCULATE INTERACTIONS *
1682              **************************/
1683
1684             if (gmx_mm_any_lt(rsq20,rcutoff2))
1685             {
1686
1687             r20              = _mm_mul_ps(rsq20,rinv20);
1688
1689             /* EWALD ELECTROSTATICS */
1690
1691             /* Analytical PME correction */
1692             zeta2            = _mm_mul_ps(beta2,rsq20);
1693             rinv3            = _mm_mul_ps(rinvsq20,rinv20);
1694             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1695             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1696             felec            = _mm_mul_ps(qq20,felec);
1697
1698             cutoff_mask      = _mm_cmplt_ps(rsq20,rcutoff2);
1699
1700             fscal            = felec;
1701
1702             fscal            = _mm_and_ps(fscal,cutoff_mask);
1703
1704              /* Update vectorial force */
1705             fix2             = _mm_macc_ps(dx20,fscal,fix2);
1706             fiy2             = _mm_macc_ps(dy20,fscal,fiy2);
1707             fiz2             = _mm_macc_ps(dz20,fscal,fiz2);
1708
1709             fjx0             = _mm_macc_ps(dx20,fscal,fjx0);
1710             fjy0             = _mm_macc_ps(dy20,fscal,fjy0);
1711             fjz0             = _mm_macc_ps(dz20,fscal,fjz0);
1712
1713             }
1714
1715             /**************************
1716              * CALCULATE INTERACTIONS *
1717              **************************/
1718
1719             if (gmx_mm_any_lt(rsq21,rcutoff2))
1720             {
1721
1722             r21              = _mm_mul_ps(rsq21,rinv21);
1723
1724             /* EWALD ELECTROSTATICS */
1725
1726             /* Analytical PME correction */
1727             zeta2            = _mm_mul_ps(beta2,rsq21);
1728             rinv3            = _mm_mul_ps(rinvsq21,rinv21);
1729             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1730             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1731             felec            = _mm_mul_ps(qq21,felec);
1732
1733             cutoff_mask      = _mm_cmplt_ps(rsq21,rcutoff2);
1734
1735             fscal            = felec;
1736
1737             fscal            = _mm_and_ps(fscal,cutoff_mask);
1738
1739              /* Update vectorial force */
1740             fix2             = _mm_macc_ps(dx21,fscal,fix2);
1741             fiy2             = _mm_macc_ps(dy21,fscal,fiy2);
1742             fiz2             = _mm_macc_ps(dz21,fscal,fiz2);
1743
1744             fjx1             = _mm_macc_ps(dx21,fscal,fjx1);
1745             fjy1             = _mm_macc_ps(dy21,fscal,fjy1);
1746             fjz1             = _mm_macc_ps(dz21,fscal,fjz1);
1747
1748             }
1749
1750             /**************************
1751              * CALCULATE INTERACTIONS *
1752              **************************/
1753
1754             if (gmx_mm_any_lt(rsq22,rcutoff2))
1755             {
1756
1757             r22              = _mm_mul_ps(rsq22,rinv22);
1758
1759             /* EWALD ELECTROSTATICS */
1760
1761             /* Analytical PME correction */
1762             zeta2            = _mm_mul_ps(beta2,rsq22);
1763             rinv3            = _mm_mul_ps(rinvsq22,rinv22);
1764             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1765             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1766             felec            = _mm_mul_ps(qq22,felec);
1767
1768             cutoff_mask      = _mm_cmplt_ps(rsq22,rcutoff2);
1769
1770             fscal            = felec;
1771
1772             fscal            = _mm_and_ps(fscal,cutoff_mask);
1773
1774              /* Update vectorial force */
1775             fix2             = _mm_macc_ps(dx22,fscal,fix2);
1776             fiy2             = _mm_macc_ps(dy22,fscal,fiy2);
1777             fiz2             = _mm_macc_ps(dz22,fscal,fiz2);
1778
1779             fjx2             = _mm_macc_ps(dx22,fscal,fjx2);
1780             fjy2             = _mm_macc_ps(dy22,fscal,fjy2);
1781             fjz2             = _mm_macc_ps(dz22,fscal,fjz2);
1782
1783             }
1784
1785             fjptrA             = f+j_coord_offsetA;
1786             fjptrB             = f+j_coord_offsetB;
1787             fjptrC             = f+j_coord_offsetC;
1788             fjptrD             = f+j_coord_offsetD;
1789
1790             gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
1791                                                    fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
1792
1793             /* Inner loop uses 279 flops */
1794         }
1795
1796         if(jidx<j_index_end)
1797         {
1798
1799             /* Get j neighbor index, and coordinate index */
1800             jnrlistA         = jjnr[jidx];
1801             jnrlistB         = jjnr[jidx+1];
1802             jnrlistC         = jjnr[jidx+2];
1803             jnrlistD         = jjnr[jidx+3];
1804             /* Sign of each element will be negative for non-real atoms.
1805              * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
1806              * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
1807              */
1808             dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
1809             jnrA       = (jnrlistA>=0) ? jnrlistA : 0;
1810             jnrB       = (jnrlistB>=0) ? jnrlistB : 0;
1811             jnrC       = (jnrlistC>=0) ? jnrlistC : 0;
1812             jnrD       = (jnrlistD>=0) ? jnrlistD : 0;
1813             j_coord_offsetA  = DIM*jnrA;
1814             j_coord_offsetB  = DIM*jnrB;
1815             j_coord_offsetC  = DIM*jnrC;
1816             j_coord_offsetD  = DIM*jnrD;
1817
1818             /* load j atom coordinates */
1819             gmx_mm_load_3rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
1820                                               x+j_coord_offsetC,x+j_coord_offsetD,
1821                                               &jx0,&jy0,&jz0,&jx1,&jy1,&jz1,&jx2,&jy2,&jz2);
1822
1823             /* Calculate displacement vector */
1824             dx00             = _mm_sub_ps(ix0,jx0);
1825             dy00             = _mm_sub_ps(iy0,jy0);
1826             dz00             = _mm_sub_ps(iz0,jz0);
1827             dx01             = _mm_sub_ps(ix0,jx1);
1828             dy01             = _mm_sub_ps(iy0,jy1);
1829             dz01             = _mm_sub_ps(iz0,jz1);
1830             dx02             = _mm_sub_ps(ix0,jx2);
1831             dy02             = _mm_sub_ps(iy0,jy2);
1832             dz02             = _mm_sub_ps(iz0,jz2);
1833             dx10             = _mm_sub_ps(ix1,jx0);
1834             dy10             = _mm_sub_ps(iy1,jy0);
1835             dz10             = _mm_sub_ps(iz1,jz0);
1836             dx11             = _mm_sub_ps(ix1,jx1);
1837             dy11             = _mm_sub_ps(iy1,jy1);
1838             dz11             = _mm_sub_ps(iz1,jz1);
1839             dx12             = _mm_sub_ps(ix1,jx2);
1840             dy12             = _mm_sub_ps(iy1,jy2);
1841             dz12             = _mm_sub_ps(iz1,jz2);
1842             dx20             = _mm_sub_ps(ix2,jx0);
1843             dy20             = _mm_sub_ps(iy2,jy0);
1844             dz20             = _mm_sub_ps(iz2,jz0);
1845             dx21             = _mm_sub_ps(ix2,jx1);
1846             dy21             = _mm_sub_ps(iy2,jy1);
1847             dz21             = _mm_sub_ps(iz2,jz1);
1848             dx22             = _mm_sub_ps(ix2,jx2);
1849             dy22             = _mm_sub_ps(iy2,jy2);
1850             dz22             = _mm_sub_ps(iz2,jz2);
1851
1852             /* Calculate squared distance and things based on it */
1853             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
1854             rsq01            = gmx_mm_calc_rsq_ps(dx01,dy01,dz01);
1855             rsq02            = gmx_mm_calc_rsq_ps(dx02,dy02,dz02);
1856             rsq10            = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
1857             rsq11            = gmx_mm_calc_rsq_ps(dx11,dy11,dz11);
1858             rsq12            = gmx_mm_calc_rsq_ps(dx12,dy12,dz12);
1859             rsq20            = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
1860             rsq21            = gmx_mm_calc_rsq_ps(dx21,dy21,dz21);
1861             rsq22            = gmx_mm_calc_rsq_ps(dx22,dy22,dz22);
1862
1863             rinv00           = gmx_mm_invsqrt_ps(rsq00);
1864             rinv01           = gmx_mm_invsqrt_ps(rsq01);
1865             rinv02           = gmx_mm_invsqrt_ps(rsq02);
1866             rinv10           = gmx_mm_invsqrt_ps(rsq10);
1867             rinv11           = gmx_mm_invsqrt_ps(rsq11);
1868             rinv12           = gmx_mm_invsqrt_ps(rsq12);
1869             rinv20           = gmx_mm_invsqrt_ps(rsq20);
1870             rinv21           = gmx_mm_invsqrt_ps(rsq21);
1871             rinv22           = gmx_mm_invsqrt_ps(rsq22);
1872
1873             rinvsq00         = _mm_mul_ps(rinv00,rinv00);
1874             rinvsq01         = _mm_mul_ps(rinv01,rinv01);
1875             rinvsq02         = _mm_mul_ps(rinv02,rinv02);
1876             rinvsq10         = _mm_mul_ps(rinv10,rinv10);
1877             rinvsq11         = _mm_mul_ps(rinv11,rinv11);
1878             rinvsq12         = _mm_mul_ps(rinv12,rinv12);
1879             rinvsq20         = _mm_mul_ps(rinv20,rinv20);
1880             rinvsq21         = _mm_mul_ps(rinv21,rinv21);
1881             rinvsq22         = _mm_mul_ps(rinv22,rinv22);
1882
1883             fjx0             = _mm_setzero_ps();
1884             fjy0             = _mm_setzero_ps();
1885             fjz0             = _mm_setzero_ps();
1886             fjx1             = _mm_setzero_ps();
1887             fjy1             = _mm_setzero_ps();
1888             fjz1             = _mm_setzero_ps();
1889             fjx2             = _mm_setzero_ps();
1890             fjy2             = _mm_setzero_ps();
1891             fjz2             = _mm_setzero_ps();
1892
1893             /**************************
1894              * CALCULATE INTERACTIONS *
1895              **************************/
1896
1897             if (gmx_mm_any_lt(rsq00,rcutoff2))
1898             {
1899
1900             r00              = _mm_mul_ps(rsq00,rinv00);
1901             r00              = _mm_andnot_ps(dummy_mask,r00);
1902
1903             /* EWALD ELECTROSTATICS */
1904
1905             /* Analytical PME correction */
1906             zeta2            = _mm_mul_ps(beta2,rsq00);
1907             rinv3            = _mm_mul_ps(rinvsq00,rinv00);
1908             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1909             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1910             felec            = _mm_mul_ps(qq00,felec);
1911
1912             cutoff_mask      = _mm_cmplt_ps(rsq00,rcutoff2);
1913
1914             fscal            = felec;
1915
1916             fscal            = _mm_and_ps(fscal,cutoff_mask);
1917
1918             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1919
1920              /* Update vectorial force */
1921             fix0             = _mm_macc_ps(dx00,fscal,fix0);
1922             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
1923             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
1924
1925             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
1926             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
1927             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
1928
1929             }
1930
1931             /**************************
1932              * CALCULATE INTERACTIONS *
1933              **************************/
1934
1935             if (gmx_mm_any_lt(rsq01,rcutoff2))
1936             {
1937
1938             r01              = _mm_mul_ps(rsq01,rinv01);
1939             r01              = _mm_andnot_ps(dummy_mask,r01);
1940
1941             /* EWALD ELECTROSTATICS */
1942
1943             /* Analytical PME correction */
1944             zeta2            = _mm_mul_ps(beta2,rsq01);
1945             rinv3            = _mm_mul_ps(rinvsq01,rinv01);
1946             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1947             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1948             felec            = _mm_mul_ps(qq01,felec);
1949
1950             cutoff_mask      = _mm_cmplt_ps(rsq01,rcutoff2);
1951
1952             fscal            = felec;
1953
1954             fscal            = _mm_and_ps(fscal,cutoff_mask);
1955
1956             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1957
1958              /* Update vectorial force */
1959             fix0             = _mm_macc_ps(dx01,fscal,fix0);
1960             fiy0             = _mm_macc_ps(dy01,fscal,fiy0);
1961             fiz0             = _mm_macc_ps(dz01,fscal,fiz0);
1962
1963             fjx1             = _mm_macc_ps(dx01,fscal,fjx1);
1964             fjy1             = _mm_macc_ps(dy01,fscal,fjy1);
1965             fjz1             = _mm_macc_ps(dz01,fscal,fjz1);
1966
1967             }
1968
1969             /**************************
1970              * CALCULATE INTERACTIONS *
1971              **************************/
1972
1973             if (gmx_mm_any_lt(rsq02,rcutoff2))
1974             {
1975
1976             r02              = _mm_mul_ps(rsq02,rinv02);
1977             r02              = _mm_andnot_ps(dummy_mask,r02);
1978
1979             /* EWALD ELECTROSTATICS */
1980
1981             /* Analytical PME correction */
1982             zeta2            = _mm_mul_ps(beta2,rsq02);
1983             rinv3            = _mm_mul_ps(rinvsq02,rinv02);
1984             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1985             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1986             felec            = _mm_mul_ps(qq02,felec);
1987
1988             cutoff_mask      = _mm_cmplt_ps(rsq02,rcutoff2);
1989
1990             fscal            = felec;
1991
1992             fscal            = _mm_and_ps(fscal,cutoff_mask);
1993
1994             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1995
1996              /* Update vectorial force */
1997             fix0             = _mm_macc_ps(dx02,fscal,fix0);
1998             fiy0             = _mm_macc_ps(dy02,fscal,fiy0);
1999             fiz0             = _mm_macc_ps(dz02,fscal,fiz0);
2000
2001             fjx2             = _mm_macc_ps(dx02,fscal,fjx2);
2002             fjy2             = _mm_macc_ps(dy02,fscal,fjy2);
2003             fjz2             = _mm_macc_ps(dz02,fscal,fjz2);
2004
2005             }
2006
2007             /**************************
2008              * CALCULATE INTERACTIONS *
2009              **************************/
2010
2011             if (gmx_mm_any_lt(rsq10,rcutoff2))
2012             {
2013
2014             r10              = _mm_mul_ps(rsq10,rinv10);
2015             r10              = _mm_andnot_ps(dummy_mask,r10);
2016
2017             /* EWALD ELECTROSTATICS */
2018
2019             /* Analytical PME correction */
2020             zeta2            = _mm_mul_ps(beta2,rsq10);
2021             rinv3            = _mm_mul_ps(rinvsq10,rinv10);
2022             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
2023             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
2024             felec            = _mm_mul_ps(qq10,felec);
2025
2026             cutoff_mask      = _mm_cmplt_ps(rsq10,rcutoff2);
2027
2028             fscal            = felec;
2029
2030             fscal            = _mm_and_ps(fscal,cutoff_mask);
2031
2032             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2033
2034              /* Update vectorial force */
2035             fix1             = _mm_macc_ps(dx10,fscal,fix1);
2036             fiy1             = _mm_macc_ps(dy10,fscal,fiy1);
2037             fiz1             = _mm_macc_ps(dz10,fscal,fiz1);
2038
2039             fjx0             = _mm_macc_ps(dx10,fscal,fjx0);
2040             fjy0             = _mm_macc_ps(dy10,fscal,fjy0);
2041             fjz0             = _mm_macc_ps(dz10,fscal,fjz0);
2042
2043             }
2044
2045             /**************************
2046              * CALCULATE INTERACTIONS *
2047              **************************/
2048
2049             if (gmx_mm_any_lt(rsq11,rcutoff2))
2050             {
2051
2052             r11              = _mm_mul_ps(rsq11,rinv11);
2053             r11              = _mm_andnot_ps(dummy_mask,r11);
2054
2055             /* EWALD ELECTROSTATICS */
2056
2057             /* Analytical PME correction */
2058             zeta2            = _mm_mul_ps(beta2,rsq11);
2059             rinv3            = _mm_mul_ps(rinvsq11,rinv11);
2060             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
2061             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
2062             felec            = _mm_mul_ps(qq11,felec);
2063
2064             cutoff_mask      = _mm_cmplt_ps(rsq11,rcutoff2);
2065
2066             fscal            = felec;
2067
2068             fscal            = _mm_and_ps(fscal,cutoff_mask);
2069
2070             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2071
2072              /* Update vectorial force */
2073             fix1             = _mm_macc_ps(dx11,fscal,fix1);
2074             fiy1             = _mm_macc_ps(dy11,fscal,fiy1);
2075             fiz1             = _mm_macc_ps(dz11,fscal,fiz1);
2076
2077             fjx1             = _mm_macc_ps(dx11,fscal,fjx1);
2078             fjy1             = _mm_macc_ps(dy11,fscal,fjy1);
2079             fjz1             = _mm_macc_ps(dz11,fscal,fjz1);
2080
2081             }
2082
2083             /**************************
2084              * CALCULATE INTERACTIONS *
2085              **************************/
2086
2087             if (gmx_mm_any_lt(rsq12,rcutoff2))
2088             {
2089
2090             r12              = _mm_mul_ps(rsq12,rinv12);
2091             r12              = _mm_andnot_ps(dummy_mask,r12);
2092
2093             /* EWALD ELECTROSTATICS */
2094
2095             /* Analytical PME correction */
2096             zeta2            = _mm_mul_ps(beta2,rsq12);
2097             rinv3            = _mm_mul_ps(rinvsq12,rinv12);
2098             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
2099             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
2100             felec            = _mm_mul_ps(qq12,felec);
2101
2102             cutoff_mask      = _mm_cmplt_ps(rsq12,rcutoff2);
2103
2104             fscal            = felec;
2105
2106             fscal            = _mm_and_ps(fscal,cutoff_mask);
2107
2108             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2109
2110              /* Update vectorial force */
2111             fix1             = _mm_macc_ps(dx12,fscal,fix1);
2112             fiy1             = _mm_macc_ps(dy12,fscal,fiy1);
2113             fiz1             = _mm_macc_ps(dz12,fscal,fiz1);
2114
2115             fjx2             = _mm_macc_ps(dx12,fscal,fjx2);
2116             fjy2             = _mm_macc_ps(dy12,fscal,fjy2);
2117             fjz2             = _mm_macc_ps(dz12,fscal,fjz2);
2118
2119             }
2120
2121             /**************************
2122              * CALCULATE INTERACTIONS *
2123              **************************/
2124
2125             if (gmx_mm_any_lt(rsq20,rcutoff2))
2126             {
2127
2128             r20              = _mm_mul_ps(rsq20,rinv20);
2129             r20              = _mm_andnot_ps(dummy_mask,r20);
2130
2131             /* EWALD ELECTROSTATICS */
2132
2133             /* Analytical PME correction */
2134             zeta2            = _mm_mul_ps(beta2,rsq20);
2135             rinv3            = _mm_mul_ps(rinvsq20,rinv20);
2136             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
2137             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
2138             felec            = _mm_mul_ps(qq20,felec);
2139
2140             cutoff_mask      = _mm_cmplt_ps(rsq20,rcutoff2);
2141
2142             fscal            = felec;
2143
2144             fscal            = _mm_and_ps(fscal,cutoff_mask);
2145
2146             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2147
2148              /* Update vectorial force */
2149             fix2             = _mm_macc_ps(dx20,fscal,fix2);
2150             fiy2             = _mm_macc_ps(dy20,fscal,fiy2);
2151             fiz2             = _mm_macc_ps(dz20,fscal,fiz2);
2152
2153             fjx0             = _mm_macc_ps(dx20,fscal,fjx0);
2154             fjy0             = _mm_macc_ps(dy20,fscal,fjy0);
2155             fjz0             = _mm_macc_ps(dz20,fscal,fjz0);
2156
2157             }
2158
2159             /**************************
2160              * CALCULATE INTERACTIONS *
2161              **************************/
2162
2163             if (gmx_mm_any_lt(rsq21,rcutoff2))
2164             {
2165
2166             r21              = _mm_mul_ps(rsq21,rinv21);
2167             r21              = _mm_andnot_ps(dummy_mask,r21);
2168
2169             /* EWALD ELECTROSTATICS */
2170
2171             /* Analytical PME correction */
2172             zeta2            = _mm_mul_ps(beta2,rsq21);
2173             rinv3            = _mm_mul_ps(rinvsq21,rinv21);
2174             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
2175             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
2176             felec            = _mm_mul_ps(qq21,felec);
2177
2178             cutoff_mask      = _mm_cmplt_ps(rsq21,rcutoff2);
2179
2180             fscal            = felec;
2181
2182             fscal            = _mm_and_ps(fscal,cutoff_mask);
2183
2184             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2185
2186              /* Update vectorial force */
2187             fix2             = _mm_macc_ps(dx21,fscal,fix2);
2188             fiy2             = _mm_macc_ps(dy21,fscal,fiy2);
2189             fiz2             = _mm_macc_ps(dz21,fscal,fiz2);
2190
2191             fjx1             = _mm_macc_ps(dx21,fscal,fjx1);
2192             fjy1             = _mm_macc_ps(dy21,fscal,fjy1);
2193             fjz1             = _mm_macc_ps(dz21,fscal,fjz1);
2194
2195             }
2196
2197             /**************************
2198              * CALCULATE INTERACTIONS *
2199              **************************/
2200
2201             if (gmx_mm_any_lt(rsq22,rcutoff2))
2202             {
2203
2204             r22              = _mm_mul_ps(rsq22,rinv22);
2205             r22              = _mm_andnot_ps(dummy_mask,r22);
2206
2207             /* EWALD ELECTROSTATICS */
2208
2209             /* Analytical PME correction */
2210             zeta2            = _mm_mul_ps(beta2,rsq22);
2211             rinv3            = _mm_mul_ps(rinvsq22,rinv22);
2212             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
2213             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
2214             felec            = _mm_mul_ps(qq22,felec);
2215
2216             cutoff_mask      = _mm_cmplt_ps(rsq22,rcutoff2);
2217
2218             fscal            = felec;
2219
2220             fscal            = _mm_and_ps(fscal,cutoff_mask);
2221
2222             fscal            = _mm_andnot_ps(dummy_mask,fscal);
2223
2224              /* Update vectorial force */
2225             fix2             = _mm_macc_ps(dx22,fscal,fix2);
2226             fiy2             = _mm_macc_ps(dy22,fscal,fiy2);
2227             fiz2             = _mm_macc_ps(dz22,fscal,fiz2);
2228
2229             fjx2             = _mm_macc_ps(dx22,fscal,fjx2);
2230             fjy2             = _mm_macc_ps(dy22,fscal,fjy2);
2231             fjz2             = _mm_macc_ps(dz22,fscal,fjz2);
2232
2233             }
2234
2235             fjptrA             = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
2236             fjptrB             = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
2237             fjptrC             = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
2238             fjptrD             = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
2239
2240             gmx_mm_decrement_3rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
2241                                                    fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,fjx2,fjy2,fjz2);
2242
2243             /* Inner loop uses 288 flops */
2244         }
2245
2246         /* End of innermost loop */
2247
2248         gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
2249                                               f+i_coord_offset,fshift+i_shift_offset);
2250
2251         /* Increment number of inner iterations */
2252         inneriter                  += j_index_end - j_index_start;
2253
2254         /* Outer loop uses 18 flops */
2255     }
2256
2257     /* Increment number of outer iterations */
2258     outeriter        += nri;
2259
2260     /* Update outer/inner flops */
2261
2262     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3W3_F,outeriter*18 + inneriter*288);
2263 }