Remove no-inline-max-size and suppress remark
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_avx_128_fma_single / nb_kernel_ElecEwSh_VdwNone_GeomW3P1_avx_128_fma_single.c
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013, 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 #ifdef HAVE_CONFIG_H
39 #include <config.h>
40 #endif
41
42 #include <math.h>
43
44 #include "../nb_kernel.h"
45 #include "types/simple.h"
46 #include "vec.h"
47 #include "nrnb.h"
48
49 #include "gromacs/simd/math_x86_avx_128_fma_single.h"
50 #include "kernelutil_x86_avx_128_fma_single.h"
51
52 /*
53  * Gromacs nonbonded kernel:   nb_kernel_ElecEwSh_VdwNone_GeomW3P1_VF_avx_128_fma_single
54  * Electrostatics interaction: Ewald
55  * VdW interaction:            None
56  * Geometry:                   Water3-Particle
57  * Calculate force/pot:        PotentialAndForce
58  */
59 void
60 nb_kernel_ElecEwSh_VdwNone_GeomW3P1_VF_avx_128_fma_single
61                     (t_nblist                    * gmx_restrict       nlist,
62                      rvec                        * gmx_restrict          xx,
63                      rvec                        * gmx_restrict          ff,
64                      t_forcerec                  * gmx_restrict          fr,
65                      t_mdatoms                   * gmx_restrict     mdatoms,
66                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
67                      t_nrnb                      * gmx_restrict        nrnb)
68 {
69     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
70      * just 0 for non-waters.
71      * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
72      * jnr indices corresponding to data put in the four positions in the SIMD register.
73      */
74     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
75     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
76     int              jnrA,jnrB,jnrC,jnrD;
77     int              jnrlistA,jnrlistB,jnrlistC,jnrlistD;
78     int              j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
79     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
80     real             rcutoff_scalar;
81     real             *shiftvec,*fshift,*x,*f;
82     real             *fjptrA,*fjptrB,*fjptrC,*fjptrD;
83     real             scratch[4*DIM];
84     __m128           fscal,rcutoff,rcutoff2,jidxall;
85     int              vdwioffset0;
86     __m128           ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
87     int              vdwioffset1;
88     __m128           ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
89     int              vdwioffset2;
90     __m128           ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
91     int              vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
92     __m128           jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
93     __m128           dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
94     __m128           dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
95     __m128           dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
96     __m128           velec,felec,velecsum,facel,crf,krf,krf2;
97     real             *charge;
98     __m128i          ewitab;
99     __m128           ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
100     __m128           beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
101     real             *ewtab;
102     __m128           dummy_mask,cutoff_mask;
103     __m128           signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
104     __m128           one     = _mm_set1_ps(1.0);
105     __m128           two     = _mm_set1_ps(2.0);
106     x                = xx[0];
107     f                = ff[0];
108
109     nri              = nlist->nri;
110     iinr             = nlist->iinr;
111     jindex           = nlist->jindex;
112     jjnr             = nlist->jjnr;
113     shiftidx         = nlist->shift;
114     gid              = nlist->gid;
115     shiftvec         = fr->shift_vec[0];
116     fshift           = fr->fshift[0];
117     facel            = _mm_set1_ps(fr->epsfac);
118     charge           = mdatoms->chargeA;
119
120     sh_ewald         = _mm_set1_ps(fr->ic->sh_ewald);
121     beta             = _mm_set1_ps(fr->ic->ewaldcoeff_q);
122     beta2            = _mm_mul_ps(beta,beta);
123     beta3            = _mm_mul_ps(beta,beta2);
124     ewtab            = fr->ic->tabq_coul_FDV0;
125     ewtabscale       = _mm_set1_ps(fr->ic->tabq_scale);
126     ewtabhalfspace   = _mm_set1_ps(0.5/fr->ic->tabq_scale);
127
128     /* Setup water-specific parameters */
129     inr              = nlist->iinr[0];
130     iq0              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
131     iq1              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
132     iq2              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
133
134     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
135     rcutoff_scalar   = fr->rcoulomb;
136     rcutoff          = _mm_set1_ps(rcutoff_scalar);
137     rcutoff2         = _mm_mul_ps(rcutoff,rcutoff);
138
139     /* Avoid stupid compiler warnings */
140     jnrA = jnrB = jnrC = jnrD = 0;
141     j_coord_offsetA = 0;
142     j_coord_offsetB = 0;
143     j_coord_offsetC = 0;
144     j_coord_offsetD = 0;
145
146     outeriter        = 0;
147     inneriter        = 0;
148
149     for(iidx=0;iidx<4*DIM;iidx++)
150     {
151         scratch[iidx] = 0.0;
152     }
153
154     /* Start outer loop over neighborlists */
155     for(iidx=0; iidx<nri; iidx++)
156     {
157         /* Load shift vector for this list */
158         i_shift_offset   = DIM*shiftidx[iidx];
159
160         /* Load limits for loop over neighbors */
161         j_index_start    = jindex[iidx];
162         j_index_end      = jindex[iidx+1];
163
164         /* Get outer coordinate index */
165         inr              = iinr[iidx];
166         i_coord_offset   = DIM*inr;
167
168         /* Load i particle coords and add shift vector */
169         gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
170                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
171
172         fix0             = _mm_setzero_ps();
173         fiy0             = _mm_setzero_ps();
174         fiz0             = _mm_setzero_ps();
175         fix1             = _mm_setzero_ps();
176         fiy1             = _mm_setzero_ps();
177         fiz1             = _mm_setzero_ps();
178         fix2             = _mm_setzero_ps();
179         fiy2             = _mm_setzero_ps();
180         fiz2             = _mm_setzero_ps();
181
182         /* Reset potential sums */
183         velecsum         = _mm_setzero_ps();
184
185         /* Start inner kernel loop */
186         for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
187         {
188
189             /* Get j neighbor index, and coordinate index */
190             jnrA             = jjnr[jidx];
191             jnrB             = jjnr[jidx+1];
192             jnrC             = jjnr[jidx+2];
193             jnrD             = jjnr[jidx+3];
194             j_coord_offsetA  = DIM*jnrA;
195             j_coord_offsetB  = DIM*jnrB;
196             j_coord_offsetC  = DIM*jnrC;
197             j_coord_offsetD  = DIM*jnrD;
198
199             /* load j atom coordinates */
200             gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
201                                               x+j_coord_offsetC,x+j_coord_offsetD,
202                                               &jx0,&jy0,&jz0);
203
204             /* Calculate displacement vector */
205             dx00             = _mm_sub_ps(ix0,jx0);
206             dy00             = _mm_sub_ps(iy0,jy0);
207             dz00             = _mm_sub_ps(iz0,jz0);
208             dx10             = _mm_sub_ps(ix1,jx0);
209             dy10             = _mm_sub_ps(iy1,jy0);
210             dz10             = _mm_sub_ps(iz1,jz0);
211             dx20             = _mm_sub_ps(ix2,jx0);
212             dy20             = _mm_sub_ps(iy2,jy0);
213             dz20             = _mm_sub_ps(iz2,jz0);
214
215             /* Calculate squared distance and things based on it */
216             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
217             rsq10            = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
218             rsq20            = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
219
220             rinv00           = gmx_mm_invsqrt_ps(rsq00);
221             rinv10           = gmx_mm_invsqrt_ps(rsq10);
222             rinv20           = gmx_mm_invsqrt_ps(rsq20);
223
224             rinvsq00         = _mm_mul_ps(rinv00,rinv00);
225             rinvsq10         = _mm_mul_ps(rinv10,rinv10);
226             rinvsq20         = _mm_mul_ps(rinv20,rinv20);
227
228             /* Load parameters for j particles */
229             jq0              = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
230                                                               charge+jnrC+0,charge+jnrD+0);
231
232             fjx0             = _mm_setzero_ps();
233             fjy0             = _mm_setzero_ps();
234             fjz0             = _mm_setzero_ps();
235
236             /**************************
237              * CALCULATE INTERACTIONS *
238              **************************/
239
240             if (gmx_mm_any_lt(rsq00,rcutoff2))
241             {
242
243             r00              = _mm_mul_ps(rsq00,rinv00);
244
245             /* Compute parameters for interactions between i and j atoms */
246             qq00             = _mm_mul_ps(iq0,jq0);
247
248             /* EWALD ELECTROSTATICS */
249
250             /* Analytical PME correction */
251             zeta2            = _mm_mul_ps(beta2,rsq00);
252             rinv3            = _mm_mul_ps(rinvsq00,rinv00);
253             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
254             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
255             felec            = _mm_mul_ps(qq00,felec);
256             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
257             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv00,sh_ewald));
258             velec            = _mm_mul_ps(qq00,velec);
259
260             cutoff_mask      = _mm_cmplt_ps(rsq00,rcutoff2);
261
262             /* Update potential sum for this i atom from the interaction with this j atom. */
263             velec            = _mm_and_ps(velec,cutoff_mask);
264             velecsum         = _mm_add_ps(velecsum,velec);
265
266             fscal            = felec;
267
268             fscal            = _mm_and_ps(fscal,cutoff_mask);
269
270              /* Update vectorial force */
271             fix0             = _mm_macc_ps(dx00,fscal,fix0);
272             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
273             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
274
275             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
276             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
277             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
278
279             }
280
281             /**************************
282              * CALCULATE INTERACTIONS *
283              **************************/
284
285             if (gmx_mm_any_lt(rsq10,rcutoff2))
286             {
287
288             r10              = _mm_mul_ps(rsq10,rinv10);
289
290             /* Compute parameters for interactions between i and j atoms */
291             qq10             = _mm_mul_ps(iq1,jq0);
292
293             /* EWALD ELECTROSTATICS */
294
295             /* Analytical PME correction */
296             zeta2            = _mm_mul_ps(beta2,rsq10);
297             rinv3            = _mm_mul_ps(rinvsq10,rinv10);
298             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
299             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
300             felec            = _mm_mul_ps(qq10,felec);
301             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
302             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv10,sh_ewald));
303             velec            = _mm_mul_ps(qq10,velec);
304
305             cutoff_mask      = _mm_cmplt_ps(rsq10,rcutoff2);
306
307             /* Update potential sum for this i atom from the interaction with this j atom. */
308             velec            = _mm_and_ps(velec,cutoff_mask);
309             velecsum         = _mm_add_ps(velecsum,velec);
310
311             fscal            = felec;
312
313             fscal            = _mm_and_ps(fscal,cutoff_mask);
314
315              /* Update vectorial force */
316             fix1             = _mm_macc_ps(dx10,fscal,fix1);
317             fiy1             = _mm_macc_ps(dy10,fscal,fiy1);
318             fiz1             = _mm_macc_ps(dz10,fscal,fiz1);
319
320             fjx0             = _mm_macc_ps(dx10,fscal,fjx0);
321             fjy0             = _mm_macc_ps(dy10,fscal,fjy0);
322             fjz0             = _mm_macc_ps(dz10,fscal,fjz0);
323
324             }
325
326             /**************************
327              * CALCULATE INTERACTIONS *
328              **************************/
329
330             if (gmx_mm_any_lt(rsq20,rcutoff2))
331             {
332
333             r20              = _mm_mul_ps(rsq20,rinv20);
334
335             /* Compute parameters for interactions between i and j atoms */
336             qq20             = _mm_mul_ps(iq2,jq0);
337
338             /* EWALD ELECTROSTATICS */
339
340             /* Analytical PME correction */
341             zeta2            = _mm_mul_ps(beta2,rsq20);
342             rinv3            = _mm_mul_ps(rinvsq20,rinv20);
343             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
344             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
345             felec            = _mm_mul_ps(qq20,felec);
346             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
347             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv20,sh_ewald));
348             velec            = _mm_mul_ps(qq20,velec);
349
350             cutoff_mask      = _mm_cmplt_ps(rsq20,rcutoff2);
351
352             /* Update potential sum for this i atom from the interaction with this j atom. */
353             velec            = _mm_and_ps(velec,cutoff_mask);
354             velecsum         = _mm_add_ps(velecsum,velec);
355
356             fscal            = felec;
357
358             fscal            = _mm_and_ps(fscal,cutoff_mask);
359
360              /* Update vectorial force */
361             fix2             = _mm_macc_ps(dx20,fscal,fix2);
362             fiy2             = _mm_macc_ps(dy20,fscal,fiy2);
363             fiz2             = _mm_macc_ps(dz20,fscal,fiz2);
364
365             fjx0             = _mm_macc_ps(dx20,fscal,fjx0);
366             fjy0             = _mm_macc_ps(dy20,fscal,fjy0);
367             fjz0             = _mm_macc_ps(dz20,fscal,fjz0);
368
369             }
370
371             fjptrA             = f+j_coord_offsetA;
372             fjptrB             = f+j_coord_offsetB;
373             fjptrC             = f+j_coord_offsetC;
374             fjptrD             = f+j_coord_offsetD;
375
376             gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
377
378             /* Inner loop uses 99 flops */
379         }
380
381         if(jidx<j_index_end)
382         {
383
384             /* Get j neighbor index, and coordinate index */
385             jnrlistA         = jjnr[jidx];
386             jnrlistB         = jjnr[jidx+1];
387             jnrlistC         = jjnr[jidx+2];
388             jnrlistD         = jjnr[jidx+3];
389             /* Sign of each element will be negative for non-real atoms.
390              * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
391              * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
392              */
393             dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
394             jnrA       = (jnrlistA>=0) ? jnrlistA : 0;
395             jnrB       = (jnrlistB>=0) ? jnrlistB : 0;
396             jnrC       = (jnrlistC>=0) ? jnrlistC : 0;
397             jnrD       = (jnrlistD>=0) ? jnrlistD : 0;
398             j_coord_offsetA  = DIM*jnrA;
399             j_coord_offsetB  = DIM*jnrB;
400             j_coord_offsetC  = DIM*jnrC;
401             j_coord_offsetD  = DIM*jnrD;
402
403             /* load j atom coordinates */
404             gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
405                                               x+j_coord_offsetC,x+j_coord_offsetD,
406                                               &jx0,&jy0,&jz0);
407
408             /* Calculate displacement vector */
409             dx00             = _mm_sub_ps(ix0,jx0);
410             dy00             = _mm_sub_ps(iy0,jy0);
411             dz00             = _mm_sub_ps(iz0,jz0);
412             dx10             = _mm_sub_ps(ix1,jx0);
413             dy10             = _mm_sub_ps(iy1,jy0);
414             dz10             = _mm_sub_ps(iz1,jz0);
415             dx20             = _mm_sub_ps(ix2,jx0);
416             dy20             = _mm_sub_ps(iy2,jy0);
417             dz20             = _mm_sub_ps(iz2,jz0);
418
419             /* Calculate squared distance and things based on it */
420             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
421             rsq10            = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
422             rsq20            = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
423
424             rinv00           = gmx_mm_invsqrt_ps(rsq00);
425             rinv10           = gmx_mm_invsqrt_ps(rsq10);
426             rinv20           = gmx_mm_invsqrt_ps(rsq20);
427
428             rinvsq00         = _mm_mul_ps(rinv00,rinv00);
429             rinvsq10         = _mm_mul_ps(rinv10,rinv10);
430             rinvsq20         = _mm_mul_ps(rinv20,rinv20);
431
432             /* Load parameters for j particles */
433             jq0              = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
434                                                               charge+jnrC+0,charge+jnrD+0);
435
436             fjx0             = _mm_setzero_ps();
437             fjy0             = _mm_setzero_ps();
438             fjz0             = _mm_setzero_ps();
439
440             /**************************
441              * CALCULATE INTERACTIONS *
442              **************************/
443
444             if (gmx_mm_any_lt(rsq00,rcutoff2))
445             {
446
447             r00              = _mm_mul_ps(rsq00,rinv00);
448             r00              = _mm_andnot_ps(dummy_mask,r00);
449
450             /* Compute parameters for interactions between i and j atoms */
451             qq00             = _mm_mul_ps(iq0,jq0);
452
453             /* EWALD ELECTROSTATICS */
454
455             /* Analytical PME correction */
456             zeta2            = _mm_mul_ps(beta2,rsq00);
457             rinv3            = _mm_mul_ps(rinvsq00,rinv00);
458             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
459             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
460             felec            = _mm_mul_ps(qq00,felec);
461             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
462             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv00,sh_ewald));
463             velec            = _mm_mul_ps(qq00,velec);
464
465             cutoff_mask      = _mm_cmplt_ps(rsq00,rcutoff2);
466
467             /* Update potential sum for this i atom from the interaction with this j atom. */
468             velec            = _mm_and_ps(velec,cutoff_mask);
469             velec            = _mm_andnot_ps(dummy_mask,velec);
470             velecsum         = _mm_add_ps(velecsum,velec);
471
472             fscal            = felec;
473
474             fscal            = _mm_and_ps(fscal,cutoff_mask);
475
476             fscal            = _mm_andnot_ps(dummy_mask,fscal);
477
478              /* Update vectorial force */
479             fix0             = _mm_macc_ps(dx00,fscal,fix0);
480             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
481             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
482
483             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
484             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
485             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
486
487             }
488
489             /**************************
490              * CALCULATE INTERACTIONS *
491              **************************/
492
493             if (gmx_mm_any_lt(rsq10,rcutoff2))
494             {
495
496             r10              = _mm_mul_ps(rsq10,rinv10);
497             r10              = _mm_andnot_ps(dummy_mask,r10);
498
499             /* Compute parameters for interactions between i and j atoms */
500             qq10             = _mm_mul_ps(iq1,jq0);
501
502             /* EWALD ELECTROSTATICS */
503
504             /* Analytical PME correction */
505             zeta2            = _mm_mul_ps(beta2,rsq10);
506             rinv3            = _mm_mul_ps(rinvsq10,rinv10);
507             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
508             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
509             felec            = _mm_mul_ps(qq10,felec);
510             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
511             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv10,sh_ewald));
512             velec            = _mm_mul_ps(qq10,velec);
513
514             cutoff_mask      = _mm_cmplt_ps(rsq10,rcutoff2);
515
516             /* Update potential sum for this i atom from the interaction with this j atom. */
517             velec            = _mm_and_ps(velec,cutoff_mask);
518             velec            = _mm_andnot_ps(dummy_mask,velec);
519             velecsum         = _mm_add_ps(velecsum,velec);
520
521             fscal            = felec;
522
523             fscal            = _mm_and_ps(fscal,cutoff_mask);
524
525             fscal            = _mm_andnot_ps(dummy_mask,fscal);
526
527              /* Update vectorial force */
528             fix1             = _mm_macc_ps(dx10,fscal,fix1);
529             fiy1             = _mm_macc_ps(dy10,fscal,fiy1);
530             fiz1             = _mm_macc_ps(dz10,fscal,fiz1);
531
532             fjx0             = _mm_macc_ps(dx10,fscal,fjx0);
533             fjy0             = _mm_macc_ps(dy10,fscal,fjy0);
534             fjz0             = _mm_macc_ps(dz10,fscal,fjz0);
535
536             }
537
538             /**************************
539              * CALCULATE INTERACTIONS *
540              **************************/
541
542             if (gmx_mm_any_lt(rsq20,rcutoff2))
543             {
544
545             r20              = _mm_mul_ps(rsq20,rinv20);
546             r20              = _mm_andnot_ps(dummy_mask,r20);
547
548             /* Compute parameters for interactions between i and j atoms */
549             qq20             = _mm_mul_ps(iq2,jq0);
550
551             /* EWALD ELECTROSTATICS */
552
553             /* Analytical PME correction */
554             zeta2            = _mm_mul_ps(beta2,rsq20);
555             rinv3            = _mm_mul_ps(rinvsq20,rinv20);
556             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
557             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
558             felec            = _mm_mul_ps(qq20,felec);
559             pmecorrV         = gmx_mm_pmecorrV_ps(zeta2);
560             velec            = _mm_nmacc_ps(pmecorrV,beta,_mm_sub_ps(rinv20,sh_ewald));
561             velec            = _mm_mul_ps(qq20,velec);
562
563             cutoff_mask      = _mm_cmplt_ps(rsq20,rcutoff2);
564
565             /* Update potential sum for this i atom from the interaction with this j atom. */
566             velec            = _mm_and_ps(velec,cutoff_mask);
567             velec            = _mm_andnot_ps(dummy_mask,velec);
568             velecsum         = _mm_add_ps(velecsum,velec);
569
570             fscal            = felec;
571
572             fscal            = _mm_and_ps(fscal,cutoff_mask);
573
574             fscal            = _mm_andnot_ps(dummy_mask,fscal);
575
576              /* Update vectorial force */
577             fix2             = _mm_macc_ps(dx20,fscal,fix2);
578             fiy2             = _mm_macc_ps(dy20,fscal,fiy2);
579             fiz2             = _mm_macc_ps(dz20,fscal,fiz2);
580
581             fjx0             = _mm_macc_ps(dx20,fscal,fjx0);
582             fjy0             = _mm_macc_ps(dy20,fscal,fjy0);
583             fjz0             = _mm_macc_ps(dz20,fscal,fjz0);
584
585             }
586
587             fjptrA             = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
588             fjptrB             = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
589             fjptrC             = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
590             fjptrD             = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
591
592             gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
593
594             /* Inner loop uses 102 flops */
595         }
596
597         /* End of innermost loop */
598
599         gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
600                                               f+i_coord_offset,fshift+i_shift_offset);
601
602         ggid                        = gid[iidx];
603         /* Update potential energies */
604         gmx_mm_update_1pot_ps(velecsum,kernel_data->energygrp_elec+ggid);
605
606         /* Increment number of inner iterations */
607         inneriter                  += j_index_end - j_index_start;
608
609         /* Outer loop uses 19 flops */
610     }
611
612     /* Increment number of outer iterations */
613     outeriter        += nri;
614
615     /* Update outer/inner flops */
616
617     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_VF,outeriter*19 + inneriter*102);
618 }
619 /*
620  * Gromacs nonbonded kernel:   nb_kernel_ElecEwSh_VdwNone_GeomW3P1_F_avx_128_fma_single
621  * Electrostatics interaction: Ewald
622  * VdW interaction:            None
623  * Geometry:                   Water3-Particle
624  * Calculate force/pot:        Force
625  */
626 void
627 nb_kernel_ElecEwSh_VdwNone_GeomW3P1_F_avx_128_fma_single
628                     (t_nblist                    * gmx_restrict       nlist,
629                      rvec                        * gmx_restrict          xx,
630                      rvec                        * gmx_restrict          ff,
631                      t_forcerec                  * gmx_restrict          fr,
632                      t_mdatoms                   * gmx_restrict     mdatoms,
633                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
634                      t_nrnb                      * gmx_restrict        nrnb)
635 {
636     /* Suffixes 0,1,2,3 refer to particle indices for waters in the inner or outer loop, or
637      * just 0 for non-waters.
638      * Suffixes A,B,C,D refer to j loop unrolling done with AVX_128, e.g. for the four different
639      * jnr indices corresponding to data put in the four positions in the SIMD register.
640      */
641     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
642     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
643     int              jnrA,jnrB,jnrC,jnrD;
644     int              jnrlistA,jnrlistB,jnrlistC,jnrlistD;
645     int              j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
646     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
647     real             rcutoff_scalar;
648     real             *shiftvec,*fshift,*x,*f;
649     real             *fjptrA,*fjptrB,*fjptrC,*fjptrD;
650     real             scratch[4*DIM];
651     __m128           fscal,rcutoff,rcutoff2,jidxall;
652     int              vdwioffset0;
653     __m128           ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
654     int              vdwioffset1;
655     __m128           ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
656     int              vdwioffset2;
657     __m128           ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
658     int              vdwjidx0A,vdwjidx0B,vdwjidx0C,vdwjidx0D;
659     __m128           jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
660     __m128           dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00;
661     __m128           dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10;
662     __m128           dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20;
663     __m128           velec,felec,velecsum,facel,crf,krf,krf2;
664     real             *charge;
665     __m128i          ewitab;
666     __m128           ewtabscale,eweps,twoeweps,sh_ewald,ewrt,ewtabhalfspace,ewtabF,ewtabFn,ewtabD,ewtabV;
667     __m128           beta,beta2,beta3,zeta2,pmecorrF,pmecorrV,rinv3;
668     real             *ewtab;
669     __m128           dummy_mask,cutoff_mask;
670     __m128           signbit = _mm_castsi128_ps( _mm_set1_epi32(0x80000000) );
671     __m128           one     = _mm_set1_ps(1.0);
672     __m128           two     = _mm_set1_ps(2.0);
673     x                = xx[0];
674     f                = ff[0];
675
676     nri              = nlist->nri;
677     iinr             = nlist->iinr;
678     jindex           = nlist->jindex;
679     jjnr             = nlist->jjnr;
680     shiftidx         = nlist->shift;
681     gid              = nlist->gid;
682     shiftvec         = fr->shift_vec[0];
683     fshift           = fr->fshift[0];
684     facel            = _mm_set1_ps(fr->epsfac);
685     charge           = mdatoms->chargeA;
686
687     sh_ewald         = _mm_set1_ps(fr->ic->sh_ewald);
688     beta             = _mm_set1_ps(fr->ic->ewaldcoeff_q);
689     beta2            = _mm_mul_ps(beta,beta);
690     beta3            = _mm_mul_ps(beta,beta2);
691     ewtab            = fr->ic->tabq_coul_F;
692     ewtabscale       = _mm_set1_ps(fr->ic->tabq_scale);
693     ewtabhalfspace   = _mm_set1_ps(0.5/fr->ic->tabq_scale);
694
695     /* Setup water-specific parameters */
696     inr              = nlist->iinr[0];
697     iq0              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+0]));
698     iq1              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+1]));
699     iq2              = _mm_mul_ps(facel,_mm_set1_ps(charge[inr+2]));
700
701     /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
702     rcutoff_scalar   = fr->rcoulomb;
703     rcutoff          = _mm_set1_ps(rcutoff_scalar);
704     rcutoff2         = _mm_mul_ps(rcutoff,rcutoff);
705
706     /* Avoid stupid compiler warnings */
707     jnrA = jnrB = jnrC = jnrD = 0;
708     j_coord_offsetA = 0;
709     j_coord_offsetB = 0;
710     j_coord_offsetC = 0;
711     j_coord_offsetD = 0;
712
713     outeriter        = 0;
714     inneriter        = 0;
715
716     for(iidx=0;iidx<4*DIM;iidx++)
717     {
718         scratch[iidx] = 0.0;
719     }
720
721     /* Start outer loop over neighborlists */
722     for(iidx=0; iidx<nri; iidx++)
723     {
724         /* Load shift vector for this list */
725         i_shift_offset   = DIM*shiftidx[iidx];
726
727         /* Load limits for loop over neighbors */
728         j_index_start    = jindex[iidx];
729         j_index_end      = jindex[iidx+1];
730
731         /* Get outer coordinate index */
732         inr              = iinr[iidx];
733         i_coord_offset   = DIM*inr;
734
735         /* Load i particle coords and add shift vector */
736         gmx_mm_load_shift_and_3rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
737                                                  &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2);
738
739         fix0             = _mm_setzero_ps();
740         fiy0             = _mm_setzero_ps();
741         fiz0             = _mm_setzero_ps();
742         fix1             = _mm_setzero_ps();
743         fiy1             = _mm_setzero_ps();
744         fiz1             = _mm_setzero_ps();
745         fix2             = _mm_setzero_ps();
746         fiy2             = _mm_setzero_ps();
747         fiz2             = _mm_setzero_ps();
748
749         /* Start inner kernel loop */
750         for(jidx=j_index_start; jidx<j_index_end && jjnr[jidx+3]>=0; jidx+=4)
751         {
752
753             /* Get j neighbor index, and coordinate index */
754             jnrA             = jjnr[jidx];
755             jnrB             = jjnr[jidx+1];
756             jnrC             = jjnr[jidx+2];
757             jnrD             = jjnr[jidx+3];
758             j_coord_offsetA  = DIM*jnrA;
759             j_coord_offsetB  = DIM*jnrB;
760             j_coord_offsetC  = DIM*jnrC;
761             j_coord_offsetD  = DIM*jnrD;
762
763             /* load j atom coordinates */
764             gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
765                                               x+j_coord_offsetC,x+j_coord_offsetD,
766                                               &jx0,&jy0,&jz0);
767
768             /* Calculate displacement vector */
769             dx00             = _mm_sub_ps(ix0,jx0);
770             dy00             = _mm_sub_ps(iy0,jy0);
771             dz00             = _mm_sub_ps(iz0,jz0);
772             dx10             = _mm_sub_ps(ix1,jx0);
773             dy10             = _mm_sub_ps(iy1,jy0);
774             dz10             = _mm_sub_ps(iz1,jz0);
775             dx20             = _mm_sub_ps(ix2,jx0);
776             dy20             = _mm_sub_ps(iy2,jy0);
777             dz20             = _mm_sub_ps(iz2,jz0);
778
779             /* Calculate squared distance and things based on it */
780             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
781             rsq10            = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
782             rsq20            = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
783
784             rinv00           = gmx_mm_invsqrt_ps(rsq00);
785             rinv10           = gmx_mm_invsqrt_ps(rsq10);
786             rinv20           = gmx_mm_invsqrt_ps(rsq20);
787
788             rinvsq00         = _mm_mul_ps(rinv00,rinv00);
789             rinvsq10         = _mm_mul_ps(rinv10,rinv10);
790             rinvsq20         = _mm_mul_ps(rinv20,rinv20);
791
792             /* Load parameters for j particles */
793             jq0              = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
794                                                               charge+jnrC+0,charge+jnrD+0);
795
796             fjx0             = _mm_setzero_ps();
797             fjy0             = _mm_setzero_ps();
798             fjz0             = _mm_setzero_ps();
799
800             /**************************
801              * CALCULATE INTERACTIONS *
802              **************************/
803
804             if (gmx_mm_any_lt(rsq00,rcutoff2))
805             {
806
807             r00              = _mm_mul_ps(rsq00,rinv00);
808
809             /* Compute parameters for interactions between i and j atoms */
810             qq00             = _mm_mul_ps(iq0,jq0);
811
812             /* EWALD ELECTROSTATICS */
813
814             /* Analytical PME correction */
815             zeta2            = _mm_mul_ps(beta2,rsq00);
816             rinv3            = _mm_mul_ps(rinvsq00,rinv00);
817             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
818             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
819             felec            = _mm_mul_ps(qq00,felec);
820
821             cutoff_mask      = _mm_cmplt_ps(rsq00,rcutoff2);
822
823             fscal            = felec;
824
825             fscal            = _mm_and_ps(fscal,cutoff_mask);
826
827              /* Update vectorial force */
828             fix0             = _mm_macc_ps(dx00,fscal,fix0);
829             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
830             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
831
832             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
833             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
834             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
835
836             }
837
838             /**************************
839              * CALCULATE INTERACTIONS *
840              **************************/
841
842             if (gmx_mm_any_lt(rsq10,rcutoff2))
843             {
844
845             r10              = _mm_mul_ps(rsq10,rinv10);
846
847             /* Compute parameters for interactions between i and j atoms */
848             qq10             = _mm_mul_ps(iq1,jq0);
849
850             /* EWALD ELECTROSTATICS */
851
852             /* Analytical PME correction */
853             zeta2            = _mm_mul_ps(beta2,rsq10);
854             rinv3            = _mm_mul_ps(rinvsq10,rinv10);
855             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
856             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
857             felec            = _mm_mul_ps(qq10,felec);
858
859             cutoff_mask      = _mm_cmplt_ps(rsq10,rcutoff2);
860
861             fscal            = felec;
862
863             fscal            = _mm_and_ps(fscal,cutoff_mask);
864
865              /* Update vectorial force */
866             fix1             = _mm_macc_ps(dx10,fscal,fix1);
867             fiy1             = _mm_macc_ps(dy10,fscal,fiy1);
868             fiz1             = _mm_macc_ps(dz10,fscal,fiz1);
869
870             fjx0             = _mm_macc_ps(dx10,fscal,fjx0);
871             fjy0             = _mm_macc_ps(dy10,fscal,fjy0);
872             fjz0             = _mm_macc_ps(dz10,fscal,fjz0);
873
874             }
875
876             /**************************
877              * CALCULATE INTERACTIONS *
878              **************************/
879
880             if (gmx_mm_any_lt(rsq20,rcutoff2))
881             {
882
883             r20              = _mm_mul_ps(rsq20,rinv20);
884
885             /* Compute parameters for interactions between i and j atoms */
886             qq20             = _mm_mul_ps(iq2,jq0);
887
888             /* EWALD ELECTROSTATICS */
889
890             /* Analytical PME correction */
891             zeta2            = _mm_mul_ps(beta2,rsq20);
892             rinv3            = _mm_mul_ps(rinvsq20,rinv20);
893             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
894             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
895             felec            = _mm_mul_ps(qq20,felec);
896
897             cutoff_mask      = _mm_cmplt_ps(rsq20,rcutoff2);
898
899             fscal            = felec;
900
901             fscal            = _mm_and_ps(fscal,cutoff_mask);
902
903              /* Update vectorial force */
904             fix2             = _mm_macc_ps(dx20,fscal,fix2);
905             fiy2             = _mm_macc_ps(dy20,fscal,fiy2);
906             fiz2             = _mm_macc_ps(dz20,fscal,fiz2);
907
908             fjx0             = _mm_macc_ps(dx20,fscal,fjx0);
909             fjy0             = _mm_macc_ps(dy20,fscal,fjy0);
910             fjz0             = _mm_macc_ps(dz20,fscal,fjz0);
911
912             }
913
914             fjptrA             = f+j_coord_offsetA;
915             fjptrB             = f+j_coord_offsetB;
916             fjptrC             = f+j_coord_offsetC;
917             fjptrD             = f+j_coord_offsetD;
918
919             gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
920
921             /* Inner loop uses 93 flops */
922         }
923
924         if(jidx<j_index_end)
925         {
926
927             /* Get j neighbor index, and coordinate index */
928             jnrlistA         = jjnr[jidx];
929             jnrlistB         = jjnr[jidx+1];
930             jnrlistC         = jjnr[jidx+2];
931             jnrlistD         = jjnr[jidx+3];
932             /* Sign of each element will be negative for non-real atoms.
933              * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
934              * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
935              */
936             dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
937             jnrA       = (jnrlistA>=0) ? jnrlistA : 0;
938             jnrB       = (jnrlistB>=0) ? jnrlistB : 0;
939             jnrC       = (jnrlistC>=0) ? jnrlistC : 0;
940             jnrD       = (jnrlistD>=0) ? jnrlistD : 0;
941             j_coord_offsetA  = DIM*jnrA;
942             j_coord_offsetB  = DIM*jnrB;
943             j_coord_offsetC  = DIM*jnrC;
944             j_coord_offsetD  = DIM*jnrD;
945
946             /* load j atom coordinates */
947             gmx_mm_load_1rvec_4ptr_swizzle_ps(x+j_coord_offsetA,x+j_coord_offsetB,
948                                               x+j_coord_offsetC,x+j_coord_offsetD,
949                                               &jx0,&jy0,&jz0);
950
951             /* Calculate displacement vector */
952             dx00             = _mm_sub_ps(ix0,jx0);
953             dy00             = _mm_sub_ps(iy0,jy0);
954             dz00             = _mm_sub_ps(iz0,jz0);
955             dx10             = _mm_sub_ps(ix1,jx0);
956             dy10             = _mm_sub_ps(iy1,jy0);
957             dz10             = _mm_sub_ps(iz1,jz0);
958             dx20             = _mm_sub_ps(ix2,jx0);
959             dy20             = _mm_sub_ps(iy2,jy0);
960             dz20             = _mm_sub_ps(iz2,jz0);
961
962             /* Calculate squared distance and things based on it */
963             rsq00            = gmx_mm_calc_rsq_ps(dx00,dy00,dz00);
964             rsq10            = gmx_mm_calc_rsq_ps(dx10,dy10,dz10);
965             rsq20            = gmx_mm_calc_rsq_ps(dx20,dy20,dz20);
966
967             rinv00           = gmx_mm_invsqrt_ps(rsq00);
968             rinv10           = gmx_mm_invsqrt_ps(rsq10);
969             rinv20           = gmx_mm_invsqrt_ps(rsq20);
970
971             rinvsq00         = _mm_mul_ps(rinv00,rinv00);
972             rinvsq10         = _mm_mul_ps(rinv10,rinv10);
973             rinvsq20         = _mm_mul_ps(rinv20,rinv20);
974
975             /* Load parameters for j particles */
976             jq0              = gmx_mm_load_4real_swizzle_ps(charge+jnrA+0,charge+jnrB+0,
977                                                               charge+jnrC+0,charge+jnrD+0);
978
979             fjx0             = _mm_setzero_ps();
980             fjy0             = _mm_setzero_ps();
981             fjz0             = _mm_setzero_ps();
982
983             /**************************
984              * CALCULATE INTERACTIONS *
985              **************************/
986
987             if (gmx_mm_any_lt(rsq00,rcutoff2))
988             {
989
990             r00              = _mm_mul_ps(rsq00,rinv00);
991             r00              = _mm_andnot_ps(dummy_mask,r00);
992
993             /* Compute parameters for interactions between i and j atoms */
994             qq00             = _mm_mul_ps(iq0,jq0);
995
996             /* EWALD ELECTROSTATICS */
997
998             /* Analytical PME correction */
999             zeta2            = _mm_mul_ps(beta2,rsq00);
1000             rinv3            = _mm_mul_ps(rinvsq00,rinv00);
1001             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1002             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1003             felec            = _mm_mul_ps(qq00,felec);
1004
1005             cutoff_mask      = _mm_cmplt_ps(rsq00,rcutoff2);
1006
1007             fscal            = felec;
1008
1009             fscal            = _mm_and_ps(fscal,cutoff_mask);
1010
1011             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1012
1013              /* Update vectorial force */
1014             fix0             = _mm_macc_ps(dx00,fscal,fix0);
1015             fiy0             = _mm_macc_ps(dy00,fscal,fiy0);
1016             fiz0             = _mm_macc_ps(dz00,fscal,fiz0);
1017
1018             fjx0             = _mm_macc_ps(dx00,fscal,fjx0);
1019             fjy0             = _mm_macc_ps(dy00,fscal,fjy0);
1020             fjz0             = _mm_macc_ps(dz00,fscal,fjz0);
1021
1022             }
1023
1024             /**************************
1025              * CALCULATE INTERACTIONS *
1026              **************************/
1027
1028             if (gmx_mm_any_lt(rsq10,rcutoff2))
1029             {
1030
1031             r10              = _mm_mul_ps(rsq10,rinv10);
1032             r10              = _mm_andnot_ps(dummy_mask,r10);
1033
1034             /* Compute parameters for interactions between i and j atoms */
1035             qq10             = _mm_mul_ps(iq1,jq0);
1036
1037             /* EWALD ELECTROSTATICS */
1038
1039             /* Analytical PME correction */
1040             zeta2            = _mm_mul_ps(beta2,rsq10);
1041             rinv3            = _mm_mul_ps(rinvsq10,rinv10);
1042             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1043             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1044             felec            = _mm_mul_ps(qq10,felec);
1045
1046             cutoff_mask      = _mm_cmplt_ps(rsq10,rcutoff2);
1047
1048             fscal            = felec;
1049
1050             fscal            = _mm_and_ps(fscal,cutoff_mask);
1051
1052             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1053
1054              /* Update vectorial force */
1055             fix1             = _mm_macc_ps(dx10,fscal,fix1);
1056             fiy1             = _mm_macc_ps(dy10,fscal,fiy1);
1057             fiz1             = _mm_macc_ps(dz10,fscal,fiz1);
1058
1059             fjx0             = _mm_macc_ps(dx10,fscal,fjx0);
1060             fjy0             = _mm_macc_ps(dy10,fscal,fjy0);
1061             fjz0             = _mm_macc_ps(dz10,fscal,fjz0);
1062
1063             }
1064
1065             /**************************
1066              * CALCULATE INTERACTIONS *
1067              **************************/
1068
1069             if (gmx_mm_any_lt(rsq20,rcutoff2))
1070             {
1071
1072             r20              = _mm_mul_ps(rsq20,rinv20);
1073             r20              = _mm_andnot_ps(dummy_mask,r20);
1074
1075             /* Compute parameters for interactions between i and j atoms */
1076             qq20             = _mm_mul_ps(iq2,jq0);
1077
1078             /* EWALD ELECTROSTATICS */
1079
1080             /* Analytical PME correction */
1081             zeta2            = _mm_mul_ps(beta2,rsq20);
1082             rinv3            = _mm_mul_ps(rinvsq20,rinv20);
1083             pmecorrF         = gmx_mm_pmecorrF_ps(zeta2);
1084             felec            = _mm_macc_ps(pmecorrF,beta3,rinv3);
1085             felec            = _mm_mul_ps(qq20,felec);
1086
1087             cutoff_mask      = _mm_cmplt_ps(rsq20,rcutoff2);
1088
1089             fscal            = felec;
1090
1091             fscal            = _mm_and_ps(fscal,cutoff_mask);
1092
1093             fscal            = _mm_andnot_ps(dummy_mask,fscal);
1094
1095              /* Update vectorial force */
1096             fix2             = _mm_macc_ps(dx20,fscal,fix2);
1097             fiy2             = _mm_macc_ps(dy20,fscal,fiy2);
1098             fiz2             = _mm_macc_ps(dz20,fscal,fiz2);
1099
1100             fjx0             = _mm_macc_ps(dx20,fscal,fjx0);
1101             fjy0             = _mm_macc_ps(dy20,fscal,fjy0);
1102             fjz0             = _mm_macc_ps(dz20,fscal,fjz0);
1103
1104             }
1105
1106             fjptrA             = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
1107             fjptrB             = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
1108             fjptrC             = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
1109             fjptrD             = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
1110
1111             gmx_mm_decrement_1rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,fjx0,fjy0,fjz0);
1112
1113             /* Inner loop uses 96 flops */
1114         }
1115
1116         /* End of innermost loop */
1117
1118         gmx_mm_update_iforce_3atom_swizzle_ps(fix0,fiy0,fiz0,fix1,fiy1,fiz1,fix2,fiy2,fiz2,
1119                                               f+i_coord_offset,fshift+i_shift_offset);
1120
1121         /* Increment number of inner iterations */
1122         inneriter                  += j_index_end - j_index_start;
1123
1124         /* Outer loop uses 18 flops */
1125     }
1126
1127     /* Increment number of outer iterations */
1128     outeriter        += nri;
1129
1130     /* Update outer/inner flops */
1131
1132     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_F,outeriter*18 + inneriter*96);
1133 }