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