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